/* Translator V2: the conversation fills the screen; small labelled controls around it.
   Colours are tokens, redefined for dark mode. Text sizes follow iOS Dynamic Type (rem), bars use px. */
:root {
  --bg: #ffffff;
  --bg2: #f2f2f7;
  --bar: rgba(247, 247, 248, 0.94);
  --menu: #f7f7f8;
  --hair: rgba(60, 60, 67, 0.29);
  --fill: #e9e9ee;
  --fg: #000000;
  --fg2: #3c3c43;
  --fg3: #626268;
  --tint: #0a64d0;
  --tint-soft: rgba(10, 100, 208, 0.10);
  --tim: #0a64d0;
  --other: #edeef1;
  --other-fg: #000000;
  --other-es: #3c3c43;
  --num-bg: rgba(10, 100, 208, 0.13);
  --num-fg: #0a4fa6;
  --uw: #b25000;
  --go: #177a3f;
  --rec: #c4201a;
  --orange: #b25000;
  --red: #c4201a;
  --red-text: #b01d17;
  --amber-bg: #fff4d6;
  --amber-fg: #5c3d00;
  --amber-line: #e6b94d;
  --pill-orange-bg: #b25000; --pill-orange-fg: #ffffff;
  --pill-red-bg: #c4201a;    --pill-red-fg: #ffffff;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --top-h: 44px;
  --dock-h: 64px;
  --rail-w: 76px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg2: #1c1c1e;
    --bar: rgba(22, 22, 24, 0.92);
    --menu: #2c2c2e;
    --hair: rgba(84, 84, 88, 0.65);
    --fill: #2c2c2e;
    --fg: #ffffff;
    --fg2: #d1d1d6;
    --fg3: #a1a1a6;
    --tint: #5aa6ff;
    --tint-soft: rgba(90, 166, 255, 0.14);
    --tim: #0a5cc2;
    --other: #1c1c1e;
    --other-fg: #ffffff;
    --other-es: #aeaeb2;
    --num-bg: rgba(90, 166, 255, 0.18);
    --num-fg: #8cc2ff;
    --uw: #ff9f0a;
    --go: #1b7a42;
    --rec: #b3261e;
    --orange: #b25000;
    --red: #b3261e;
    --red-text: #ff8a80;
    --amber-bg: #33290c;
    --amber-fg: #ffd666;
    --amber-line: #7a5f10;
    --pill-orange-bg: #3d2606; --pill-orange-fg: #ffb454;
    --pill-red-bg: #3b1614;    --pill-red-fg: #ff9a91;
    --shadow: 0 2px 14px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { font-size: 17px; font: -apple-system-body; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  font-size: clamp(15px, 1rem, 30px);
  line-height: 1.3;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, textarea, select { font: inherit; color: var(--fg); background: var(--bg); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 24px; height: 24px; flex: none; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; }

/* ---------- buttons (sheets and cards) ---------- */
.btn {
  min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 0;
  background: var(--fill); color: var(--fg); font-weight: 600; font-size: 16px; line-height: 1.2;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: #0a64d0; color: #fff; }
.btn.go { background: var(--go); color: #fff; }
.btn.danger { color: var(--red-text); }
.btn.danger-fill { background: #b3261e; color: #fff; }   /* 6.5:1 with white, both themes */
.btn.big { display: block; width: 100%; min-height: 52px; font-size: 17px; margin: 8px 0; }
.btn.small { min-height: 44px; padding: 6px 14px; font-size: 15px; border-radius: 10px; }
.btn.plain { background: transparent; color: var(--tint); }
.btn.link { background: transparent; color: var(--tint); padding: 0 6px; min-height: 44px; font-size: inherit; }
.btn:disabled { opacity: .5; }
.link-btn { display: block; margin: 0 auto 8px; min-height: 44px; background: none; border: 0; color: var(--tint); font-size: 15px; font-weight: 600; }

/* ---------- sign in ---------- */
.login-box { max-width: 420px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 20px 20px; }
.login-box h1 { font-size: 34px; margin: 0 0 8px; letter-spacing: -.01em; }
.login-box input {
  width: 100%; min-height: 56px; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--hair);
  background: var(--bg2); margin: 14px 0 6px; font-size: 22px; letter-spacing: .12em; text-align: center;
}
.msg { color: var(--red-text); font-weight: 600; min-height: 1.4em; }

/* ---------- main layout ---------- */
#main {
  display: grid; height: 100vh; overflow: hidden;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top" "stage" "composer" "dock";
}
@supports (height: 100dvh) { #main { height: 100dvh; } }

.top {
  grid-area: top; z-index: 6;
  height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) calc(4px + var(--safe-r)) 0 calc(4px + var(--safe-l));
  display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; align-items: center;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--hair);
}
.tb-btn {
  width: 52px; height: 44px; border: 0; background: none; color: var(--tint); padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.tb-btn .ico { width: 22px; height: 22px; }
.tb-lbl { font-size: 10px; font-weight: 600; line-height: 1; }
.who {
  min-width: 0; height: 44px; border: 0; background: none; padding: 0 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.who-line { display: flex; align-items: center; gap: 3px; max-width: 100%; }
.who-name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .chev { width: 13px; height: 13px; color: var(--fg3); }
.who-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tint); flex: none; }
.test-tag {
  flex: none; font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 5px; border-radius: 5px;
  background: var(--amber-bg); color: var(--amber-fg); border: 1px solid var(--amber-line); margin-left: 4px;
}
.who-sub { font-size: 13px; color: var(--fg3); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stage { grid-area: stage; position: relative; min-height: 0; overflow: hidden; }
.feed {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px calc(10px + var(--safe-r)) 14px calc(10px + var(--safe-l));
}
.stage.has-pill .feed { padding-top: 50px; }
.feed-empty { color: var(--fg3); padding: 28px 12px; max-width: 34em; margin: 0 auto; }
.feed-empty .big-hint { font-size: 1.3rem; color: var(--fg); }

/* ---------- the status pill (over the feed) ---------- */
.pill {
  position: absolute; top: 7px; left: 50%; transform: translateX(-50%); z-index: 5;
  height: 36px; max-width: calc(100% - 24px); border-radius: 18px;
  display: flex; align-items: center; box-shadow: var(--shadow);
  background: var(--amber-bg); color: var(--amber-fg); border: 1px solid var(--amber-line);
}
.pill.orange { background: var(--pill-orange-bg); color: var(--pill-orange-fg); border-color: transparent; }
.pill.red { background: var(--pill-red-bg); color: var(--pill-red-fg); border-color: transparent; }
.pill-main {
  height: 44px; margin: -4px 0; min-width: 0; border: 0; background: none; color: inherit;
  display: flex; align-items: center; gap: 6px; padding: 0 12px 0 11px; font-size: 14px; font-weight: 600;
}
.pill-ico { width: 18px; height: 18px; --on-ico: var(--pill-red-bg); }
.pill-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pill-more {
  flex: none; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
  background: rgba(127, 127, 127, 0.28);
}
.pill-act {
  position: relative; height: 44px; margin: -4px 4px -4px -2px; padding: 0 15px; border: 0; background: none;
  color: #b3261e; font-size: 15px; font-weight: 700; flex: none; z-index: 0;
}
.pill-act::before { content: ""; position: absolute; inset: 7px 0; border-radius: 15px; background: #ffffff; z-index: -1; }
.new-pill {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 4;
  background: #0a64d0; color: #fff; border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 700;
  box-shadow: var(--shadow); min-height: 44px; font-size: 15px;
}

/* ---------- feed items ---------- */
.divider { text-align: center; color: var(--fg3); font-size: 12px; font-weight: 600; margin: 14px 0 4px; }
.turn { margin: 6px 0; }
.row { display: flex; gap: 6px; align-items: flex-start; }
.turn.tim .row { justify-content: flex-end; }
.col { display: flex; flex-direction: column; max-width: 80%; min-width: 0; }
.turn.tim .col { align-items: flex-end; }
.turn.other .col { align-items: flex-start; max-width: calc(80% + 10px); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; margin-top: 3px;
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
}
.bubble {
  position: relative; padding: 8px 12px 9px; border-radius: 18px; max-width: 100%;
  -webkit-user-select: text; user-select: text; overflow-wrap: anywhere; cursor: default;
  -webkit-touch-callout: none;
}
.turn.tim .bubble { background: var(--tim); color: #fff; border-bottom-right-radius: 6px; }
.turn.other .bubble { background: var(--other); color: var(--other-fg); border-bottom-left-radius: 6px; }
.en { font-size: 1rem; line-height: 1.3; white-space: pre-wrap; }
.turn.other .en { font-size: calc(1rem * 20 / 17); font-weight: 600; line-height: 1.25; }
.es-line {
  margin-top: 6px; padding-top: 5px; border-top: 0.5px solid rgba(255, 255, 255, 0.5);
  font-size: calc(1rem * 15 / 17); color: rgba(255, 255, 255, 0.88); white-space: pre-wrap;
}
.es.muted { opacity: .7; }
.lang-tag {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .05em; line-height: 1;
  padding: 2px 4px 1px; border-radius: 4px; border: 1px solid currentColor; margin-right: 5px; vertical-align: 2px;
}
.orig { font-size: calc(1rem * 14 / 17); color: var(--other-es); margin-top: 5px; white-space: pre-wrap; cursor: pointer; }
.orig.clamped { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.streaming::after { content: "▍"; margin-left: 1px; opacity: .6; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.shimmer { display: grid; gap: 6px; margin: 7px 0 3px; min-width: min(190px, 60vw); }
.shimmer i {
  display: block; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, rgba(127,127,127,.18) 0%, rgba(127,127,127,.42) 50%, rgba(127,127,127,.18) 100%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
.turn.tim .shimmer i { background-image: linear-gradient(90deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.55) 50%, rgba(255,255,255,.22) 100%); }
.shimmer i:nth-child(2) { width: 68%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }

.st { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-top: 5px; font-size: 13px; font-weight: 600; }
.turn.tim .st { color: rgba(255, 255, 255, 0.92); }
.turn.other .st { color: var(--fg3); }
.st-ico { width: 16px; height: 16px; --on-ico: var(--tim); }
.turn.other .st-ico { --on-ico: var(--other); }
.st-btn {
  min-height: 44px; padding: 0 16px; margin: -4px 0; border-radius: 22px; border: 0; font-weight: 700; font-size: 15px;
  background: #fff; color: #0a4fa6;
}
.turn.other .st-btn { background: #0a64d0; color: #fff; }
.st.err { font-weight: 600; }
.err-text { color: var(--red-text); }
.turn.tim .err-text { color: #8c1d18; background: #fff4f3; border-radius: 8px; padding: 3px 8px; }
.flag { margin-top: 4px; font-size: 13px; opacity: .92; display: flex; align-items: center; gap: 4px; }
.flag.warn { font-weight: 700; }
.flag-ico { width: 14px; height: 14px; }

.q-badge {
  position: absolute; top: -7px; width: 22px; height: 22px; border-radius: 50%; padding: 0;
  background: #b25000; color: #fff; font-size: 13px; font-weight: 800; line-height: 18px;
  border: 2px solid var(--bg);
}
.q-badge::after { content: ""; position: absolute; inset: -11px; }
.turn.tim .q-badge { left: -7px; }
.turn.other .q-badge { right: -7px; }
.uw {
  text-decoration: underline dotted; text-decoration-thickness: 2px; text-underline-offset: 3px;
  text-decoration-color: var(--uw); cursor: pointer;
}
.turn.tim .uw { text-decoration-color: #ffd28a; }
.nm { font-weight: 800; border-radius: 5px; padding: 0 3px; background: var(--num-bg); color: var(--num-fg); cursor: pointer; }
.turn.tim .nm { background: #ffffff; color: #0a4fa6; }   /* 7.5:1 inside the blue bubble */
.num-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.nm.chip { padding: 3px 9px; border-radius: 10px; font-size: 15px; }

.acts { display: flex; gap: 2px; margin: 1px -4px 0; }
.act {
  position: relative; width: 44px; height: 44px; border: 0; background: none; padding: 0;
  display: grid; place-items: center; color: var(--fg3); border-radius: 22px;
}
.act .ico { width: 26px; height: 26px; }
.act-say { color: var(--tint); }
.act-say .when-speaking { display: none; }
.act-say[data-state="speaking"] .ico:first-child { display: none; }
.act-say[data-state="speaking"] .when-speaking { display: block; width: 20px; height: 20px; }
.act-say .ring { position: absolute; inset: 5px; border-radius: 50%; border: 2.5px solid transparent; pointer-events: none; }
.act-say[data-state="queued"] .ring { border-color: var(--tint) transparent var(--tint) transparent; animation: spin .9s linear infinite; }
.act-say[data-state="queued"] .ico:first-child { opacity: .55; }
.act-say .bar { display: none; position: absolute; left: 8px; right: 8px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--hair); overflow: hidden; }
.act-say[data-state="speaking"] .bar { display: block; }
.act-say .bar i { display: block; height: 100%; width: 0; background: var(--tint); transition: width .12s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* a message still being said (patient turns): a quiet dashed edge, "Still listening…", Done */
.turn.open .bubble { outline: 1.5px dashed var(--fg3); outline-offset: 3px; }
.turn.tim.open .bubble { outline-color: var(--tim); }
.st-listening { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; opacity: .9; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite; }
.tail { opacity: .6; }
.tail .dots { padding: 0 2px; vertical-align: middle; }
.turn.tim .tail .dots i { background: rgba(255, 255, 255, .85); }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* live words while someone talks */
.turn.ghost .bubble { background: transparent !important; color: var(--fg2) !important; border: 1.5px dashed var(--fg3); opacity: .85; }
.turn.ghost.tim .bubble { border-color: var(--tim); }
.turn.ghost .en, .turn.ghost #ghost-text { font-size: 1rem; }
.dots { display: inline-flex; gap: 4px; padding: 6px 2px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--fg3); animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* one-line system rows and cards in the feed */
.sys-row {
  max-width: 92%; margin: 8px auto; text-align: center; color: var(--fg3); font-size: 13px; font-weight: 500;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 2px;
}
.sys-row .btn.link { font-size: 13px; font-weight: 700; }
.sys-row.switched { flex-wrap: nowrap; }
.sys-row.switched .sys-txt { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-row.switched .sys-dot, .sys-row.switched .btn { flex: none; }
.sys-row.switched .sys-dot { padding: 0 2px; }
.sys-row.suggest { gap: 6px; color: var(--fg2); background: var(--bg2); border-radius: 14px; padding: 6px 10px; }
.note-box { display: block; text-align: center; }
.note-box ul { text-align: left; margin: 6px 0 0; padding-left: 18px; color: var(--fg2); }
.note-box li { margin: 4px 0; }
.note-box li button { margin-left: 6px; }
.note-sub { margin-top: 8px; font-weight: 600; color: var(--fg); text-align: left; }
.note-box > .btn { margin-top: 8px; }
.suggestion { text-align: left; margin: 8px 0; padding: 8px 10px; border-radius: 12px; background: var(--tint-soft); color: var(--fg); }
.suggestion .help { margin: 2px 0 0; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.row-btns.confirm { font-weight: 700; }
.col-btns { display: flex; flex-direction: column; gap: 6px; }
.card { margin: 10px 2px; padding: 12px 14px; border-radius: 16px; background: var(--bg2); }
.card.ask { border: 1.5px solid var(--tint); box-shadow: var(--shadow); }
.proposal h3 { margin: 0 0 3px; font-size: 17px; }
.proposal p { margin: 4px 0 0; color: var(--fg2); font-size: 15px; }
.proposal .row-btns .btn { flex: 1 1 auto; }
.prop-job { font-weight: 600; color: var(--fg2); font-size: 15px; }
.choice-list .btn { display: block; width: 100%; margin: 6px 0; text-align: left; line-height: 1.25; }
.summary { -webkit-user-select: text; user-select: text; border: 1.5px solid var(--go); }
.summary h3 { margin: 0 0 6px; }
.summary h4 { margin: 10px 0 2px; font-size: 14px; font-weight: 700; color: var(--fg3); }
.summary ul { margin: 0; padding-left: 20px; }
.help { color: var(--fg3); font-size: 14px; }
.card .help { margin: 0 0 6px; }

/* ---------- composer (inline, above the bar) ---------- */
.composer {
  grid-area: composer; background: var(--bar); border-top: 0.5px solid var(--hair);
  padding: 6px calc(8px + var(--safe-r)) 2px calc(4px + var(--safe-l));
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.comp-row { display: flex; align-items: flex-end; gap: 4px; }
.comp-row .tb-btn { width: 44px; color: var(--fg3); }
#type-text {
  flex: 1; min-width: 0; min-height: 40px; max-height: 120px; resize: none; margin: 2px 0;
  padding: 9px 14px; border-radius: 20px; border: 1px solid var(--hair); background: var(--bg);
  font-size: 17px; line-height: 1.25;
}
.send-btn { width: 44px; height: 44px; border: 0; background: none; color: #0a64d0; padding: 0; display: grid; place-items: center; }
.send-btn .ico { width: 34px; height: 34px; }
.send-btn:disabled { color: var(--fg3); opacity: .5; }
.comp-opt { display: flex; align-items: center; gap: 10px; min-height: 48px; padding-left: 8px; font-size: 15px; color: var(--fg2); }

/* ---------- the bar ---------- */
.dock {
  grid-area: dock; z-index: 6;
  height: calc(var(--dock-h) + var(--safe-b)); padding: 0 calc(8px + var(--safe-r)) var(--safe-b) calc(8px + var(--safe-l));
  display: grid; grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr); align-items: center;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 0.5px 0 var(--hair);   /* a hairline that takes no room from the 64 pt mic */
}
.dock-side { display: flex; align-items: center; min-width: 0; }
.dock-side.left { justify-content: space-evenly; }
.dock-side.right { justify-content: space-evenly; }
.bar-btn {
  min-width: 58px; height: 52px; padding: 0 4px; border: 0; background: none; color: var(--fg2); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.bar-btn .ico { width: 26px; height: 26px; }
.bar-lbl { font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap; }
.bar-btn[aria-expanded="true"] { color: var(--tint); background: var(--tint-soft); }
#lang-toggle.other { color: var(--tint); }

.mic {
  position: relative; justify-self: center; width: 64px; height: 64px; border-radius: 50%; border: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  color: #fff; background: var(--go); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  --lvl: 0;
}
.mic .mic-ico { width: 26px; height: 26px; }
.mic-lbl { font-size: 11px; font-weight: 800; line-height: 1; letter-spacing: .02em; }
.mic.on { background: var(--rec); }
.mic.on .mic-ico { width: 20px; height: 20px; margin: 3px 0 2px; }
.mic.resume { background: var(--orange); animation: breathe 1.6s ease-in-out infinite; }
.mic.held { transform: scale(1.06); }
.mic-ring {
  position: absolute; inset: -5px; border-radius: 50%; pointer-events: none;
  border: 3px solid var(--rec); opacity: 0; transform: scale(calc(1 + var(--lvl) * 0.22));
  transition: transform .08s linear, opacity .2s;
}
.mic.on .mic-ring { opacity: .55; }
.mic.on.pulse .mic-ring { animation: ring 1.4s ease-out infinite; }
.mic.resume .mic-ring { border-color: var(--orange); opacity: .5; }
@keyframes ring { 0% { transform: scale(1); opacity: .6; } 100% { transform: scale(1.22); opacity: 0; } }
@keyframes breathe { 50% { box-shadow: 0 0 0 7px rgba(178, 80, 0, 0.25); } }
@media (prefers-reduced-motion: reduce) {
  .mic.on.pulse .mic-ring, .mic.resume, .shimmer i, .dots i, .streaming::after, .act-say[data-state="queued"] .ring { animation: none; }
}

/* ---------- sheets, action menus, popovers ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.42); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: calc(24px + var(--safe-t)); z-index: 21;
  background: var(--bg); border-radius: 14px 14px 0 0; display: flex; flex-direction: column;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3); max-width: 720px; margin: 0 auto;
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 16px; border-bottom: 0.5px solid var(--hair); }
.sheet-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 700; }
.sheet-body { flex: 1; overflow-y: auto; padding: 8px 16px calc(24px + var(--safe-b)); }
.sheet-body h3 { margin: 22px 0 6px; font-size: 15px; font-weight: 700; color: var(--fg2); }
.sheet-body .help { margin: 4px 0 10px; }

.actsheet {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); z-index: 31;
  max-width: 480px; margin: 0 auto; max-height: calc(100% - 40px - var(--safe-t)); overflow-y: auto;
}
#actsheet-backdrop { z-index: 30; }
.as-group { background: var(--menu); border-radius: 14px; overflow: hidden; }
.as-title { padding: 12px 16px; text-align: center; font-size: 13px; color: var(--fg3); border-bottom: 0.5px solid var(--hair); }
.as-item {
  display: block; width: 100%; min-height: 56px; padding: 10px 16px; border: 0; background: none;
  color: var(--tint); font-size: 19px; text-align: center; border-top: 0.5px solid var(--hair);
}
#actsheet-list .as-item:first-child { border-top: 0; }
.as-cancel { margin-top: 8px; background: var(--menu); border-radius: 14px; font-weight: 700; border: 0; }

.pop {
  position: fixed; z-index: 70; background: var(--menu); color: var(--fg); border-radius: 13px;
  padding: 12px 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28); font-size: 16px; max-height: 50vh; overflow-y: auto;
}
.pop p { margin: 4px 0; }
.pop-title { font-size: 13px; font-weight: 600; color: var(--fg3); margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  min-width: 58px; min-height: 44px; padding: 0 12px; border-radius: 22px; border: 1px solid var(--hair);
  background: var(--bg); color: var(--fg); font-weight: 700; font-size: 16px;
}
.chip-btn[aria-checked="true"] { background: #0a64d0; border-color: #0a64d0; color: #fff; }

.bignum {
  position: fixed; inset: 0; z-index: 80; background: var(--bg); color: var(--fg); padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.bignum-n { font-size: min(26vw, 26vh, 190px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bignum-m { font-size: 24px; margin-top: 16px; color: var(--fg2); }
.bignum-hint { position: absolute; bottom: calc(20px + var(--safe-b)); font-size: 15px; color: var(--fg3); }

/* ---------- Show mode ---------- */
.show {
  position: fixed; inset: 0; z-index: 50; background: #000; color: #fff;
  display: flex; flex-direction: column;
}
.show-half { display: flex; flex-direction: column; }
.show-es { flex: 1; min-height: 0; padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l)); }
.show.flipped .show-es { transform: rotate(180deg); padding-top: 12px; padding-bottom: calc(16px + var(--safe-t)); }
/* up to three lines at 40 pt or more; longer text scrolls (auto margins centre it without clipping) */
.show-text {
  flex: 0 1 auto; min-height: 0; overflow-y: auto; font-size: clamp(40px, 10.5vw, 72px); font-weight: 700; line-height: 1.15;
  max-height: calc(3 * 1.15em + 4px); margin: auto 0; overflow-wrap: anywhere;
}
.show-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.show-big {
  min-height: 118px; border-radius: 26px; border: 0; color: #fff; padding: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 30px; font-weight: 800;
}
.show-big .ico { width: 36px; height: 36px; }
.show-big small { font-size: 14px; font-weight: 600; opacity: .9; }
.show-again { background: #0a64d0; }
.show-mic { background: #177a3f; }
.show-mic.on { background: #c4201a; }
.show-mic.resume { background: #b25000; }
.show-big:disabled { opacity: .45; }
.show-tim { flex: none; background: #1c1c1e; padding: 12px calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l)); }
.show-reply { font-size: 20px; margin-bottom: 10px; max-height: 4.2em; overflow-y: auto; }
.show-top { display: flex; gap: 10px; }
.show-small {
  flex: 1; min-height: 52px; border-radius: 14px; border: 0; background: #3a3a3c; color: #fff;
  font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.show-small .ico { width: 20px; height: 20px; }
.show-small.done { background: #fff; color: #000; flex: 0 0 38%; }
.show-small[aria-pressed="true"] { background: #0a64d0; }
body.showing { overflow: hidden; }

/* ---------- lists and forms in sheets ---------- */
.list-item {
  display: block; width: 100%; text-align: left; padding: 12px 14px; margin: 8px 0; border-radius: 12px;
  border: 0; background: var(--bg2); min-height: 56px;
}
.list-item.current { box-shadow: inset 0 0 0 2px var(--tint); }
.list-item.hidden-person { opacity: .8; box-shadow: inset 0 0 0 1px var(--hair); }
.li-title { font-weight: 700; }
.li-sub { font-size: 14px; color: var(--fg3); font-weight: 400; }
.li-line { font-size: 15px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--fg3); margin-top: 4px; }
.li-flag { font-size: 13px; font-weight: 700; color: var(--tint); margin-top: 2px; }
.banner-inline { padding: 8px 10px; border-radius: 10px; background: var(--amber-bg); color: var(--amber-fg); border: 1px solid var(--amber-line); font-weight: 600; }
.person-card { background: var(--bg2); border-radius: 14px; padding: 12px 14px; margin: 8px 0 4px; }
.pc-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.pc-row { display: flex; gap: 10px; padding: 3px 0; font-size: 15px; }
.pc-row span { flex: 0 0 64px; color: var(--fg3); }
.pc-row b { font-weight: 500; }

.field { margin: 10px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .hint { font-size: 13px; color: var(--fg3); margin-bottom: 4px; }
.field input, .field textarea, .field select { width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--hair); font-size: 17px; }
.field textarea { min-height: 90px; }

.toggle-row, .menu-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 0.5px solid var(--hair); }
.menu-row { flex-wrap: wrap; }
.menu-row.col { flex-direction: column; align-items: stretch; gap: 4px; }
.menu-row.col .txt { flex: none; }
.toggle-row .txt, .menu-row .txt { flex: 1 1 200px; }
.toggle-row .txt b, .menu-row .txt b { display: block; }
.toggle-row .txt span, .menu-row .txt span { font-size: 14px; color: var(--fg3); }
.switch { width: 64px; height: 44px; border-radius: 999px; border: 0; background: transparent; position: relative; flex: none; padding: 0; }
.switch::before { content: ""; position: absolute; left: 6px; right: 6px; top: 6px; bottom: 6px; border-radius: 999px; background: var(--fill); transition: background .15s; box-shadow: inset 0 0 0 1px var(--hair); }
.switch::after { content: ""; position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .15s; }
.switch[aria-checked="true"]::before { background: #34a853; background: var(--go); }
.switch[aria-checked="true"]::after { left: 28px; }
.help-box { margin: 12px 0; }
.help-box summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--tint); cursor: pointer; }
.help-box p { color: var(--fg2); font-size: 15px; }

.notice-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 0.5px solid var(--hair); flex-wrap: wrap; }
.notice-ico { width: 26px; height: 26px; margin-top: 2px; color: var(--amber-fg); }
.notice-row.orange .notice-ico { color: var(--orange); }
.notice-row.red .notice-ico { color: var(--red-text); }
.notice-txt { flex: 1 1 200px; }
.notice-txt p { margin: 2px 0 0; color: var(--fg2); }

.spend-big { font-size: 26px; font-weight: 800; }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; }
table.mini { width: 100%; border-collapse: collapse; font-size: 14px; }
table.mini td { padding: 4px 2px; border-bottom: 0.5px solid var(--hair); }
table.mini td:last-child { text-align: right; }

.fact { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0; }
.fact textarea { flex: 1; min-width: 0; min-height: 48px; border-radius: 10px; border: 1px solid var(--hair); padding: 6px; }
.gl-item { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; padding: 10px; border-radius: 12px; background: var(--bg2); }
.gl-l { display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-weight: 700; color: var(--fg3); }
.gl-item input, .gl-item textarea { min-height: 44px; border-radius: 8px; border: 1px solid var(--hair); padding: 6px 8px; width: 100%; font-size: 17px; font-weight: 400; color: var(--fg); resize: vertical; }
.gl-status { font-size: 14px; color: var(--fg3); }
.hist { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; padding: 8px 0; border-bottom: 0.5px solid var(--hair); overflow-wrap: anywhere; }
.hist .help { margin: 2px 0 0; }

/* ---------- short messages ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + var(--safe-t));
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 14px; z-index: 90; font-weight: 600;
  max-width: min(90vw, 480px); text-align: center; font-size: 15px; box-shadow: var(--shadow); pointer-events: none;
}
/* on the main screen: over the bottom of the conversation, just above the bar; taps go through */
.toast.dock-toast { position: absolute; top: auto; bottom: 12px; z-index: 4; max-height: 40%; overflow: hidden; }

/* ---------- a phone held sideways: everything moves into one rail on the right ----------
   The conversation keeps the whole height. The rail holds Chats and Menu, the name, then Type, the
   language chip, the mic and Show, every one 44 pt or more. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --rail-w: 88px; }
  #main {
    grid-template-columns: minmax(0, 1fr) calc(var(--rail-w) + var(--safe-r));
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "stage top" "stage dock" "composer dock";
  }
  .top {
    height: auto; align-self: start; padding: calc(4px + var(--safe-t)) calc(2px + var(--safe-r)) 0 2px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 44px 44px; row-gap: 2px; justify-items: center;
    overflow: hidden;
    border-bottom: 0; box-shadow: inset 0.5px 0 0 var(--hair);
  }
  .tb-btn { width: 44px; height: 44px; }
  #btn-convs { grid-column: 1; grid-row: 1; }
  #btn-menu { grid-column: 2; grid-row: 1; }
  .who { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; width: auto; min-width: 0; height: 44px; padding: 0 2px; }
  .who-line { flex-direction: column; gap: 1px; position: relative; }
  .who .chev { display: none; }
  .who-dot { position: absolute; top: 2px; right: -8px; }
  .who-name { font-size: 15px; max-width: 80px; }
  .who-sub { display: none; }
  .test-tag { font-size: 8px; padding: 0 3px; margin-left: 0; }
  .feed { padding-right: 10px; }
  .composer { padding-right: 8px; }
  .dock {
    height: auto; padding: 0 calc(2px + var(--safe-r)) calc(4px + var(--safe-b)) 2px;
    box-shadow: inset 0.5px 0 0 var(--hair);
    display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  }
  .dock-side { flex-direction: column; gap: 2px; }
  .dock-side.left { order: 0; }
  .mic { order: 1; }
  .dock-side.right { order: 2; }
  .bar-btn { min-width: 80px; height: 44px; gap: 2px; }
  .bar-btn .ico { width: 22px; height: 22px; }
  .show-es { flex-direction: row; gap: 16px; align-items: stretch; }
  .show-text { flex: 1 1 60%; font-size: clamp(40px, 6vh + 2vw, 56px); margin: auto 0; }
  .show-actions { flex: 0 0 34%; grid-template-columns: 1fr; margin-top: 0; }
  .show-big { min-height: 0; font-size: 24px; }
}
