/* ==========================================================================
   Chwma — "Night Line"
   Soft charcoal ground, the stranger's video as the whole stage, your camera as a
   corner tile, one dock of controls. One accent (amber unless the user picks
   another): Start / Next, the search line, the unread dot, and whatever is
   picked or can be picked (mode, interests, languages, toggles).
   ========================================================================== */

:root {
    color-scheme: dark;

    /* ground and surfaces: elevation by lightness alone */
    --ground: #16171a;
    --surface: #1e1f23;
    --raised: #28292e;
    --raised-hover: #33353b;
    --line: #2e3035;
    --control-line: #44464d;

    /* ink: three tiers, each ≥ 4.5:1 on --surface */
    --text: #ffffff;
    --muted: #b4b4b4;
    --faint: #949494;

    /* the one accent: streetlight amber */
    --accent: #ffb224;
    --accent-hover: #ffc04d;
    --accent-ink: #1a1200;

    /* amber as text, icons and focus rings (on dark the fill colour is bright enough) */
    --accent-strong: #ffb224;
    --focus: #ffb224;

    --positive: #3fc07a;
    --negative: #e5484d;
    --negative-hover: #f05a5f;

    /* inverted controls (white on dark), floating things, and what sits over video */
    --inverted-hover: #e6e6e6;
    --control-line-hover: #5e6068;
    --shadow-float: rgba(0, 0, 0, 0.7);
    --backdrop: rgba(0, 0, 0, 0.78);
    --scrim: rgba(0, 0, 0, 0.62);
    --scrim-text: #ffffff;
    /* over video and photos, in both themes: light ink, dark scrims */
    --on-media: #f7f6f2;
    --on-media-soft: rgb(255 255 255 / 0.15);
    --on-media-line: rgb(255 255 255 / 0.3);
    --media-scrim: rgb(0 0 0 / 0.58);
    --media-scrim-strong: rgb(0 0 0 / 0.74);
    --media-text-shadow: rgb(0 0 0 / 0.8);
    --veil: rgb(0 0 0 / 0.35);
    --page-dim: rgb(0 0 0 / 0.45);
    --danger-solid: #d92d20;
    --on-danger: #ffffff; /* white on red: tinting it drops below 4.5:1 */
    --tile-edge: rgba(255, 255, 255, 0.14);

    --font: 'Schibsted Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --radius-stage: 20px;
    --radius-card: 16px;
    --radius-control: 999px;

    --gutter: 16px;
    --bar-height: 64px;
    --control-size: 48px;

    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* --------------------------------------------------------------------------
   Light theme ("Day Line"): same structure, white surfaces, near-black ink.
   Set by /js/chwma/theme.js as <html data-theme="light"> (Auto follows the device).
   Amber stays the fill for Start / Next; text, icons and focus rings use a deeper
   amber, because #ffb224 on white is under 2:1.
   -------------------------------------------------------------------------- */
:root[data-theme='light'] {
    color-scheme: light;

    --ground: #f3f3f3;
    --surface: #fdfcfa;
    --raised: #ebebeb;
    --raised-hover: #dedede;
    --line: #e3e3e3;
    --control-line: #c9c9c9;

    --text: #111111;
    --muted: #555555;
    --faint: #6b6b6b;

    --accent-strong: #9a5b00;
    --focus: #9a5b00;

    --positive: #1e8449;
    --negative: #d93036;
    --negative-hover: #c2272d;

    --inverted-hover: #2a2a2a;
    --control-line-hover: #9a9a9a;
    --shadow-float: rgba(0, 0, 0, 0.16);
    --backdrop: rgba(0, 0, 0, 0.42);
    --scrim: rgba(255, 255, 255, 0.82);
    --scrim-text: #111111;
    --tile-edge: rgba(0, 0, 0, 0.12);
}

/* --------------------------------------------------------------------------
   Accent colours (Settings → Accent). Set by /js/ui/theme.js as <html data-accent>;
   amber is the default in :root above. Each fill keeps its ink ≥ 7:1 and stays
   ≥ 7:1 on --surface in dark; the light *-strong shades are ≥ 4.5:1 on --raised.
   -------------------------------------------------------------------------- */
:root[data-accent='teal'] {
    --accent: #2fd3b5;
    --accent-hover: #5ee0c8;
    --accent-ink: #00211b;
    --accent-strong: #2fd3b5;
    --focus: #2fd3b5;
}

:root[data-accent='blue'] {
    --accent: #5cb1ff;
    --accent-hover: #80c3ff;
    --accent-ink: #001a33;
    --accent-strong: #5cb1ff;
    --focus: #5cb1ff;
}

:root[data-accent='violet'] {
    --accent: #b897ff;
    --accent-hover: #cbb2ff;
    --accent-ink: #1b0a3d;
    --accent-strong: #b897ff;
    --focus: #b897ff;
}

:root[data-accent='rose'] {
    --accent: #ff7fa6;
    --accent-hover: #ff9ebc;
    --accent-ink: #33000f;
    --accent-strong: #ff7fa6;
    --focus: #ff7fa6;
}

:root[data-theme='light'][data-accent='teal'] {
    --accent-strong: #00766a;
    --focus: #00766a;
}

:root[data-theme='light'][data-accent='blue'] {
    --accent-strong: #0b62c4;
    --focus: #0b62c4;
}

:root[data-theme='light'][data-accent='violet'] {
    --accent-strong: #6d3fd4;
    --focus: #6d3fd4;
}

:root[data-theme='light'][data-accent='rose'] {
    --accent-strong: #c0245a;
    --focus: #c0245a;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    background: var(--ground);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    background: var(--ground);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

h1,
h2,
p {
    margin: 0;
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   Shell: top bar / stage / dock / footer
   -------------------------------------------------------------------------- */

/* Loading: the logo splash shows while chwma-app.js sets the page up (icons, interest chips, Start placement,
   labels), so the unfinished page never flashes. The ring draws itself and the amber dot arrives in its
   opening; then the splash fades out as the app fades in. If the script fails, both happen after 3s. */
.chwma-splash {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: var(--ground);
    color: var(--text);
    pointer-events: none;
}

.chwma-booting .chwma-splash {
    animation: chwma-splash-out 300ms ease 3s forwards;
}

.chwma-ready .chwma-splash {
    animation: chwma-splash-out 320ms ease forwards;
}

.chwma-ready .chwma-splash-mark {
    animation: chwma-mark-out 320ms ease forwards;
}

@keyframes chwma-splash-out {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* The small logo glides into the big logo's place (/js/ui/splash.js sets where) while the page appears around it. */
.chwma-glide .app-shell {
    animation: none;
}

.chwma-glide .chwma-splash {
    background-color: transparent;
    animation: none;
    transition: background-color 420ms ease;
}

.chwma-glide:not(.chwma-gliding) .chwma-splash {
    display: none;
}

.chwma-glide .chwma-splash-mark {
    animation: none;
    transform-origin: 0 0;
    transition: transform 560ms cubic-bezier(0.5, 0, 0.15, 1);
}

.chwma-gliding .chwma-mark {
    visibility: hidden;
}

/* a dialog opening meanwhile (a full server, say) waits for the logo to land, then opens as usual */
.chwma-gliding :is(.capacity-modal, .capacity-modal-card) {
    visibility: hidden;
    animation: none;
}

@keyframes chwma-mark-out {
    to {
        transform: scale(0.9);
    }
}

.chwma-splash-ring {
    opacity: 0;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: chwma-ring-draw 520ms cubic-bezier(0.65, 0, 0.35, 1) 60ms forwards;
}

@keyframes chwma-ring-draw {
    from {
        opacity: 0; /* hides the round line-end that would show as a dot before drawing starts */
    }
    12% {
        opacity: 1;
    }
    to {
        opacity: 1;
        stroke-dashoffset: 0;
    }
}

.chwma-splash-dot {
    fill: var(--accent);
    opacity: 0;
    transform: translateX(9px);
    transform-box: fill-box;
    transform-origin: center;
    animation: chwma-dot-arrive 420ms cubic-bezier(0.2, 0.9, 0.3, 1.25) 380ms forwards;
}

@keyframes chwma-dot-arrive {
    to {
        opacity: 1;
        transform: none;
    }
}

.chwma-booting .app-shell {
    visibility: hidden;
    animation: chwma-reveal 0s 3s forwards;
}

@keyframes chwma-reveal {
    to {
        visibility: visible;
    }
}

.chwma-ready .app-shell {
    animation: chwma-app-in 520ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes chwma-app-in {
    from {
        transform: translateY(12px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .chwma-splash-ring,
    .chwma-splash-dot,
    .chwma-ready .chwma-splash-mark {
        animation: none;
        opacity: 1;
        stroke-dashoffset: 0;
        transform: none;
    }

    .chwma-ready .app-shell {
        animation: none;
    }
}

.app-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    height: 100vh;
    height: 100dvh;
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}

.top-bar {
    position: relative;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: var(--bar-height);
    padding-top: env(safe-area-inset-top);
}

.brand,
.top-bar h1 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}

.app-title-icon {
    width: 28px;
    height: 28px;
    flex: none;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Connection state: a dot and a word, no chip */
.connection-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.connection-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--faint);
    flex: none;
}

.connection-badge.searching,
.connection-badge.waiting {
    color: var(--text);
}

.connection-badge.searching::before,
.connection-badge.waiting::before {
    background: var(--accent);
    animation: live-dot 1.4s ease-in-out infinite;
}

.connection-badge.connected {
    color: var(--text);
}

.connection-badge.connected::before {
    background: var(--positive);
}

.connection-badge.reconnecting::before,
.connection-badge.error::before {
    background: var(--negative);
}

.connection-badge.reconnecting,
.connection-badge.error {
    color: var(--text);
}

@keyframes live-dot {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.35;
    }
}

/* --------------------------------------------------------------------------
   Settings sheet (floats, so it may carry a shadow): a heading, three tabs, one short pane at a time
   -------------------------------------------------------------------------- */

.settings-panel {
    position: absolute;
    top: calc(var(--bar-height) + env(safe-area-inset-top) - 4px);
    right: 0;
    width: min(360px, 100%);
    max-height: calc(100dvh - var(--bar-height) - env(safe-area-inset-top) - 12px);
    overflow-y: auto;
    padding: 16px 20px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: 0 24px 64px var(--shadow-float);
    overscroll-behavior: contain;
    animation: sheet-in 160ms var(--ease);
}

.settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -4px -8px 12px 0;
}

.settings-heading {
    font-size: 17px;
    font-weight: 600;
}

.settings-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    margin-bottom: 20px;
    background: var(--raised);
    border-radius: 12px;
}

.settings-tabs button {
    height: 36px;
    padding: 0 8px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    transition:
        background-color 140ms ease,
        color 140ms ease;
}

.settings-tabs button:hover {
    color: var(--text);
}

.settings-tabs button[aria-selected='true'] {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--line);
}

/* the same height whichever tab is open, so the panel doesn't jump */
.settings-pane {
    display: grid;
    align-content: start;
    min-height: 222px;
}

