/* Precise Translator: the one flat stylesheet.
   The look is the prototype (design canvas artifact 0a5fea4b, Main.dc.html); the theme
   values are docs/WEB-APP.md section 2. <html> carries the state the controller sets:
   data-appearance, data-accent, data-gate, data-live, data-typing,
   data-layout and the --scale custom property. */

/* ===== 1. Theme: shared values per appearance ===== */

html {
  --scale: 1;
  /* Size (More, 1.1 A6): one zoom factor for the whole interface. Zoom scales every length
     inside .app and the sheets, so the screen's own measures (the safe-area insets and the
     banner strip, which the native 50 dp banner fills at a fixed size) are divided back. */
  --ui-zoom: 1;
  --sa-top: calc(env(safe-area-inset-top, 0px) / var(--ui-zoom, 1));
  --sa-right: calc(env(safe-area-inset-right, 0px) / var(--ui-zoom, 1));
  --sa-bottom: calc(env(safe-area-inset-bottom, 0px) / var(--ui-zoom, 1));
  --sa-left: calc(env(safe-area-inset-left, 0px) / var(--ui-zoom, 1));
  --strip-z: calc(var(--strip) / var(--ui-zoom, 1));
  --dock-inset-z: calc(var(--dock-inset) / var(--ui-zoom, 1));
  --strip-h: 54px;
  --strip: calc(var(--strip-h) + env(safe-area-inset-bottom, 0px));
  --dock-inset: 0px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', 'Noto Sans SC', sans-serif;
  --ease: cubic-bezier(.2,.8,.2,1);
  /* The board's fixed colours in both appearances: the teal minutes pill and search
     button with dark ink, and the blue translate button with white ink. */
  --teal: #36e8ce;
  --teal-ink: #0a1421;
  --blue: #348dff;
}

html[data-typing="true"] {
  --strip: 0px;
  --dock-inset: env(safe-area-inset-bottom, 0px);
}

html[data-appearance="dark"] {
  color-scheme: dark;
  --bg: #0a1421;
  --panel: #111f2b;
  --ink: #f5f5fc;
  --muted: #acb6cf;
  --line: #364857;
  --b: #202640;
  --b-line: #414968;
  --note: #f2ce86;
  --well: #0d1926;
  --on-accent: #0a1421;
  --sheet: rgba(17,31,43,0.9);
  --glass: linear-gradient(150deg, rgba(255,255,255,0.055), rgba(255,255,255,0) 60%);
  --edge: rgba(255,255,255,0.09);
  --lift: #ffffff;
  --sheet-shadow: 0 -14px 28px rgba(0,0,0,.5);
  --depth: linear-gradient(180deg, var(--depth-top) 0%, var(--bg) 36%);
  --scrim: rgba(3,8,14,0.62);
  --sw-green: #36e8ce;
  --sw-blue: #348dff;
  --sw-purple: #b879ff;
  --sw-red: #ff6b73;
}

html[data-appearance="light"] {
  color-scheme: light;
  --bg: #ede3cf;
  --panel: #f3ebdb;
  --ink: #2a2118;
  --muted: #5c5039;
  --line: #d3c3a3;
  --b: #e4d7bd;
  --b-line: #bfae8a;
  --note: #6e4708;
  --well: #e6d9c0;
  --lift: #faf5e8;
  --on-accent: #ffffff;
  --sheet: rgba(243,235,219,0.94);
  --glass: linear-gradient(150deg, rgba(255,250,236,0.6), rgba(255,250,236,0) 60%);
  --edge: rgba(255,250,236,0.85);
  --sheet-shadow: 0 -14px 28px rgba(60,44,20,.24);
  --depth: linear-gradient(180deg, var(--depth-top) 0%, var(--bg) 30%);
  --scrim: rgba(42,33,24,0.38);
  --sw-green: #066b5e;
  --sw-blue: #1b58b8;
  --sw-purple: #6e32b8;
  --sw-red: #a82738;
}

/* ===== 2. Theme: the eight appearance and accent pairs ===== */

html[data-appearance="dark"][data-accent="green"] {
  --accent: #36e8ce; --a: #152f32; --a-line: #337074; --accent-soft: #0e2731; --accent-line: #368081;
  --depth-top: #0d232d; --blade: rgba(23,63,69,0.97);
}
html[data-appearance="dark"][data-accent="blue"] {
  --accent: #348dff; --a: #142b47; --a-line: #365f97; --accent-soft: #0e1f35; --accent-line: #356092;
  --depth-top: #0d1c31; --blade: rgba(23,49,77,0.97);
}
html[data-appearance="dark"][data-accent="purple"] {
  --accent: #b879ff; --a: #30213f; --a-line: #705392; --accent-soft: #1a1d35; --accent-line: #645992;
  --depth-top: #161b31; --blade: rgba(44,45,77,0.97);
}
html[data-appearance="dark"][data-accent="red"] {
  --accent: #ff6b73; --a: #39232e; --a-line: #875058; --accent-soft: #201c28; --accent-line: #7c5461;
  --depth-top: #1b1a27; --blade: rgba(55,43,55,0.97);
}
html[data-appearance="light"][data-accent="green"] {
  --accent: #066b5e; --a: #dfe6cf; --a-line: #86ad9c; --accent-soft: #e1e2cb; --accent-line: #84aa98;
  --depth-top: #f6eedf; --blade: rgba(220,228,206,0.97);
}
html[data-appearance="light"][data-accent="blue"] {
  --accent: #1b58b8; --a: #dde3e2; --a-line: #94a9c6; --accent-soft: #dfe0d6; --accent-line: #8ea5c2;
  --depth-top: #f6eedf; --blade: rgba(222,226,224,0.97);
}
html[data-appearance="light"][data-accent="purple"] {
  --accent: #6e32b8; --a: #e8dfe6; --a-line: #b09bcb; --accent-soft: #e4dcdf; --accent-line: #a894c4;
  --depth-top: #f6eedf; --blade: rgba(233,224,230,0.97);
}
html[data-appearance="light"][data-accent="red"] {
  --accent: #a82738; --a: #f0dccf; --a-line: #cc9a98; --accent-soft: #eadcd0; --accent-line: #c0948f;
  --depth-top: #f6eedf; --blade: rgba(240,222,210,0.97);
}

/* ===== 3. Base ===== */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background-color: var(--bg);
  background-image: var(--depth);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
  transition: background-color .25s linear, color .25s linear;
}

button, input, textarea { font: inherit; color: inherit; margin: 0; }
button { appearance: none; cursor: pointer; background: transparent; border: 0; padding: 0; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="range"] { accent-color: var(--accent); }
svg { fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app {
  /* Size: zoom scales viewport units too, so the height is divided back to the screen's. */
  zoom: var(--ui-zoom, 1);
  height: calc(100vh / var(--ui-zoom, 1));
  height: calc(100dvh / var(--ui-zoom, 1));
  display: flex;
  flex-direction: column;
  padding-bottom: var(--strip-z);
  overflow: hidden;
}

/* Glass panels share one surface. */
.card, .pack, .hist-row {
  background-color: var(--panel);
  background-image: var(--glass);
  box-shadow: inset 0 1px 0 var(--edge);
}

/* ===== 4. Header ===== */
/* The board's header: the mark (30px), PT over the tier line, the language pair as
   compact round pills with the swap between them, the minutes pill in teal. One line at
   390px in either interface language: the language names shorten with an ellipsis. */

.top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin-bottom: 8px;
  padding: calc(12px + var(--sa-top)) calc(12px + var(--sa-right)) 10px calc(12px + var(--sa-left));
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 18px 18px;
  background-color: color-mix(in srgb, var(--panel) 72%, var(--well));
  box-shadow: 0 1px 0 var(--edge);
}

.brand { flex: none; display: flex; align-items: center; gap: 8px; min-width: 0; }
.mark { display: block; flex: none; width: 30px; height: 30px; stroke: none; }
/* The tier sits beside the mark; the mark is the app's icon, so no text repeats the name. */
.brand-col { display: flex; flex-direction: row; align-items: center; gap: 6px; line-height: 1.1; }

