    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    /* Design language ported from the /grok app (public/grok/style.css):
       deep-navy radial glow, soft radius system (cards 18 / buttons 14 /
       inner 10-12 / pills 999), blue gradient primary, system font stack. */
    :root {
      --bg:#0b1020; --surface:#161c30; --surface-hi:#1b2540; --border:#243049;
      --accent:#4f8cff; --accent-dim:#35578f; --en:#5b93ff; --vi:#f0a030;
      --text:#e6e9f2; --muted:#9aa3bd; --danger:#f87171; --ready:#34d399;
    }
    html, body {
      height:100%; background:var(--bg); color:var(--text);
      font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size:16px;
      overflow:hidden; -webkit-tap-highlight-color:transparent; touch-action:manipulation;
      position:relative;
    }
    /* Older phones measure 100% before the address bar settles, so the layout
       is built for a screen taller than what is visible and a dead band sits
       at the bottom until a rotation forces a re-measure. --app-h is set from
       the real inner height by shared script (re-measured after load and on
       every resize); dvh replaces it where the browser understands it. */
    body { height: var(--app-h, 100%); }
    @supports (height: 100dvh) { body { height: 100dvh; } }

    /* Screens stack on top of each other so incoming/outgoing can animate
       past one another instead of just popping. Direction-aware: forward
       nav slides from the right, back nav slides from the left. */
    .screen {
      position:absolute; inset:0;
      display:flex; flex-direction:column; align-items:center; justify-content:center;
      padding:24px 20px; gap:18px;
      background:radial-gradient(1200px 600px at 50% -10%, #16203c 0%, var(--bg) 55%);
      visibility:hidden; pointer-events:none;
      transform:translateX(0) scale(1); opacity:1;
      transition:transform .36s cubic-bezier(.16,1,.3,1), opacity .3s ease;
    }
    .screen.active { visibility:visible; pointer-events:auto; }
    .screen.no-anim { transition:none !important; }
    .screen.pos-right { transform:translateX(7%) scale(.96); opacity:0; }
    .screen.pos-left  { transform:translateX(-7%) scale(.96); opacity:0; }

    @keyframes room-live-pulse {
      0%   { box-shadow:0 0 0 0 rgba(0,212,170,.55); }
      70%  { box-shadow:0 0 0 18px rgba(0,212,170,0); }
      100% { box-shadow:0 0 0 0 rgba(0,212,170,0); }
    }
    .pulse-live { animation:room-live-pulse .9s cubic-bezier(.16,1,.3,1); border-radius:14px; }
    .logo { font-size:12px; font-weight:700; letter-spacing:.22em; color:var(--muted); text-transform:uppercase; }
    .logo span { color:var(--accent); }
    .logo em { font-style:normal; color:var(--vi); font-size:9px; vertical-align:super; }

    .title { font-size:32px; font-weight:800; line-height:1.1; text-align:center; letter-spacing:.02em; }
    .title em { font-style:normal; color:var(--accent); }
    .sub { font-size:14px; color:var(--muted); text-align:center; max-width:320px; line-height:1.5; }

    .btn-primary { width:100%; max-width:320px; padding:17px 24px; background:linear-gradient(180deg,#5b93ff,#3b74e6); color:#fff; border:none; border-radius:14px; font-size:17px; font-weight:700; cursor:pointer; transition:transform .05s ease, opacity .15s; }
    .btn-primary:active { opacity:.9; transform:scale(.99); }
    .btn-secondary { width:100%; max-width:320px; padding:14px 24px; background:var(--surface-hi); color:var(--text); border:1px solid var(--border); border-radius:12px; font-size:15px; font-weight:700; cursor:pointer; }
    .divider { display:flex; align-items:center; gap:12px; width:100%; max-width:320px; }
    .divider::before,.divider::after { content:''; flex:1; height:1px; background:var(--border); }
    .divider span { font-size:12px; color:var(--muted); letter-spacing:.12em; }
    .input-row { display:flex; gap:8px; width:100%; max-width:320px; }
    .code-input { flex:1; padding:14px; background:var(--surface-hi); border:1px solid var(--border); border-radius:12px; color:var(--text); font-size:17px; letter-spacing:.25em; text-align:center; font-variant-numeric:tabular-nums; outline:none; }
    .code-input:focus { border-color:var(--accent); }
    .btn-go { padding:14px 22px; background:var(--surface-hi); border:1px solid var(--border); border-radius:12px; color:var(--accent); font-size:17px; font-weight:700; cursor:pointer; }

    .status-row { display:flex; align-items:center; gap:8px; font-size:12px; letter-spacing:.1em; text-transform:uppercase; font-weight:600; color:var(--muted); }
    .dot { width:9px; height:9px; border-radius:50%; background:var(--muted); flex-shrink:0; }
    .dot.waiting { background:var(--en); animation:pulse 1.2s infinite; }
    .dot.live    { background:var(--ready); animation:pulse 1.5s infinite; }
    .dot.error   { background:var(--danger); }
    .dot.muted   { background:var(--vi); }
    @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }

    /* Full-screen OK-to-talk light (ported from the Grok app) — green while
       the mic is actively listening, red while gated (TTS playing / off). */
    #screen-active.talk-go   { background: radial-gradient(circle at 50% 22%, #18c574 0%, #0a7a45 78%); transition: background .3s ease; }
    #screen-active.talk-wait { background: radial-gradient(circle at 50% 22%, #ef5a56 0%, #9e1b1b 78%); transition: background .3s ease; }

    /* UI language: a flag in the top-right corner of every screen. A flag is
       readable without already knowing the interface language, which a text
       label ("UI language") is not — that was the whole problem. The native
       <select> sits invisible on top so tapping opens the OS picker, where
       each language is listed in its own script. */
    .ui-lang-corner { position:fixed; top:10px; right:10px; z-index:500; }
    .ui-lang-flag { display:flex; align-items:center; gap:5px; background:var(--surface-hi); border:1px solid var(--border); border-radius:999px; padding:6px 11px; font-size:17px; line-height:1; box-shadow:0 4px 14px rgba(0,0,0,.3); }
    .ui-lang-flag .chev { font-size:10px; color:var(--muted); }
    .ui-lang-corner select { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
    html[dir="rtl"] .ui-lang-corner { right:auto; left:10px; }
    .room-controls { display:flex; align-items:center; gap:6px; }
    .mode-switch-btn { color:var(--accent); border-color:var(--accent-dim); }
    .btn-leave-compact { width:auto; max-width:none; align-self:center; padding:7px 14px; font-size:12px; flex:0 0 auto; }

    /* LOBBY */
    #qr-box { background:#fff; padding:12px; border-radius:12px; }
    #qr-box img, #qr-box canvas { display:block; }
    .room-code-value { font-size:28px; font-weight:800; color:var(--accent); letter-spacing:.22em; font-variant-numeric:tabular-nums; }
    .earbud-hint { display:flex; gap:10px; align-items:center; background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:12px 16px; max-width:320px; font-size:13px; color:var(--muted); line-height:1.45; }
    .earbud-hint b { color:var(--text); font-weight:600; }

    /* Same-room push-to-talk toggle, on the two-phone setup screens */
    .room-toggle { display:flex; align-items:center; gap:10px; width:100%; max-width:320px; background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:12px 16px; cursor:pointer; }
    .room-toggle input { width:19px; height:19px; accent-color:var(--accent); flex-shrink:0; cursor:pointer; }
    .room-toggle span { font-size:13px; color:var(--text); line-height:1.4; }

    /* Push-to-talk button on the active screen — replaces the sensitivity
       slider (which has nothing to gate against once PTT overrides it). */
    .ptt-row { width:100%; }
    .ptt-button { width:100%; height:100%; padding:14px 24px; border-radius:12px; background:var(--surface-hi); border:1px solid var(--border); color:var(--text); font-size:15px; font-weight:700; cursor:pointer; -webkit-user-select:none; user-select:none; touch-action:manipulation; transition:background .1s,border-color .1s,transform .05s; }
    .ptt-button.held { background:linear-gradient(180deg,#3ddfa4,#1fae76); border-color:#1fae76; color:#052e1e; transform:scale(.98); }
    .lang-block { width:100%; max-width:320px; display:flex; flex-direction:column; gap:6px; }
    .lang-block label { font-size:12px; letter-spacing:.08em; text-transform:uppercase; font-weight:600; color:var(--muted); text-align:center; }
    .lang-select { width:100%; padding:13px; background:var(--surface-hi); border:1px solid var(--border); border-radius:12px; color:var(--text); font-size:16px; font-weight:600; outline:none; appearance:none; text-align:center; text-align-last:center; cursor:pointer; }
    .lang-select:focus { border-color:var(--accent); }

    /* ACTIVE — conversation canvas */
    #screen-active { justify-content:flex-start; padding:12px; gap:8px; }
    .session-header { display:flex; align-items:center; justify-content:space-between; width:100%; padding:0 4px; }
    .lang-pair { font-size:13px; font-weight:700; display:flex; gap:6px; align-items:center; }
    .lang-pair .arrow { color:var(--muted); font-size:10px; }
    .room-tag { font-size:11px; color:var(--muted); letter-spacing:.12em; font-variant-numeric:tabular-nums; }
    .lang-switch-btn { padding:6px 12px; background:var(--surface-hi); border:1px solid var(--border); border-radius:999px; color:var(--muted); font-size:11px; font-weight:600; cursor:pointer; }
    .lang-switch-btn:active { border-color:var(--accent); color:var(--accent); }

    .banner { display:none; width:100%; padding:10px 14px; border-radius:12px; text-align:center; font-size:13px; font-weight:700; }
    .banner.show { display:block; }
    .banner.error { background:rgba(248,113,113,.12); border:1px solid var(--danger); color:var(--danger); }

    /* Single running column, no matter one phone or two: translation big,
       original small + subtler underneath. No left/right "mine vs theirs"
       split — .mine/.theirs classes are still added for internal bookkeeping
       but render identically. */
    #canvas { flex:1; width:100%; overflow-y:auto; display:flex; flex-direction:column; gap:8px; padding:6px 2px; -webkit-overflow-scrolling:touch; }
    .bubble { width:100%; padding:12px 16px; border-radius:14px; line-height:1.35; background:var(--surface); border:1px solid var(--border); box-shadow:0 6px 20px rgba(0,0,0,.25); }
    .bubble .primary { font-size:18px; }
    .bubble .secondary { font-size:14px; color:var(--text); text-align:right; margin-top:6px; padding-top:6px; border-top:1px solid var(--border); }
    .replay-row { margin-top:8px; display:flex; justify-content:flex-end; gap:6px; }
    .replay-btn { background:var(--surface-hi); border:1px solid var(--border); border-radius:999px; color:var(--accent); font-size:12px; font-weight:700; padding:5px 14px; cursor:pointer; }
    .replay-btn:active { opacity:.6; }
    /* "What did they actually mean?" — the thing a word-for-word translator
       cannot do. Sits beside PLAY on every bubble. */
    .explain-btn { background:var(--surface-hi); border:1px solid var(--border); border-radius:999px; color:var(--vi); font-size:13px; font-weight:700; padding:5px 13px; cursor:pointer; }
    .explain-btn:active { opacity:.6; }
    .explain-note { margin-top:8px; padding:10px 12px; border-radius:12px; background:rgba(240,160,48,.10); border:1px solid rgba(240,160,48,.35); color:var(--text); font-size:14px; line-height:1.45; }
    .explain-note .explain-head { display:block; font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--vi); margin-bottom:3px; }
    .bubble.pending .primary { color:var(--muted); }
    .tone-badge { display:flex; align-items:center; gap:5px; margin-top:6px; padding:4px 11px; border-radius:999px; font-size:11px; font-weight:600; width:fit-content; }
    .tone-badge.good { background:rgba(52,211,153,.12); border:1px solid rgba(52,211,153,.35); color:var(--ready); }
    .tone-badge.warn { background:rgba(240,160,48,.12); border:1px solid rgba(240,160,48,.35); color:var(--vi); }
    .tone-badge.bad  { background:rgba(248,113,113,.12); border:1px solid rgba(248,113,113,.35); color:var(--danger); }
    .tone-note { color:var(--muted); font-style:italic; margin-left:3px; text-transform:none; font-weight:400; }

    /* TEXT MODE — two persistent columns */
    #screen-text-solo, #screen-text-room { justify-content:flex-start; padding-top:28px; gap:12px; }
    .text-lang-select { padding:10px 6px; font-size:13px; }
    .text-columns-head { display:grid; grid-template-columns:1fr 1fr; gap:8px; width:100%; max-width:480px; }
    .text-columns-head select, .text-columns-head span { text-align:center; }
    .text-columns-head span { font-size:12px; letter-spacing:.08em; font-weight:600; color:var(--muted); text-transform:uppercase; padding:8px 0; }
    .text-columns-body { flex:1; width:100%; max-width:480px; overflow-y:auto; display:flex; flex-direction:column; gap:6px; padding:2px; -webkit-overflow-scrolling:touch; }
    .text-row { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
    .text-cell { padding:10px 12px; background:var(--surface); border:1px solid var(--border); border-radius:12px; font-size:15px; line-height:1.35; word-break:break-word; }
    .text-cell.pending { color:var(--muted); font-style:italic; }
    .text-cell.col-a { border-left:3px solid var(--en); }
    .text-cell.col-b { border-left:3px solid var(--vi); }
    .text-cell .tone-badge { margin-top:5px; }
    .text-col-input-row { display:flex; gap:8px; width:100%; max-width:480px; }
    .chat-input { flex:1; padding:11px 14px; background:var(--surface-hi); border:1px solid var(--border); border-radius:12px; color:var(--text); font-size:15px; outline:none; }
    .chat-input:focus { border-color:var(--accent); }
    .chat-send-btn { padding:11px 18px; background:var(--surface-hi); border:1px solid var(--border); border-radius:12px; color:var(--accent); font-size:14px; font-weight:700; cursor:pointer; }
    .chat-send-btn:active { border-color:var(--accent); }

    /* Voice-forward toggle */
    #btn-voice-forward.off { color:var(--muted); border-color:var(--border); opacity:.6; }
    #btn-voice-forward.on { color:var(--accent); border-color:var(--accent-dim); }

    /* Pause toggle — big and obvious, sits right under the VAD meter. Shares
       .action-row with the push-to-talk button when PTT is on, so the two
       sit side by side instead of stacking and eating vertical space. */
    .btn-pause { width:100%; padding:14px 24px; background:var(--surface-hi); color:var(--text); border:1px solid var(--border); border-radius:12px; font-size:15px; font-weight:700; cursor:pointer; }
    .btn-pause.paused { background:var(--vi); border-color:var(--vi); color:#241503; }
    /* Hard 50/50 split via a fixed flex-basis, not flex-grow. flex:1 with
       min-width:0 on both still rendered unequal (measured 320px vs 370px
       for identical flex-grow/shrink/min-width) — a <button> as a direct
       flex item and a <div> wrapping a <button> apparently don't get the
       same automatic minimum-size treatment. flex-grow:0/flex-shrink:0
       with a fixed basis sidesteps that entirely: each is exactly half the
       row, full stop, regardless of content. */
    .action-row { display:flex; gap:8px; width:100%; align-items:stretch; }
    .action-row .ptt-row { flex:0 0 calc(50% - 4px); width:auto; }
    .action-row .btn-pause { flex:0 0 calc(50% - 4px); width:auto; }

    /* Typed-message row on the voice active screen (chat-input/-send-btn shared with text mode, defined above) */
    .chat-input-row { display:flex; gap:8px; width:100%; padding-top:4px; }
    #live-partial { align-self:flex-end; max-width:86%; font-size:14px; color:var(--muted); font-style:italic; padding:0 6px; display:none; }

    .vad-area { width:100%; display:flex; flex-direction:column; align-items:center; gap:8px; padding:6px 0 2px; }
    .vad-bars { display:flex; align-items:center; gap:4px; height:34px; }
    .vad-bar { width:5px; border-radius:3px; background:var(--muted); transition:height .08s ease, background .15s; min-height:4px; }
    .vad-bar.active { background:var(--ready); }
    .vad-status { font-size:12px; letter-spacing:.1em; font-weight:600; text-transform:uppercase; color:var(--muted); display:flex; align-items:center; gap:8px; }
    .vad-status.speaking { color:var(--ready); }
    .vad-status.muted { color:var(--vi); }

    /* Mic sensitivity — drag until room noise stops lighting the meter above */
    .sens-row { width:100%; display:flex; flex-direction:column; gap:5px; padding:2px 2px 6px; }
    .sens-label { font-size:11px; letter-spacing:.1em; font-weight:600; text-transform:uppercase; color:var(--muted); text-align:center; }
    .sens-track { display:flex; align-items:center; gap:10px; }
    .sens-track span { font-size:13px; flex:0 0 auto; }
    .sens-row input[type=range] { flex:1; min-width:0; height:22px; background:transparent; appearance:none; cursor:pointer; }
    .sens-row input[type=range]::-webkit-slider-runnable-track { height:4px; border-radius:999px; background:var(--border); }
    .sens-row input[type=range]::-webkit-slider-thumb { appearance:none; width:18px; height:18px; margin-top:-7px; border-radius:50%; background:var(--accent); border:2px solid var(--bg); }
    .sens-row input[type=range]::-moz-range-track { height:4px; border-radius:999px; background:var(--border); }
    .sens-row input[type=range]::-moz-range-thumb { width:16px; height:16px; border-radius:50%; background:var(--accent); border:2px solid var(--bg); }

    .toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:var(--danger); color:#fff; padding:11px 22px; border-radius:999px; font-size:13px; font-weight:600; opacity:0; pointer-events:none; transition:opacity .3s; z-index:999; max-width:90vw; text-align:center; box-shadow:0 8px 24px rgba(0,0,0,.35); }
    .toast.info { background:var(--accent); color:#fff; }
    .toast.show { opacity:1; }
    /* HOME — grouped sections */
    .home-group { width:100%; max-width:320px; display:flex; flex-direction:column; align-items:center; gap:10px; }
    .home-group-label { font-size:12px; letter-spacing:.14em; font-weight:700; color:var(--muted); text-transform:uppercase; }
    .home-group-row { display:flex; gap:10px; width:100%; }
    .home-group-row .btn-primary { width:auto; flex:1; max-width:none; }
    .btn-link { display:block; text-align:center; text-decoration:none; }

    /* QR SCAN */
    .qr-scan-viewport { position:relative; width:100%; max-width:320px; aspect-ratio:1/1; background:#000; border-radius:14px; overflow:hidden; }
    #qr-scan-video { width:100%; height:100%; object-fit:cover; }
    .qr-scan-frame { position:absolute; inset:12%; border:2px solid var(--accent); border-radius:14px; box-shadow:0 0 0 999px rgba(0,0,0,.35); pointer-events:none; }

    /* Correct-and-redo — editable "original heard" text under own bubbles */
    .secondary.editable { display:flex; align-items:center; justify-content:space-between; gap:8px; }
    .secondary.editable .secondary-text { flex:1; }
    .edit-btn { background:none; border:none; color:var(--muted); font-size:12px; line-height:1; cursor:pointer; padding:2px 4px; flex-shrink:0; }
    .edit-btn:active { opacity:.6; }
    .secondary.editing { display:flex; gap:6px; align-items:center; }
    .edit-input { flex:1; min-width:0; padding:7px 10px; background:var(--bg); border:1px solid var(--accent-dim); border-radius:10px; color:var(--text); font-size:13px; outline:none; }
    .edit-input:focus { border-color:var(--accent); }
    .edit-save-btn, .edit-cancel-btn { background:var(--surface-hi); border:1px solid var(--border); border-radius:10px; font-size:12px; padding:6px 10px; cursor:pointer; flex-shrink:0; }
    .edit-save-btn { color:var(--ready); }
    .edit-cancel-btn { color:var(--danger); }

    /* Liveness check — "are you still there" safety net for voice sessions */
    #liveness-check { position:fixed; inset:0; background:rgba(11,16,32,.93); display:none; align-items:center; justify-content:center; z-index:1000; padding:24px; }
    #liveness-check.show { display:flex; }
    .liveness-card { width:100%; max-width:320px; display:flex; flex-direction:column; align-items:center; gap:16px; text-align:center; }
    .liveness-card .title { font-size:26px; }
    .liveness-countdown { font-size:13px; letter-spacing:.1em; font-weight:700; color:var(--vi); text-transform:uppercase; }
    #btn-liveness-confirm { background:linear-gradient(180deg,#3ddfa4,#1fae76); color:#052e1e; }

    @media (max-width:360px){ .title{font-size:30px} .room-code-value{font-size:22px} }

    /* Cultural review — held between the writer tapping SEND and the message
       actually going out, so it sits directly above the input it belongs to. */
    .review-panel { display:none; margin:0 0 8px; padding:12px 14px; border-radius:14px;
      background:rgba(240,160,48,.10); border:1px solid rgba(240,160,48,.40); }
    .review-panel.show { display:block; }
    .review-head { display:block; font-size:11px; font-weight:700; letter-spacing:.08em;
      text-transform:uppercase; color:var(--vi); margin-bottom:4px; }
    .review-note { font-size:14px; line-height:1.45; color:var(--text); }
    .review-draft { margin-top:8px; padding:8px 10px; border-radius:10px; background:var(--surface);
      border:1px solid var(--border); font-size:14px; color:var(--muted); word-break:break-word; }
    .review-actions { margin-top:10px; display:flex; gap:8px; }
    .review-actions button { flex:1; border-radius:999px; padding:9px 12px; font-size:13px;
      font-weight:700; letter-spacing:.04em; cursor:pointer; border:1px solid var(--border); }
    .btn-review-edit { background:var(--surface-hi); color:var(--text); }
    .btn-review-send { background:rgba(240,160,48,.22); border-color:rgba(240,160,48,.55); color:var(--text); }
    .review-actions button:active { opacity:.6; }
    /* The check runs on the send tap, so the input needs to show it is busy. */
    .chat-send-btn.checking { opacity:.55; pointer-events:none; }
    /* "?" on a text cell sits under the text, same idea as the voice bubbles. */
    .text-cell .replay-row { margin-top:6px; justify-content:flex-start; }

    /* The link a host sends to a partner in another city. Shown above the QR,
       which only helps when the two phones are in the same room. */
    .lobby-link { display:flex; flex-direction:column; align-items:center; gap:10px; width:100%; max-width:320px; }
    .room-link { width:100%; font-size:13px; word-break:break-all; color:var(--muted); padding:9px 12px;
      background:var(--surface); border:1px solid var(--border); border-radius:10px; text-align:center; }
    .lobby-link .home-group-row { width:100%; }