/* with the notifications switch, Camera & sound is the tallest tab */
.settings-panel:has(#chwmaNotifyRow:not([hidden])) .settings-pane {
    min-height: 282px;
}

.notify-row {
    display: grid;
    gap: 2px;
}

.notify-row[hidden] {
    display: none;
}

/* the one-time offer in the conversation: the line, then its button */
.chat-message.notify-offer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 12px;
}

/* text mode has no camera or microphone: the panes are as tall as Matching */
:root[data-chat-mode='text'] .settings-pane,
:root[data-chat-mode='text'] .settings-panel:has(#chwmaNotifyRow:not([hidden])) .settings-pane {
    min-height: 158px;
}

.settings-pane[hidden] {
    display: none;
}

.device-controls {
    gap: 16px;
}

.input-group {
    display: grid;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
}

.input-group select {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 16px;
    background-color: var(--raised);
    color: var(--text);
    border: 1px solid var(--control-line);
    border-radius: 12px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b4b4b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
    transition: border-color 140ms ease;
}

.input-group select:hover:not(:disabled) {
    border-color: var(--control-line-hover);
}

.input-group select:disabled {
    color: var(--faint);
    cursor: not-allowed;
}

.input-group select option {
    background: var(--surface);
    color: var(--text);
}

.background-image-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.background-image-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    color: var(--muted);
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-flex;
    flex: none;
}

.switch input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch-track {
    position: relative;
    width: 40px;
    height: 24px;
    border-radius: 999px;
    background: var(--raised-hover);
    transition: background-color 160ms ease;
}

.switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--muted);
    transition:
        transform 160ms var(--ease),
        background-color 160ms ease;
}

.switch input:checked + .switch-track {
    background: var(--accent);
}

.switch input:checked + .switch-track::after {
    transform: translateX(16px);
    background: var(--accent-ink);
}

.switch input:focus-visible + .switch-track {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.settings-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font-size: 13px;
}

.settings-links a {
    color: var(--faint);
    text-decoration: none;
}

.settings-links a:hover {
    color: var(--text);
}

@keyframes sheet-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sheet-up {
    from {
        transform: translateY(100%);
    }
}

/* --------------------------------------------------------------------------
   Stage: the stranger fills it, you sit in the corner
   -------------------------------------------------------------------------- */

.video-layout {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
}

.video-card {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border-radius: var(--radius-stage);
}

.video-card video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--surface);
}

.video-card.remote {
    grid-area: 1 / 1;
}

/* your own camera: a floating corner tile */
.video-card.local {
    grid-area: 1 / 1;
    z-index: 5;
    align-self: end;
    justify-self: end;
    width: clamp(168px, 19vw, 300px);
    aspect-ratio: 4 / 3;
    margin: 16px;
    border-radius: var(--radius-card);
    /* a quiet camera glyph shows through until your camera's first frame covers it */
    background: var(--raised)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='none' stroke='%23949494' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5'/%3E%3Crect x='2' y='6' width='14' height='12' rx='2'/%3E%3C/svg%3E")
        center / 28px no-repeat;
    /* a hairline edge separates it from any video behind it; no drop shadow */
    box-shadow: 0 0 0 1px var(--tile-edge);
}

.video-card.local video {
    background: transparent;
}

/* mirror the self-view, as every camera app does */
#localVideo {
    transform: scaleX(-1);
}

.video-layout.self-preview-hidden .local {
    display: none;
}

/* the stage's labels */
.video-header {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.video-label {
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
    color: var(--on-media); /* always over video */
    background: var(--media-scrim);
    border-radius: 999px;
}

/* nobody to label until a stranger is actually on the line */
.remote .video-label {
    display: none;
}

.app-shell:has(.connection-badge.connected, .connection-badge.reconnecting) .remote .video-label {
    display: inline-block;
}

.local .video-header {
    top: 10px;
    left: 10px;
}

.local .video-label {
    font-size: 12px;
    padding: 4px 8px;
}

.media-status {
    display: inline-flex;
}

.media-pill {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    color: var(--on-danger);
    background: var(--negative);
    border-radius: 50%;
    pointer-events: auto;
}

.media-pill svg {
    width: 14px;
    height: 14px;
}

/* the night line: one amber line along the top of the stage.
   It sweeps while we look for someone and holds steady once you're connected. */
.night-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 6;
    height: 3px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 240ms ease;
}

.night-line::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent);
    transform-origin: left center;
}

.app-shell:has(.connection-badge.searching, .connection-badge.waiting) .night-line {
    opacity: 1;
}

.app-shell:has(.connection-badge.searching, .connection-badge.waiting) .night-line::after {
    width: 34%;
    animation: line-sweep 1.6s var(--ease) infinite;
}

.app-shell:has(.connection-badge.connected) .night-line {
    opacity: 0.9;
}

.app-shell:has(.connection-badge.reconnecting) .night-line {
    opacity: 1;
}

.app-shell:has(.connection-badge.reconnecting) .night-line::after {
    background: var(--negative);
    animation: live-dot 1.2s ease-in-out infinite;
}

@keyframes line-sweep {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(300%);
    }
}

/* camera-off avatars */
.local-avatar-overlay,
.remote-avatar-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 16px;
    background: var(--surface);
    color: var(--muted);
    font-size: 15px;
    text-align: center;
}

.local-avatar-overlay {
    background: var(--raised);
    gap: 8px;
    font-size: 12px;
}

.video-avatar {
    position: relative;
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--raised);
    color: var(--muted);
}

.video-avatar > svg {
    width: 40px;
    height: 40px;
}

.local .video-avatar {
    width: 48px;
    height: 48px;
    background: var(--raised-hover);
}

.local .video-avatar > svg {
    width: 22px;
    height: 22px;
}

.video-avatar-badge {
    position: absolute;
    right: 0;
    bottom: 0;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--text);
    color: var(--ground);
    box-shadow: 0 0 0 3px var(--surface);
}

.video-avatar-badge svg {
    width: 15px;
    height: 15px;
}

.local .video-avatar-badge {
    width: 20px;
    height: 20px;
    right: -2px;
    bottom: -2px;
    box-shadow: 0 0 0 2px var(--raised);
}

.local .video-avatar-badge svg {
    width: 11px;
    height: 11px;
}

/* waiting / searching / matched message on the stage */
.video-placeholder {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 12px;
    padding: 32px;
    text-align: center;
    background: var(--surface);
}

.placeholder-title {
    max-width: 18ch;
    font-size: 32px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.placeholder-text {
    max-width: 36ch;
    font-size: 16px;
    color: var(--muted);
    text-wrap: pretty;
}

.placeholder-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
}

.pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: live-dot 1.4s ease-in-out infinite;
}

/* the search beacon: an amber dot with one ring opening out of it */
.video-spinner,
.match-check {
    display: none;
    place-items: center;
    width: 72px;
    height: 72px;
    margin-bottom: 8px;
}

.video-placeholder[data-mode='searching'] .video-spinner {
    display: grid;
    position: relative;
}

.video-spinner::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
}

.video-spinner::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: beacon 1.8s var(--ease) infinite;
}

@keyframes beacon {
    0% {
        transform: scale(0.25);
        opacity: 0.9;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

.video-placeholder[data-mode='matched'] .match-check {
    display: grid;
    color: var(--accent-strong);
    animation: match-in 280ms var(--ease);
}

.match-check svg {
    width: 44px;
    height: 44px;
    stroke-width: 2.5;
}

@keyframes match-in {
    from {
        opacity: 0;
        transform: scale(0.6);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --------------------------------------------------------------------------
   Chat: a column beside the stage on desktop, a sheet on phones
   -------------------------------------------------------------------------- */

.video-layout:has(.chat-panel:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) 360px;
}

.chat-panel {
    grid-area: 1 / 2;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    min-height: 0;
    background: var(--surface);
    border-radius: var(--radius-stage);
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 12px 16px 20px;
    border-bottom: 1px solid var(--line);
}

.chat-title h2 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

.chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--positive);
}

.chat-scroll {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.chat-notice {
    align-self: center;
    font-size: 12px;
    color: var(--faint);
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 82%;
    animation: chat-message-in 180ms var(--ease);
}

.chat-message.me {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message.partner {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-message-text {
    padding: 8px 16px;
    font-size: 15px;
    line-height: 1.4;
    border-radius: 18px;
    overflow-wrap: anywhere;
}

.chat-message.me .chat-message-text {
    background: var(--text);
    color: var(--ground);
    border-bottom-right-radius: 6px;
}

.chat-message.partner .chat-message-text {
    background: var(--raised);
    color: var(--text);
    border-bottom-left-radius: 6px;
}

.chat-message-time {
    padding: 0 8px;
    font-family: var(--font);
    font-size: 11px;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
}

.chat-typing {
    display: inline-flex;
    align-self: flex-start;
    gap: 4px;
    padding: 12px 16px;
    background: var(--raised);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: chat-typing-bounce 1.2s ease-in-out infinite;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.15s;
}

.chat-typing-dot:nth-child(4) {
    animation-delay: 0.3s;
}

.chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
}

.chat-form input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 20px;
    font-size: 15px;
    background: var(--raised);
    border: 1px solid transparent;
    border-radius: 999px;
    transition: border-color 140ms ease;
}

.chat-form input::placeholder {
    color: var(--faint);
}

.chat-form input:focus-visible {
    outline: none;
    border-color: var(--focus);
}

.icon-btn.chat-send-btn {
    width: 44px;
    height: 44px;
    background: var(--text);
    color: var(--ground);
}

.icon-btn.chat-send-btn:hover:not(:disabled) {
    background: var(--inverted-hover);
}

@keyframes chat-message-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes chat-typing-bounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   Dock: status, call controls, the one action
   -------------------------------------------------------------------------- */

.control-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

.status-area {
    min-width: 0;
}

.status-area p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    color: var(--muted);
}

.call-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.control-divider {
    width: 1px;
    height: 28px;
    margin: 0 4px;
    background: var(--line);
}

.match-controls {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Wide screens: the call's buttons and End / Next are one group in the middle, under the conversation,
   instead of Next waiting in the far corner. (Tablets and phones stack the dock, below.) */
@media (min-width: 1025px) {
    .control-bar {
        grid-template-columns: minmax(0, 1fr) auto auto minmax(0, 1fr);
        column-gap: 20px;
    }

    .call-controls {
        grid-column: 2;
    }

    .match-controls {
        grid-column: 3;
        justify-content: flex-start;
    }
}

/* buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    transition:
        background-color 140ms ease,
        color 140ms ease,
        transform 120ms var(--ease),
        opacity 140ms ease;
}

.btn:active:not(:disabled) {
    transform: scale(0.96);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

.btn svg {
    width: 20px;
    height: 20px;
    flex: none;
}

.icon-btn {
    position: relative;
    width: var(--control-size);
    height: var(--control-size);
    padding: 0;
    border-radius: 50%;
    background: var(--raised);
    color: var(--text);
}

.icon-btn:hover:not(:disabled) {
    background: var(--raised-hover);
}

/* a control that is switched off (mic muted, camera off, preview hidden) inverts */
.icon-btn.off {
    background: var(--text);
    color: var(--ground);
}

.icon-btn.off:hover:not(:disabled) {
    background: var(--inverted-hover);
}

.ghost-btn {
    background: transparent;
    color: var(--muted);
}

.ghost-btn:hover:not(:disabled) {
    background: var(--raised);
    color: var(--text);
}

.top-bar .icon-btn {
    width: 44px;
    height: 44px;
}

.top-bar .icon-btn[aria-expanded='true'] {
    background: var(--raised);
    color: var(--text);
}

.icon-btn.end-btn {
    background: var(--negative);
    color: var(--on-danger);
}

.icon-btn.end-btn:hover:not(:disabled) {
    background: var(--negative-hover);
}

.icon-btn.has-unread::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--ground);
}

