:root {
    --bg-dark: #0b0e14;
    color-scheme: dark;

    /* Theme tokens (dark = the original look). Light values further down. */
    --page-bg: radial-gradient(circle at center, #1e293b 0%, #0b0e14 100%);
    --sidebar-bg: #11141c;
    --tile-bg: #161b22;
    --tile-card-bg: radial-gradient(circle at 50% 40%, #1c2330 0%, #161b22 70%);
    --letterbox: #000;
    --surface-1: rgba(255, 255, 255, 0.02);
    --surface-sunken: rgba(0, 0, 0, 0.2);
    --surface-sunken-2: rgba(0, 0, 0, 0.3);
    --hover: rgba(255, 255, 255, 0.05);
    --hover-strong: rgba(255, 255, 255, 0.08);
    --dock-bg: rgba(15, 23, 42, 0.4);
    --ctrl-fg: #ffffff;
    --shadow-tile: rgba(0, 0, 0, 0.4);
    --shadow-soft: rgba(0, 0, 0, 0.25);
    --avatar-ring: rgba(255, 255, 255, 0.08);
    --chat-time: #8b949e;
    --chat-sender: #58a6ff;
    --toast-bg: rgba(15, 23, 42, 0.9);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-blue: #00C1CA;
    --accent-green: #00CE6F;
    --accent-red: #F62617;
    --text-primary: #e2e8f0;
    --text-dim: #94a3b8;
    --tomato-red: 			#F62617;
	--ruby-red: 			#DF2F44;
	--candy-pink:			#DE349B;
	--salmon-pink:			#EF7A63;
	--fire-orange:			#F3560F;
	--banana-yellow:		#FCDC4D;
	--mustard-yellow: 		#EB9C03;
	--acid-yellow: 			#EDF231;
	--cloth-beige: 			#F1EBE5;
	--mushroom-brown: 		#B8998B;
	--choc-brown: 			#8F5F24;	
	--leaf-green: 			#00CE6F;
	--moss-green:			#006248;
	--mold-green:			#58AF76;
	--baby-blue:  			#008BE5;
	--aqua-blue:  			#005972;
	--ice-blue: 			#83DEE8;
	--sky-blue: 			#00C1CA;
	--iris-blue: 			#182287;
	--lavender-blue: 		#2B4FB8;
	--roman-purple: 		#A61EDD;
	--ash-grey:				#292B2B;
	--smoke-grey:			#CCCCCC;	
	--cloud-grey:			#999999;	
	--tomato-red-fade: 		#F45145;
	--ruby-red-fade: 		#E15766;
	--candy-pink-fade:		#E05CAD;
	--salmon-pink-fade:		#F19A87;
	--fire-orange-fade:		#ED7C43;
	--banana-yellow-fade:	#FECD40;
	--mustard-yellow-fade: 	#EAB238;
	--acid-yellow-fade: 	#DAE030;
	--cloth-beige-fade: 	#E0D4C6;
	--mushroom-brown-fade: 	#B8AFAB;
	--choc-brown-fade: 		#90724C;	
	--leaf-green-fade: 		#47B382;
	--moss-green-fade:		#117D62;
	--mold-green-fade:		#94AF9E;
	--baby-blue-fade:  		#00A2FF;
	--aqua-blue-fade:  		#10718B;
	--ice-blue-fade: 		#BDE3E8;
	--sky-blue-fade: 		#1DABB2;
	--iris-blue-fade: 		#333A89;
	--lavender-blue-fade: 	#4A66BB;
	--roman-purple-fade: 	#B340E0;
	--ash-grey-fade:		#3F4241;
	--smoke-grey-fade:		#EEEEEE;
	--cloud-grey-fade:		#BBBBBB;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: auto;
}

/* ===== MAIN LAYOUT ===== */
.app-wrapper {
    display: flex;
    flex-direction: row;
    height: 100vh;
    gap: 16px;
    padding: 16px;
    box-sizing: border-box;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Important for flex child to shrink properly */
    overflow: hidden;
    position: relative;
}

/* Video section fills available space and scrolls internally */
#videoSection {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

#videoGrid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px;
    align-content: start;
}

.video-wrapper {
    position: relative;
    background: var(--tile-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px var(--shadow-tile);
    aspect-ratio: 16/9;
}

.video-wrapper video,
.video-wrapper canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Q1: screens and Stream are shown whole inside the tile, never cropped */
.video-wrapper.fit-contain { background: var(--letterbox); }
.video-wrapper.fit-contain video,
.video-wrapper.fit-contain canvas { object-fit: contain; }

/* T1: name card while someone's camera is off */
.name-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--tile-card-bg);
    text-align: center;
    padding: 12px;
}
.name-card-avatar {
    width: clamp(48px, 22%, 96px);
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: clamp(1.1rem, 4.5cqw, 2.2rem);
    letter-spacing: 0.02em;
    box-shadow: 0 0 0 3px var(--avatar-ring);
    margin-bottom: 4px;
}
.name-card-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.name-card-status {
    color: var(--text-dim);
    font-size: 0.8rem;
}
.video-wrapper { container-type: inline-size; }
/* with video on: hide the card; with video off: hide the (frozen) video */
.video-wrapper.has-video .name-card { display: none; }
.video-wrapper:has(.name-card):not(.has-video) video,
.video-wrapper:has(.name-card):not(.has-video) canvas { visibility: hidden; }

