/* The listener's phone page: a cheerful retro desktop. Cream windows with chunky
   outlines on a warm peach desk. The operator console uses
   the same look (retro-op.css); the projector screen uses glass.css. */
:root {
  color-scheme: light;
  --desk: #f4c28e;
  --paper: #fde8cf;
  --paper-2: #f9dcbb;
  --ink: #3a2418;          /* outlines and text */
  --ink-2: #6e4b38;        /* secondary text */
  --ink-3: #8a6650;        /* hints, earlier captions */
  --red: #ec5b2f;
  --orange: #f5a04a;
  --mauve: #d9aac6;
  --tan: #f3c27e;          /* buttons */
  --line: 3px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --caption-scale: 1;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  background-color: var(--desk);
  background-image: radial-gradient(rgba(58, 36, 24, .07) 1px, transparent 1.2px), radial-gradient(rgba(255, 255, 255, .25) 1px, transparent 1.2px);
  background-size: 7px 7px, 11px 11px; background-position: 0 0, 3px 5px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Scenery */

/* Windows */
.win { background: var(--paper); border: var(--line); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; }
.win-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding: 5px 8px 5px 12px;
  border-bottom: var(--line); background: var(--red); }
.win-bar.orange { background: var(--orange); }
.win-bar.mauve { background: var(--mauve); }
.win-title { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: .01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-btns { display: flex; gap: 5px; flex: none; }
.win-btns i { position: relative; width: 20px; height: 20px; border: 2.5px solid var(--ink); border-radius: 3px; background: var(--tan); }
.win-btns .b-min::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: 3px; height: 2.5px; background: var(--ink); }
.win-btns .b-max::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--orange); }
.win-btns .b-close { background: var(--red); }
.win-btns .b-close::before, .win-btns .b-close::after { content: ""; position: absolute; left: 1px; right: 1px; top: 6px; height: 2.5px; background: var(--ink); transform: rotate(45deg); }
.win-btns .b-close::after { transform: rotate(-45deg); }
.win-body { padding: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 22px;
  border: var(--line); border-radius: 6px; background: var(--tan); color: var(--ink); font-weight: 800; font-size: 16px;
  box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--red); color: #fff8ef; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.lg { min-height: 60px; font-size: 19px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.icon-btn:active { transform: translate(3px, 3px); box-shadow: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: var(--line); border-radius: 6px;
  background: var(--paper); font-size: 14px; font-weight: 800; white-space: nowrap; box-shadow: 3px 3px 0 var(--ink); }
