/*
  Built for older users on a phone at arm's length: warm off-white, dark
  text, generous type, one big button. Body text is about 15:1 and secondary
  text about 8:1 against the background. This theme skips the usual terminal
  look on purpose.
*/
:root {
  --bg: #FAF9F6;
  --card: #FFFFFF;
  --text: #1F1F1F;
  --text-2: #4D4D4D;
  --line: #D6D3CC;
  --line-strong: #8F8B83;
  --soft: #EFEDE8;
  --go: #1E7A46;
  --go-bg: #E5F3EA;
  --go-text: #14532D;
  --talk: #C2560C;
  --talk-bg: #FCEBDD;
  --talk-text: #7A2E00;
  --stop: #B42318;
  --stop-bg: #FDECEA;
  --idle: #9A968E;
  --scale: 1;
}

* { box-sizing: border-box; }
html { font-size: calc(19px * var(--scale)); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45; min-height: 100dvh;
}
[hidden] { display: none !important; }
small { color: var(--text-2); font-size: .85rem; }

button { font: inherit; cursor: pointer; color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--talk); outline-offset: 2px; }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 6px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}
h1 { font-size: 1.15rem; font-weight: 700; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Install button in the header: an icon over a short word. */
.install {
  flex: none; min-width: 60px; min-height: 44px; padding: 3px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 11px; font-weight: 700; line-height: 1.1;
  background: var(--talk-bg); color: var(--talk-text); border: 1px solid #F3CBAA; border-radius: 2px;
}
.install svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.install-help {
  width: min(420px, calc(100vw - 32px)); padding: 24px 22px 20px; border: 0; border-radius: 2px;
  background: var(--bg); color: var(--text); text-align: center;
}
.install-help[open] { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.install-help::backdrop { background: rgba(31, 31, 31, .45); }
.install-help img { border-radius: 16px; }
.install-help h2 { margin: 0; font-size: 1.15rem; }
.install-help p { margin: 0; font-size: 1.05rem; line-height: 1.45; }
.install-help .share { width: 26px; height: 26px; vertical-align: -6px; margin-inline-end: 6px; fill: none; stroke: #0A66D8; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.install-help .primary { align-self: stretch; }
.size { display: flex; gap: 6px; }
.size-btn {
  min-width: 52px; min-height: 44px; padding: 0 10px;
  font-size: 18px; font-weight: 700; /* fixed size so it never grows off screen */
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 2px;
}
.size-btn:disabled { opacity: .4; cursor: default; }

main { max-width: 820px; margin: 0 auto; padding: 8px 12px 12px; }
/* Room for the fixed dock, only while it's showing. */
body.running main { padding-bottom: 170px; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 10px 0; }

/* access code */
.gate form { display: flex; flex-direction: column; gap: 12px; }
.gate input {
  font-size: 1.1rem; padding: 14px; border: 1px solid var(--line-strong); border-radius: 2px;
  background: var(--card); color: var(--text);
}
.primary {
  font-size: 1.1rem; font-weight: 700; padding: 16px; min-height: 64px;
  background: var(--text); color: #fff; border: 0; border-radius: 2px;
}
.err { color: var(--stop); font-weight: 600; }

/* mode switch + settings (on every language card) */
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 2px; overflow: hidden; background: var(--card); }
.seg button {
  flex: 1; min-height: 52px; padding: 8px 10px; font-weight: 600; font-size: .95rem;
  background: transparent; border: 0; border-inline-end: 1px solid var(--line);
}
.seg button:last-child { border-inline-end: 0; }
.seg button[aria-checked="true"] { background: var(--text); color: #fff; }
.seg.small button { min-height: 44px; font-size: .9rem; }

.settings { border: 1px solid var(--line); border-radius: 2px; background: var(--card); }
.settings summary { padding: 12px 14px; font-weight: 600; cursor: pointer; }
.settings .row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.settings .row.col { flex-direction: column; align-items: stretch; }
.settings input[type="checkbox"] { width: 26px; height: 26px; margin-top: 2px; accent-color: var(--go); flex: none; }

/* status */
.status {
  font-size: 1.15rem; font-weight: 600; text-align: center;
  padding: 12px 14px; border-radius: 2px; border: 1px solid transparent;
}
.status.idle { background: var(--soft); color: var(--text); }
.status.live { background: var(--go-bg); color: var(--go-text); border-color: #B9DFC8; }
.status.speaking { background: var(--talk-bg); color: var(--talk-text); border-color: #F3CBAA; }
.status.err { background: var(--stop-bg); color: var(--stop); border-color: #F4C1BC; }


/*
  Conversation as chat bubbles, oldest at the top. The home speaker (whoever
  set it up) is on the right, the other person on the left. Each bubble shows
  the original small and the translation large, since the translation is what
  the other person needs to read. The rounded bubble is a deliberate exception
  to the usual square corners: it's the shape everyone already reads as chat.
*/
.log { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.turn { display: flex; }
.turn.home { justify-content: flex-end; }
.turn.other { justify-content: flex-start; }
.bubble {
  max-width: 85%; padding: 10px 14px 12px; border-radius: 20px;
  transition: background-color .2s;
}
.turn.other .bubble { background: #ECEAE5; color: var(--text); border-end-start-radius: 6px; }
.turn.home .bubble { background: #2B2B2B; color: #fff; border-end-end-radius: 6px; }
.bubble .heard { font-size: .9rem; opacity: .75; }
.bubble .heard:empty { display: none; }
.bubble .spoken { font-size: 1.1rem; font-weight: 600; line-height: 1.35; }
.bubble .spoken:empty { display: none; }
.bubble .heard + .spoken:not(:empty) { margin-top: 6px; padding-top: 6px; border-top: 1px solid currentColor; border-top-color: color-mix(in srgb, currentColor 25%, transparent); }
.bubble:has(.heard:empty):has(.spoken:empty)::before { content: "…"; opacity: .6; }
/* The newest translation is the one people need, so it's the biggest. */
.turn:last-child .spoken { font-size: 1.35rem; font-weight: 700; }

/* A bubble with a translation can be tapped to hear it again. */
.bubble.has-audio { cursor: pointer; position: relative; }
.bubble.has-audio .spoken::after {
  content: ""; display: inline-block; width: .8em; height: .8em; margin-inline-start: .4em; vertical-align: -.05em;
  background: currentColor; opacity: .45;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.5 4.5 0 0 0 2.5-4zM14 3.2v2.1a7 7 0 0 1 0 13.4v2.1a9 9 0 0 0 0-17.6z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.5 4.5 0 0 0 2.5-4zM14 3.2v2.1a7 7 0 0 1 0 13.4v2.1a9 9 0 0 0 0-17.6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Messages from the interpreter itself, like "have the other person talk first." */
.turn.system { justify-content: center; }
.turn.system .bubble {
  background: transparent; color: var(--text-2); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 6px 14px; font-size: .9rem; text-align: center;
}
.turn.system .heard { display: none; }
.turn.system .spoken, .turn.system:last-child .spoken { font-size: .9rem; font-weight: 600; }
.turn.system .heard + .spoken:not(:empty) { margin: 0; padding: 0; border: 0; }

/* bottom controls */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 16px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
  display: flex; justify-content: center; gap: 10px;
}
.main {
  flex: 1; max-width: 600px; min-height: 84px;
  display: flex; gap: 12px; justify-content: center; align-items: center;
  font-size: 28px; font-weight: 700; /* fixed: the button is already big */
  background: var(--text); color: #fff; border: 0; border-radius: 2px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
}
.main .icon { width: 36px; height: 36px; fill: currentColor; }
/* Glow that follows the mic: green = voice being sent, gray = noise only,
   orange = translation playing. Set from JS each frame. */
.main {
  --glow: 0px; --glow-color: transparent;
  box-shadow: 0 0 var(--glow) calc(var(--glow) / 3) var(--glow-color);
  transition: box-shadow 80ms linear, background-color .2s;
}
.main.stop { background: var(--stop); }
.main.hold { background: var(--go); }
.main.hold[aria-pressed="true"] { background: #0F4F2B; }
/* Welcome message button, at the top of the conversation during a session. */
.welcome {
  width: 100%; min-height: 56px; margin-top: 10px; padding: 10px 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 1.05rem; font-weight: 700;
  background: var(--card); color: var(--text); border: 2px solid var(--text); border-radius: 2px;
}
.welcome svg { width: 22px; height: 22px; fill: var(--talk); flex: none; }
.welcome:disabled { opacity: .45; }

/* Offered once when the room is too loud for hands-free. */
.noisy {
  position: absolute; left: 16px; right: 16px; bottom: calc(100% + 8px);
  padding: 14px 16px; font-size: 1rem; font-weight: 600; text-align: center;
  background: var(--talk-bg); color: var(--talk-text); border: 1px solid #F3CBAA; border-radius: 2px;
}
.face {
  flex: none; width: 84px; min-height: 84px; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; font-weight: 700; line-height: 1.15;
  background: var(--card); color: var(--text); border: 1px solid var(--line-strong); border-radius: 2px;
}
.face svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.face[aria-pressed="true"] { background: var(--text); color: #fff; border-color: var(--text); }

/*
  Face-to-face panel: the top of the screen, turned upside down for the
  person across the table, with the latest turn in their language.
*/
.facing {
  position: fixed; top: 0; left: 0; right: 0; height: 38dvh; z-index: 4;
  display: flex; align-items: center; justify-content: center; padding: 18px 22px;
  background: var(--card); border-bottom: 2px solid var(--text);
  transform: rotate(180deg);
}
.facing p { margin: 0; font-size: 1.6rem; font-weight: 700; line-height: 1.3; text-align: center; overflow: auto; max-height: 100%; }
.facing p:empty::before { content: "…"; color: var(--text-2); }
body.face-on main { padding-top: calc(38dvh + 14px); }
body.face-on .top { display: none; }
/* The owner can't read the other language, so in face-to-face their half
   shows only their own: their words as they said them, and the other
   person's words translated. The other language is on the turned-around
   panel for the person across the table. */
body.face-on .turn.home .spoken, body.face-on .turn.other .heard { display: none; }
body.face-on .turn.home .heard { font-size: 1.1rem; font-weight: 600; opacity: 1; line-height: 1.35; }
body.face-on .turn.home:last-child .heard { font-size: 1.35rem; font-weight: 700; }
body.face-on .bubble .heard + .spoken:not(:empty) { margin-top: 0; padding-top: 0; border-top: 0; }
body.face-on .turn.other .bubble:has(.spoken:empty)::before,
body.face-on .turn.home .bubble:has(.heard:empty)::before { content: "…"; opacity: .6; }

.end {
  min-width: 96px; min-height: 84px; font-size: 20px; font-weight: 700;
  background: var(--card); color: var(--stop); border: 2px solid var(--stop); border-radius: 2px;
}

/*
  How-to carousel: one card per language with the directions and a Start
  button in that language. Cards are absolutely positioned and moved by
  carousel.js; neighbors peek in at the edges so it's obvious you can swipe.
*/
.carousel { margin-top: 2px; }
.car-track {
  position: relative; overflow: hidden; transition: height .25s ease;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.car-card { position: absolute; left: 50%; top: 0; will-change: transform, opacity; -webkit-touch-callout: none; }
.car-card:not(.center) { cursor: pointer; }
.car-nav { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.car-arrow {
  min-height: 44px; padding: 0 6px; font-size: .9rem; font-weight: 600;
  background: transparent; color: var(--text-2); border: 0;
}
.car-arrow span[aria-hidden] { font-size: 1.6rem; line-height: 1; vertical-align: -2px; }
.car-arrow:hover { color: var(--text); }
/* The language in the middle, named in itself. */
.car-current { font-size: 1.05rem; font-weight: 700; color: var(--talk-text); text-align: center; }
.car-arrow { flex: 1 1 0; min-width: 0; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car-arrow.next { text-align: end; }

.how {
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 2px;
  padding: 12px 16px 14px; display: flex; flex-direction: column;
}
.how ol { list-style: none; padding: 0; margin: 4px 0 10px; }
.how li { display: flex; align-items: center; gap: 12px; margin: 8px 0; line-height: 1.35; font-size: .95rem; }
/* A picture for each step, with its number tucked on the corner. */
.step-pic {
  position: relative; flex: none; width: 56px; height: 56px;
  display: grid; place-items: center; background: var(--soft); border-radius: 2px;
}
.step-pic svg {
  width: 46px; height: 46px; fill: none; stroke: var(--text);
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}
.step-pic .a { stroke: var(--talk); }
.step-pic .f { fill: var(--text); }
.step-pic .bg { fill: var(--soft); }
.step-pic .go { fill: var(--go); stroke: var(--go); }
.step-num {
  position: absolute; top: -6px; inset-inline-start: -6px; width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--text); color: #fff; font-size: 13px; font-weight: 700;
}
.how:lang(ko) { word-break: keep-all; } /* Korean wraps between words, not mid-word */
/* Settings as a quiet line under Start; it opens into the full panel. */
.how .settings { margin-top: 8px; border-color: transparent; background: transparent; }
.how .settings[open] { border-color: var(--line); background: var(--card); }
.how .settings summary { padding: 6px 4px; font-size: .9rem; color: var(--text-2); }

/* "The other person's language: Español ›" on each card. */
.other-pick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start;
  margin-bottom: 10px; padding-block: 8px; padding-inline: 14px 44px; position: relative;
  background: var(--card); border: 2px solid var(--text); border-radius: 2px;
}
.other-pick::after {
  content: "›"; position: absolute; inset-inline-end: 16px; top: 50%; transform: translateY(-52%);
  font-size: 2rem; line-height: 1; color: var(--text-2);
}
.how[dir="rtl"] .other-pick::after { content: "‹"; }
.other-label { font-size: .85rem; color: var(--text-2); font-weight: 600; }
.other-name { font-size: 1.2rem; font-weight: 700; line-height: 1.25; }
.other-name.unset { color: var(--talk-text); }

/* The language list: a sheet from the bottom, one big row per language. */
.picker {
  width: min(560px, 100vw); max-width: 100vw; max-height: 86dvh; margin: auto auto 0;
  padding: 0; border: 0; border-radius: 2px 2px 0 0; background: var(--bg); color: var(--text);
  display: none; flex-direction: column;
}
.picker[open] { display: flex; }
.picker::backdrop { background: rgba(31, 31, 31, .45); }
.picker h2 { margin: 0; padding: 18px 18px 12px; font-size: 1.2rem; border-bottom: 1px solid var(--line); }
.pick-list { overflow: auto; padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); }
.pick {
  width: 100%; min-height: 60px; margin: 6px 0; padding: 10px 16px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; text-align: start;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 2px;
}
.pick-name { font-size: 1.15rem; font-weight: 700; }
.pick-native { font-size: 1rem; color: var(--text-2); }
.pick[aria-pressed="true"] { background: var(--text); color: #fff; border-color: var(--text); }
.pick[aria-pressed="true"] .pick-native { color: #ddd; }
.pick.auto { font-size: 1rem; font-weight: 600; color: var(--text-2); justify-content: center; }
body[data-mode="ptt"] .how .step-auto, body:not([data-mode="ptt"]) .how .step-ptt { display: none; }
.how-start {
  min-height: 64px; display: flex; gap: 12px; justify-content: center; align-items: center;
  font-size: 26px; font-weight: 700; /* fixed: the button is already big */
  background: var(--text); color: #fff; border: 0; border-radius: 2px;
}
.how-start .icon { width: 32px; height: 32px; fill: currentColor; flex: none; }

/* The interpreter's name and face in the header, linking to their page. */
.who { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.who img { width: 34px; height: 34px; border-radius: 2px; object-fit: cover; flex: none; }
/* A crew member's app has one card, so the carousel arrows have nowhere to go. */
.carousel.single .car-arrow { visibility: hidden; }

/* Purchases: the plans link under the code box, the thank-you dialog, and
   the manage-plan button, which only shows when this phone holds a key. */
.gate-buy { margin-top: 18px; }
.gate-buy a { color: var(--talk-text); }
.thanks .license { font-size: 1.5rem; letter-spacing: .06em; font-family: "JetBrains Mono", ui-monospace, monospace; }
.thanks #thanks-body button { margin-bottom: 10px; }
.manage-plan { display: none; margin-top: 14px; background: none; border: 1px solid var(--line-strong); border-radius: 2px; padding: 10px 14px; }
body.licensed .manage-plan { display: inline-block; }

/* Sign in with email. */
.gate p { color: var(--text-2); }
.gate .free-note { margin-top: 14px; font-weight: 600; color: var(--go-text); }
.gate .otp { font-size: 2rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.gate-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; }
.linkish { background: none; border: 0; padding: 4px 0; color: var(--talk-text); text-decoration: underline; text-underline-offset: 3px; font-size: .95rem; }
#gate-err.ok { color: var(--go-text); }
.free-left { font-size: .8rem; font-weight: 600; color: var(--go-text); background: var(--go-bg); padding: 6px 10px; border-radius: 2px; text-decoration: none; white-space: nowrap; }
.sign-out { display: none; margin-top: 14px; margin-inline-start: 8px; background: none; border: 1px solid var(--line-strong); border-radius: 2px; padding: 10px 14px; }
body.signed-in .sign-out { display: inline-block; }

/* "you agree to the Terms and the Privacy Policy" under the sign-in form */
.gate .agree { margin-top: 18px; font-size: .8rem; color: var(--text-2); }
.gate .agree a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