.pill-btn {
    height: var(--control-size);
    min-width: 132px;
    padding: 0 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-control);
    background: var(--raised);
    color: var(--text);
    white-space: nowrap;
}

.pill-btn:hover:not(:disabled) {
    background: var(--raised-hover);
}

.pill-btn.primary-btn {
    background: var(--accent);
    color: var(--accent-ink);
}

.pill-btn.primary-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.pill-btn.subtle-btn {
    background: var(--raised);
    color: var(--muted);
}

.pill-btn.end-btn {
    background: var(--negative);
    color: var(--on-danger);
}

.pill-btn.end-btn:hover:not(:disabled) {
    background: var(--negative-hover);
}

.subtle-btn {
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 999px;
    background: var(--raised);
    color: var(--text);
    flex: none;
}

.subtle-btn:hover:not(:disabled) {
    background: var(--raised-hover);
}

/* footer */
.app-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 0 0 max(16px, env(safe-area-inset-bottom));
    font-size: 13px;
}

.app-footer a {
    color: var(--faint);
    text-decoration: none;
}

.app-footer a:hover {
    color: var(--text);
}

/* --------------------------------------------------------------------------
   Dialogs
   -------------------------------------------------------------------------- */

.capacity-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
    background: var(--backdrop);
    overscroll-behavior: contain;
    animation: modal-backdrop-in 180ms ease;
}

.capacity-modal-card {
    display: grid;
    gap: 12px;
    width: min(440px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 32px 80px var(--shadow-float);
    animation: modal-card-in 220ms var(--ease);
}

.modal-icon {
    display: flex;
    margin-bottom: 4px;
    color: var(--text);
}

.modal-icon svg {
    width: 28px;
    height: 28px;
}

.modal-warning .modal-icon {
    color: var(--accent-strong);
}

.modal-danger .modal-icon {
    color: var(--negative);
}

.capacity-modal-card h2 {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.capacity-modal-card p {
    font-size: 15px;
    color: var(--muted);
    text-wrap: pretty;
}

.capacity-modal-card p a {
    color: var(--text);
    text-underline-offset: 3px;
}

.report-reasons {
    display: grid;
    gap: 2px;
    margin: 4px 0 0;
    padding: 0;
    border: 0;
}

.report-reasons legend {
    margin-bottom: 8px;
    padding: 0;
    font-size: 15px;
    font-weight: 600;
}

.report-reasons label {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
}

.report-reasons label:has(input:checked) {
    border-color: var(--accent-strong);
}

.report-reasons input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent-strong);
}

/* 18+ dialog: the Terms box that has to be ticked first */
.consent-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 4px;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
}

.consent-check:has(input:checked) {
    border-color: var(--accent-strong);
}

.consent-check:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.consent-check input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--accent-strong);
    cursor: pointer;
}

.consent-check a {
    color: var(--text);
    text-underline-offset: 3px;
}

.modal-actions .pill-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
}

.modal-actions .pill-btn {
    min-width: 0;
}

@keyframes modal-backdrop-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modal-card-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* tooltips: a plain box, no arrow */
.tippy-box[data-theme~='chwma'] {
    background: var(--text);
    color: var(--ground);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    border-radius: 8px;
}

.tippy-box[data-theme~='chwma'] .tippy-content {
    padding: 8px 12px;
}

.tippy-box[data-theme~='chwma'] > .tippy-arrow {
    display: none;
}

/* --------------------------------------------------------------------------
   Offline page (pages/offline.html shares this stylesheet)
   -------------------------------------------------------------------------- */

.offline-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.offline-layout {
    display: grid;
    place-items: center;
    min-height: 0;
}

.offline-card {
    display: grid;
    gap: 20px;
    width: min(520px, 100%);
    padding: 32px;
    border-radius: 24px;
}

.offline-card .video-header {
    position: static;
    justify-content: space-between;
    font-size: 14px;
    color: var(--muted);
}

.offline-content {
    display: grid;
    gap: 12px;
}

.offline-content h2 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.offline-content p {
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   Tablet
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
    .video-layout:has(.chat-panel:not([hidden])) {
        grid-template-columns: minmax(0, 1fr) 320px;
    }

    .control-bar {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            'status status'
            'controls match';
        gap: 12px 16px;
    }

    .status-area {
        grid-area: status;
    }

    .call-controls {
        grid-area: controls;
        justify-content: flex-start;
    }

    .match-controls {
        grid-area: match;
    }
}

/* --------------------------------------------------------------------------
   Phone: edge-to-edge stage, chat as a bottom sheet, one big action
   -------------------------------------------------------------------------- */

@media (max-width: 720px) {
    :root {
        --bar-height: 56px;
        --control-size: 48px;
        --radius-stage: 18px;
    }

    .app-shell {
        padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
    }

    .top-bar {
        padding-left: 8px;
        padding-right: 4px;
    }

    .brand,
    .top-bar h1 {
        font-size: 19px;
    }

    /* phones: a sheet from the bottom, within thumb reach, over a dimmed page */
    .settings-panel {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 60;
        width: auto;
        max-height: 88dvh;
        padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
        border-width: 1px 0 0;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 0 0 100vmax var(--page-dim);
        animation: sheet-up 220ms var(--ease);
    }

    .settings-panel::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        margin: 0 auto 12px;
        border-radius: 2px;
        background: var(--control-line);
    }

    .video-card.local {
        width: 31vw;
        max-width: 150px;
        aspect-ratio: 3 / 4;
        margin: 12px;
        border-radius: 14px;
    }

    .local .video-label {
        display: none;
    }

    .placeholder-title {
        font-size: 26px;
    }

    .placeholder-text {
        font-size: 15px;
    }

    .video-placeholder {
        padding: 24px 24px 33vw;
    }

    /* chat slides up over the stage */
    .video-layout:has(.chat-panel:not([hidden])) {
        grid-template-columns: minmax(0, 1fr);
    }

    .chat-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        height: min(64dvh, 560px);
        border-radius: 22px 22px 0 0;
        border: 1px solid var(--line);
        border-bottom: 0;
        box-shadow: 0 -24px 64px var(--shadow-float);
        padding-bottom: env(safe-area-inset-bottom);
        animation: sheet-up 220ms var(--ease);
    }

    .control-bar {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            'status'
            'controls'
            'match';
        gap: 12px;
        padding: 12px 8px max(12px, env(safe-area-inset-bottom));
    }

    .status-area p {
        font-size: 14px;
        text-align: center;
    }

    .call-controls {
        justify-content: center;
        gap: 12px;
    }

    .match-controls .pill-btn {
        flex: 1;
        height: 54px;
        font-size: 17px;
    }

    .app-footer {
        display: none;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .pill-btn {
        width: 100%;
    }

    .capacity-modal {
        align-items: end;
        padding: 8px;
    }

    .capacity-modal-card {
        padding: 24px;
        border-radius: 24px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }

    .offline-card {
        padding: 24px;
    }
}

@keyframes sheet-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@media (max-width: 380px) {
    :root {
        --control-size: 44px;
    }

    .call-controls {
        gap: 8px;
    }

    .control-divider {
        display: none;
    }
}

/* short landscape screens: keep the dock compact */
@media (max-height: 560px) and (min-width: 721px) {
    :root {
        --bar-height: 52px;
        --control-size: 44px;
    }

    .control-bar {
        padding: 12px 0;
    }

    .app-footer {
        display: none;
    }
}

@media (pointer: fine) {
    html {
        overscroll-behavior: none;
    }
}

/* --------------------------------------------------------------------------
   Reduced motion: keep every state, drop the travel
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }

    .app-shell:has(.connection-badge.searching, .connection-badge.waiting) .night-line::after {
        width: 100%;
        opacity: 0.6;
        transform: none;
    }

    .video-spinner::after {
        opacity: 0.5;
        transform: none;
    }
}

/* ==========================================================================
   Chat mode switch (Video / Text) and text mode
   ========================================================================== */

.mode-switch {
    display: inline-flex;
    gap: 4px;
    margin-top: 20px;
    padding: 4px;
    background: var(--raised);
    border-radius: 999px;
}

.mode-switch button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 20px;
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition:
        background-color 140ms ease,
        color 140ms ease;
}

.mode-switch button svg {
    width: 18px;
    height: 18px;
}

.mode-switch button:hover {
    color: var(--text);
}

.mode-switch button[aria-checked='true'] {
    background: var(--accent);
    color: var(--accent-ink);
}

/* the choice is made before Start; once matching begins it gets out of the way */
.video-placeholder:not([data-mode='idle']) .mode-switch,
.app-shell:has(#startBtn[hidden]) .mode-switch {
    display: none;
}

/* system lines inside a chat */
.chat-message.system {
    align-self: center;
    max-width: 90%;
    padding: 4px 0;
    font-size: 13px;
    color: var(--faint);
    text-align: center;
    animation: none;
}

/* ---- text mode ---- */

:root[data-chat-mode='text'] .video-card.local,
:root[data-chat-mode='text'] #muteBtn,
:root[data-chat-mode='text'] #cameraBtn,
:root[data-chat-mode='text'] #hideSelfBtn,
:root[data-chat-mode='text'] #enableSoundBtn,
:root[data-chat-mode='text'] #chatBtn,
:root[data-chat-mode='text'] #chatCloseBtn,
:root[data-chat-mode='text'] .control-divider,
:root[data-chat-mode='text'] .remote .video-header,
:root[data-chat-mode='text'] .settings-panel .input-group,
:root[data-chat-mode='voice'] .settings-panel .input-group:has(#cameraSelect) {
    display: none !important;
}

/* the conversation takes the whole stage */
:root[data-chat-mode='text'] .video-layout:has(.chat-panel:not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
}

:root[data-chat-mode='text'] .chat-panel {
    grid-area: 1 / 1;
    z-index: 7;
    position: relative;
    inset: auto;
    height: auto;
    border: 0;
    border-radius: var(--radius-stage);
    box-shadow: none;
    padding-bottom: 0;
    animation: none;
}