.status .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper-2); flex: none; }
.status.live .dot { background: #5ad16f; animation: blink 1.6s steps(2) infinite; }
.status.reconnecting .dot { background: var(--orange); }
@keyframes blink { 50% { background: #2f9e44; } }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 640px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 800; font-size: 16px; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 34px; height: 34px; border: var(--line); border-radius: 8px; flex: none; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.aa { font-weight: 900; font-size: 15px; }
.lang-pill { height: 44px; padding: 0 12px 0 4px; gap: 8px; font-size: 16px; min-width: 0; cursor: pointer; }
.lang-pill .badge { width: 32px; height: 32px; font-size: 15px; border-width: 2.5px; }
.lang-pill .lang-name { overflow: hidden; text-overflow: ellipsis; }

main { max-width: 640px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
.view { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.lead { margin: 0 0 16px; font-size: 16px; line-height: 1.5; color: var(--ink-2); font-weight: 600; }
.lead.hero { margin: 8px 2px 18px; padding: 10px 14px; background: var(--paper); border: var(--line); border-radius: 6px; box-shadow: 3px 3px 0 var(--ink); color: var(--ink); font-weight: 700; }
.fine { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px 4px 0; font-size: 13px; font-weight: 700; color: var(--ink-2); text-align: center; }
.fine .ic { width: 16px; height: 16px; }
.banner { margin: 0 0 16px; padding: 14px 16px; border: var(--line); border-radius: 6px; background: #ffd6c9; box-shadow: 3px 3px 0 var(--ink); font-weight: 700; line-height: 1.45; }

/* Language list */
.badge { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: var(--line); border-radius: 8px;
  background: var(--mauve); font-weight: 900; font-size: 18px; color: var(--ink); }
.badge .ic { width: 20px; height: 20px; }
.search { display: flex; align-items: center; gap: 10px; height: 50px; margin-bottom: 12px; padding: 0 14px; border: var(--line); border-radius: 6px; background: #fff7ec; }
.search .ic { color: var(--ink-2); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 16px; font-weight: 700; }
.search input::placeholder { color: var(--ink-3); }
.list { display: grid; gap: 10px; }
.lang { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 66px; padding: 8px 10px; text-align: start;
  border: var(--line); border-radius: 6px; background: #fff7ec; box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.lang:hover { background: #fff1de; }
.lang:active { transform: translate(3px, 3px); box-shadow: none; }
.lang .txt { flex: 1; min-width: 0; display: grid; gap: 1px; }
.lang b { font-size: 18px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang small { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.lang .go { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border: 2.5px solid var(--ink); border-radius: 6px; background: var(--tan); }
.lang .go .ic { width: 18px; height: 18px; }
[dir=rtl] .lang .go .ic.flip { transform: scaleX(-1); }
.lang.first { background: #ffe0b8; }
.lang.first .badge { background: var(--orange); }
.lang.first .go { background: var(--red); color: #fff8ef; }
.list .no-results { padding: 24px 12px; text-align: center; font-weight: 700; color: var(--ink-2); }
.more { width: 100%; margin-top: 14px; }
.more .ic { width: 18px; height: 18px; }

/* One tap to start */
.start-win { margin-top: 24px; }
.start-card { display: grid; justify-items: center; gap: 6px; padding: 30px 22px 22px; text-align: center; }
.start-card h1 { margin: 14px 0 0; font-size: clamp(28px, 8vw, 38px); font-weight: 900; }
.start-card .lead { margin: 2px 0 22px; }
.start-card .btn.lg { width: 100%; max-width: 340px; }
.start-card .btn.ghost { margin-top: 6px; }
.badge.xl { width: 84px; height: 84px; font-size: 38px; border-radius: 14px; background: var(--orange); box-shadow: 4px 4px 0 var(--ink); }

/* Listening */
#listen { display: grid; gap: 14px; }
.stage { position: relative; display: flex; flex-direction: column; min-height: 0;
  height: calc(100dvh - 260px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); background: #fff7ec; }
@supports not (height: 100dvh) { .stage { height: calc(100vh - 280px); } }
.captions { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 20px 20px 28px;
  font-size: calc(23px * var(--caption-scale)); line-height: 1.45; font-weight: 700; }
.captions p { margin: 0 0 .75em; color: var(--ink-3); overflow-wrap: anywhere; }
.captions p.recent { color: var(--ink); }
.captions p.partial { color: var(--ink-2); }
.captions p .chunk { animation: chunkIn .35s ease-out; }
@keyframes chunkIn { from { opacity: 0; } }
.captions .orig { display: none; margin-top: .35em; padding-left: 10px; border-left: 3px solid var(--mauve); font-size: .68em; line-height: 1.4; font-weight: 600; color: var(--ink-2); }
body.show-orig .captions .orig { display: block; }
.captions .empty { display: grid; place-items: center; align-content: center; gap: 18px; height: 100%; padding: 20px; text-align: center; font-size: 17px; font-weight: 700; line-height: 1.5; color: var(--ink-2); }
/* "Downloading…": a segmented progress bar while waiting */
.captions .empty .bars { display: flex; gap: 3px; padding: 4px; border: var(--line); border-radius: 4px; background: var(--paper); }
.captions .empty .bars i { width: 14px; height: 22px; border: 2px solid var(--ink); border-radius: 2px; background: var(--paper-2); animation: load 2s steps(1) infinite; }
.captions .empty .bars i:nth-child(2) { animation-delay: .25s; }
.captions .empty .bars i:nth-child(3) { animation-delay: .5s; }
.captions .empty .bars i:nth-child(4) { animation-delay: .75s; }
.captions .empty .bars i:nth-child(5) { animation-delay: 1s; }
@keyframes load { 0% { background: var(--paper-2); } 50% { background: var(--red); } }
.typing { display: inline-flex; gap: 6px; padding: 4px 0; }
.typing i { width: 10px; height: 10px; border: 2px solid var(--ink); border-radius: 2px; background: var(--paper-2); animation: dot 1.2s steps(1) infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0% { background: var(--orange); } 40% { background: var(--paper-2); } }
.jump { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); }
.jump:active { transform: translate(calc(-50% + 3px), 3px); }
.jump .ic { width: 16px; height: 16px; }

.dock { display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 10px; }
.play { display: grid; place-items: center; width: 60px; height: 60px; flex: none; border: var(--line); border-radius: 8px;
  background: var(--red); color: #fff8ef; box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.play .ic { width: 28px; height: 28px; stroke-width: 2.6; }
.play:active { transform: translate(3px, 3px); box-shadow: none; }
.play[aria-pressed="false"] { background: var(--tan); color: var(--ink); }
.dock-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.dock-label { font-size: 15px; font-weight: 800; }
#viz { width: 100%; height: 26px; display: block; }
.dock.blocked .play { animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: rotate(-6deg) scale(1.06); } }
.note { display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-size: 15px; font-weight: 700; line-height: 1.45; }
.note .ic { color: var(--red); }
.disclaimer { margin-top: 2px; }

/* Text size window */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(58, 36, 24, .35); opacity: 0; pointer-events: none; transition: opacity .25s; }
.backdrop.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; z-index: 50; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); width: min(520px, calc(100% - 28px));
  transform: translate(-50%, calc(100% + 60px)); transition: transform .3s cubic-bezier(.2, 1.2, .4, 1); }
.sheet.open { transform: translate(-50%, 0); }
.sheet-head { padding-right: 6px; }
.win-x { display: grid; place-items: center; width: 30px; height: 30px; border: 2.5px solid var(--ink); border-radius: 4px; background: var(--red); color: var(--ink); padding: 0; }
.win-x .ic { width: 16px; height: 16px; stroke-width: 3; }
.sheet-body { display: grid; gap: 18px; padding: 18px; }
.sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sizes label { position: relative; }
.sizes input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.sizes span { display: grid; place-items: center; height: 62px; border: var(--line); border-radius: 6px; background: #fff7ec; font-weight: 900; box-shadow: 3px 3px 0 var(--ink); }
.sizes input:checked + span { background: var(--orange); transform: translate(3px, 3px); box-shadow: none; }
.sizes input:focus-visible + span { outline: 3px dashed var(--ink); outline-offset: 3px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; font-size: 16px; font-weight: 800; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 56px; height: 32px; flex: none; border: var(--line); border-radius: 6px; background: var(--paper-2); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; box-sizing: border-box; width: 21px; height: 21px; border: 2.5px solid var(--ink); border-radius: 3px; background: var(--tan); transition: transform .15s; }
.switch input:checked + .track { background: var(--orange); }
.switch input:checked + .track::after { transform: translateX(24px); background: var(--red); }
.switch input:focus-visible + .track { outline: 3px dashed var(--ink); outline-offset: 3px; }

@media (min-width: 700px) { .stage { height: calc(100vh - 290px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Babel brand */
.brand-text { display: grid; line-height: 1.1; min-width: 0; }
.brand-text b { font-size: 19px; font-weight: 900; letter-spacing: -.01em; }
.brand-text small { font-size: 12px; font-weight: 700; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-title .bar-logo { width: 22px; height: 22px; margin-right: 8px; vertical-align: -5px; }
.win-btns .b-max::after { border-radius: 2px; inset: 3px; }
.win-btns .b-close { background: var(--mauve); }
.brand-text .slogan { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; font-size: 10.5px; white-space: normal; line-height: 1.25; margin-top: 2px; }
.top-right { margin-left: auto; }
.captions .piece::before { content: ' '; }