/* The plan: Free or Pro, with an Upgrade tag that opens the Minutes sheet. */
/* A larger touch target than the drawn tag, without making the header taller. */
/* The gold P and T for Pro and Pro+; Free keeps white. */
/* Upgrade: a small accent text line under the minutes pill; it opens Minutes. Hidden for Pro+. */
.pill-col { flex: none; display: flex; flex-direction: column; align-items: center; gap: 0; }

.pair {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  align-self: flex-start;
}

.lang-btn {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 28px;
  padding: 0 7px 0 9px;
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color .18s linear;
}
.lang-btn::after { content: ''; position: absolute; inset: -8px -1px; }
.lang-btn[aria-expanded="true"] { border-color: var(--accent); }
.lang-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 12px; height: 12px; flex: none; stroke: var(--muted); stroke-width: 2.2; }

.swap-btn { flex: none; width: 24px; height: 28px; display: flex; align-items: center; justify-content: center; }
.swap-btn svg { width: 15px; height: 15px; stroke-width: 1.9; }

/* ===== 5. The minutes pill ===== */

.pill-btn { position: relative; flex: none; height: 28px; display: flex; align-items: center; }
.pill-btn::after { content: ''; position: absolute; inset: -8px -4px; }
.pill {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 21px;
  padding: 0 9px;
  border-radius: 999px;
  background-color: var(--teal);
  color: var(--teal-ink);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== 6. Language picker ===== */

/* The menu opens under the pill that was pressed and covers that side only (polish order
   P5): data-side="a" the left half, "b" the right half, one column, scrolling past 60vh. */
.lang-picker {
  position: fixed;
  left: calc(10px + var(--sa-left));
  right: calc(10px + var(--sa-right));
  top: calc(50px + var(--sa-top));
  z-index: 12;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  max-height: calc(60vh / var(--ui-zoom, 1));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background-color: var(--sheet);
  background-image: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 var(--edge);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity .16s linear, transform .18s var(--ease);
}
.lang-picker[data-side="a"] { left: calc(10px + var(--sa-left)); right: calc(50% + 3px); }
.lang-picker[data-side="b"] { left: calc(50% + 3px); right: calc(10px + var(--sa-right)); }
.lang-picker[data-open="true"] { opacity: 1; transform: translateY(0); pointer-events: auto; }
.lang-option {
  height: 40px;
  padding: 0 8px;
  text-align: left;
  font-size: 14px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-option[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }

/* ===== 7. Conversation: the well ===== */
/* #conversation is the well: a rounded window on the page background with the word
   ground painted behind it. #convScroll scrolls inside it, bottom-anchored with
   column-reverse, so the newest card sits at the bottom and stays in view when the
   sheet opens and the well shrinks. */

.main { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }

.conversation {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 calc(8px + var(--sa-right)) 0 calc(8px + var(--sa-left));
  border-radius: 18px;
  overflow: hidden;
  background-color: transparent;
  transition: flex-basis .22s var(--ease);
}

/* The word ground (restyle R4): the icon's rows of conversation lines, two static SVGs
   from scripts/make-ground.mjs, on the well only (never the header, the bar, the field or
   the tabs). One image at the board's 374 by 844, read from the bottom left as the board
   draws it; it stays put while #convScroll scrolls over it, so the browser composites one
   image. It tiles on a well wider or taller than the board's. The Word ground switch in
   Words sets data-ground="off". */
#conversation { background-position: left bottom; background-size: 374px 844px; background-repeat: repeat; }
html[data-appearance="dark"] #conversation { background-image: url(./assets/ground-dark.svg); }
html[data-appearance="light"] #conversation { background-image: url(./assets/ground-light.svg); }
html[data-ground="off"] #conversation { background-image: none; }

.conv-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column-reverse;
  scrollbar-width: none;
  touch-action: pan-y;
}
.conv-scroll::-webkit-scrollbar { display: none; }

.conv-inner {
  flex: none;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 3px 6px 8px;
}

.empty { margin: auto 0; text-align: center; padding: 16px; }
.ring {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring span { display: block; width: 20px; height: 20px; border-radius: 50%; background-color: var(--accent); }
.empty h2 { margin: 22px 0 10px; font-size: 22px; font-weight: 550; color: var(--ink); }
.empty p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.empty .house { margin-top: 18px; font-size: 12px; line-height: 1.3; letter-spacing: 0.04em; color: var(--accent); }

.date-line { text-align: center; color: var(--muted); font-size: 11px; padding: 4px 0 8px; }

/* Search in the open chat: matches are outlined, the rest dimmed. */
.cards .card.search-dim { opacity: .32; }
.cards .card.search-hit { border-color: var(--sw-green); box-shadow: 0 0 0 1px var(--sw-green); }

/* ===== 8. Cards (everything scales with --scale) ===== */
/* As the board draws them (restyle R5): side 1 at 78% against the left edge on the panel,
   side 2 at 78% against the right on the second speaker's surface, PTAI centred at 84% in
   gold. The cards are opaque, so the word ground shows only between them. */

.card {
  width: 78%;
  margin: 0 0 calc(7px * var(--scale)) 0;
  padding: calc(9px * var(--scale)) calc(12px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 16px;
  background-color: var(--panel);
  font-size: calc(16px * var(--scale));
  line-height: 1.35;
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .18s linear, transform .2s var(--ease), border-color .45s linear, background-color .25s linear;
}
.card[data-side="1"] { margin-left: 0; }
.card[data-side="2"] { margin-left: 22%; background-color: var(--b); border-color: var(--b-line); }
.card.seated { opacity: 1; transform: translateY(0); }
.card.flash { border-color: var(--accent); }

.card-line { margin-bottom: calc(2px * var(--scale)); }
.card-line .text { white-space: pre-wrap; }
.card-line:has(.text:empty) { display: none; }
html[data-layout="trans"] .card:not(.ptai) .l1 { display: none; }

.play {
  margin-left: calc(3px * var(--scale));
  width: calc(26px * var(--scale));
  height: calc(20px * var(--scale));
  line-height: 0;
  vertical-align: baseline;
}
.play .glyph {
  display: inline-block;
  width: calc(10px * var(--scale));
  height: calc(12px * var(--scale));
  background-color: var(--accent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.play.playing .glyph { clip-path: none; height: calc(10px * var(--scale)); }

.card-roman { font-size: calc(12px * var(--scale)); line-height: 1.3; color: var(--muted); }
.card-note { margin-top: calc(6px * var(--scale)); font-size: calc(13px * var(--scale)); line-height: 1.35; color: var(--note); }
.card-roman:empty, .card-note:empty { display: none; }
html[data-layout="both"] .card-roman, html[data-layout="trans"] .card-roman,
html[data-layout="both"] .ptai-sug-roman, html[data-layout="trans"] .ptai-sug-roman { display: none; }

/* The foot: the number, time and engine at the left, the PTAI control at the right. */
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 0; height: 26px; margin: 2px 0 -5px; }
.card-foot .time { flex: 1; min-width: 0; letter-spacing: 0.08em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask { flex: none; min-width: 44px; height: 26px; display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
.ask-tag { font-size: 10px; letter-spacing: 0.12em; color: var(--accent); }
/* Flag on a PTAI reply (Play's AI-generated content policy): a quiet text control at the end of the head row. */
.ptai-head .flag { margin-left: auto; padding: 4px 6px; min-height: 24px; font-size: 10px; letter-spacing: 0.12em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; background-color: transparent; }
.ptai-head .flag:active { color: var(--accent); border-color: var(--accent); }
.flag-reasons { display: grid; gap: 6px; }
.flag-reasons input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; }
.flag-note { font-family: inherit; resize: none; margin-top: 6px; height: auto; min-height: 72px; line-height: 1.4; }
.sparkle { width: 12px; height: 12px; flex: none; stroke-width: 1.8; }
.time { font-size: max(10px, calc(10px * var(--scale))); color: var(--muted); font-variant-numeric: tabular-nums; }

.card-actions { display: flex; gap: 6px; margin-top: 6px; }
.card-actions button {
  flex: 1;
  height: 36px;
  padding: 0 6px;
  font-size: 12px;
  color: var(--ink);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background-color: var(--panel);
  background-image: var(--glass);
}

/* PTAI cards are gold and centred at 84%: the assistant's voice, told apart from the two
   speakers at a glance. */
.card.ptai { width: 84%; margin-left: 8%; margin-right: 8%; border-color: var(--note); background-color: color-mix(in srgb, var(--note) 9%, var(--panel)); }
.card.ptai.flash { border-color: var(--note); box-shadow: 0 0 0 1px var(--note); }
.ptai-head { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.ptai-label { font-size: 10px; letter-spacing: 0.12em; color: var(--note); }
/* The AI panel's buttons show their state: the last request run, and whether PTAI is on. */
/* The selected style (F9): an accent outline and accent text, no fill. Segments and chips copy it. */
.modes .well-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
/* A preset is a switch with its own explanation; several may be on. */
.well-btn.preset { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; min-height: 44px; padding: 5px 9px; }
.preset-name { font-size: var(--menu-font, 14px); font-weight: 600; }
.preset-name::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; border: 1px solid var(--muted); vertical-align: 1px; }
.well-btn.preset[aria-pressed="true"] .preset-name::before { background-color: var(--accent); border-color: var(--accent); }
.ptai-q {
  flex: 1;
  min-width: 0;
  font-size: calc(12px * var(--scale));
  color: var(--note);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ptai-body { font-size: calc(13px * var(--scale)); line-height: 1.45; white-space: pre-wrap; }
.ptai-body:empty, .ptai-sug-roman:empty, .ptai-sug-back:empty { display: none; }
.ptai-sug-roman { font-size: calc(12px * var(--scale)); line-height: 1.3; color: var(--muted); }
.ptai-sug-back { font-size: calc(13px * var(--scale)); line-height: 1.35; color: var(--muted); margin-top: 3px; }
.say {
  margin: 8px 0 2px;
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 650;
  color: var(--on-accent);
  background-color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
}

/* The live transcript card, with its caret blinking 0.44s on and 0.44s off. */
.ghost {
  width: 78%;
  margin: 0 0 calc(7px * var(--scale)) 0;
  padding: calc(9px * var(--scale)) calc(12px * var(--scale));
  border: 1px dashed var(--line);
  border-radius: 16px;
  font-size: calc(16px * var(--scale));
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.ghost[data-side="2"] { margin-left: 22%; border-color: var(--b-line); }
.caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background-color: var(--accent);
  animation: caret-blink .88s step-end infinite;
}
@keyframes caret-blink { 0% { opacity: 1; } 50% { opacity: 0; } }

/* ===== 9. The dock: the sheet and its panes ===== */

.dock {
  position: relative;
  flex: none;
  margin-top: 8px;
  padding: 10px calc(10px + var(--sa-right)) calc(8px + var(--dock-inset-z)) calc(10px + var(--sa-left));
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  background-color: color-mix(in srgb, var(--panel) 72%, var(--well));
  box-shadow: 0 -1px 0 var(--edge);
}

/* The sheet (#optionsPanel): a rounded sheet in the flow between the well and the status
   word. It takes up to 56% of the screen; the well (flex: 1) gives up the room and, being
   bottom-anchored, keeps the newest card in view above it. The head stays put and the
   panes scroll inside .sheet-body. Rows inside it sit on --row, the panel surface. */
html { --row: var(--well); --row-line: var(--line); }
.options {
  --row: var(--panel);
  --row-line: color-mix(in srgb, var(--line) 55%, var(--well));
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  transform: translateY(12px);
  transition: max-height .24s var(--ease), opacity .16s linear, margin-bottom .22s linear, transform .24s var(--ease);
}
.options[data-open="true"] { max-height: calc(56vh / var(--ui-zoom, 1)); max-height: calc(56dvh / var(--ui-zoom, 1)); opacity: 1; margin-bottom: 8px; transform: translateY(0); }

.options-inner {
  display: flex;
  flex-direction: column;
  max-height: calc(56vh / var(--ui-zoom, 1));
  max-height: calc(56dvh / var(--ui-zoom, 1));
  position: relative;
  padding: 24px 12px 10px;
  border: 1px solid var(--sheet-line, var(--accent-line));
  border-top: 2px solid var(--sheet-edge, var(--accent));
  border-radius: 18px;
  background-color: color-mix(in srgb, var(--panel) 94%, var(--lift) 6%);
  background-image: var(--sheet-corners), var(--glass);
  box-shadow: var(--sheet-shadow), inset 0 1px 0 var(--edge);
  touch-action: pan-y;
}
/* The glass sheet (options sheet and every dialog): the accent edge's highlight carries into
   the two top corners as soft glows, a 40 by 4 px handle sits at the top (a 80 by 44 px
   button, closes the sheet), and a Close pill with a chevron sits at the right of the head. */
.options-inner, dialog.sheet {
  --sheet-corners: radial-gradient(circle at 0 0, color-mix(in srgb, var(--sheet-edge, var(--accent)) 30%, transparent), transparent 38px), radial-gradient(circle at 100% 0, color-mix(in srgb, var(--sheet-edge, var(--accent)) 30%, transparent), transparent 38px);
}
.sheet-grab { position: absolute; z-index: 2; top: 0; left: 50%; width: 80px; height: 44px; margin-left: -40px; display: flex; align-items: flex-start; justify-content: center; }
.sheet-grab:focus { outline: none; }
.sheet-grab i { display: block; width: 40px; height: 4px; margin-top: 8px; border-radius: 2px; background-color: var(--muted); opacity: .8; }
.close-pill { position: relative; isolation: isolate; flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 14px; font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.close-pill::before { content: ''; position: absolute; z-index: -1; inset: 5px 0; border: 1px solid var(--line); border-radius: 17px; background-color: var(--bg); }
.close-pill svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.panel-head .close-pill { margin-left: auto; margin-right: 0; }
.sheet-head .close-pill { margin-right: 0; }
/* The chat dims while any sheet or dialog is open (app.js sets data-sheet on the page). */
#conversation { transition: filter .22s linear; }
html[data-sheet="true"] #conversation { filter: brightness(.62); }
.panel-head { display: flex; align-items: center; justify-content: flex-start; gap: 8px; flex: none; }
.panel-title { font-size: 14px; font-weight: 600; color: var(--ink); }
/* The AI pane is gold (PTAI): its title, edge, tab underline, labels, examples and hint. */
/* G4: gold in the AI pane for four things only: the word AI (title), the outline of chosen boxes, the play arrows and the menu outline. Everything else keeps the normal colours. */
.options[data-pane="ai"] { --sheet-edge: var(--note); --sheet-line: color-mix(in srgb, var(--note) 45%, var(--line)); }
.options[data-pane="ai"] .panel-title { color: var(--note); }
#paneAi .modes .well-btn[aria-pressed="true"] { border-color: var(--note); box-shadow: inset 0 0 0 1px var(--note); }
#paneAi .example::before { border-left-color: var(--note); }
.inline-play { display: inline-block; width: 11px; height: 14px; vertical-align: -2px; fill: var(--accent); }
#paneAi .examples { display: flex; flex: none; max-height: none; overflow: visible; }
#paneAi .example { display: flex; height: auto; max-height: none; overflow: visible; white-space: normal; }
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -12px;
  padding: 0 12px 2px;
  scrollbar-width: none;
}
.sheet-body::-webkit-scrollbar { display: none; }

.icon-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex: none; }
.icon-btn svg { width: 18px; height: 18px; stroke: var(--ink); stroke-width: 1.8; }

.label {
  display: block;
  font-size: calc(var(--menu-label, 13.5px) - 2px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 0 4px;
}

.hint { margin: 5px 0 0; font-size: 11px; line-height: 1.4; color: var(--muted); }
.hint.first { margin: 0 0 8px; }
.hint.tight { margin: 0 0 4px; }

/* The AI pane's examples: round rows with a small play mark, sent as PTAI requests. */
.examples { display: flex; flex-direction: column; gap: 5px; margin-top: 5px; }
.example {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  margin: 0;
  text-align: left;
  padding: 6px 12px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink);
  border: 1px solid var(--row-line);
  border-radius: 20px;
  background-color: var(--row);
}
.example::before {
  content: '';
  flex: none;
  width: 0;
  height: 0;
  border-left: 7px solid var(--accent);
  border-top: 4.5px solid transparent;
  border-bottom: 4.5px solid transparent;
}

/* Segmented controls: a fully round 16px track with a sliding 14px thumb in the accent. */
.seg {
  --n: 2;
  --seg-index: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  height: 36px;
  padding: 2px;
  border: 1px solid var(--row-line);
  border-radius: 16px;
  background-color: var(--row);
}
.seg[data-count="2"] { --n: 2; }
.seg[data-count="3"] { --n: 3; }
.seg[data-count="4"] { --n: 4; }
.seg-thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / var(--n));
  border-radius: 14px;
  background-color: transparent;
  border: 1px solid var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  transform: translateX(calc(var(--seg-index) * 100%));
  transition: transform .18s var(--ease);
  pointer-events: none;
}
.seg-opt {
  position: relative;
  min-width: 0;
  padding: 0 4px;
  font-size: var(--menu-label, 13.5px);
  color: var(--muted);
  white-space: nowrap;
  transition: color .18s linear;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg-opt[aria-pressed="true"] { color: var(--accent); font-weight: 600; }
/* The Speed segment: each option is the speed's name over its rate, two short lines. */
.seg-speed { height: auto; min-height: 50px; }
.seg-speed .seg-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 4px;
  white-space: normal;
  line-height: 1.15;
}
.seg-speed .seg-name { font-size: var(--menu-font, 14px); }
.seg-speed .seg-opt[aria-disabled="true"] { opacity: .45; }
.ultra-line { margin-top: 8px; }
.about-speed { margin: 0 0 6px; font-size: 13px; color: var(--muted); }

/* Rows and buttons inside the panes */
.well-btn {
  min-height: 40px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--ink);
  border: 1px solid var(--row-line);
  border-radius: 12px;
  background-color: var(--row);
}
.well-btn.row { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; }
.well-btn.row svg { width: 18px; height: 18px; flex: none; }
.well-btn.row.wallet-row { height: auto; min-height: 44px; padding-top: 6px; padding-bottom: 6px; }
.wallet-row .wallet-label { flex: none; }
.wallet-id { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10.5px; line-height: 1.35; color: var(--muted); text-align: right; overflow-wrap: anywhere; word-break: break-all; }
.well-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.accent-btn {
  height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 650;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background-color: var(--accent-soft);
}
.accent-btn.solid { padding: 0 14px; color: var(--on-accent); background-color: var(--accent); border-color: var(--accent); }
.accent-btn.solid svg { width: 16px; height: 16px; stroke: var(--on-accent); stroke-width: 2.2; }

.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.modes .wide { grid-column: 1 / -1; }

.block { display: block; }

/* Text size in the Words pane: A, the slider, a larger A, and the percentage. */
.scale { display: flex; align-items: center; gap: 10px; height: 40px; margin: 0 4px; }
.scale input { flex: 1; min-width: 40px; width: 100%; height: 36px; }
.scale-a { flex: none; line-height: 1; color: var(--muted); }
.scale-a.small { font-size: 11px; }
.scale-a.big { font-size: 18px; }
.scale-label { flex: none; min-width: 38px; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wide-range { display: block; width: 100%; height: 38px; }

/* More: one column of labelled controls, then rounded rows. */
.more-grid { display: flex; flex-direction: column; gap: 0; }
.more-grid > .well-btn.row { margin-top: 6px; }
.more-grid > .well-btn.row:first-of-type { margin-top: 12px; }
.more-grid > .accent-btn { margin-top: 10px; }

.swatches { display: flex; align-items: center; gap: 10px; height: 36px; }
.swatch { position: relative; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 999px; }
.swatch[aria-pressed="true"] .chip { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch .chip { display: block; width: 28px; height: 28px; border-radius: 50%; transition: outline-color .18s linear; }
.swatch[data-accent="green"] .chip { background-color: var(--sw-green); }
.swatch[data-accent="blue"] .chip { background-color: var(--sw-blue); }
.swatch[data-accent="purple"] .chip { background-color: var(--sw-purple); }
.swatch[data-accent="red"] .chip { background-color: var(--sw-red); }
.swatch .lock { position: absolute; left: 50%; top: 50%; width: 13px; height: 13px; transform: translate(-50%, -50%); stroke: var(--ink); stroke-width: 2; }
.well-btn .lock { width: 13px; height: 13px; margin-left: auto; stroke: var(--muted); }

/* Pro-only controls: dimmed with a padlock until Pro */

.version { text-align: center; font-size: 10px; color: var(--muted); padding: 10px 0 0; margin: 0; }
.links { display: flex; justify-content: center; gap: 4px; }
.link-btn { height: 40px; padding: 0 10px; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

/* The voice list (rows rendered by app.js) */
.voice-section { margin-top: 2px; }
.voice-list { display: flex; flex-direction: column; gap: 5px; }
.voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
  font-size: 13px;
  color: var(--ink);
  border: 1px solid var(--row-line);
  border-radius: 12px;
  background-color: var(--row);
  transition: border-color .18s linear, color .18s linear;
}
.voice-row[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.voice-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Milestone 5d P1: each row is a voice-item, the row (selects) with the round Play button
   (plays the sample) laid over its right end; a note, when the table knows the voice,
   follows the number. */
.voice-item { position: relative; }
.voice-item .voice-row { padding-right: 46px; }
.voice-label:has(+ .voice-note:not([hidden])) { flex: 0 0 auto; }
.voice-note { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.voice-play {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--row-line);
  background-color: var(--row);
  line-height: 0;
}
.voice-play .glyph {
  display: inline-block;
  width: 10px;
  height: 12px;
  margin-left: 2px;
  background-color: var(--accent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.voice-play:active { border-color: var(--accent); }
.voice-online { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.voice-online:empty { display: none; }
.voice-lock { display: inline-flex; width: 14px; height: 14px; flex: none; }
.voice-lock svg { width: 14px; height: 14px; stroke: var(--muted); stroke-width: 2; }

/* Saved: the search row with the enter symbol, the chats or the padlock row, Pro+ coming soon. */
#paneSaved .hist-tools { margin: 10px 0 6px; }
#paneSaved #historySearch { height: 36px; padding: 0 14px; font-size: 16px; border-color: var(--row-line); background-color: var(--row); }
#paneSaved #historySearch::placeholder { font-size: 12px; color: var(--muted); }
.round-btn.enter { width: 36px; height: 36px; font-size: 15px; line-height: 1; color: var(--ink); border: 1px solid var(--row-line); background-color: var(--row); }
#paneSaved .hist-list { overflow: visible; }
#paneSaved .export-all { width: 100%; margin-top: 2px; }
.saved-soon-block { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--row-line); border-radius: 12px; background-color: var(--row); }
.saved-tag { margin: 0 0 6px; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--note); }

/* ===== 10. The status word and the bar ===== */
/* One word above the bar. The bar is #listenToggle, 48px and fully round: Play and Stop in
   its middle, 13 dots to each side that become the live level bars while listening
   (--level 0..1 from app.js). The gate beat runs as a 2px line inside its curve. */

.status {
  display: block;
  margin: 0 0 6px;
  /* The bar sits right of the + button (44px and the 8px gap), so the word is centred over the bar,
     which is where Play and Stop are, not over the whole dock (D8). Both scale with Size. */
  padding: 0 0 0 calc(44px + 8px);
  text-align: center;
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  transition: color .18s linear;
}
html[data-gate="speak"] .status, html[data-gate="read"] .status { color: var(--accent); }
/* Mic on: the status word bold, 14 px, in the accent. */
html[data-live="true"] .status { font-size: 14px; font-weight: 700; color: var(--accent); }

.dock-top { display: flex; align-items: center; gap: 8px; }
.dock-top .round-btn.new { width: 44px; height: 44px; }
.dock-top .round-btn.new::before { width: 44px; height: 44px; }
.dock-top .round-btn.new svg { width: 20px; height: 20px; }
.waveform { position: relative; flex: 1; min-width: 0; }
/* Play and Stop in the middle of the bar; the dots run out to both ends. */
.mid { flex: none; display: flex; align-items: center; gap: 6px; padding: 0 6px; }
.mid-btn { margin: 0; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--on-accent); background-color: var(--accent); transition: opacity .18s linear; }
.mid-btn svg { width: 18px; height: 18px; }
.mid-btn:active { opacity: .82; }
html[data-live="true"] .mid-btn.play, html[data-live="false"] .mid-btn.stop { opacity: .38; }

.listen {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background-color: var(--panel);
  background-image: var(--glass);
  box-shadow: inset 0 1px 0 var(--edge);
  transition: border-color .18s linear;
  isolation: isolate;
}
html[data-live="true"] .listen { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), inset 0 1px 0 var(--edge); }
/* While the mic is open (data-live is true only while listening and not paused) a light,
   glassy accent layer fills the whole bar under the dots and the buttons and pulses between
   about 14% and 38% over 2 s (polish order P6). It sits below the content (z-index -1 in the
   bar's own stacking context), so the dots and Play and Stop keep their contrast. */
.listen::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--accent);
  background-image: var(--glass);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s linear;
}
html[data-live="true"] .listen::before { opacity: .24; animation: listen-pulse 2s ease-in-out infinite; }
@keyframes listen-pulse { 0%, 100% { opacity: .14; } 50% { opacity: .38; } }

.bars {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 40px;
  pointer-events: none;
}
.bars i {
  display: block;
  flex: none;
  width: 2.5px;
  height: calc(3px + 34px * var(--level, 0));
  border-radius: 2px;
  background-color: var(--accent);
  transition: height .12s linear;
}

/* The gate beat: app.js sets --beat-ms, then the width from 100% to 0%. */
.beat-track { position: absolute; left: 24px; right: 24px; bottom: 3px; height: 2px; pointer-events: none; }
.beat {
  position: absolute;
  left: 0;
  top: 0;
  height: 2px;
  border-radius: 1px;
  width: var(--beat-width, 0%);
  background-color: var(--accent);
  transition: width var(--beat-ms, 0ms) linear;
}

/* ===== 11. The field and the tabs ===== */

.dock-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
/* The field grows with its text up to half the screen (D6); Translate stays at the bottom right and the
   expand button, once the text runs past two lines, at the top right. */
.field { flex: 1; min-width: 0; min-height: 44px; display: grid; grid-template-columns: minmax(0, 1fr) 48px; grid-template-rows: auto 42px; align-items: start; border: 1px solid var(--line); border-radius: 22px; background-color: var(--panel); }
.field:focus-within { border-color: var(--accent); }
#typeField {
  grid-column: 1;
  grid-row: 1 / 3;
  min-width: 0;
  display: block;
  box-sizing: border-box;
  height: 42px;
  max-height: calc(50vh / var(--ui-zoom, 1));
  max-height: calc(50dvh / var(--ui-zoom, 1));
  margin: 0;
  padding: 9px 4px 9px 16px;
  font-size: 16px; /* 16px keeps iOS from zooming the page on focus */
  line-height: 24px;
  color: var(--ink);
  border: 0;
  outline: 0;
  resize: none;
  overflow-y: auto;
  background: transparent;
}
#typeField::placeholder { color: var(--muted); font-size: 14px; }
.expand-btn { grid-column: 2; grid-row: 1; justify-self: center; width: 44px; height: 44px; margin: -1px 0 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.expand-btn svg { width: 20px; height: 20px; }
.expand-btn .ex-close, html[data-editor="open"] .expand-btn .ex-open { display: none; }
html[data-editor="open"] .expand-btn .ex-close { display: inline; }
.expand-btn:active { opacity: .7; }
.field-line { grid-column: 2; grid-row: 2; justify-self: start; align-self: center; width: 1px; height: 24px; background-color: var(--line); }
.send-btn { grid-column: 2; grid-row: 2; align-self: center; width: 48px; height: 44px; margin: -1px 0; display: flex; align-items: center; justify-content: center; }
.send-btn svg { width: 21px; height: 21px; fill: none; stroke: #348dff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cam-pill { flex: none; display: flex; align-items: center; height: 44px; align-self: flex-end; border: 1px solid var(--line); border-radius: 22px; color: var(--ink); }
.cam-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--ink); }
.cam-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cam-line { flex: none; width: 1px; height: 24px; background-color: var(--line); }
.cam-btn:active, .send-btn:active { opacity: .7; }

/* The full-height editor (D6): the same field, lifted over the screen, so the text, the caret and the
   focus stay where they are. Close sits top right and Translate bottom right; Enter adds a new line. */
html[data-editor="open"] .field {
  position: fixed;
  z-index: 60;
  top: calc(var(--sa-top) + 8px);
  right: calc(8px + var(--sa-right));
  bottom: calc(8px + var(--dock-inset-z));
  left: calc(8px + var(--sa-left));
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 44px;
  border-radius: 18px;
  border-color: var(--accent);
  box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bg) 70%, transparent);
}
html[data-editor="open"] #typeField { grid-column: 1; grid-row: 1 / 4; height: 100%; max-height: none; padding-top: 10px; padding-bottom: 10px; }
html[data-editor="open"] .expand-btn { margin: 0; }
html[data-editor="open"] .field-line { display: none; }
html[data-editor="open"] .send-btn { grid-row: 3; align-self: end; margin: 0; }