/* keep lines readable on wide screens: one centred 720px column */
:root[data-chat-mode='text'] .chat-header,
:root[data-chat-mode='text'] .chat-scroll,
:root[data-chat-mode='text'] .starter-chips,
:root[data-chat-mode='text'] .chat-form {
    padding-inline: max(16px, calc((100% - 720px) / 2));
}

:root[data-chat-mode='text'] .chat-message-text {
    font-size: 16px;
}

:root[data-chat-mode='text'] .call-controls {
    gap: 12px;
}

/* ==========================================================================
   Interests, who's online, "You both like…", and Ask to video
   ========================================================================== */

.interests {
    display: grid;
    justify-items: center;
    gap: 12px;
    width: min(560px, 100%);
    margin-top: 20px;
}

.interests-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.interests-label span {
    font-weight: 400;
    color: var(--faint);
}

.interest-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.interest-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    background: var(--raised);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    flex: none;
    transition:
        background-color 140ms ease,
        color 140ms ease;
}

.interest-chip:hover:not(:disabled) {
    color: var(--text);
    background: var(--raised-hover);
}

.interest-chip[aria-pressed='true'],
.interest-chip[aria-pressed='true']:hover:not(:disabled) {
    background: var(--accent);
    color: var(--accent-ink);
}

.interest-chip[aria-pressed='true']:hover:not(:disabled) {
    background: var(--accent-hover);
}

.interest-chip[aria-pressed='true'] svg {
    width: 14px;
    height: 14px;
}

.interest-chip:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.interest-form input {
    width: min(260px, 70vw);
    height: 38px;
    padding: 0 16px;
    font-size: 14px;
    text-align: center;
    background: transparent;
    border: 1px dashed var(--accent-strong);
    border-radius: 999px;
}

.interest-form input::placeholder {
    color: var(--accent-strong);
}

.interest-form input:focus-visible {
    outline: none;
    border-style: solid;
    border-color: var(--focus);
}

.interest-form input:disabled {
    background: var(--raised);
    color: var(--faint);
    border-color: var(--line);
    cursor: not-allowed;
}

.presence {
    display: block;
    min-height: 1.5em;
    margin-top: 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
    transition: opacity 200ms ease;
}

/* Keeps its line while the count is on its way (or under 2), so nothing below it jumps. */
.app-shell:not(:has(#startBtn[hidden])) .presence[hidden] {
    display: block !important; /* beats the global [hidden] rule; still invisible */
    visibility: hidden;
    opacity: 0;
}

.presence::before {
    content: '';
    display: inline-block;
    margin-right: 8px;
    vertical-align: 1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--positive);
}

/* the picker and the count belong to the start screen only */
.video-placeholder:not([data-mode='idle']) :is(.interests, .presence),
.app-shell:has(#startBtn[hidden]) :is(.interests, .presence) {
    display: none;
}

/* "You both like Music" next to the Stranger label */
.video-label.common-tags {
    background: var(--media-scrim-strong);
    color: var(--accent);
}

/* an invitation to switch to video, inside the chat */
.chat-message.upgrade-invite {
    display: grid;
    gap: 12px;
    justify-items: center;
    width: min(360px, 100%);
    margin: 8px 0;
    padding: 16px;
    font-size: 15px;
    color: var(--text);
    background: var(--raised);
    border-radius: 16px;
}

.upgrade-actions {
    display: flex;
    gap: 8px;
}

.upgrade-actions .pill-btn {
    height: 40px;
    min-width: 0;
    padding: 0 20px;
    font-size: 15px;
}

.upgrade-actions .pill-btn:not(.primary-btn) {
    background: var(--raised-hover);
}

/* phone: suggestions become one row you swipe through */
@media (max-width: 720px) {
    .interests {
        width: calc(100% + 48px);
        margin-inline: -24px;
    }

    .interest-chips {
        flex-wrap: nowrap;
        justify-content: flex-start;
        width: 100%;
        padding: 2px 24px;
        overflow-x: auto;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
    }

    .interest-chips::-webkit-scrollbar {
        display: none;
    }

    .mode-switch {
        margin-top: 16px;
    }
}

/* ==========================================================================
   UX pass: small screens, quieter controls, Start where the choices are,
   Stop, a movable self-view, full-screen calls on phones
   ========================================================================== */

/* Small phones: the start screen scrolls instead of being cut off at the top
   ("safe" centring falls back to the top edge when the content is taller than the stage).
   No overscroll-behavior: contain here: Chrome then keeps the wheel and swipes from reaching the page
   even when the stage has nothing to scroll, so the page below couldn't be scrolled from it. */
.video-placeholder {
    overflow-y: auto;
    align-content: center;
    align-content: safe center;
}

/* Controls are tapped, not read: no long-press text selection or callout on them. */
.btn,
.mode-switch,
.interest-chip,
.interests-label,
.connection-badge,
.video-label {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Only show controls that can be used right now (no greyed-out mute, report or hang-up before a chat). */
.call-controls .btn:disabled {
    display: none;
}

.call-controls:not(:has(.btn:not([hidden]):not(:disabled))) {
    display: none;
}

.call-controls:not(:has(#reportBtn:not([hidden]):not(:disabled), #endSessionBtn:not(:disabled))) .control-divider {
    display: none;
}

/* The status line only appears when it has something to say. */
.status-area:has(p:empty) {
    visibility: hidden;
}

/* Start, on wide screens, sits under the choices on the stage. */
.start-slot:empty {
    display: none;
}

.start-slot {
    margin-top: 24px;
}

.start-slot #startBtn {
    height: 54px;
    min-width: 220px;
    font-size: 17px;
}

/* Stop replaces Next while searching. */
.app-shell:has(#chwmaStopBtn:not([hidden])) #nextBtn {
    display: none;
}

.interest-chip.interest-more {
    background: transparent;
    color: var(--accent-strong);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* A text chat that has ended: still readable, clearly finished. */
.chat-form input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Your camera tile, in the corner you dragged it to. */
.video-card.local {
    cursor: grab;
    transition: transform 220ms var(--ease);
}

.video-card.local.is-dragging {
    cursor: grabbing;
    transition: none;
    z-index: 8;
}

.video-card.local[data-corner='tl'] {
    align-self: start;
    justify-self: start;
}

.video-card.local[data-corner='tr'] {
    align-self: start;
    justify-self: end;
}

.video-card.local[data-corner='bl'] {
    align-self: end;
    justify-self: start;
}

.video-card.local[data-corner='br'] {
    align-self: end;
    justify-self: end;
}

/* the stranger's label moves out of the way of a tile in the top-left corner */
.app-shell:has(.video-card.local[data-corner='tl']) .remote .video-header {
    left: auto;
    right: 14px;
}

/* No tooltips on touch screens: a tap would leave them stuck over the controls. */
@media (hover: none) {
    [data-tippy-root] {
        display: none !important;
    }
}

@media (max-width: 720px) {
    /* text mode has no camera tile to keep clear of */
    :root[data-chat-mode='text'] .video-placeholder {
        padding-bottom: 24px;
    }

    /* Full-screen video call: controls float over the video and fade out; tap to bring them back. */
    :root[data-immersive='on'] .control-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
        padding: 16px 16px max(16px, env(safe-area-inset-bottom));
        background: var(--scrim);
        transition:
            transform 240ms var(--ease),
            opacity 240ms ease;
    }

    :root[data-immersive='on'][data-controls='hidden'] .control-bar {
        transform: translateY(100%);
        opacity: 0;
        pointer-events: none;
    }

    :root[data-immersive='on'] .video-layout {
        margin-bottom: max(8px, env(safe-area-inset-bottom));
    }

    :root[data-immersive='on'] .status-area:has(p:empty) {
        display: none;
    }

    /* keep the self-view clear of the floating controls while they're shown */
    :root[data-immersive='on']:not([data-controls='hidden']) .video-card.local[data-corner^='b'] {
        translate: 0 -152px;
    }

    :root[data-immersive='on'] .video-card.local {
        transition:
            transform 220ms var(--ease),
            translate 240ms var(--ease);
    }
}

/* Short screens (small phones, landscape): tighter start screen. */
@media (max-height: 700px) {
    .placeholder-title {
        font-size: 24px;
    }

    .placeholder-text {
        font-size: 14px;
    }

    .mode-switch {
        margin-top: 12px;
    }

    .mode-switch button {
        height: 36px;
    }

    .interests {
        margin-top: 12px;
        gap: 8px;
    }

    .interest-chip {
        height: 32px;
    }

    .interest-form input {
        height: 34px;
    }

    .presence {
        margin-top: 12px;
    }

    .video-placeholder {
        gap: 8px;
        padding-top: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    :root[data-immersive='on'] .control-bar,
    .video-card.local {
        transition: none;
    }
}

@media (max-width: 1024px) {
    /* stacked dock: an empty status row takes no space at all */
    .status-area:has(p:empty) {
        display: none;
    }
}

.chat-status.is-ended .chat-status-dot {
    background: var(--faint);
}

.icon-btn.chat-send-btn:disabled {
    background: var(--raised);
    color: var(--faint);
}

/* ==========================================================================
   On-screen keyboard (see /js/chwma/keyboard.js)
   ========================================================================== */

/* the app fits the part of the screen the keyboard leaves visible */
:root[data-keyboard='open'] .app-shell {
    height: var(--app-height, 100dvh);
}

@media (max-width: 720px) {
    /* while typing, the conversation gets the room: call controls step aside until the keyboard closes */
    :root[data-keyboard='open'] .control-bar,
    :root[data-keyboard='open'] .app-footer {
        display: none;
    }

    /* the video-mode chat sheet hangs from under the top bar, so its input sits right above the keyboard
       (in text mode the chat already fills the stage, which shrinks with the app) */
    :root[data-keyboard='open']:not([data-chat-mode='text']) .chat-panel {
        top: calc(var(--bar-height) + env(safe-area-inset-top));
        bottom: auto;
        height: calc(var(--app-height, 100dvh) - var(--bar-height) - env(safe-area-inset-top));
        border-radius: 22px 22px 0 0;
        animation: none;
    }
}

/* ==========================================================================
   Appearance: Auto / Light / Dark (settings panel)
   ========================================================================== */

.app-title-icon {
    color: var(--text);
}

/* the offline page still uses the logo image (white C); darken it on light */
:root[data-theme='light'] img.app-title-icon {
    filter: invert(1) hue-rotate(180deg);
}

.theme-row {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
}

.theme-switch {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    background: var(--raised);
    border-radius: 12px;
}

.theme-switch button {
    height: 36px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition:
        background-color 140ms ease,
        color 140ms ease;
}

.theme-switch button:hover {
    color: var(--text);
}

.theme-switch button[aria-checked='true'] {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--line);
}

/* Accent: one round swatch per colour; the picked one gets a ring */
.accent-switch {
    display: flex;
    gap: 12px;
    padding: 4px 2px;
}

.accent-switch button {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--swatch);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: box-shadow 140ms ease;
}