.vid-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    z-index: 10;
    color: white;
}

#webcam { display: none; }

/* ===== RIGHT SIDEBAR (RESIZABLE) ===== */
.sidebar-wrapper {
    resize: horizontal;
    direction: rtl; /* Puts the resize handle on the left corner (bottom-left) */
    overflow: hidden;
    min-width: 440px; /* Increased to support wider horizontal layout */
    max-width: 700px; /* Don't allow it to take over the whole screen */
    width: 440px; /* Default width */
    flex-shrink: 0;
    border-radius: 16px;
    /* Hide scrollbar of wrapper if any */
}

.sidebar-glass {
    direction: ltr; /* Reset content direction */
    background: var(--sidebar-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    box-shadow: 0 4px 20px var(--shadow-soft);
}

.sidebar-inner {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.sidebar-inner::-webkit-scrollbar {
    width: 6px;
}
.sidebar-inner::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

/* Top Banner */
.top-banner {
    background: var(--surface-1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
}

.banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.banner-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.logo-icon {
    margin-top: 2px;
    color: var(--accent-blue);
    flex-shrink: 0;
}

.app-info {
    display: flex;
    flex-direction: column;
}

.app-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    flex-shrink: 0;
}

.status-dot-sm {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-blue);
    margin-right: 6px;
    flex-shrink: 0;
}

.node-id {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.status-indicator {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--surface-sunken-2);
    border: 1px solid var(--glass-border);
    text-transform: uppercase;
}

.status-indicator.online {
    background: rgba(0, 206, 111, 0.15);
    border-color: rgba(0, 206, 111, 0.3);
    color: var(--accent-green);
}

.peer-list {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Join Section */
.room-join {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-group {
    display: flex;
    align-items: center;
    background: var(--surface-sunken);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0 12px;
    transition: border-color 0.2s;
    min-width: 0; /* Flex shrink protection */
}

.input-group:focus-within {
    border-color: var(--accent-blue);
}

.input-icon {
    color: var(--text-dim);
    margin-right: 8px;
    flex-shrink: 0;
}

.input-group input {
    flex: 1;
    min-width: 0; /* Flex shrink protection */
    background: transparent;
    border: none;
    padding: 12px 0;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

.join-row {
    display: flex;
    gap: 10px;
}
.join-row .input-group {
    flex: 1;
}

.btn-primary {
    background: rgba(0, 193, 202, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--accent-blue);
    border-radius: 8px;
    padding: 0 20px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-primary:hover {
    background: rgba(0, 193, 202, 0.15);
    box-shadow: 0 0 10px rgba(0, 193, 202, 0.1);
}
.btn-primary svg {
    color: var(--accent-blue);
}

/* Advanced Section */
.collapsible {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-manual {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    gap: 6px;
    width: fit-content;
}
.btn-manual:hover {
    color: var(--text-primary);
}
.btn-manual svg {
    transition: transform 0.2s;
}

.manual-section {
    padding-top: 12px;
}
.manual-section > * + * {
    margin-top: 16px;
}

.signalling-box {
    background: var(--surface-1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.signalling-box textarea {
    width: 100%;
    background: var(--surface-sunken-2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: monospace;
    min-height: 80px;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}

.signalling-box textarea:focus {
    border-color: var(--accent-blue);
}

/* Mesh Modes */
.mesh-mode-row {
    display: flex;
    gap: 10px;
}
.btn-mesh-mode {
    flex: 1;
    min-width: 0;
    background: var(--surface-sunken-2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px 10px;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    text-align: left;
}
.btn-mesh-mode svg {
    color: var(--text-dim);
    flex-shrink: 0;
}
.mode-text {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mode-text small {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 2px;
}
.btn-mesh-mode:hover {
    background: var(--hover-strong);
}
#joinRelayBtn {
    border-color: var(--accent-green);
    color: var(--text-primary);
    background: rgba(0, 206, 111, 0.05);
}
#joinRelayBtn svg {
    color: var(--accent-green);
}
#joinMeshBtn2 {
    border-color: var(--accent-blue);
    color: var(--text-primary);
    background: rgba(0, 193, 202, 0.05);
}
#joinMeshBtn2 svg {
    color: var(--accent-blue);
}
.btn-mesh-mode:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.info-text {
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
}

.token-actions {
    display: flex;
    gap: 16px;
}
.btn-outline {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-outline:hover {
    background: var(--hover);
}
.token-actions .btn-primary {
    flex: 1.2;
    padding: 12px;
    font-size: 0.9rem;
}

/* Meters Panel */
.meters-panel {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    background: var(--surface-sunken);
    border-radius: 12px;
    padding: 16px 12px;
    border: 1px solid var(--glass-border);
}
.meter-item {
    display: flex;
    align-items: center;
    gap: 10px;
}
.meter-icon {
    color: var(--text-dim);
    flex-shrink: 0;
}
.meter-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.meter-value-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.meter-label {
    font-size: 0.75rem;
    color: var(--text-dim);
}
.meter-divider {
    width: 1px;
    height: 32px;
    background: var(--glass-border);
}

/* Effect Controls */
.effect-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--surface-sunken);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
}

.ctrl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}
.ctrl-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.ctrl-group select {
    background: var(--hover);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    outline: none;
    font-size: 0.85rem;
    max-width: 130px;
}
.ctrl-group select:focus {
    border-color: var(--accent-blue);
}

.ctrl-group.range-wrap {
    flex: 1;
    justify-content: flex-end;
    min-width: 120px;
}

.ctrl-group input[type="range"] {
    width: 100%;
    max-width: 80px;
    min-width: 40px; /* robust shrinking */
    accent-color: var(--accent-blue);
    margin: 0;
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s;
}
.ctrl-group input[type="range"]:hover {
    opacity: 1;
}

.val-badge {
    font-size: 0.85rem;
    color: var(--text-primary);
    min-width: 18px; /* keeps alignment stable as numbers change */
    text-align: right;
}

.effect-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 4px;
}
.effect-btn, .effect-btn-sm {
    background: var(--hover);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-dim);
    padding: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}
.effect-btn-sm {
    padding: 6px 12px;
}
.effect-btn:hover, .effect-btn-sm:hover {
    background: var(--hover-strong);
    color: var(--text-primary);
}
.effect-btn.active, .effect-btn-sm.active {
    background: rgba(0, 193, 202, 0.1);
    border-color: var(--accent-blue);
    color: var(--text-primary);
}
.effect-btn.active svg, .effect-btn-sm.active svg {
    color: var(--accent-blue);
}

/* Chat & Files Group */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1; /* allow it to grow in the sidebar */
    min-height: 250px;
    background: var(--surface-1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--glass-border);
    background: var(--surface-sunken);
}
.sidebar-tabs .tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 12px 0;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.sidebar-tabs .tab:hover {
    color: var(--text-primary);
}
.sidebar-tabs .tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.chat-wrapper .scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}
.chat-wrapper .scroll-area::-webkit-scrollbar {
    width: 6px;
}
.chat-wrapper .scroll-area::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

#chatbox {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.4;
}
.msg {
    margin-bottom: 8px;
    line-height: 1.4;
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--glass-border);
    background: var(--surface-sunken);
}
.chat-input-area input {
    flex: 1;
    min-width: 0;
    background: var(--hover);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
}
.chat-input-area input:focus {
    border-color: var(--accent-blue);
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.icon-btn:hover {
    background: var(--hover);
    color: var(--text-primary);
}

.icon-btn-primary {
    background: rgba(0, 193, 202, 0.1);
    border: 1px solid var(--accent-blue);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.icon-btn-primary:hover:not(:disabled) {
    background: rgba(0, 193, 202, 0.2);
}
.icon-btn-primary svg {
    color: var(--accent-blue);
}
.icon-btn-primary:disabled, .icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* File Transfer Section */
.file-section {
    display: none;
}
.file-item {
    background: var(--surface-sunken);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.file-item span {
    flex-grow: 1;
    font-size: 0.85rem;
}
.download-btn {
    background: transparent;
    padding: 6px;
    border-radius: 6px;
    border: none;
    color: var(--accent-blue);
    cursor: pointer;
}
.progress-bar-container {
    background: var(--surface-sunken-2);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin: 10px 0;
}
.progress-bar {
    background: var(--accent-blue);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}

/* Bottom Stack / Controls Dock */
#bottomStack {
    display: flex;
    justify-content: center;
    padding: 0 20px 20px 20px;
    background: transparent;
}
.controls-dock {
    flex: 1;
    background: var(--dock-bg);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 0;
    justify-content: space-around;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 24px var(--shadow-soft);
}
.ctrl-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.ctrl-btn {
    background: var(--hover);
    border: 1px solid var(--glass-border);
    color: var(--ctrl-fg);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.ctrl-btn svg {
    color: inherit;
}
.ctrl-btn:hover {
    background: var(--hover-strong);
    transform: scale(1.05);
}
.ctrl-btn.active {
    background: var(--accent-blue);
    color: var(--bg-dark);
}
.end-call {
    background: rgba(246, 38, 23, 0.1);
    border-color: rgba(246, 38, 23, 0.3);
    color: var(--accent-red);
}
.end-call:hover {
    background: var(--accent-red);
    color: white;
}
.btn-on {
    background: rgba(0, 206, 111, 0.1);
    border-color: rgba(0, 206, 111, 0.3);
    color: var(--accent-green);
}
.btn-on:hover {
    background: var(--accent-green);
    color: white;
}
.btn-off {
    background: var(--hover);
}
.ctrl-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.03em;
    user-select: none;
}

/* ===== DRAG & DROP ===== */
#drop-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(91, 108, 249, 0.2);
    backdrop-filter: blur(10px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent-blue);
    border: 4px dashed var(--accent-blue);
}

@media (max-width: 900px) {
    .app-wrapper {
        flex-direction: column;
        height: auto;
        min-height: unset;
    }

    .main-content {
        width: 100%;
        max-width: none;
        resize: none;
        min-height: 400px; /* give it some height */
    }

    #videoSection {
        overflow: visible;
        max-height: none;
        height: auto;
    }

    .sidebar-wrapper {
        width: 100%;
        max-width: none;
        min-width: 0;
        height: auto;
        flex: none;
        resize: none;
    }
}