.round-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.round-btn svg { width: 18px; height: 18px; stroke-width: 2.2; }
/* First update: Find and Translate drawn as outlines at the size of Play and Stop (34px),
   so they no longer outweigh them; the + for a new chat is filled like Play. The buttons keep
   a 40px box, so the tap area does not shrink. */
.round-btn.new::before { content: ''; position: absolute; width: 34px; height: 34px; border-radius: 50%; }
.round-btn.new { position: relative; }
.round-btn.new::before { background-color: var(--accent); }
.round-btn.new svg { position: relative; width: 16px; height: 16px; stroke-width: 2.2; }
.round-btn.new svg { stroke: var(--on-accent); stroke-width: 2.6; }
.round-btn:active { opacity: .82; }

.tabs { display: flex; justify-content: space-between; padding: 2px 6px 0; }
/* Size (More, 1.1 A6): the setting keeps its stored name, menu, and now sets --ui-zoom, which
   scales the whole interface (the app, the banner strip and the sheets): Small 0.9, Medium 1,
   Large 1.15. The menu words keep one size of their own so they are not scaled twice. */
/* One step up from the first build now that the grey lines are tooltips (polish order P2). */
html { --menu-font: 14px; --menu-label: 13.5px; }
html[data-menu="small"] { --ui-zoom: 0.9; }
html[data-menu="large"] { --ui-zoom: 1.15; }
.tab {
  min-width: 0;
  height: 34px;
  padding: 8px 4px 2px;
  font-size: var(--menu-font, 14px);
  font-weight: 400;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color .18s linear, border-color .18s linear;
}
.tab[aria-pressed="true"] { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }

/* ===== 12. The banner strip ===== */

.ad-strip {
  /* Not zoomed: the native banner it reserves room for is a fixed 50 dp (Ads.kt). */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding-top: 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background-color: var(--bg);
  pointer-events: none;
}
.ad-slot {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  background-color: var(--well);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  pointer-events: auto;
}
.ad-badge { padding: 1px 5px; font-size: 9px; letter-spacing: 0.1em; border: 1px solid var(--line); border-radius: 9px; }
html[data-typing="true"] .ad-strip { display: none; }

/* ===== 12b. The web version (a plain browser, app.js sets data-web): no ads, no packs, no camera, no Basic ===== */
html[data-web="true"] { --strip-h: 0px; }
html[data-web="true"] .ad-strip,
html[data-web="true"] .cam-pill,
html[data-web="true"] .packs,
html[data-web="true"] .restore,
html[data-web="true"] #neverLine { display: none; }
.web-packs { display: none; margin: 4px 0 0; padding: 14px 16px; border-radius: 12px; background-color: var(--well); color: var(--ink); font-size: 14px; line-height: 1.4; text-align: center; }
html[data-web="true"] .web-packs { display: block; }
html[data-web="true"] .seg-opt:disabled { opacity: 1; color: var(--muted); background-color: var(--panel); border: 1px dashed var(--line); cursor: default; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
html[data-web="true"] .seg-opt:disabled::after { content: attr(data-note); font-size: 11px; line-height: 1.1; color: var(--muted); }
.web-note { flex: none; display: flex; align-items: center; gap: 10px; margin: 0 12px 6px; padding: 6px 6px 6px 14px; border-radius: 12px; background-color: var(--well); border: 1px solid var(--line); color: var(--ink); font-size: 13px; line-height: 1.35; }
.web-note[hidden] { display: none; }
.web-note > span { flex: 1; }

/* ===== 13. Toast ===== */
/* #toast carries popover="manual": app.js may call showPopover() so the toast sits above
   an open sheet; data-show drives its visibility either way. */

#toast {
  position: fixed;
  inset: calc(54px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) auto calc(10px + env(safe-area-inset-left, 0px));
  display: block;
  width: auto;
  height: auto;
  margin: 0;
  z-index: 30;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  background-color: var(--sheet);
  background-image: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s linear, transform .2s var(--ease);
}
#toast[data-show="true"] { opacity: 1; transform: translateY(0); }
#toast[data-show="true"][data-action="true"] { pointer-events: auto; }
#toast .toast-action {
  display: block;
  min-height: 44px;
  min-width: 44px;
  margin-top: 6px;
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
}