.accent-switch button:hover {
    box-shadow:
        0 0 0 2px var(--surface),
        0 0 0 4px var(--control-line);
}

.accent-switch button[aria-checked='true'] {
    box-shadow:
        0 0 0 2px var(--surface),
        0 0 0 4px var(--text);
}

.accent-switch button:focus-visible {
    outline-offset: 5px;
}

.accent-switch [data-accent-choice='amber'] {
    --swatch: #ffb224;
}

.accent-switch [data-accent-choice='teal'] {
    --swatch: #2fd3b5;
}

.accent-switch [data-accent-choice='blue'] {
    --swatch: #5cb1ff;
}

.accent-switch [data-accent-choice='violet'] {
    --swatch: #b897ff;
}

.accent-switch [data-accent-choice='rose'] {
    --swatch: #ff7fa6;
}

/* Custom: a colour wheel, with the picked colour in the middle once there is one (--swatch is set
   inline by /js/app.js). The real <input type="color"> sits invisibly on top so the browser's picker
   opens next to the swatch. */
.accent-custom {
    position: relative;
    display: inline-flex;
}

.accent-switch [data-accent-choice='custom'] {
    --swatch: transparent;
    background:
        radial-gradient(circle, var(--swatch) 0 40%, transparent 42%),
        conic-gradient(#ff4d4d, #ffd84d, #4dff88, #4dd2ff, #7a5cff, #ff4dd2, #ff4d4d);
}

.accent-custom input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

/* the first row of a tab sits right under the tabs */
.settings-pane > .theme-row:first-child {
    margin-top: 0;
}

/* ==========================================================================
   Start screen extras ("What is Chwma?" goes to the website, chwma.com)
   ========================================================================== */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

.learn-more {
    margin-top: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    text-underline-offset: 4px;
}

.learn-more:hover {
    color: var(--text);
}

.video-placeholder:not([data-mode='idle']) .learn-more,
.app-shell:has(#startBtn[hidden]) .learn-more {
    display: none;
}

/* --------------------------------------------------------------------------
   New Features: Camera Flip, Blur & P2P File Sharing
   -------------------------------------------------------------------------- */
#blurBtn.active {
    background: var(--accent);
    color: var(--accent-ink);
}

#flipCameraBtn:active {
    transform: rotate(180deg);
    transition: transform 300ms ease;
}

.chat-attach-btn {
    color: var(--muted);
    transition: color 150ms ease;
    margin-right: 4px;
}

/* With the attach button the row is one button wider: let the message box shrink (a text input's built-in
   minimum width otherwise pushes the send button past the panel edge on phones). */
.chat-form {
    min-width: 0;
}

.chat-form input#chatInput {
    width: 0;
}

.chat-attach-btn:hover {
    color: var(--text);
}

.chat-file-bubble {
    padding: 6px;
}

/* a photo in the chat; the stranger's is blurred under a veil until the check (or a tap) clears it */
.chat-photo {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.chat-photo-open {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}

.chat-file-img {
    display: block;
    width: auto;
    max-width: min(240px, 60vw);
    max-height: 240px;
    min-width: 120px;
    min-height: 90px;
    object-fit: cover;
    border-radius: 12px;
}

.chat-photo[data-veil] .chat-photo-open {
    cursor: default;
}

.chat-photo[data-veil] .chat-file-img {
    /* room for the words and buttons, however narrow the photo */
    min-width: min(220px, 60vw);
    min-height: 150px;
    filter: blur(28px) saturate(0.6);
    transform: scale(1.15); /* no sharp edge where the blur fades out */
}

.chat-photo-veil {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    justify-items: center;
    gap: 8px;
    padding: 10px;
    text-align: center;
    color: #fff;
    background: rgb(0 0 0 / 0.4);
}

.chat-photo-text {
    max-width: 100%;
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.chat-photo-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.chat-photo-actions .btn {
    height: 30px;
    padding: 0 12px;
    font-size: 13px;
}

.chat-photo-actions .btn[hidden] {
    display: none;
}

.chat-photo[data-veil='checking'] .chat-photo-show {
    opacity: 0.85;
}

.chat-progress {
    font-size: 13px;
}

/* a photo opened larger, over everything; any tap closes it */
.photo-viewer {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    background: rgb(0 0 0 / 0.88);
    cursor: zoom-out;
}

.photo-viewer img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    object-fit: contain;
}

.photo-viewer-close {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    color: #fff;
    background: rgb(255 255 255 / 0.14);
}

/* ==========================================================================
   Languages, Settings → Matching, conversation starters and Mutual ReConnect
   ========================================================================== */

.interests.languages {
    margin-top: 16px;
}

/* "+ Add a language": a chip that opens the browser's own list */
.language-select {
    max-width: 200px;
    padding-right: 16px;
    color: var(--accent-strong);
    background: transparent;
    border: 1px dashed var(--accent-strong);
    appearance: none;
    text-overflow: ellipsis;
}

.language-select:hover:not(:disabled) {
    border-style: solid;
}

.language-select:focus-visible {
    outline: none;
    border-style: solid;
    border-color: var(--focus);
}

.language-select option {
    background: var(--surface);
    color: var(--text);
}

.matching-settings {
    gap: 4px;
}

.matching-settings .theme-row {
    margin-top: 8px;
}

.matching-note {
    font-size: 13px;
    font-weight: 400;
    color: var(--faint);
    text-wrap: pretty;
}

/* conversation starter over the stranger's video */
.starter-overlay {
    position: absolute;
    left: 50%;
    bottom: 16px;
    z-index: 4;
    display: grid;
    gap: 8px;
    width: min(460px, calc(100% - 32px));
    padding: 16px 16px;
    color: var(--scrim-text);
    background: var(--scrim);
    border-radius: var(--radius-card);
    transform: translateX(-50%);
    animation: modal-card-in 220ms var(--ease);
}

.starter-label {
    font-size: 13px;
    color: var(--accent-strong);
}

.starter-text {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
    text-wrap: pretty;
}

.starter-overlay-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.starter-overlay-actions .pill-btn {
    height: 36px;
    min-width: 0;
    padding: 0 16px;
    font-size: 14px;
    color: var(--scrim-text);
    background: var(--on-media-soft);
}

.starter-overlay-actions .icon-btn {
    width: 36px;
    height: 36px;
    color: var(--scrim-text);
}

/* a text chat: three ideas right above the message box; tap one to put it in the box */
.starter-chips {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 12px 12px 0;
    border-top: 1px solid var(--line);
}

.starter-chips:not([hidden]) + .chat-form {
    border-top: 0;
}

:root:not([data-chat-mode='text']) .starter-chips {
    display: none;
}

/* each idea: tap the text to use it, × for a different one */
.starter-chip {
    display: flex;
    align-items: stretch;
    min-width: 0;
    min-height: 44px;
    background: var(--raised);
    border: 1px solid transparent;
    border-radius: 14px;
    transition: border-color 140ms ease;
}

.starter-chip:has(.starter-chip-use:hover) {
    border-color: var(--accent);
}

.starter-chip:has(:focus-visible) {
    border-color: var(--focus);
}

.starter-chip button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

.starter-chip button:focus-visible {
    outline: none;
}

.starter-chip-use {
    flex: 1;
    min-width: 0;
    padding: 8px 4px 8px 16px;
    font-size: 13px;
    line-height: 1.35;
    text-align: left;
    color: var(--text);
}

.starter-chip-use span {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    text-wrap: pretty;
}

.starter-chip-skip {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    color: var(--faint);
    border-radius: 0 14px 14px 0;
    transition: color 140ms ease;
}

.starter-chip-skip:hover,
.starter-chip-skip:focus-visible {
    color: var(--text);
}

.starter-chip-skip svg {
    width: 16px;
    height: 16px;
}

/* phones: one row that scrolls sideways */
@media (max-width: 720px) {
    .starter-chips {
        grid-auto-columns: 72%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .starter-chips::-webkit-scrollbar {
        display: none;
    }

    .starter-chip {
        scroll-snap-align: start;
    }
}

/* Reconnect: amber once tapped */
.reconnect-btn.active,
.reconnect-btn[aria-pressed='true'] {
    color: var(--accent-strong);
}

.reconnect-btn[aria-disabled='true'] {
    cursor: default;
}

/* start screen: the way into Connections */
.connections-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    margin-top: 12px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--raised);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 140ms ease;
}

.connections-btn:hover {
    background: var(--raised-hover);
}

.connections-btn svg {
    width: 16px;
    height: 16px;
}

.connections-count {
    font-weight: 500;
    color: var(--muted);
}

.connections-btn.has-online .connections-count::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    vertical-align: 1px;
    border-radius: 50%;
    background: var(--positive);
}

.video-placeholder:not([data-mode='idle']) .connections-btn,
.app-shell:has(#startBtn[hidden]) .connections-btn {
    display: none;
}

/* the Connections dialog */
.connections-card {
    width: min(520px, 100%);
}

.connections-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.connections-list {
    display: grid;
    gap: 8px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.connection-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 12px 12px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.connection-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.capacity-modal-card .connection-name {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.capacity-modal-card .connection-meta,
.capacity-modal-card .connection-confirm {
    font-size: 13px;
    color: var(--faint);
}

.capacity-modal-card .connection-confirm {
    margin-top: 4px;
    color: var(--muted);
}

.connection-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 8px;
    vertical-align: 1px;
    border-radius: 50%;
    background: var(--faint);
}

.connection-row[data-online='true'] .connection-status {
    color: var(--positive);
}

.connection-row[data-online='true'] .connection-status::before {
    background: var(--positive);
}

.connection-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 2px;
}

.connection-chat-btn {
    height: 36px;
    min-width: 0;
    margin-right: 4px;
    padding: 0 16px;
    font-size: 14px;
}

.connection-chat-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.connection-icon-btn {
    width: 36px;
    height: 36px;
    color: var(--muted);
}

.connection-icon-btn svg {
    width: 16px;
    height: 16px;
}

.connection-waiting {
    margin-right: 8px;
    font-size: 13px;
    color: var(--muted);
}

.connection-rename input {
    width: 100%;
    height: 34px;
    padding: 0 12px;
    font-size: 15px;
    color: var(--text);
    background: var(--raised);
    border: 1px solid var(--control-line);
    border-radius: 8px;
}

.connection-rename input:focus-visible {
    outline: none;
    border-color: var(--focus);
}

.connection-empty {
    padding: 16px;
    font-size: 14px;
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: 14px;
}