@media (max-width: 640px) {
    .app-wrapper {
        padding: 10px;
        gap: 10px;
    }

    body { font-size: 1.05rem; }
    .app-title { font-size: 1.25rem; }

    .input-group input, textarea {
        font-size: 1rem;
        padding: 12px 0;
    }
    textarea { padding: 12px; }

    .btn-primary { font-size: 1rem; padding: 12px 18px; }
    .tab { font-size: 1rem; }
    #chatbox { font-size: 0.95rem; }
    .vid-label { font-size: 0.95rem; }
    .status-indicator { font-size: 0.85rem; }
    .node-id { font-size: 0.85rem; }
    .ctrl-label { font-size: 0.72rem; }
    .ctrl-btn { width: 44px; height: 44px; font-size: 1.1rem; }
    .meters-panel { font-size: 0.82rem; padding: 10px; gap: 8px; }
    .effect-controls { font-size: 0.9rem; }
    .effect-btn, .effect-btn-sm { font-size: 0.88rem; padding: 6px 10px; }
    .ctrl-group select { font-size: 0.95rem; }
    .peer-list { font-size: 0.9rem; }
    .file-item span { font-size: 0.92rem; }
}

/* Access Gate */
#accessGate {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
}

.gate-card {
    width: min(360px, calc(100% - 40px));
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gate-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.gate-title .logo-icon {
    color: var(--accent-blue);
}

.gate-subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.gate-error {
    min-height: 1.2em;
    text-align: center;
    font-size: 0.85rem;
    color: var(--accent-red);
}


/* ===== LIGHT THEME =====
   Soft cool greys rather than pure white, and text a little short of black,
   so long calls stay easy on the eyes. Accents are darker shades of the brand
   teal/green/red so text and icons stay readable (4.5:1 or better on the sidebar). */
:root[data-theme="light"] {
    color-scheme: light;
    --bg-dark: #e9edf2;
    --page-bg: radial-gradient(circle at center, #f4f6f9 0%, #e4e8ee 100%);
    --sidebar-bg: #f7f8fa;
    --tile-bg: #dfe4ea;
    --tile-card-bg: radial-gradient(circle at 50% 40%, #f1f4f7 0%, #dde3ea 75%);
    --letterbox: #1e2329;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(15, 23, 42, 0.12);
    --surface-1: rgba(15, 23, 42, 0.025);
    --surface-sunken: rgba(15, 23, 42, 0.04);
    --surface-sunken-2: rgba(15, 23, 42, 0.06);
    --hover: rgba(15, 23, 42, 0.05);
    --hover-strong: rgba(15, 23, 42, 0.08);
    --dock-bg: rgba(255, 255, 255, 0.7);
    --ctrl-fg: #334155;
    --shadow-tile: rgba(15, 23, 42, 0.10);
    --shadow-soft: rgba(15, 23, 42, 0.08);
    --avatar-ring: rgba(255, 255, 255, 0.9);
    --text-primary: #1f2937;
    --text-dim: #556070;
    --accent-blue: #087f87;
    --accent-green: #08834a;
    --accent-red: #d12a1c;
    --chat-time: #556070;
    --chat-sender: #0b63c5;
    --toast-bg: rgba(255, 255, 255, 0.95);
}
/* the green "online" glow is too strong on a light background */
:root[data-theme="light"] .status-dot { box-shadow: 0 0 6px rgba(8, 131, 74, 0.45); }

/* ===== THEME TOGGLE ===== */
.banner-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.theme-toggle {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}
.theme-toggle:hover { background: var(--hover); color: var(--text-primary); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
/* show the moon in light theme (switch to dark), the sun in dark theme (switch to light) */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ===== TILE STATUS (S4) =====
   Camera / mic / screen / Stream on every person's tile; slashed and red when off.
   Sits on video, so it keeps the same dark chip in both themes, like the name label. */
.tile-status {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 10;
}
.tile-status .chip {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    color: #fff;
}
.tile-status .chip .slash { display: none; }
.tile-status .chip.off { color: #ff8a80; background: rgba(0, 0, 0, 0.45); }
.tile-status .chip.off .slash { display: inline; }
.tile-status .chip.on { box-shadow: inset 0 0 0 1.5px rgba(0, 206, 111, 0.85); }
.tile-status .chip[hidden],
.tile-status .rec[hidden] { display: none; }
.tile-status .rec {
    height: 26px;
    padding: 0 8px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.tile-status .rec::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff3b30;
}

/* ===== CHAT LINES, FILES, TOASTS (were inline colours) ===== */
.chat-line { color: var(--chat-time); }
.chat-line .chat-sender { color: var(--chat-sender); }
#assetStatus {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toast-bg);
    backdrop-filter: blur(15px);
    padding: 12px 24px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    font-size: 0.85rem;
    color: var(--text-dim);
    z-index: 1000;
}

/* ===== ROOM DETAILS TAB ===== */
.details-section {
    display: none;
    flex-direction: column;
    gap: 14px;
}
.detail-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
}
.detail-value {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--surface-sunken);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 9px 12px;
    user-select: all;
    word-break: break-all;
}
.detail-input {
    width: 100%;
    min-width: 0;
    background: var(--hover);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 9px 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}
.detail-input:focus { border-color: var(--accent-blue); }
.detail-input[readonly] { color: var(--text-dim); cursor: text; }
.detail-times {
    display: grid;
    /* side by side when the sidebar is wide enough, stacked otherwise (never cut off) */
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 10px;
}
.detail-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
}
.detail-hint:empty { display: none; }
.btn-primary.detail-copy {
    width: 100%;
    padding: 11px 16px;
}
.detail-feedback {
    min-height: 1.1em;
    font-size: 0.8rem;
    color: var(--accent-green);
    text-align: center;
}
.detail-feedback.error { color: var(--accent-red); }

/* ===== AGENDA TAB ===== */
.agenda-section {
    display: flex;   /* Agenda is the tab that opens first */
    flex-direction: column;
    gap: 12px;
}
.agenda-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.agenda-progress {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
}
.agenda-actions { display: flex; gap: 6px; }
.agenda-add {
    display: flex;
    gap: 8px;
    margin: 0;
}
.agenda-add .icon-btn-primary { width: 38px; height: auto; }
.agenda-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.agenda-empty {
    font-size: 0.8rem;
    color: var(--text-dim);
    padding: 4px 2px;
}
.agenda-item {
    background: var(--surface-sunken);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 6px 6px 6px 10px;
}
.agenda-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.agenda-check {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    accent-color: var(--accent-green);
    cursor: pointer;
    margin: 0;
}
.agenda-title {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
}
.agenda-title:hover { border-color: var(--glass-border); }
.agenda-title:focus { border-color: var(--accent-blue); background: var(--hover); }
.agenda-item.done .agenda-title { color: var(--text-dim); text-decoration: line-through; }
.agenda-item-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}
.agenda-item-btn:hover { background: var(--hover-strong); color: var(--text-primary); }
.agenda-item-btn.has-notes { color: var(--accent-blue); }
.agenda-item-btn:focus-visible, .agenda-check:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.agenda-item-notes {
    margin: 6px 0 2px 25px;
    width: calc(100% - 25px);
    resize: vertical;
    min-height: 54px;
}
.agenda-notes { resize: vertical; min-height: 44px; line-height: 1.4; }
/* small dot on the Agenda tab when someone else changed it */
.sidebar-tabs .tab.has-update::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    vertical-align: middle;
}