/* ===== 13a. The tooltip (polish order P2, opened by a tap) ===== */
/* One #tip for every info button: a tap opens it above the button (below it when there is
   no room), kept 8px inside the screen; ui.js sets left and top. */
.tip {
  position: fixed;
  left: 8px;
  top: 8px;
  z-index: 35;
  max-width: min(300px, calc(100vw - 16px));
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
  color: var(--ink);
  border: 1px solid var(--accent-line);
  border-radius: 14px;
  background-color: var(--sheet);
  background-image: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 var(--edge), 0 6px 18px rgba(0,0,0,0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s linear;
}
.tip[data-open="true"] { opacity: 1; }
/* The info button after a label: the glyph "i" in a 16px circle with an accent outline, in
   the label's colour; ::after widens the hit area to 32 by 32px without moving the label.
   The row flows as text, so a label that wraps keeps its button right after its last word;
   the row takes the label's size so its line is as tall as the label's was. */
.label-row { display: block; margin: 10px 0 4px; font-size: calc(var(--menu-label, 13.5px) - 2px); }
.label-row > .label { display: inline; margin: 0; }
.label-row > .tip-btn { margin-left: 6px; vertical-align: baseline; }
.tip-btn {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tip-btn::after { content: ''; position: absolute; top: -8px; right: -8px; bottom: -8px; left: -8px; }
.tip-btn[aria-expanded="true"] { color: var(--accent); background-color: var(--accent-soft); }
.panel-head .tip-btn { color: var(--ink); }

/* ===== 14. The sheets (native dialogs) ===== */
/* Bottom-anchored, full width, stopping above the banner strip so the banner is never
   covered. The scrim (::backdrop) stops at the same line. */

dialog.sheet {
  zoom: var(--ui-zoom, 1);
  position: fixed;
  inset: auto 0 var(--strip-z) 0;
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh / var(--ui-zoom, 1) - var(--sa-top) - var(--strip-z) - 12px);
  margin: 0;
  padding: 24px calc(10px + var(--sa-right)) 10px calc(10px + var(--sa-left));
  color: var(--ink);
  border: 1px solid var(--accent-line);
  border-bottom: 0;
  border-top: 2px solid var(--accent);
  border-radius: 18px 18px 0 0;
  background-color: color-mix(in srgb, var(--panel) 94%, var(--lift) 6%);
  background-image: var(--sheet-corners), var(--glass);
  box-shadow: var(--sheet-shadow), inset 0 1px 0 var(--edge);
  overflow-y: auto;
  transform: translateY(calc(104% + 54px));
  transition: transform .26s var(--ease), overlay .26s allow-discrete, display .26s allow-discrete;
}
dialog.sheet[open] { display: flex; flex-direction: column; transform: translateY(0); }
@starting-style {
  dialog.sheet[open] { transform: translateY(calc(104% + 54px)); }
}
html[data-typing="true"] dialog.sheet { padding-bottom: calc(10px + var(--sa-bottom)); }

dialog.sheet.sheet-minutes { height: 600px; }

/* Custom properties are not inherited by ::backdrop in older WebViews, so the scrim's
   colour and bottom edge are written out per state. */
dialog.sheet::backdrop {
  inset: 0 0 calc(54px + env(safe-area-inset-bottom, 0px)) 0;
  background-color: rgba(3,8,14,0.62);
  opacity: 1;
  transition: opacity .22s linear, overlay .26s allow-discrete, display .26s allow-discrete;
}
@starting-style {
  dialog.sheet[open]::backdrop { opacity: 0; }
}
html[data-appearance="light"] dialog.sheet::backdrop { background-color: var(--scrim); }
html[data-typing="true"] dialog.sheet::backdrop { inset: 0; }

.sheet-head { display: flex; align-items: center; justify-content: space-between; flex: none; min-height: 44px; }
.sheet-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.sheet-head .icon-btn { margin-right: -8px; }
.sheet-hint { margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: var(--muted); flex: none; }
.grow { flex: 1; min-height: 0; }

/* Minutes */
.min-big { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; flex: none; }
#minutesBig { font-size: 64px; line-height: 1; font-weight: 300; letter-spacing: -2px; font-variant-numeric: tabular-nums; color: var(--ink); }
#minutesLeftLabel { font-size: 16px; color: var(--muted); }
.meter { position: relative; height: 4px; margin: 12px 0 10px; border-radius: 2px; overflow: hidden; background-color: var(--line); flex: none; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--meter, 0%); background-color: var(--accent); transition: width .26s var(--ease); }
.min-explain { margin: 0 0 10px; font-size: 15px; line-height: 1.45; color: var(--ink); flex: none; }