@media (max-width: 480px) {
    .connection-row {
        flex-wrap: wrap;
    }

    .connection-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ==========================================================================
   The logo is the hero: the big C and the name. Its dot leaves while searching and lands
   when someone is found. Quiet everywhere else: no cards, no badge, few controls.
   ========================================================================== */

.video-card.remote,
.video-placeholder {
    background: var(--ground);
}

.night-line,
.control-divider,
.video-spinner,
.match-check,
.placeholder-pill,
.remote .video-header > .video-label:first-child {
    display: none !important;
}

/* the badge speaks only when something is wrong */
.connection-badge:not(.reconnecting, .error) {
    display: none;
}

.video-placeholder,
.video-placeholder[data-mode] {
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
    gap: 24px;
    text-align: left;
}

.chwma-hero {
    display: grid;
    gap: 20px;
    justify-items: start;
}

.chwma-mark {
    display: block;
    width: 100%;
    max-width: 330px;
    height: auto;
    margin-left: -8px;
    color: var(--text);
}

.chwma-wordmark {
    margin: -8px 0 -8px;
    font-size: 60px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
}

.video-placeholder:not([data-mode='idle']) .chwma-wordmark {
    display: none;
}

/* the name, always easy to read; on the start screen the big one below takes over */
.brand {
    gap: 12px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand .app-title-icon {
    width: 30px;
    height: 30px;
}

.app-shell:has(.video-placeholder[data-mode='idle']) .brand {
    visibility: hidden;
}

/* Settings: a round gear on a solid circle (easy to spot, unlike a faint icon); it turns a little
   while the panel is open */
#settingsBtn {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    color: var(--text);
    background: var(--raised);
    border: 1px solid var(--control-line);
    border-radius: 50%;
}

#settingsBtn:hover,
#settingsBtn[aria-expanded='true'] {
    background: var(--raised-hover);
}

#settingsBtn svg {
    width: 20px;
    height: 20px;
    transition: transform 320ms var(--ease);
}

#settingsBtn[aria-expanded='true'] svg {
    transform: rotate(60deg);
}

@media (prefers-reduced-motion: reduce) {
    #settingsBtn svg {
        transition: none;
    }
}

.chwma-dot {
    fill: var(--accent);
    transition: transform 520ms cubic-bezier(0.3, 1.5, 0.5, 1);
}

.video-placeholder[data-mode='searching'] .chwma-dot {
    animation: chwma-dot-away 1.8s ease-in-out infinite alternate;
    transform: translate(12px, -5px);
}

@keyframes chwma-dot-away {
    from {
        transform: translate(7px, -3px);
    }
    to {
        transform: translate(12px, -5px);
    }
}

/* On the start screen the logo keeps telling its story: the dot drifts out of the C, comes back with a
   small bounce, and a ring ripples where it lands, as if someone just arrived. */
.chwma-dot-ring {
    fill: none;
    stroke: var(--accent);
    stroke-width: 0.8;
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}

.video-placeholder[data-mode='idle'] .chwma-dot {
    animation: chwma-dot-idle 7s ease-in-out infinite;
}

.video-placeholder[data-mode='idle'] .chwma-dot-ring {
    animation: chwma-ring-land 7s ease-out infinite;
}

@keyframes chwma-dot-idle {
    0%,
    55% {
        transform: none;
    }
    68%,
    76% {
        transform: translate(10px, -4px);
    }
    84% {
        transform: translate(-0.8px, 0.3px);
    }
    89%,
    100% {
        transform: none;
    }
}

@keyframes chwma-ring-land {
    0%,
    83% {
        opacity: 0;
        transform: scale(1);
    }
    84% {
        opacity: 0.7;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(2.6);
    }
}

/* after the glide the name, tagline and choices arrive just behind the logo */
html.chwma-glide .video-placeholder[data-mode='idle'] .chwma-wordmark {
    animation-delay: 400ms;
}

html.chwma-glide .video-placeholder[data-mode='idle'] .placeholder-title {
    animation-delay: 480ms;
}

.chwma-gliding .chwma-choices,
.chwma-gliding .top-bar-actions {
    animation: chwma-rise 480ms var(--ease) 360ms both;
}

/* the name and tagline rise in when the start screen appears */
.chwma-ready .video-placeholder[data-mode='idle'] :is(.chwma-wordmark, .placeholder-title) {
    animation: chwma-rise 520ms var(--ease) both;
}

.chwma-ready .video-placeholder[data-mode='idle'] .placeholder-title {
    animation-delay: 90ms;
}

@keyframes chwma-rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}