/* ===== DETAILS / AGENDA BOX (under the Room ID) =====
   Keeps its own height so a long agenda scrolls inside the box instead of
   pushing the chat down. */
.chat-wrapper.meeting-wrapper {
    flex: 0 0 auto;
    min-height: 0;
}
.meeting-wrapper .scroll-area {
    max-height: min(46vh, 520px);
}

/* ===== COLLAPSIBLE SECTIONS: Meeting Details, Discussion, Advanced ===== */
.collapsible-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.collapsible-section [hidden] { display: none !important; }
.section-toggle {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 6px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    width: fit-content;
    transition: color 0.2s;
}
.section-toggle:hover,
.section-toggle[aria-expanded="true"] { color: var(--text-primary); }
.section-toggle:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 3px; border-radius: 4px; }
.section-toggle .chev { transition: transform 0.2s; flex-shrink: 0; }
.section-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
/* an open Discussion fills the remaining height, like the chat box did */
.discussion-section.open { flex: 1 1 auto; }
.discussion-section.open .chat-wrapper { flex: 1 1 auto; }

/* orange badge on a closed section: agenda items waiting, or unread messages */
.section-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: #C2410C;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    animation: section-badge-pulse 1.6s ease-out 2;
}
@keyframes section-badge-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.65); }
    100% { box-shadow: 0 0 0 9px rgba(234, 88, 12, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .section-badge { animation: none; }
    .section-toggle .chev { transition: none; }
}

/* ===== SPEAKING RING (U3) ===== */
.video-wrapper { transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.video-wrapper.speaking {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px var(--accent-green), 0 8px 32px var(--shadow-tile);
}

/* ===== SPOTLIGHT LAYOUT (U4): one big tile, the rest in a row underneath ===== */
#videoGrid .video-wrapper { cursor: zoom-in; }
#videoGrid .video-wrapper.spot { cursor: zoom-out; }
#videoGrid.spotlight { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
#videoGrid.spotlight .video-wrapper.spot { grid-column: 1 / -1; order: -1; }
/* small tiles: tighter name card, chips and label */
@container (max-width: 240px) {
    .name-card { gap: 2px; padding: 6px; }
    .name-card-avatar { width: 34px; font-size: 0.8rem; box-shadow: none; margin-bottom: 0; }
    .name-card-name, .name-card-status { display: none; }   /* the label already names them */
    .name-card { padding-bottom: 18px; }
    .tile-status { top: 5px; right: 5px; gap: 3px; }
    .tile-status .chip { width: 18px; height: 18px; }
    .tile-status .chip svg { width: 10px; height: 10px; }
    .tile-status .rec { height: 18px; padding: 0 5px; font-size: 0.6rem; }
    .vid-label { bottom: 5px; left: 5px; padding: 2px 6px; font-size: 0.68rem; max-width: calc(100% - 10px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ===== ROOM BAR (U5): shown instead of the join form once you're in ===== */
.room-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px 10px 10px 14px;
}
.room-bar[hidden] { display: none; }
.room-bar-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.room-bar-label { font-size: 0.7rem; color: var(--text-dim); font-weight: 600; }
.room-bar-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.room-bar-btn { padding: 8px 12px; flex: 0 0 auto; }

/* ===== ROOM ID GUIDANCE ===== */
.new-room-btn { width: auto; height: auto; padding: 0 10px; }
.room-hint {
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-dim);
    background: color-mix(in srgb, #EB9C03 12%, transparent);
    border: 1px solid color-mix(in srgb, #EB9C03 40%, transparent);
    border-radius: 8px;
    padding: 8px 10px;
}
.room-hint[hidden] { display: none; }

/* ===== BACKGROUNDS MENU (dock button) ===== */
#bottomStack { position: relative; }
.ctrl-wrap { position: relative; }
.effects-popover {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: calc(100% - 8px);
    background: var(--sidebar-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: 0 12px 40px var(--shadow-tile);
    padding: 12px;
    z-index: 60;
}
.effects-popover[hidden] { display: none; }
.effects-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.effects-popover .effect-controls { display: flex; }

/* ===== IN-APP DIALOG (Leave) ===== */
.app-dialog {
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: var(--sidebar-bg);
    color: var(--text-primary);
    padding: 22px 22px 18px;
    width: min(420px, calc(100% - 32px));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.app-dialog::backdrop { background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(3px); }
.app-dialog h2 { margin: 0 0 8px; font-size: 1.1rem; }
.app-dialog p { margin: 0 0 18px; font-size: 0.88rem; line-height: 1.45; color: var(--text-dim); }
.app-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.app-dialog-actions button { flex: 0 0 auto; padding: 10px 14px; }
.app-dialog-actions .btn-primary[hidden] { display: none; }

/* people list in the banner: names side by side, wrapping */
.peer-list { flex-wrap: wrap; }
.peer-tag { white-space: nowrap; margin-right: 10px; }

/* ===== YOUR NAME in the banner (N1): click to change it any time ===== */
.status-indicator { white-space: nowrap; }

/* N1: in a room the "Your name" field stays, so anyone can rename at any time */
.room-join.in-room .join-row, .room-join.in-room .room-hint { display: none !important; }
.room-join.in-room .input-group.needs-name { border-color: color-mix(in srgb, #C2410C 60%, transparent); }

/* ===== CHAT: shared files under the message box (C2) ===== */
.chat-wrapper { position: relative; }
.chat-files {
    border-top: 1px solid var(--glass-border);
    background: var(--surface-sunken);
    padding: 8px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chat-files[hidden], .file-transfer[hidden], .progress-bar-container[hidden] { display: none; }
.chat-files-head {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.chat-files-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 148px;
    overflow-y: auto;
}
.chat-files-list:empty { display: none; }
.received-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 10px;
    background: var(--surface-1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    min-width: 0;
}
.received-file .file-info { flex: 1; min-width: 0; }
.received-file .file-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.received-file .file-meta { font-size: 0.72rem; color: var(--text-dim); }
.received-file .file-download {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--accent-green);
    cursor: pointer;
}
.received-file .file-download:hover { background: var(--hover); border-color: var(--accent-green); }
.received-file .file-download:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.file-transfer { display: flex; flex-direction: column; gap: 4px; }
.file-transfer-text {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-dim);
}
.file-transfer-text #fileTransferStatus { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-transfer .progress-bar-container { margin: 0; }

/* drop files on the chat to share them */
.drop-hint {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--accent-blue);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-1) 88%, transparent);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 5;
}
.chat-wrapper.drop-ready .drop-hint { display: flex; }

/* Backgrounds menu: video quality sits last, set apart */
.effects-popover .fx-quality { border-top: 1px solid var(--glass-border); padding-top: 10px; margin-top: 2px; }

/* ===== AGENDA: "Unpack" (who presents an item) ===== */
.agenda-add { align-items: stretch; }
.agenda-add-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.agenda-add-unpack { font-size: 0.8rem; padding-top: 7px; padding-bottom: 7px; }
.agenda-unpack-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 0 25px;
    min-width: 0;
}
.agenda-unpack-label {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.agenda-unpack {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 3px 6px;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: inherit;
    outline: none;
}
.agenda-unpack::placeholder { color: var(--text-dim); opacity: 0.7; }
.agenda-unpack:hover { border-color: var(--glass-border); }
.agenda-unpack:focus { border-color: var(--accent-blue); background: var(--hover); }
.agenda-item.done .agenda-unpack { color: var(--text-dim); }

/* room bar: Topic / room-id */
.room-bar-sep, .room-bar-id { color: var(--text-dim); font-weight: 500; }
.room-bar-name > .room-bar-id:only-child { color: var(--text-primary); font-weight: 600; }

/* ===== DOCK: equal columns, so the buttons sit evenly whatever the label length ===== */
.controls-dock { justify-content: stretch; padding: 12px 4px; }
.controls-dock > .ctrl-wrap { flex: 1 1 0; min-width: 0; }
.controls-dock .ctrl-label { white-space: nowrap; text-align: center; letter-spacing: 0; }   /* a long label may spill evenly into the gaps either side */
@media (max-width: 480px) {
    .controls-dock .ctrl-label { display: none; }   /* seven labels don't fit; the buttons keep their tooltips */
}

/* ===== AGENDA NOTICES (left side) ===== */
.meeting-toasts {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 80;
    display: flex;
    flex-direction: column-reverse;   /* newest in the corner, older ones stack above */
    gap: 8px;
    width: min(340px, calc(100vw - 32px));
    pointer-events: none;
}
.meeting-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    text-align: left;
    font: inherit;
    color: var(--text-primary);
    background: var(--sidebar-bg);
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--accent-blue);
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 8px 28px var(--shadow-tile);
    cursor: pointer;
    opacity: 0;
    transform: translateX(-12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.meeting-toast.in { opacity: 1; transform: none; }
.meeting-toast.out { opacity: 0; transform: translateX(-12px); }
.meeting-toast.bump { animation: toast-bump 0.25s ease; }
@keyframes toast-bump { 50% { transform: scale(1.02); } }
.meeting-toast:hover { border-color: var(--accent-blue); }
.meeting-toast:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.meeting-toast-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 14%, transparent);
}
.meeting-toast-icon.icon-done { color: var(--accent-green); background: color-mix(in srgb, var(--accent-green) 14%, transparent); }
.meeting-toast-icon.icon-remove { color: var(--accent-red); background: color-mix(in srgb, var(--accent-red) 12%, transparent); }
.meeting-toast:has(.icon-done) { border-left-color: var(--accent-green); }
.meeting-toast:has(.icon-remove) { border-left-color: var(--accent-red); }
.meeting-toast-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.meeting-toast-kicker {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.meeting-toast-text { font-size: 0.84rem; line-height: 1.35; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
    .meeting-toast { transition: none; transform: none; }
    .meeting-toast.bump { animation: none; }
}

/* ===== NAME SUGGESTIONS (Unpack) ===== */
.suggest-menu {
    position: fixed;
    z-index: 90;
    max-height: 220px;
    overflow-y: auto;
    padding: 6px;
    background: var(--sidebar-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    box-shadow: 0 10px 32px var(--shadow-tile);
}
.suggest-menu[hidden] { display: none; }
.suggest-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 7px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.85rem;
}
.suggest-option[aria-selected="true"], .suggest-option:hover { background: var(--hover-strong); }
.suggest-avatar {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 16%, transparent);
}
.suggest-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== MEETING NOTES TIMELINE (T3) ===== */
.notes-add { display: flex; gap: 8px; margin: 0; align-items: stretch; }
.notes-add .agenda-notes { flex: 1; min-width: 0; }
.notes-add .icon-btn-primary { width: 38px; height: auto; }
.notes-timeline {
    list-style: none;
    margin: 2px 0 0;
    padding: 0 0 0 18px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.notes-timeline[hidden] { display: none; }
.notes-timeline::before {   /* the line */
    content: "";
    position: absolute;
    left: 5px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    border-radius: 1px;
    background: var(--glass-border);
}
.note-entry {
    position: relative;
    background: var(--surface-sunken);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 10px;
}
.note-entry::before {   /* the dot */
    content: "";
    position: absolute;
    left: -18px;
    top: 13px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--sidebar-bg);
}
.note-entry:first-child::before { background: var(--accent-green); }
.note-entry.legacy::before { background: var(--text-dim); }
.note-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.note-avatar {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 16%, transparent);
}
.note-who {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.note-time { font-size: 0.72rem; color: var(--text-dim); white-space: nowrap; margin-left: auto; }
.note-del { width: 22px; height: 22px; margin-right: -4px; }
.note-text {
    margin: 4px 0 0 28px;
    font-size: 0.84rem;
    line-height: 1.4;
    color: var(--text-primary);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ===== P1/P2: chat notices, and "for you" ===== */
.meeting-toast.tone-you { border-left-color: #C2410C; }
.meeting-toast.tone-you .meeting-toast-icon { color: #fff; background: #C2410C; }
.meeting-toast.tone-you .meeting-toast-kicker { color: #C2410C; }
:root[data-theme="light"] .meeting-toast.tone-you .meeting-toast-kicker { color: #9A3412; }

.agenda-item.for-me {
    border-color: color-mix(in srgb, #C2410C 55%, var(--glass-border));
    box-shadow: inset 3px 0 0 #C2410C;
    background: color-mix(in srgb, #C2410C 7%, var(--surface-sunken));
}
.agenda-item.for-me.done { box-shadow: none; border-color: var(--glass-border); background: var(--surface-sunken); }
.agenda-unpack-you {
    flex-shrink: 0;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #fff;
    background: #C2410C;
    border-radius: 999px;
    padding: 1px 7px;
}
.agenda-unpack-you[hidden] { display: none; }
.agenda-item.for-me .agenda-unpack { font-weight: 600; }
.agenda-item.for-me.done .agenda-unpack-you { background: var(--text-dim); }
.section-badge.for-you { padding: 0 7px; width: auto; }

/* ===== H1: ALL HANDS MODE ===== */
:root:not([data-all-hands]) .all-hands-only,
:root:not([data-all-hands]) .agenda-unpack-row { display: none !important; }
:root[data-all-hands] .notes-plain { display: none !important; }
.room-mode-pill {
    display: inline-block;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 16px;
    vertical-align: 1px;
    color: #fff;
    background: #C2410C;
}
.room-mode-pill[hidden] { display: none; }
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--surface-sunken);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    cursor: pointer;
}
.switch-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-title { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.switch-desc { font-size: 0.75rem; color: var(--text-dim); line-height: 1.35; }
.switch {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    position: relative;
    width: 40px;
    height: 22px;
    margin: 0;
    border-radius: 999px;
    background: var(--hover-strong);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.switch::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: transform 0.2s, background 0.2s;
}
.switch:checked { background: #C2410C; border-color: #C2410C; }
.switch:checked::before { transform: translateX(18px); background: #fff; }
.switch:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.switch:disabled { opacity: 0.45; cursor: not-allowed; }
.switch-row:has(.switch:disabled) { cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::before { transition: none; } }