.packs { display: flex; flex-direction: column; gap: 6px; flex: none; }
.pack {
  height: 56px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.pack-name { font-size: 18px; }
.pack-price { font-size: 20px; font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; }
.never { margin: 10px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); flex: none; }
.restore { flex: none; height: 44px; font-size: 15px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

/* Free, Pro and Pro+ compared: compact rows that read at 390px; the sheet scrolls. */
/* Each row of the table is a rounded row on the well surface. */

/* Saved: the Pro+ list, coming soon (in the Saved pane) */
.saved-list { margin: 0 0 8px; padding-left: 18px; font-size: 13px; line-height: 1.45; color: var(--ink); }
.saved-list li { margin-bottom: 4px; }
.saved-note { margin: 0 0 6px; font-size: 12px; color: var(--muted); }

/* The saved chats (in the Saved pane) and the key field */
.hist-tools { display: flex; gap: 6px; flex: none; margin-bottom: 8px; }
#historySearch {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 8px 10px;
  font-size: 16px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: var(--well);
}
.hist-list { flex: 1; min-height: 0; overflow-y: auto; }
.hist-row { margin: 0 0 6px; border: 1px solid var(--row-line); border-radius: 12px; }
.hist-row[aria-current="true"] { border-color: var(--accent); }
.hist-main { display: flex; align-items: stretch; }
.hist-open { flex: 1; min-width: 0; min-height: 54px; padding: 8px 10px; text-align: left; color: var(--ink); }
.hist-title { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.hist-main .icon-btn { height: auto; min-height: 44px; }
.hist-main .icon-btn svg { width: 19px; height: 19px; stroke: var(--accent); }
.hist-main .icon-btn svg.muted-ico { stroke: var(--muted); }
.hist-recap-box { padding: 0 10px 10px; }
.hist-recap-label { display: block; font-size: 10px; letter-spacing: 0.12em; color: var(--accent); margin-bottom: 3px; }
.hist-recap-text { display: block; font-size: 13px; line-height: 1.45; color: var(--ink); }
.export-all { flex: none; margin-top: 8px; font-size: 13px; }

/* Offline models, About, Confirm */
.models-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.model-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 0 0 10px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--well);
}
.model-name { flex: 1; min-width: 0; }
.model-size { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.model-row button { height: 44px; padding: 0 12px; font-size: 12px; color: var(--accent); }
.about-text, .confirm-text { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }
.about-text { color: var(--ink); }
.confirm-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.confirm-row .well-btn { border-radius: 999px; }

/* ===== 15. Reduced motion ===== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, dialog.sheet::backdrop {
    transition-duration: 0s !important;
    animation: none !important;
  }
  .card { transform: none; }
  /* The bar's tint stays still at 24%. */
  html[data-live="true"] .listen::before { animation: none; opacity: .24; }
}