.placeholder-title {
    max-width: none;
    font-size: 26px;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.placeholder-text {
    max-width: 40ch;
    margin-top: -12px;
}

.placeholder-text:empty {
    display: none;
}

.chwma-choices {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.video-placeholder:not([data-mode='idle']) .chwma-choices {
    display: none;
}

/* Video / Text: two words, the picked one underlined */
.mode-switch {
    justify-self: start;
    gap: 16px;
    padding: 0;
    margin: 0;
    background: transparent;
}

.mode-switch button,
.mode-switch button[aria-checked='true'],
.mode-switch button:hover {
    min-height: 44px;
    padding: 0 4px;
    font-size: 17px;
    border-radius: 0;
    background: transparent;
    border-bottom: 2px solid transparent;
    color: var(--muted);
}

.mode-switch button[aria-checked='true'] {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.mode-switch button svg {
    display: none;
}

.interests {
    justify-items: start;
    text-align: left;
}

.chwma-options {
    display: grid;
    gap: 16px;
}

.interest-chips {
    justify-content: flex-start;
}

.chwma-options-btn {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 44px;
    padding: 0;
    color: var(--muted);
    font: inherit;
    font-size: 15px;
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.chwma-options-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chwma-options-btn svg {
    flex: none;
    width: 18px;
    height: 18px;
}

.presence {
    margin: 0;
}

.learn-more {
    justify-self: start;
    margin: 0;
}

/* nothing to show in your camera tile before you start */
.app-shell:has(#startBtn:not([hidden])) .video-card.local {
    display: none;
}

/* the call dock */
.call-controls {
    gap: 12px;
}

#reportBtn {
    order: 4;
}

.more-wrap {
    position: relative;
    order: 5;
    display: inline-flex;
}

.more-wrap[hidden] {
    display: none;
}

.more-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    z-index: 30;
    display: grid;
    gap: 2px;
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 8px;
    background: var(--raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: 0 16px 48px var(--shadow-float);
}

.more-menu[hidden] {
    display: none;
}

.more-menu .btn.icon-btn {
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    height: auto;
    padding: 12px 12px;
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
}

.more-menu .btn.icon-btn:hover {
    background: var(--raised-hover);
}

.more-menu .btn.icon-btn::after {
    content: attr(aria-label);
}

.match-controls .end-btn {
    flex: none;
}

@media (max-width: 720px) {
    .video-placeholder,
    :root[data-chat-mode='text'] .video-placeholder {
        padding: 16px 24px;
    }

    .chwma-mark {
        max-width: min(330px, 34vh);
    }

    .chwma-wordmark {
        font-size: clamp(44px, 8vh, 64px);
    }

    .chwma-options-btn {
        display: flex;
    }

    .chwma-options:not([data-open]) {
        display: none;
    }

    /* interests open: "hi" makes room for them */
    .chwma-hero:has(~ .chwma-choices .chwma-options[data-open]) .chwma-mark {
        max-width: 120px;
    }

    .chwma-hero:has(~ .chwma-choices .chwma-options[data-open]) .chwma-wordmark {
        font-size: 36px;
    }

    .chwma-hero:has(~ .chwma-choices .chwma-options[data-open]) .placeholder-title {
        display: none;
    }

    /* opened interests line up with everything else, and wrap */
    .interests {
        width: 100%;
        margin: 0;
    }

    .interest-chips {
        flex-wrap: wrap;
        width: 100%;
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    /* the "Looking for…" line wraps before it reaches the camera tile */
    .video-placeholder[data-mode='searching'] .placeholder-text {
        max-width: 58%;
    }

    /* searching on a phone: your camera sits low, clear of "hi" */
    .app-shell:has(.video-placeholder[data-mode='searching']) .video-card.local {
        align-self: end !important;
        justify-self: end !important;
    }

    /* searching on a phone: just your camera and Stop */
    .app-shell:has(.video-placeholder[data-mode='searching']) :is(#muteBtn, #cameraBtn) {
        display: none;
    }

    .match-controls .pill-btn {
        height: 64px;
        font-size: 20px;
    }

    .match-controls .end-btn {
        width: 64px;
        height: 64px;
    }

    .call-controls {
        gap: 12px;
    }

    .call-controls > .btn,
    .more-wrap > .btn {
        width: clamp(44px, 13.3vw, 52px);
        height: clamp(44px, 13.3vw, 52px);
    }

    /* a full-screen call: the video runs behind the dock */
    :root[data-immersive='on'] .control-bar {
        background: transparent;
    }

    :root[data-immersive='on'] .call-controls > .btn,
    :root[data-immersive='on'] .more-wrap > .btn {
        color: var(--on-media);
        background: var(--media-scrim-strong);
    }

    /* the starter stays clear of the dock */
    :root[data-immersive='on'] .starter-overlay {
        bottom: 176px;
    }
}

@media (min-width: 721px) {
    /* "hi" on the left; the choices, or your camera while searching, on the right. The two sit together
       in the middle of the stage: the left column is as wide as the logo, not the leftover space. */
    :root {
        --hero-width: min(480px, 50vh, 36vw);
        --hero-gap: clamp(48px, 7vw, 128px);
        --stage-pad: clamp(24px, 5vw, 96px);
    }

    .video-placeholder,
    .video-placeholder[data-mode] {
        grid-template-columns: var(--hero-width) minmax(0, 520px);
        justify-content: center;
        align-items: center;
        column-gap: var(--hero-gap);
        padding: 24px var(--stage-pad);
    }

    .chwma-mark {
        width: var(--hero-width);
        max-width: none;
    }

    .chwma-wordmark {
        font-size: clamp(64px, 7vw, 104px);
    }

    .placeholder-title {
        font-size: clamp(28px, 2.6vw, 36px);
    }

    /* While searching your camera takes the choices' place. The tile is a grid item of the stage, not of
       the start screen, so its width and position repeat the start screen's columns (100% = the stage). */
    .app-shell:has(.video-placeholder[data-mode='searching']) .video-card.local {
        --choices-width: min(520px, 100% - 2 * var(--stage-pad) - var(--hero-width) - var(--hero-gap));
        align-self: center !important;
        justify-self: end !important;
        width: var(--choices-width);
        margin-right: calc((100% - var(--hero-width) - var(--hero-gap) - var(--choices-width)) / 2);
    }

    #startBtn {
        width: 100%;
        height: 68px;
        font-size: 22px;
    }

    .start-slot {
        margin: 0;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chwma-dot {
        transition: none;
    }

    .video-placeholder[data-mode] .chwma-dot,
    .video-placeholder[data-mode] .chwma-dot-ring,
    .chwma-ready .video-placeholder[data-mode='idle'] :is(.chwma-wordmark, .placeholder-title) {
        animation: none;
    }
}

/* "Liked talking?" after a chat: floats over the next search without stopping it */
.reconnect-prompt {
    position: fixed;
    top: calc(var(--bar-height) + env(safe-area-inset-top));
    left: 50%;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    width: max-content;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    padding: 8px 8px 8px 20px;
    background: var(--raised);
    border: 1px solid var(--control-line);
    border-radius: 999px;
    box-shadow: 0 12px 36px var(--shadow-float);
    transform: translateX(-50%);
    animation: reconnect-prompt-in 260ms var(--ease);
}

.reconnect-prompt[hidden] {
    display: none;
}

.reconnect-prompt-text {
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
}

.reconnect-prompt .pill-btn {
    flex: none;
    width: auto;
    height: 44px;
    padding: 0 20px;
    font-size: 15px;
}

.reconnect-prompt .icon-btn {
    flex: none;
    width: 44px;
    height: 44px;
}

@keyframes reconnect-prompt-in {
    from {
        opacity: 0;
        transform: translate(-50%, -8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .reconnect-prompt {
        animation: none;
    }
}

/* ==========================================================================
   Safety veil, voice chats, invite a friend, 👍 / 👎, install
   ========================================================================== */

/* A new video starts blurred (and nudity is blurred again): the picture stays, unreadable */
.video-card.remote[data-veil] #remoteVideo {
    filter: blur(48px) saturate(0.6);
}

.veil {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    text-align: center;
    color: var(--on-media);
    background: var(--veil);
}

.veil[hidden] {
    display: none;
}

.veil > svg {
    width: 28px;
    height: 28px;
    opacity: 0.85;
}

.veil-text {
    max-width: 30ch;
    font-size: 15px;
    font-weight: 600;
    text-wrap: balance;
}

.veil-actions {
    display: flex;
    gap: 8px;
}

.veil .pill-btn {
    color: var(--on-media);
    background: var(--on-media-soft);
    border-color: var(--on-media-line);
}

.veil .danger-btn {
    background: var(--danger-solid);
    border-color: var(--danger-solid);
}

/* while it's only being checked, the veil is quiet: a small line, no big icon */
.video-card.remote[data-veil='checking'] .veil > svg {
    display: none;
}

/* Voice: your camera tile and the picture make way for a calm stage */
.voice-stage {
    display: none;
}

:root[data-chat-mode='voice'] .video-card.local {
    display: none !important;
}

:root[data-chat-mode='voice'] .voice-stage {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--muted);
    background: var(--surface);
}

.voice-orb {
    display: grid;
    place-items: center;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    color: var(--accent-ink);
    background: var(--accent);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent);
    animation: voice-breathe 2.4s ease-in-out infinite;
}

.voice-orb svg {
    width: 44px;
    height: 44px;
}

.voice-label {
    font-size: 15px;
    font-weight: 600;
}

@keyframes voice-breathe {
    50% {
        box-shadow: 0 0 0 18px color-mix(in srgb, var(--accent) 0%, transparent);
        transform: scale(1.04);
    }
}

@media (prefers-reduced-motion: reduce) {
    .voice-orb {
        animation: none;
    }
}

/* Invite a friend: the link and its buttons, under "Waiting for your friend…" */
.invite-box {
    display: grid;
    gap: 12px;
    width: min(100%, 420px);
    margin-top: 16px;
}

.invite-box[hidden] {
    display: none;
}

.invite-link {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--raised);
    border: 1px solid var(--control-line);
    border-radius: 12px;
}

.invite-actions {
    display: flex;
    gap: 8px;
}

.invite-actions .btn {
    flex: 1;
    justify-content: center;
    gap: 8px;
}

.invite-actions svg {
    width: 18px;
    height: 18px;
}

/* 👍 / 👎 in the bar after a chat */
.rate-buttons {
    display: inline-flex;
    gap: 2px;
}

.rate-buttons[hidden] {
    display: none;
}

/* Settings → General: install */
.install-row {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.install-row[hidden] {
    display: none;
}

.install-row .btn {
    justify-content: center;
    gap: 8px;
}

.install-row svg {
    width: 18px;
    height: 18px;
}

/* with 👍 / 👎 in it, the bar keeps "How was it?" on one line and tightens up to fit beside Reconnect */
.reconnect-prompt:has(.rate-buttons:not([hidden])) {
    gap: 8px;
}

.reconnect-prompt:has(.rate-buttons:not([hidden])) .reconnect-prompt-text {
    white-space: nowrap;
}

.reconnect-prompt:has(.rate-buttons:not([hidden])) .pill-btn {
    padding: 0 16px;
}

.rate-buttons .icon-btn {
    width: 40px;
    height: 40px;
}

.reconnect-prompt .pill-btn {
    min-width: 0;
}

.rate-buttons,
.reconnect-prompt .icon-btn {
    flex: none;
}

/* phones: beside Keep in touch the thumbs speak for themselves (the question is still read out) */
@media (max-width: 480px) {
    .reconnect-prompt:has(.rate-buttons:not([hidden]) ~ #chwmaReconnectPromptBtn:not([hidden])) .reconnect-prompt-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
}

/* opened from a friend's link: their chat's kind is already chosen, so only Join is offered */
:root[data-invite='pending'] :is(.mode-switch, .chwma-options-btn, .chwma-options, .invite-btn) {
    display: none !important;
}

/* the safety note waits for the picture: before it arrives the stage still says "Connecting your video…" */
.video-card.remote:has(#remotePlaceholder:not([hidden])) .veil {
    display: none;
}

/* the install prompt borrows the post-chat bar's look; its text may take two lines */
.install-prompt {
    border-radius: 22px;
    padding-left: 8px;
    width: min(440px, calc(100% - 32px));
}

.install-prompt-icon {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 9px;
}

.install-prompt .reconnect-prompt-text {
    flex: 1;
    font-size: 14px;
}

.install-prompt .pill-btn {
    height: 40px;
    padding: 0 16px;
}

/* the human check: only shown when Cloudflare wants a tap */
.human-check {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 70;
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: 0 0 0 100vmax var(--page-dim), 0 24px 64px var(--shadow-float);
    transform: translate(-50%, -50%);
}

.human-check[hidden] {
    display: none;
}

.human-check p {
    font-size: 15px;
    font-weight: 600;
}

/* a setting's one-line explanation under its name */
.toggle-note {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 400;
    color: var(--faint);
}

/* ==========================================================================
   Friendlier UI: mode cards, labelled controls, tips, "Connected!", search tips
   ========================================================================== */

/* Video / Voice / Text: three cards with a line each; the picked one lights up */
.mode-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    justify-self: stretch;
}

.mode-switch button,
.mode-switch button[aria-checked='true'],
.mode-switch button:hover {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
    min-height: 112px;
    padding: 16px 12px;
    border: 2px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    text-align: left;
    transition:
        transform 160ms var(--ease),
        border-color 160ms ease,
        background-color 160ms ease;
}

.mode-switch button:hover {
    border-color: var(--control-line-hover);
}

.mode-switch button[aria-checked='true'] {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    transform: translateY(-2px);
}

.mode-switch button svg {
    display: block;
    flex: none;
    width: 40px;
    height: 40px;
    padding: 8px;
    box-sizing: border-box;
    border-radius: 12px;
    background: var(--raised);
    color: var(--text);
}

.mode-switch button[aria-checked='true'] svg {
    background: var(--accent);
    color: var(--accent-ink);
}

.mode-line {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--muted);
}

/* the dock: a word under each icon, so nobody has to guess */
.call-controls {
    padding-bottom: 20px;
    overflow: visible;
}

.call-controls > .btn.icon-btn[data-label],
.more-wrap > #chwmaMoreBtn {
    position: relative;
    overflow: visible;
}

.call-controls > .btn.icon-btn[data-label]::after,
.more-wrap > #chwmaMoreBtn::after {
    content: attr(data-label);
    position: absolute;
    top: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    color: var(--muted);
    pointer-events: none;
}

/* over a phone's full-screen video the words need to stand out */
:root[data-immersive='on'] .call-controls > .btn.icon-btn[data-label]::after,
:root[data-immersive='on'] .more-wrap > #chwmaMoreBtn::after {
    color: var(--on-media);
    text-shadow: 0 1px 3px var(--media-text-shadow);
}

/* End says End, in red; Next says what it does */
.match-controls .end-btn {
    width: auto;
    gap: 8px;
    padding: 0 20px 0 16px;
    border-radius: 999px;
    font-weight: 700;
}

.end-btn .end-label {
    font-size: 15px;
}

#chwmaStopBtn {
    gap: 8px;
}

#chwmaStopBtn svg {
    width: 18px;
    height: 18px;
}

/* buttons press in a little when tapped */
.btn:active:not(:disabled) {
    transform: scale(0.96);
}

.mode-switch button:active {
    transform: scale(0.98);
}

/* "Connected!" for a moment over the stranger's video */
.connected-pop {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 5;
    display: grid;
    justify-items: start;
    gap: 8px;
    pointer-events: none;
    animation: pop-in 320ms cubic-bezier(0.3, 1.5, 0.5, 1);
}

.connected-pop[hidden] {
    display: none;
}

.connected-pop.is-leaving {
    opacity: 0;
    transform: translateY(-6px);
    transition:
        opacity 280ms ease,
        transform 280ms ease;
}

.connected-pop-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 15px;
    font-weight: 800;
}

.connected-pop-pill svg {
    width: 16px;
    height: 16px;
    stroke-width: 3;
}

.connected-pop-text {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--media-scrim);
    color: var(--on-media);
    font-size: 13px;
    font-weight: 600;
}

.connected-pop-text[hidden] {
    display: none;
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-6px);
    }
}

/* a tip while searching */
.search-tip {
    display: grid;
    gap: 4px;
    width: min(100%, 420px);
    margin: 20px 0 0;
    padding: 16px 16px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    font-size: 15px;
    line-height: 1.4;
    color: var(--text);
    text-align: left;
}

.search-tip[hidden] {
    display: none;
}

.search-tip strong {
    font-size: 13px;
    color: var(--accent);
}

/* text chat ideas: whole sentences you tap, never cut off at the edge */
@media (max-width: 720px) {
    .starter-chips:not([hidden]) {
        display: grid;
        grid-auto-flow: row;
        grid-template-columns: minmax(0, 1fr);
        grid-auto-columns: auto;
        overflow: visible;
    }

    /* phones: interests show straight away instead of behind a fold */
    .chwma-options-btn {
        display: none;
    }

    .chwma-options:not([data-open]) {
        display: grid;
    }

    .chwma-mark {
        max-width: min(150px, 18vh);
    }

    .chwma-wordmark {
        font-size: clamp(40px, 6.5vh, 52px);
    }

    .mode-switch button,
    .mode-switch button[aria-checked='true'],
    .mode-switch button:hover {
        min-height: 104px;
    }
}

/* wide screens: the choices are a roomy panel beside the logo */
@media (min-width: 721px) {
    .chwma-choices {
        padding: 8px 0;
    }

    .chwma-choices .interest-chip {
        min-height: 40px;
        font-size: 15px;
    }
}

/* the language box goes once three are picked (a chip's display would otherwise keep it) */
.language-select[hidden] {
    display: none;
}

/* Wide but short windows (laptops, a browser that isn't full screen): the panel tightens so it fits
   beside the logo instead of scrolling on its own. The stage still scrolls as a last resort (a very
   short window, or many custom interests), with a slim bar in the page's colours. */
