/* ng-voice-mobile.css — VOICE MODE, the phone-first full-screen voice surface
 * (2026-09-05). the operator's ask, verbatim: "speak, see it's being processed,
 * review the last few chats, switch chats, see pinned chats" — on an iPhone.
 *
 * Scope discipline: EVERYTHING here lives under #nvm-fab / #nvm-root, which
 * ng-voice-mobile.js creates. No existing selector is touched, so desktop
 * 1440px renders byte-identical with this sheet loaded. The FAB is the only
 * element visible before the overlay opens, and it only paints <=1024px
 * (phones + iPads); NGVoiceMobile.open() can still summon the overlay on any
 * width for testing.
 *
 * iOS notes baked in:
 *   - env(safe-area-inset-*) on header + bottom stack (viewport-fit=cover is
 *     already in the page meta).
 *   - touch-action:none + -webkit-touch-callout:none on the PTT button so a
 *     long-press is a recording, not a text-selection callout or scroll.
 *   - no <input> anywhere in the overlay -> no iOS focus-zoom to defend.
 *   - all animation gated behind prefers-reduced-motion: no-preference.
 */

/* ---------------------------------------------------------------- FAB --- */
#nvm-fab {
  position: fixed; z-index: 180;
  right: max(14px, env(safe-area-inset-right));
  /* clear of .bottomnav (64px) AND the composer stack (~100px) — at 76px the
     pill sat right on top of the send button (seen in emu screenshot 01) */
  bottom: calc(178px + env(safe-area-inset-bottom));
  display: none; align-items: center; gap: 8px;
  padding: 12px 16px; min-height: 48px;
  font-family: var(--fm, ui-monospace, monospace);
  font-size: 11px; font-weight: 700; letter-spacing: .14em;
  color: var(--s0, #041018); background: var(--x-cyan, #37e8ff);
  border: 1px solid var(--x-cyan, #37e8ff); border-radius: 999px;
  box-shadow: 0 6px 24px color-mix(in srgb, var(--x-cyan, #37e8ff) 35%, transparent);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
#nvm-fab:active { transform: scale(.96); }
@media (max-width: 1024px) { #nvm-fab { display: inline-flex; } }
body.nvm-open #nvm-fab { display: none; }

/* ------------------------------------------------------------- overlay --- */
#nvm-root {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(21, 60, 102, .55), transparent 60%),
    linear-gradient(180deg, var(--s1, #050b14) 0%, var(--s0, #030810) 100%);
  color: var(--t1, #d7e8ff);
  font-family: var(--fm, ui-monospace, monospace);
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: contain;
}
#nvm-root[hidden] { display: none; }

/* header: close · conversation switcher · mute */
#nvm-top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  flex: 0 0 auto;
}
#nvm-top button {
  font-family: inherit; color: var(--t2, #9fb6d4);
  background: color-mix(in srgb, var(--s2, #0a1a30) 55%, transparent); border: 1px solid var(--line2, #1d3a5f);
  border-radius: 10px; min-height: 44px; min-width: 44px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  font-size: 13px;
}
#nvm-conv {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  gap: 8px; overflow: hidden; padding: 0 12px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em;
}
#nvm-conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
#nvm-conv .nvm-caret { color: var(--x-cyan, #37e8ff); font-size: 10px; flex: 0 0 auto; }
#nvm-mute[data-muted="1"] { opacity: .45; }

/* ------------------------------------------------------- centre stage --- */
#nvm-stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 14px; padding: 2vh 18px 0; text-align: center;
}
#nvm-bit { width: min(38vw, 168px); height: min(38vw, 168px); flex: 0 0 auto; }
#nvm-bit svg { width: 100%; height: 100%; display: block; }
@media (prefers-reduced-motion: no-preference) {
  #nvm-bit svg { animation: nvm-bob 3.4s ease-in-out infinite; }
  #nvm-root[data-s="speaking"] #nvm-bit svg { animation: nvm-talk 1.05s ease-in-out infinite; }
  #nvm-root[data-s="listening"] #nvm-bit svg { animation: none; transform: scale(1.06); }
  @keyframes nvm-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
  @keyframes nvm-talk { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
}

/* the BIG state chip — the operator must SEE processing from arm's length */
#nvm-chip {
  display: inline-flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 36px);
  padding: 12px 18px; border-radius: 14px;
  border: 1px solid var(--line2, #1d3a5f);
  background: color-mix(in srgb, var(--s1, #060e1a) 60%, transparent);
  font-size: 15px; font-weight: 700; letter-spacing: .12em;
  color: var(--t3, #5f7a9a);
}
#nvm-chip i { width: 12px; height: 12px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
#nvm-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nvm-root[data-s="listening"]     #nvm-chip { color: var(--x-cyan, #37e8ff); border-color: color-mix(in srgb, var(--x-cyan, #37e8ff) 50%, transparent); background: color-mix(in srgb, var(--x-cyan, #37e8ff) 8%, transparent); }
#nvm-root[data-s="transcribing"]  #nvm-chip,
#nvm-root[data-s="thinking"]      #nvm-chip { color: var(--x-violet, #8f6dff); border-color: color-mix(in srgb, var(--x-violet, #8f6dff) 50%, transparent); background: color-mix(in srgb, var(--x-violet, #8f6dff) 8%, transparent); }
#nvm-root[data-s="speaking"]      #nvm-chip { color: var(--x-violet, #8f6dff); border-color: color-mix(in srgb, var(--x-violet, #8f6dff) 60%, transparent); background: color-mix(in srgb, var(--x-violet, #8f6dff) 12%, transparent); }
#nvm-root[data-s="error"]         #nvm-chip,
#nvm-root[data-s="down"]          #nvm-chip { color: var(--x-red, #ff5470); border-color: color-mix(in srgb, var(--x-red, #ff5470) 55%, transparent); background: color-mix(in srgb, var(--x-red, #ff5470) 8%, transparent); white-space: normal; }
#nvm-root[data-s="error"] #nvm-chip span,
#nvm-root[data-s="down"]  #nvm-chip span { white-space: normal; line-height: 1.4; font-size: 13px; letter-spacing: .05em; }
@media (prefers-reduced-motion: no-preference) {
  #nvm-root[data-s="listening"] #nvm-chip i,
  #nvm-root[data-s="transcribing"] #nvm-chip i,
  #nvm-root[data-s="thinking"] #nvm-chip i,
  #nvm-root[data-s="speaking"] #nvm-chip i { animation: nvm-pulse 1.1s ease-in-out infinite; }
  @keyframes nvm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
}

/* transcript + progress + reply snippet */
#nvm-live { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }
#nvm-transcript {
  align-self: flex-end; max-width: 92%;
  background: color-mix(in srgb, var(--x-cyan, #37e8ff) 10%, transparent); border: 1px solid color-mix(in srgb, var(--x-cyan, #37e8ff) 35%, transparent);
  border-radius: 14px 14px 4px 14px; padding: 10px 14px;
  font-size: 15px; line-height: 1.45; text-align: left; color: var(--t0, #d7f6ff);
  overflow-wrap: anywhere;
}
#nvm-transcript[hidden], #nvm-prog[hidden], #nvm-reply[hidden] { display: none; }
#nvm-prog {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 12px; letter-spacing: .1em; color: var(--t3, #5f7a9a);
}
#nvm-prog .nvm-dots { display: inline-flex; gap: 4px; }
#nvm-prog .nvm-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--x-violet, #8f6dff); }
@media (prefers-reduced-motion: no-preference) {
  #nvm-prog .nvm-dots i { animation: nvm-dot 1.2s ease-in-out infinite; }
  #nvm-prog .nvm-dots i:nth-child(2) { animation-delay: .15s; }
  #nvm-prog .nvm-dots i:nth-child(3) { animation-delay: .3s; }
  @keyframes nvm-dot { 0%, 100% { opacity: .2; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
}
#nvm-elapsed { color: var(--x-violet, #8f6dff); font-weight: 700; font-variant-numeric: tabular-nums; }
#nvm-reply {
  align-self: flex-start; max-width: 92%;
  background: color-mix(in srgb, var(--s2, #0a1a30) 60%, transparent); border: 1px solid var(--line2, #1d3a5f);
  border-radius: 14px 14px 14px 4px; padding: 10px 14px;
  font-size: 14px; line-height: 1.5; text-align: left; color: var(--t2, #9fb6d4);
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4;
  overflow-wrap: anywhere;
}
#nvm-reply[hidden] { display: none; }

/* ------------------------------------------------- bottom third: PTT --- */
#nvm-bottom {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 8px 18px calc(14px + env(safe-area-inset-bottom));
}
#nvm-ptt {
  width: 108px; height: 108px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-family: inherit; font-size: 10.5px; font-weight: 800; letter-spacing: .14em;
  color: color-mix(in srgb, var(--x-cyan, #37e8ff) 45%, var(--t0, #eaf6ff)); background: color-mix(in srgb, var(--s2, #0a1a30) 70%, transparent);
  border: 2px solid color-mix(in srgb, var(--x-cyan, #37e8ff) 55%, transparent);
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--x-cyan, #37e8ff) 6%, transparent), 0 8px 30px rgba(0, 0, 0, .5);
  cursor: pointer;
  touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#nvm-ptt .nvm-mic-glyph { font-size: 30px; line-height: 1; }
#nvm-ptt[data-held="1"] {
  color: var(--s0, #041018); background: var(--x-cyan, #37e8ff); border-color: var(--x-cyan, #37e8ff);
  box-shadow: 0 0 0 16px color-mix(in srgb, var(--x-cyan, #37e8ff) 16%, transparent), 0 0 44px color-mix(in srgb, var(--x-cyan, #37e8ff) 55%, transparent);
}
#nvm-root[data-s="speaking"] #nvm-ptt,
#nvm-root[data-s="thinking"] #nvm-ptt { border-color: color-mix(in srgb, var(--x-violet, #8f6dff) 55%, transparent); color: color-mix(in srgb, var(--x-violet, #8f6dff) 40%, var(--t0, #eaf6ff)); }
#nvm-hint { font-size: 10px; letter-spacing: .1em; color: var(--t3, #5f7a9a); }
#nvm-stopv {
  display: none; font-family: inherit; font-size: 11px; font-weight: 700; letter-spacing: .12em;
  color: var(--x-red, #ff5470); background: color-mix(in srgb, var(--x-red, #ff5470) 10%, transparent); border: 1px solid color-mix(in srgb, var(--x-red, #ff5470) 50%, transparent);
  border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#nvm-root[data-s="speaking"] #nvm-stopv,
#nvm-root[data-s="thinking"] #nvm-stopv { display: inline-flex; align-items: center; }
#nvm-peek {
  font-family: inherit; font-size: 10.5px; font-weight: 700; letter-spacing: .13em;
  color: var(--t2, #9fb6d4); background: transparent; border: 0; padding: 10px 16px; min-height: 44px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}

/* ------------------------------------------------------- bottom sheet --- */
#nvm-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 210;
  max-height: 72vh; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--s0, #050c16) 97%, transparent);
  border-top: 1px solid var(--line2, #1d3a5f);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 44px rgba(0, 0, 0, .6);
  transform: translateY(105%);
  padding-bottom: env(safe-area-inset-bottom);
  transition: transform .22s ease;
}
@media (prefers-reduced-motion: reduce) { #nvm-sheet { transition: none; } }
#nvm-sheet[data-open="1"] { transform: translateY(0); }
#nvm-grab { flex: 0 0 auto; padding: 10px 0 6px; cursor: grab; touch-action: none; }
#nvm-grab::before { content: ""; display: block; width: 44px; height: 4px; margin: 0 auto; border-radius: 2px; background: var(--line2, #1d3a5f); }
.nvm-tabs { flex: 0 0 auto; display: flex; gap: 8px; padding: 2px 14px 10px; }
.nvm-tabs button {
  flex: 1 1 0; font-family: inherit; font-size: 10.5px; font-weight: 700; letter-spacing: .13em;
  color: var(--t3, #5f7a9a); background: color-mix(in srgb, var(--s2, #0a1a30) 50%, transparent);
  border: 1px solid var(--line2, #1d3a5f); border-radius: 10px; min-height: 44px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.nvm-tabs button.on { color: var(--x-cyan, #37e8ff); border-color: color-mix(in srgb, var(--x-cyan, #37e8ff) 50%, transparent); background: color-mix(in srgb, var(--x-cyan, #37e8ff) 8%, transparent); }
#nvm-sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 14px 14px; }
.nvm-empty { padding: 22px 6px; text-align: center; font-size: 12px; color: var(--t3, #5f7a9a); letter-spacing: .08em; }

/* last-6 message rows (compact, renderer-backed) */
.nvm-msg { margin: 0 0 10px; max-width: 94%; }
.nvm-msg-meta { font-size: 9.5px; letter-spacing: .1em; color: var(--t3, #5f7a9a); margin: 0 0 3px; }
.nvm-msg-body {
  border-radius: 12px; padding: 8px 12px; font-size: 13.5px; line-height: 1.5;
  overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6;
}
.nvm-msg-body pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px; }
.nvm-msg-body img { max-width: 100%; }
.nvm-msg-user { margin-left: auto; text-align: right; }
.nvm-msg-user .nvm-msg-body {
  text-align: left; background: color-mix(in srgb, var(--x-cyan, #37e8ff) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--x-cyan, #37e8ff) 30%, transparent); color: var(--t0, #d7f6ff);
}
.nvm-msg-sp .nvm-msg-body { background: color-mix(in srgb, var(--s2, #0a1a30) 60%, transparent); border: 1px solid var(--line2, #1d3a5f); color: var(--t1, #d7e8ff); }

/* conversation switcher rows */
.nvm-sec { font-size: 9.5px; font-weight: 700; letter-spacing: .16em; color: var(--t3, #5f7a9a); padding: 10px 2px 6px; }
.nvm-sec:first-child { padding-top: 2px; }
.nvm-conv-row {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  font-family: inherit; color: var(--t1, #d7e8ff);
  background: color-mix(in srgb, var(--s2, #0a1a30) 45%, transparent); border: 1px solid var(--line2, #1d3a5f);
  border-radius: 12px; padding: 10px 12px; min-height: 52px; margin: 0 0 8px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.nvm-conv-row.active { border-color: color-mix(in srgb, var(--x-cyan, #37e8ff) 55%, transparent); background: color-mix(in srgb, var(--x-cyan, #37e8ff) 7%, transparent); }
.nvm-conv-row .nvm-pin { flex: 0 0 auto; color: var(--x-amber, #ffd166); font-size: 13px; }
.nvm-conv-row .nvm-cmain { flex: 1 1 auto; min-width: 0; }
.nvm-conv-row .nvm-ctitle { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nvm-conv-row .nvm-cmeta { font-size: 10px; color: var(--t3, #5f7a9a); letter-spacing: .06em; margin-top: 2px; }
.nvm-conv-row .nvm-clive { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--x-mint, #3fe0c8); }
.nvm-new-row { justify-content: center; color: var(--x-cyan, #37e8ff); font-weight: 700; letter-spacing: .12em; font-size: 11px; border-style: dashed; }

/* ---------------------------------------------- landscape phone branch ---
   At 852x393 the portrait column overflowed: BIT (168px) + chip + PTT stack
   don't fit 393px, and flex children drew over each other. Short viewports
   get a horizontal stage (BIT | chip | live) and a compact bottom row. */
@media (max-height: 520px) {
  #nvm-top { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  #nvm-top button { min-height: 38px; min-width: 38px; }
  #nvm-stage {
    flex-direction: row; align-items: center; justify-content: center;
    gap: 20px; padding: 2px 14px 0; overflow: hidden;
  }
  #nvm-bit { width: 76px; height: 76px; }
  #nvm-chip { font-size: 12px; padding: 8px 14px; max-width: 40vw; }
  #nvm-live { max-width: 34vw; gap: 6px; }
  #nvm-transcript, #nvm-reply { font-size: 12px; padding: 7px 10px; -webkit-line-clamp: 3; }
  #nvm-bottom {
    flex-direction: row; justify-content: center; align-items: center;
    gap: 16px; padding: 4px 14px calc(8px + env(safe-area-inset-bottom));
  }
  #nvm-ptt { width: 72px; height: 72px; font-size: 8px; }
  #nvm-ptt .nvm-mic-glyph { font-size: 20px; }
  #nvm-hint { display: none; }
  #nvm-sheet { max-height: 86vh; }
}