/* ===== First update: Saved as two cards, Pro then Pro+ (names in the PTAI gold) ===== */

/* ===== First update: each language in its own script, its name in the app language beneath ===== */
.lang-option.two { height: 44px; display: flex; flex-direction: column; justify-content: center; line-height: 1.15; }
.lang-option .lo-native { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.lang-option .lo-sub { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* =====================================================================
   The camera screen: Photo (1.1 order B4, B6, B7). Written for camera.js.
   Full screen, outside the dock. While the camera is on, html.camera-on makes html, body
   and the viewfinder hole transparent so the native preview shows through; the rest of
   the screen is painted by a box-shadow around the viewfinder, so the hole is a real hole.
   ===================================================================== */

html.camera-on,
html.camera-on body { background: transparent; }
/* The chat, the dock and the banner strip never draw inside the viewfinder (review 1 and 5). */
html.cam-open .app,
html.cam-open .ad-strip { visibility: hidden; }

.cam-screen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  color: var(--ink);
  background: transparent;
}
.cam-screen[hidden] { display: none; }
.cam-top, .cam-bottom { position: relative; z-index: 1; flex: none; }

.cam-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px 10px; }
.cam-close {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background-color: var(--panel);
}
.cam-close svg { width: 18px; height: 18px; stroke: var(--ink); stroke-width: 2.2; }
.cam-pair {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background-color: transparent; color: var(--ink);
  font-size: 15px; font-weight: 600; text-align: center;
}
.cam-pair span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cam-view {
  position: relative; z-index: 0; flex: 1; min-height: 0; margin: 0 10px;
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 0 0 100vmax var(--bg);
  background-color: var(--well);
}
html.camera-on .cam-view { background-color: transparent; }
.cam-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background-color: #000; }
.cam-img[hidden], .cam-off[hidden], .cam-reason[hidden], .cam-busy[hidden], .cam-actions[hidden], .cam-tip[hidden] { display: none; }
.cam-plates { position: absolute; inset: 0; pointer-events: none; }
.cam-plates[hidden] { display: none; }

/* A plate: dark, an accent left edge, text fitted to the box. It sits over a photo, so it is dark in both appearances. */
.plate {
  --plate-bg: rgba(22, 30, 40, 0.94);
  --plate-ink: #ffffff;
  position: absolute; display: flex; align-items: center; box-sizing: border-box;
  padding: 0 6px 0 8px; overflow: hidden;
  border-left: 3px solid var(--accent); border-radius: 9px;
  color: var(--plate-ink); background-color: var(--plate-bg);
  font-weight: 600; line-height: 1.2; transform-origin: 50% 50%;
}
.plate[hidden] { display: none; }
.plate-text { display: block; width: 100%; overflow: hidden; overflow-wrap: anywhere; }

.cam-off, .cam-reason {
  position: absolute; left: 0; right: 0; margin: 0; padding: 0 28px; text-align: center;
  font-size: 14px; line-height: 1.4; color: var(--muted);
}
.cam-off { inset: 0; display: grid; place-items: center; background-color: var(--well); }
.cam-off p { margin: 0; }
.cam-reason { bottom: 18px; }
.cam-busy {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  font-size: 13px; color: #fff; background-color: rgba(10, 14, 20, 0.78);
}
.cam-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: var(--accent); animation: cam-spin .8s linear infinite; }
@keyframes cam-spin { to { transform: rotate(360deg); } }
.cam-view[data-busy="true"] .cam-img { filter: brightness(.8); }

.cam-bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 12px 12px; }
.cam-shoot { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 72px; }
.cam-shoot[hidden] { display: none; }
.cam-shutter {
  width: 66px; height: 66px; display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 4px solid var(--ink); background-color: transparent;
}
.cam-shutter span { width: 48px; height: 48px; border-radius: 50%; background-color: var(--ink); }
.cam-shutter:active span { transform: scale(.92); }
.cam-gallery {
  width: 44px; height: 48px; display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background-color: var(--panel);
}
.cam-gallery svg { width: 22px; height: 22px; stroke: var(--ink); stroke-width: 1.8; }

.cam-actions { display: flex; gap: 8px; width: 100%; }
.cam-act {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background-color: transparent; color: var(--ink);
  font-size: 14px; font-weight: 600;
}
.cam-act.gold { color: var(--note); border-color: var(--note); }
.cam-act.solid { color: var(--on-accent); background-color: var(--accent); border-color: var(--accent); }
.cam-act[aria-pressed="true"] { border-color: var(--accent); }
.cam-act[disabled] { opacity: .45; }

.cam-speedrow { display: flex; align-items: center; justify-content: center; gap: 10px; }
.cam-speed { display: flex; padding: 3px; border-radius: 999px; border: 1px solid var(--line); background-color: var(--panel); }
.cam-speed-btn {
  min-width: 68px; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 0;
  font-size: 15px; font-weight: 600; color: var(--ink); background-color: transparent;
}
.cam-speed-btn[aria-pressed="true"] { color: var(--accent); background-color: transparent; border: 1px solid var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cam-speed-btn.locked { opacity: .6; }
.cam-tipbtn {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border-radius: 50%;
  border: 0; background-color: transparent;
}
.cam-tipbtn span {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--accent); color: var(--accent); font-style: italic; font-weight: 600; font-size: 15px;
}
.cam-tip {
  position: absolute; left: 12px; right: 12px; bottom: 84px; z-index: 2;
  margin: 0; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--accent-line);
  font-size: 15px; line-height: 1.45; color: var(--ink);
  background-color: color-mix(in srgb, var(--panel) 92%, var(--lift) 4%);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}
.cam-note { margin: 0; padding: 0 12px; text-align: center; font-size: 14px; line-height: 1.35; color: var(--muted); }
#photoScreen .cam-bottom { z-index: 3; }

/* The photo card in the chat (B7): a thumbnail and the title, each line as original over translation, the foot. It spans the width like a PTAI card, on the panel. */
.card.photo-card { width: 84%; margin-left: 8%; margin-right: 8%; background-color: var(--panel); }
.photo-head { display: flex; align-items: center; gap: 10px; margin-bottom: calc(6px * var(--scale)); }
.photo-thumb {
  flex: none; width: 34px; height: 44px; border-radius: 9px; overflow: hidden;
  border: 1px solid var(--line); background-color: var(--well);
}
.photo-thumb-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-thumb-img[hidden] { display: none; }
.photo-title { flex: 1; min-width: 0; font-size: calc(13px * var(--scale)); font-weight: 600; line-height: 1.3; color: var(--muted); }
.photo-row { padding: calc(3px * var(--scale)) 0; }
.photo-orig { font-size: calc(13px * var(--scale)); line-height: 1.3; color: var(--muted); }
.photo-trans { font-size: calc(16px * var(--scale)); line-height: 1.3; }
.photo-rows:empty { display: none; }
.photo-trans:empty { display: none; }

/* The two temporary buttons, until session A's dock buttons exist. */