.video-placeholder {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--text) 22%, transparent) transparent;
}

@media (min-width: 721px) and (max-height: 900px) {
    .video-placeholder,
    .video-placeholder[data-mode] {
        padding-block: 16px;
    }

    .chwma-choices {
        gap: 12px;
        padding: 20px 22px;
    }

    .chwma-options {
        gap: 12px;
    }

    .chwma-choices .interests {
        gap: 8px;
        margin-top: 4px;
    }

    .mode-switch button,
    .mode-switch button[aria-checked='true'],
    .mode-switch button:hover {
        gap: 4px;
        min-height: 0;
        padding: 10px 12px;
    }

    .mode-switch button svg {
        width: 30px;
        height: 30px;
        padding: 6px;
        border-radius: 9px;
    }

    .chwma-choices .interest-chip {
        min-height: 34px;
        font-size: 14px;
    }

    .chwma-choices .interest-form input {
        height: 34px;
    }
}

@media (min-width: 721px) and (max-height: 720px) {
    :root {
        --hero-width: min(480px, 34vh, 36vw);
    }

    .chwma-wordmark {
        font-size: clamp(48px, 9vh, 104px);
    }

    .chwma-choices {
        gap: 10px;
        padding: 16px 20px;
    }

    /* "What is Chwma?" goes (the About link at the bottom leads to the same place), and so does the
       line under each mode; the icon sits beside its name */
    .chwma-choices .learn-more,
    .mode-line {
        display: none;
    }

    .mode-switch button,
    .mode-switch button[aria-checked='true'],
    .mode-switch button:hover {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    #startBtn {
        height: 48px;
        font-size: 18px;
    }

    .chwma-choices .invite-btn {
        margin-top: 0;
    }

    /* no empty line kept for the online count: there's no room to spare */
    .app-shell:not(:has(#startBtn[hidden])) .presence[hidden] {
        display: none !important;
    }
}

/* the cards size to their content (the old tabs had a fixed height) */
.mode-switch button,
.mode-switch button[aria-checked='true'],
.mode-switch button:hover {
    height: auto;
}

/* room for the words under the dock's icons ("Keep in touch" is the longest), in every mode */
:root .call-controls,
:root[data-chat-mode] .call-controls {
    column-gap: 28px;
}

@media (max-width: 720px) {
    :root .call-controls,
    :root[data-chat-mode] .call-controls {
        column-gap: 20px;
    }

    /* keep the search tip clear of your camera tile in the corner */
    .search-tip {
        width: calc(100% - 136px);
        min-width: 200px;
    }
}

/* ===================================================================
   Phones, start screen: one scroll for the whole page
   ========================================================================== */

/* The start screen used to scroll inside the stage, between the top bar and Start. That gave it a
   scrollbar of its own, and a swipe stalled where the stage ended and the page took over. Now the
   stage grows with its content and the page scrolls as one, down into the section below; Start stays
   pinned to the bottom of the screen until the app has scrolled past. Once a chat starts the app is a
   fixed screen again. */
@media (max-width: 720px) {
    .app-shell:has(.video-placeholder[data-mode='idle']) {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .app-shell:has(.video-placeholder[data-mode='idle']) .video-card.remote {
        overflow: visible;
    }

    /* nothing but the start screen in the stage (the empty video would otherwise take room) */
    .video-card.remote:has(> .video-placeholder[data-mode='idle']) > :not(.video-placeholder) {
        display: none;
    }

    .video-placeholder[data-mode='idle'] {
        position: relative;
        inset: auto;
        min-height: 100%;
        overflow: visible;
    }

    .app-shell:has(.video-placeholder[data-mode='idle']) .control-bar {
        position: sticky;
        bottom: 0;
        z-index: 20;
        background: var(--ground);
    }
}
=======
/* the page never scrolls sideways (clip, not hidden: sticky and fixed children keep working) */
html,
body {
    overflow-x: clip;
}

/* ==========================================================================
   A wait that finds nobody: switch to where someone is waiting, or be told
   ========================================================================== */
.quiet-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    width: min(100%, 420px);
    margin: 12px 0 0;
}

.quiet-actions[hidden] {
    display: none;
}

.quiet-text {
    flex: 1 0 100%;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    text-align: left;
}

.quiet-actions .pill-btn {
    width: auto;
    min-width: 0;
    height: 44px;
    padding: 0 20px;
    font-size: 15px;
}

@media (max-width: 720px) {
    /* clear of your camera tile in the corner, like the tip above */
    .quiet-actions {
        width: calc(100% - 136px);
        min-width: 200px;
    }

    :root:not([data-chat-mode='video']) :is(.quiet-actions, .search-tip) {
        width: 100%;
    }
}

/* ==========================================================================
   Computers, video: your camera on the start screen, in the logo's place
   ========================================================================== */
.start-preview,
.preview-btn {
    display: none;
}

@media (min-width: 721px) {
    .video-placeholder[data-mode='idle'] .start-preview:not([hidden]) {
        position: relative;
        display: block;
        width: var(--hero-width);
        aspect-ratio: 4 / 3;
        overflow: hidden;
        border-radius: 28px;
        background: var(--surface);
    }

    .start-preview video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transform: scaleX(-1); /* a mirror, like your tile in a call */
    }

    .start-preview .icon-btn {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        color: var(--on-media);
        background: var(--media-scrim-strong);
    }

    /* the big logo makes way; the name and "Say hi" stay under the picture */
    .video-placeholder[data-mode='idle'] .chwma-hero:has(.start-preview:not([hidden])) .chwma-mark {
        display: none;
    }

    .video-placeholder[data-mode='idle'] .preview-btn:not([hidden]) {
        display: inline-flex;
        margin-top: 4px;
    }
}

/* ==========================================================================
   Voice call: the circle moves with the stranger's voice, and a clock runs
   ========================================================================== */
.voice-stage {
    --voice-level: 0;
}

.voice-stage[data-live] .voice-orb {
    animation: none;
    transform: scale(calc(1 + var(--voice-level) * 0.22));
    box-shadow: 0 0 0 calc(6px + var(--voice-level) * 34px) color-mix(in srgb, var(--accent) 22%, transparent);
    transition:
        transform 110ms linear,
        box-shadow 110ms linear;
}

.voice-stage[data-speaking] .voice-label {
    color: var(--text);
}

.voice-timer {
    margin-top: -8px;
    font-size: 15px;
    color: var(--muted);
}

.voice-timer[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .voice-stage[data-live] .voice-orb {
        transform: none;
        transition: none;
        box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent);
    }

    .voice-stage[data-live][data-speaking] .voice-orb {
        box-shadow: 0 0 0 16px color-mix(in srgb, var(--accent) 30%, transparent);
    }
}

/* ==========================================================================
   Text chat: room for the conversation
   ========================================================================== */
/* when a message was sent: there on a tap (a mouse sees it on hover) */
.chat-message-time {
    display: none;
}

.chat-message.show-time .chat-message-time {
    display: block;
}

.chat-message.me,
.chat-message.partner {
    cursor: default;
}

/* the light bulb only belongs to a text chat's ideas */
:root:not([data-chat-mode='text']) #chwmaIdeasBtn {
    display: none;
}

#chwmaIdeasBtn[aria-expanded='true'] {
    color: var(--accent-strong);
}

@media (max-width: 720px) {
    /* phones: one idea at a time (× brings the next) */
    .starter-chips > :nth-child(n + 2) {
        display: none;
    }
}

/* ==========================================================================
   Phones, start screen: everything you can choose fits above Start
   ========================================================================== */
@media (max-width: 720px) {
    /* "Add your own" sits in the row with the suggestions instead of on a line of its own */
    #chwmaInterests {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    #chwmaInterests .interests-label {
        flex: 1 0 100%;
        margin: 0 0 4px;
    }

    #chwmaInterests .interest-chips {
        display: contents;
    }

    #chwmaInterests .interest-form {
        flex: 1 1 132px;
        min-width: 0;
        max-width: 190px;
    }

    #chwmaInterests .interest-form input {
        width: 100%;
        height: 34px;
        padding: 0 12px;
    }

    .video-placeholder[data-mode='idle'] {
        gap: 16px;
    }

    .video-placeholder[data-mode='idle'] .chwma-hero {
        gap: 12px;
    }

    .video-placeholder[data-mode='idle'] .chwma-choices,
    .video-placeholder[data-mode='idle'] .chwma-options {
        gap: 12px;
    }

    .video-placeholder[data-mode='idle'] .interests {
        margin-top: 0;
    }
}

@media (max-width: 720px) {
    #chwmaInterests .interest-form {
        flex-basis: 116px;
    }

    #chwmaInterests .interest-more {
        padding: 0 8px;
    }

    /* the logo starts level with the settings button across from it, not a row below */
    .app-shell:has(.video-placeholder[data-mode='idle']) .video-placeholder {
        padding-top: 0;
    }

    .video-placeholder[data-mode='idle'] .chwma-hero {
        margin-top: -12px;
    }
}

/* narrow phones: each way to chat keeps its line to one row */
@media (max-width: 380px) {
    #chwmaModeSwitch {
        gap: 8px;
    }

    #chwmaModeSwitch button {
        padding-inline: 10px;
    }

    #chwmaModeSwitch .mode-line {
        white-space: nowrap;
    }
}

@media (max-width: 720px) {
    /* "+ Add" stays beside the languages picked instead of dropping to a row of its own */
    #chwmaLanguageChips .language-select {
        flex: 1 1 96px;
        min-width: 0;
        max-width: 160px;
    }
}

/* short phones (a browser's bars take a lot of a small screen): a smaller logo, so the languages still fit */
@media (max-width: 720px) and (max-height: 720px) {
    .video-placeholder[data-mode='idle'] .chwma-mark {
        max-width: 92px;
    }

    .video-placeholder[data-mode='idle'] .chwma-wordmark {
        font-size: 40px;
    }

    .video-placeholder[data-mode='idle'] .chwma-hero {
        gap: 8px;
    }
}

/* Phones, start screen: the bar that floats at the top after a chat ("How was it?", install) sits where the
   logo starts, so the logo steps down while it's up */
@media (max-width: 720px) {
    .app-shell:has(.reconnect-prompt:not([hidden])) .video-placeholder[data-mode='idle'] .chwma-hero {
        margin-top: 64px;
    }
}

/* Voice call: while a conversation idea is up, the circle and the clock move up clear of it */
:root[data-chat-mode='voice'] .video-card.remote:has(.starter-overlay:not([hidden])) .voice-stage {
    padding-bottom: 176px;
}

/* Settings → Look: the Language box */
.locale-select {
    min-height: 40px;
    padding: 0 12px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--raised);
    border: 1px solid var(--control-line);
    border-radius: 12px;
}

/* another language: nothing shows until its text has been swapped (/js/ui/locale-boot.js, /js/ui/i18n.js) */
html.i18n-pending body {
    visibility: hidden;
}