/* The chat menu (1.1 E4): two full-width buttons, 44 px or more. */
.chat-menu-list { display: grid; gap: 8px; margin-top: 8px; }
.chat-menu-list .well-btn { min-height: 48px; border-radius: 999px; }
.current-chat { margin-bottom: 8px; }
.current-info { cursor: default; }
/* ===== Pro+ (1.1 order C, session E) ===== */
.star { position: relative; flex: none; width: 44px; height: 44px; margin: -9px 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.star svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.7; }
.star[aria-pressed="true"] svg { fill: var(--note); stroke: var(--note); }
.card.ptai .star { margin-right: 2px; }
.card.found { outline: 2px solid var(--accent); outline-offset: 2px; }
.saved-seg { margin: 0 0 10px; flex: none; }
.saved-seg { height: 52px; }
.saved-seg .seg-opt { display: flex; align-items: center; justify-content: center; gap: 4px; height: 100%; min-height: 44px; line-height: 1; }
.saved-seg .seg-thumb { background-color: transparent; border: 1px solid var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.saved-seg .seg-opt[aria-pressed="true"] { color: var(--accent); }
.saved-seg .seg-n { font-weight: 500; font-size: 12px; opacity: .85; }
.saved-seg .seg-n:empty { display: none; }
.saved-seg .seg-opt[data-locked="true"] { opacity: .7; }
.pin-list, .phrase-list { display: flex; flex-direction: column; gap: 8px; }
.pin { padding: 10px 12px; border: 1px solid var(--row-line); border-radius: 16px; background-color: var(--panel); }
.pin-head { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.pin-head .pin-star { flex: none; position: relative; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
.pin-head .pin-star::after { content: ''; position: absolute; inset: -8px; }
.pin-star svg { width: 22px; height: 22px; fill: var(--note); stroke: var(--note); stroke-width: 1.7; }
.pin-label { flex: 1; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; line-height: 1.3; font-variant-numeric: tabular-nums; }
#backupChoose, #backupNow, #backupRestore { min-height: 44px; }
.pin-more { min-width: 44px; font-size: 20px; color: var(--ink); }
.pin-find { flex: none; min-height: 44px; padding: 0 4px; font-size: 14px; font-weight: 600; color: var(--accent); }
.pin-src { margin-top: 2px; font-size: 18px; line-height: 1.3; color: var(--ink); }
.pin-dst { font-size: 15px; line-height: 1.35; color: var(--muted); }
.pin-note { margin-top: 8px; padding: 6px 10px; font-size: 14px; line-height: 1.35; color: var(--note); border: 1px solid var(--note); border-radius: 12px; background-color: color-mix(in srgb, var(--note) 10%, transparent); }
.pin-pair + .pin-pair { margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.chip-btn { min-height: 44px; padding: 0 16px; font-size: 15px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; background-color: transparent; }
.chip-btn[aria-pressed="true"] { color: var(--accent); background-color: transparent; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip-btn.add { color: var(--accent); border-style: dashed; }
.phrase { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 12px; border: 1px solid var(--row-line); border-radius: 16px; background-color: var(--panel); -webkit-user-select: none; user-select: none; }
/* F8: the same drawn size as the chat card's play mark (10 by 12 px at Medium), in a 44 px target. */
.phrase-play { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: none; }
.phrase-play svg { width: calc(10px * var(--scale, 1)); height: calc(12px * var(--scale, 1)); fill: var(--accent); stroke: none; }
.phrase-text { flex: 1; min-width: 0; }
.phrase-src { font-size: 18px; line-height: 1.25; color: var(--ink); }
.phrase-dst { font-size: 15px; line-height: 1.3; color: var(--muted); }
.phrase-cat { flex: none; max-width: 30%; font-size: 12px; letter-spacing: .04em; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.empty-line { padding: 14px 4px; font-size: 15px; color: var(--muted); }
mark.hit { color: inherit; background-color: color-mix(in srgb, var(--accent) 35%, transparent);  }
.hist-title-field { flex: 1; min-width: 0; height: 44px; padding: 0 10px; font-size: 15px; color: var(--ink); border: 1px solid var(--accent); border-radius: 12px; background-color: var(--well); }
.plus-dialog-body { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 12px; }
.plus-dialog-body input[type="text"] { height: 48px; padding: 0 14px; font-size: 16px; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; background-color: var(--well); }
.plus-menu-btn { min-height: 48px; padding: 0 16px; text-align: left; font-size: 16px; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; background-color: var(--well); }
.undo-btn { margin-left: 10px; padding: 0 6px; min-height: 44px; font-weight: 700; color: var(--accent); pointer-events: auto; }
.wheel-box, .backup-box { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.hue-wheel { position: relative; width: 112px; height: 112px; margin: 6px 22px; touch-action: none; }
.hue-wheel::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, hsl(0 80% 60%), hsl(60 80% 55%), hsl(120 70% 50%), hsl(180 80% 50%), hsl(240 80% 65%), hsl(300 80% 60%), hsl(360 80% 60%)); -webkit-mask: radial-gradient(circle, transparent 54%, #000 55%); mask: radial-gradient(circle, transparent 54%, #000 55%); }
.hue-wheel i { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 4px solid #fff; background-color: var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.wheel-box[data-locked="true"] .hue-wheel { opacity: .55; }
.backup-line { margin: 0; font-size: 14px; color: var(--muted); }
.backup-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.backup-box[data-locked="true"] { opacity: .75; }

/* F4: the Add to Phrasebook control in the card footer, beside the star. */
/* Each footer control is a full 44 px target of its own; the margins keep the foot 26 px tall. */
.book-add { position: relative; flex: none; width: 44px; height: 44px; margin: -9px 0; display: flex; align-items: center; justify-content: center; }
.book-add svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.book-add[data-locked="true"] { opacity: .7; }
/* F6: the Pro+ is on line. */
/* F7: four custom colour slots. */
.accent-saves { margin-top: 8px; }
.save-slot { width: 36px; height: 36px; position: relative; border-radius: 50%; border: 1.5px dashed var(--muted); color: var(--muted); font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; -webkit-user-select: none; user-select: none; }
.save-slot::after { content: ''; position: absolute; inset: -4px; }
.save-slot[data-filled="true"] { border: 2px solid var(--line); }
.save-slot[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.accent-saves[data-locked="true"] { opacity: .55; }
/* F11: the star before a saved chat's recap stays gold whatever the accent. */
.hist-main .hist-recap svg.sparkle { stroke: var(--note); fill: none; }

/* The PTAI card keeps its header to the mark, the question, the time and Flag; the book and star sit in the footer. */
.ptai-foot { display: flex; align-items: center; justify-content: flex-end; gap: 14px; min-height: 44px; margin-top: 2px; }

/* ===== Build 20: the picker holds 100 languages, so it has a filter and a quiet state label ===== */
.lang-search {
  position: sticky; top: -6px; z-index: 1;
  width: 100%; height: 44px; padding: 0 14px;
  font: inherit; font-size: 15px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  background-color: var(--sheet);
  -webkit-appearance: none; appearance: none;
}
.lang-search::placeholder { color: var(--muted); }
.lang-rows { display: grid; gap: 4px; }
.lang-none { padding: 12px 8px; font-size: 13px; color: var(--muted); }
.lang-option .lo-line { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; min-width: 0; }
.lang-option .lo-line .lo-sub { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.lang-option .lo-state { flex: none; font-size: 11px; color: var(--muted); letter-spacing: .01em; }
.lang-option .lo-state.offline { color: var(--accent); }
/* With 100 languages and a filter the picker is full width (it still opens under the pressed pill). */
.lang-picker[data-side="a"], .lang-picker[data-side="b"] { left: calc(10px + var(--sa-left)); right: calc(10px + var(--sa-right)); }
.lang-option .lo-line { align-items: center; }
/* The state label sits right-aligned on the name's line; the English name sits under the native one. */
.lang-option.two { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; align-content: center; column-gap: 8px; }
.lang-option.two .lo-native { grid-column: 1; grid-row: 1; }
.lang-option.two .lo-line { display: contents; }
.lang-option.two .lo-sub { grid-column: 1; grid-row: 2; }
.lang-option.two .lo-state { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right; white-space: nowrap; }
.lang-option .lo-native { white-space: nowrap; }
/* Minutes: one card (A3): what is free, what minutes buy, the three packs. */
.min-card { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background-color: var(--panel); }
.min-card p { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.min-card p strong { color: var(--ink); font-weight: 650; }
.min-card .tip-btn { margin-left: auto; }
