/* ==========================================================================
   Niloogram — "Tangerine" theme (alt skin for the hosted edition).
   Bright, candy, sticker-style: cream paper, polka-dot confetti, thick ink
   borders with hard offset shadows, hot-orange accents. Same markup and class
   names as styles-modern.css — swapped at runtime via the theme <link> tags.
   ========================================================================== */

:root {
  /* paper & panels */
  --paper: #fff2df;
  --panel: #ffffff;
  --panel-2: #fff7ec;

  /* ink — high contrast on cream/white */
  --ink: #241536;
  --text: #241536;
  --muted: #574a70;
  --muted-2: #7a6d97;

  /* hot-orange accents */
  --orange: #ff5a00;
  --orange-hot: #ff8324;
  --orange-deep: #d94800;
  --yellow: #ffc21f;
  --teal: #0f9e90;
  --purple: #7c4dff;
  --rec: #ff2d1a;

  --line: #241536;
  --hairline: 3px solid var(--line);
  --hairline-2: 2px solid var(--line);
  --sticker-shadow: 5px 6px 0 #241536;
  --sticker-shadow-sm: 3px 3px 0 #241536;
  --glow-orange: 0 0 34px rgba(255, 90, 0, 0.4);
  --glow-rec: 0 0 40px rgba(255, 45, 26, 0.5);

  /* geometry */
  --radius: 22px;
  --radius-sm: 15px;

  /* type stacks */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  /* flat color only — the dot pattern lives on the fixed .bg-decor layer,
     because background-attachment: fixed is broken on iOS Safari */
  background-color: var(--paper);
  min-height: 100vh;
}

.app {
  max-width: 620px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  position: relative;
}

/* ------------------------------------------------------------- backdrop -- */
.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  /* polka dots 🎉 — on a fixed layer so they don't scroll-jitter on iOS */
  background-image:
    radial-gradient(circle, rgba(255, 90, 0, 0.14) 5px, transparent 6px),
    radial-gradient(circle, rgba(15, 158, 144, 0.12) 3px, transparent 4px),
    radial-gradient(circle, rgba(255, 194, 31, 0.20) 6px, transparent 7px),
    radial-gradient(circle, rgba(124, 77, 255, 0.10) 3px, transparent 4px);
  background-size: 104px 104px, 76px 76px, 136px 136px, 60px 60px;
  background-position: 0 0, 38px 26px, 68px 84px, 14px 46px;
}

/* oversized confetti dots drifting gently down the page */
.scanline {
  position: absolute;
  inset: -30% -10%;
  background-image:
    radial-gradient(circle, rgba(255, 90, 0, 0.08) 24px, transparent 25px),
    radial-gradient(circle, rgba(255, 194, 31, 0.11) 16px, transparent 17px),
    radial-gradient(circle, rgba(15, 158, 144, 0.07) 28px, transparent 29px);
  background-size: 340px 340px, 260px 260px, 420px 420px;
  background-position: 40px 60px, 180px 220px, 90px 340px;
  animation: drift 46s linear infinite;
}
@keyframes drift {
  0%   { transform: translateY(0); }
  100% { transform: translateY(420px); }
}

.app > *:not(.bg-decor) {
  position: relative;
  z-index: 1;
}

/* --------------------------------------------------------------- header -- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 2px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rec-dot {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2.5px solid var(--line);
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.rec-dot.live {
  background: var(--rec);
  box-shadow: var(--glow-rec);
}

.wordmark {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
}

.mode-badge {
  flex-shrink: 0;
  font: 800 0.68rem/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
  border: var(--hairline-2);
  border-radius: 999px;
  padding: 6px 11px;
}

/* ------------------------------------------------------------- top nav --- */
nav {
  display: flex;
  gap: 3px;
  background: var(--panel);
  border: var(--hairline-2);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--sticker-shadow-sm);
}

nav button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 800 0.82rem/1 var(--font-ui);
  letter-spacing: 0.03em;
  text-transform: capitalize;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}
nav button.active { color: #fff; }
nav svg {
  width: 17px;
  height: 17px;
  position: relative;
  z-index: 1;
}

/* narrow phones: nav drops to its own row, tabs share the width */
@media (max-width: 540px) {
  nav { width: 100%; }
  nav button { flex: 1; }
}
.nav-pill {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(160deg, var(--orange-hot), var(--orange-deep));
  box-shadow: var(--glow-orange);
}
.nav-label { position: relative; z-index: 1; }

/* ---------------------------------------------------------------- panels - */
main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

.dictate .controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* format chips: one horizontally-scrollable row (no wrap pile-up) */
.mode-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  /* breathing room so sticker shadows aren't clipped */
  padding: 4px 0 8px;
  margin-bottom: 8px;
}

.chip {
  position: relative;
  flex-shrink: 0;
  border: var(--hairline-2);
  background: var(--panel);
  color: var(--ink);
  font: 800 0.88rem/1 var(--font-ui);
  letter-spacing: 0.01em;
  min-height: 44px;
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--sticker-shadow-sm);
  transition: color 0.25s var(--ease), transform 0.15s var(--ease);
}
.chip.active { color: #fff; }
.chip-glow {
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  background: linear-gradient(160deg, var(--orange-hot), var(--orange-deep));
  border: 2.5px solid var(--line);
  box-shadow: var(--glow-orange);
}
.chip-label { position: relative; z-index: 1; }

/* language picker (dictate screen) — chosen before recording. Hosted
   markup is <label class="lang-row"><span class="lang-label">…</span>
   <select>…</select></label>: an inline-flex sticker pill with the label
   tucked inside, so it reads as one piece with the format chips above. */
.lang-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  /* Give it breathing room from the chips row above (which carries its own
     bottom margin) and the mic stage below. */
  margin: 4px 0 18px;
  padding: 8px 14px 8px 16px;
  background: var(--panel);
  border: var(--hairline-2);
  border-radius: 999px;
  box-shadow: var(--sticker-shadow-sm);
  font: 800 0.82rem/1 var(--font-ui);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
}
.lang-label { flex-shrink: 0; }
.lang-row select {
  appearance: none;
  border: 2px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  color-scheme: light;
  /* 16px+ so iOS Safari doesn't zoom on focus */
  font: 700 1rem/1.2 var(--font-ui);
  min-height: 36px;
  padding: 8px 34px 8px 12px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23241536' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}
.lang-row select:hover { background: #ffedc4; }
.lang-row select:focus { border-color: var(--orange); }
.lang-row select:disabled { opacity: 0.5; cursor: not-allowed; }
.lang-row select option {
  color: var(--text);
  background: var(--panel);
}

/* the stage: fluid square that fits any phone, visualizer ring + mic */
.stage {
  position: relative;
  width: min(76vw, 300px);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}

.visualizer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* big candy-button mic — 44% of the stage, matching the visualizer's ring */
.mic {
  position: relative;
  width: 44%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 3.5px solid var(--line);
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.9), transparent 42%),
    radial-gradient(circle, rgba(255, 90, 0, 0.14) 3px, transparent 4px) 0 0 / 26px 26px,
    linear-gradient(165deg, #ffffff 0%, #fff0e4 60%, #ffe0cc 100%);
  color: var(--orange-deep);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow:
    6px 8px 0 #241536,
    var(--glow-orange);
  transition: color 0.3s var(--ease), box-shadow 0.35s var(--ease), transform 0.15s var(--ease);
}
.mic svg { width: 38%; height: 38%; }
.mic.recording {
  color: var(--rec);
  box-shadow:
    6px 8px 0 #241536,
    var(--glow-rec);
  animation: mic-pulse 1.4s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.mic:disabled { cursor: default; opacity: 0.85; }

/* "Upload a voice memo" — secondary sticker button under the mic stage */
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  border: var(--hairline-2);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.9rem;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--sticker-shadow-sm);
  transition: background 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.upload-btn svg { width: 17px; height: 17px; }
.upload-btn:hover { background: #ffedc4; }
.upload-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #241536;
}
.upload-btn:disabled { opacity: 0.6; cursor: default; }

/* history: Translate button carries a small inline icon */
.actions button.translate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.actions button.translate svg { width: 16px; height: 16px; flex: 0 0 auto; }
.actions button.translate:disabled { opacity: 0.7; cursor: default; }

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid rgba(255, 90, 0, 0.22);
  border-top-color: var(--orange);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* readouts */
.timer {
  font: 800 1.6rem/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  min-height: 1.6rem;
  margin: 6px 0 0;
  transition: color 0.3s var(--ease);
}
.timer.rec { color: var(--rec); }

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 4px 0 0;
  text-align: center;
}

.error {
  color: #c31a10;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  margin: 6px 0 0;
}

/* --------------------------------------------------------------- result -- */
.result {
  background: var(--panel);
  border: var(--hairline-2);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  box-shadow: var(--sticker-shadow);
}

/* card / note titles: dark, big, high-contrast */
.result h2 {
  margin: 0 0 10px;
  padding-bottom: 9px;
  border-bottom: 3px solid var(--orange);
  font-size: 1.18rem;
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow-wrap: break-word;
}

.result .clean {
  margin: 0 0 12px;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 1rem;
  color: var(--text);
  overflow-wrap: break-word;
}

.result details {
  margin: 0 0 12px;
  border-top: 2.5px dashed rgba(36, 21, 54, 0.22);
  padding-top: 10px;
}
.result summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 0;
}
.result .raw {
  color: var(--muted);
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 10px;
}
.actions button { flex: 1 1 auto; }

button {
  font-family: var(--font-ui);
}

/* bigger, clearer buttons with comfortable tap targets */
.actions button,
.settings button,
.account-row button,
.redo-toggle {
  border: var(--hairline-2);
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.95rem;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--sticker-shadow-sm);
  transition: background 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.actions button:hover,
.settings button:hover,
.redo-toggle:hover { background: #ffedc4; }
.actions button:active,
.settings button:active,
.redo-toggle:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #241536;
}

button.primary {
  background: linear-gradient(160deg, var(--orange-hot), var(--orange-deep));
  color: #fff;
  border: var(--hairline-2);
  box-shadow: var(--sticker-shadow-sm), var(--glow-orange);
}
button.primary:hover { background: linear-gradient(160deg, var(--orange), var(--orange-deep)); }
button.primary:disabled { opacity: 0.7; cursor: default; }

button.danger {
  color: #c31a10;
  border-color: var(--line);
}
button.danger:hover { background: #ffe6e2; }

.meta {
  color: var(--muted);
  font: 700 0.75rem/1.5 var(--font-mono);
  margin: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* --------------------------------------------------------- redo cleanup -- */
.redo {
  margin: 0 0 12px;
}
.redo-toggle {
  font-size: 0.9rem;
  background: #fff0e4;
  width: 100%;
}
.redo-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 2.5px dashed var(--purple);
  border-radius: var(--radius-sm);
  background:
    radial-gradient(circle, rgba(124, 77, 255, 0.08) 3px, transparent 4px) 0 0 / 24px 24px,
    #f8f5ff;
}
.redo-panel label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.redo-panel select {
  appearance: none;
  border: var(--hairline-2);
  background: var(--panel);
  color: var(--text);
  /* 16px minimum so iOS Safari doesn't zoom on focus */
  font: 700 1rem/1.4 var(--font-ui);
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23241536' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 38px;
}
.redo-panel select:focus { border-color: var(--purple); }
.redo-panel .error { text-align: left; }

/* -------------------------------------------------------------- history -- */
.history { gap: 16px; }
.history audio {
  width: 100%;
  height: 44px;
  margin: 6px 0 10px;
}

/* ------------------------------------------------------------- settings -- */
.settings { gap: 16px; padding-bottom: 8px; }

.settings h2 {
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 18px 0 0;
  border-top: 2.5px dashed rgba(36, 21, 54, 0.22);
  padding-top: 18px;
}

.settings label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ink);
}
.settings label.row {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 700;
}

.settings select,
.settings input[type="text"],
.settings input[type="password"],
.settings textarea {
  appearance: none;
  border: var(--hairline-2);
  background: var(--panel);
  color: var(--text);
  color-scheme: light;
  /* 16px minimum so iOS Safari doesn't zoom on focus */
  font: 700 1rem/1.4 var(--font-ui);
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  box-shadow: var(--sticker-shadow-sm);
  transition: border-color 0.2s var(--ease);
}
.settings textarea { min-height: unset; }
.settings select:focus,
.settings input:focus,
.settings textarea:focus { border-color: var(--orange); }

.settings select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23241536' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 38px;
}

.settings textarea { resize: vertical; }

.settings input[type="checkbox"] {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  min-height: unset;
  box-shadow: none;
  accent-color: var(--orange);
}

.save-flash { color: var(--teal); font-weight: 800; }

/* custom prompts */
.prompt-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--panel);
  border: var(--hairline-2);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  box-shadow: var(--sticker-shadow-sm);
}
.prompt-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.prompt-name { font-weight: 900; font-size: 0.95rem; color: var(--ink); }
.prompt-hint-text {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.prompt-row .danger {
  border: 0;
  background: transparent;
  box-shadow: none;
  min-height: 44px;
  min-width: 44px;
  padding: 4px 8px;
  font-size: 1.1rem;
  cursor: pointer;
}
.prompt-row-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.prompt-row-actions button {
  border: 0;
  background: transparent;
  box-shadow: none;
  min-height: 44px;
  min-width: 44px;
  padding: 4px 8px;
  font-size: 1.1rem;
  cursor: pointer;
}
.prompt-edit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.prompt-edit-actions {
  display: flex;
  gap: 10px;
}
.prompt-edit-actions .primary { flex: 1; }

.prompt-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* BYOK keys */
.key-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.key-name {
  width: 92px;
  flex-shrink: 0;
  font: 800 0.86rem/1.2 var(--font-mono);
  color: var(--ink);
}
.key-row input { flex: 1; min-width: 140px; }
.key-row button { min-height: 48px; padding: 10px 16px; }

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* boot shimmer while /api/me resolves */
.boot {
  margin: auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid rgba(255, 90, 0, 0.22);
  border-top-color: var(--orange);
  animation: spin 0.8s linear infinite;
}

/* ------------------------------------------------------- larger screens -- */
@media (min-width: 700px) {
  .wordmark { font-size: 1.45rem; }
  .actions button { flex: 0 1 auto; }
  .redo-toggle { width: auto; }
  .stage { width: min(44vh, 320px); }
}

/* wide screens: use the width — two-column dictate, history card grid */
@media (min-width: 960px) {
  .app {
    max-width: 1100px;
    padding-left: 28px;
    padding-right: 28px;
  }

  /* dictate: recorder on the left, transcript on the right */
  .dictate {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 40px;
    align-items: start;
    justify-content: center;
  }
  /* no transcript yet: keep the recorder centered, not stranded left */
  .dictate:not(:has(.result)) {
    grid-template-columns: 420px;
  }
  .dictate .controls {
    position: sticky;
    top: 24px;
  }
  /* history: two-column card grid */
  .history {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
  }
  .history > .hint,
  .history > .error { grid-column: 1 / -1; }

  /* settings: forms read best at a comfortable measure, centered */
  .settings {
    width: 100%;
    max-width: 660px;
    margin: 0 auto;
  }
}

/* ==========================================================================
   Hosted-edition extras (not in the reference repo's markup). The hosted
   App.tsx renders progress bars, status badges, a model picker, an upload
   row, a redo row, ghost buttons, and an error disclosure — all restyled
   here in the tangerine sticker idiom so this theme fully covers the app.
   ========================================================================== */

/* -------------------------------------------------------- progress bar ----- */
.progress { width: 100%; max-width: 320px; margin-top: 10px; }
.progress-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--panel-2);
  border: var(--hairline-2);
  box-shadow: var(--sticker-shadow-sm);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  position: absolute;
  inset: 0;
  width: 35%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange-deep), var(--yellow), var(--orange-deep));
  background-size: 200% 100%;
  animation: progress-slide 1.1s ease-in-out infinite;
}
@keyframes progress-slide {
  0%   { left: -35%; }
  100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .progress-fill { animation: progress-pulse 1.4s ease-in-out infinite; left: 0; width: 100%; opacity: 0.6; }
  @keyframes progress-pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 0.8; } }
}

/* -------------------------------------------------------- upload button ------ */
/* Hosted uses a centered "Upload a file" ghost button under the hint. Render
   it as a sticker pill to match the rest of this theme. */
.upload-row {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

/* -------------------------------------------------------- model picker ------ */
.model-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: -2px;
  padding: 14px;
  background: var(--panel-2);
  border: var(--hairline-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--sticker-shadow-sm);
}
.model-picker .hint { margin: 2px 0 0; }
.model-picker label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ink);
}
.model-picker input {
  appearance: none;
  border: var(--hairline-2);
  background: var(--panel);
  color: var(--text);
  color-scheme: light;
  font: 700 1rem/1.4 var(--font-ui);
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  box-shadow: var(--sticker-shadow-sm);
}
.model-picker input:focus { border-color: var(--orange); }

/* ----------------------------------------------------------- status badges -- */
.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font: 800 0.66rem/1.6 var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  box-shadow: 2px 2px 0 #241536;
}
.badge-failed { background: #ffe1de; color: #c31a10; }
.badge-partial { background: #fff0cc; color: var(--orange-deep); }

/* Collapsible error disclosure on history cards. */
.error-detail { margin: 10px 0 0; }
.error-detail > summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
  list-style: none;
}
.error-detail > summary::-webkit-details-marker { display: none; }
.error-detail[open] > summary { color: #c31a10; margin-bottom: 6px; }
.error-detail .error {
  font: 700 0.78rem/1.5 var(--font-mono);
  background: #ffe1de;
  border: var(--hairline-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: var(--sticker-shadow-sm);
}

/* Redo-cleanup row on a history card (hosted markup, not the reference's
   .redo-toggle/.redo-panel). Styled as an inline sticker row. */
.redo-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2.5px dashed rgba(36, 21, 54, 0.22);
}
.redo-row label { white-space: nowrap; font-weight: 800; }
.redo-row select {
  appearance: none;
  border: var(--hairline-2);
  background: var(--panel);
  color: var(--text);
  color-scheme: light;
  font: 700 0.92rem/1.4 var(--font-ui);
  min-height: 48px;
  padding: 10px 36px 10px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  flex: 1;
  min-width: 140px;
  box-shadow: var(--sticker-shadow-sm);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23241536' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.redo-row select:focus { border-color: var(--orange); }

/* Subtle secondary button (used by Apply in the redo row). */
button.ghost {
  background: var(--panel);
  border: var(--hairline-2);
  color: var(--ink);
  font-weight: 800;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--sticker-shadow-sm);
}
button.ghost:hover:not(:disabled) { background: #ffedc4; }
button.ghost:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #241536;
}
button.ghost:disabled { opacity: 0.5; cursor: default; }

/* ----------------------------------------------------- prompt edit fields -- */
/* Inline editing of a prompt uses these — sticker inputs to match Settings. */
.prompt-edit input,
.prompt-edit textarea {
  appearance: none;
  border: var(--hairline-2);
  background: var(--panel);
  color: var(--text);
  color-scheme: light;
  font: 700 1rem/1.4 var(--font-ui);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  width: 100%;
  min-height: 48px;
  box-shadow: var(--sticker-shadow-sm);
}
.prompt-edit textarea { resize: vertical; min-height: 72px; }
.prompt-edit input:focus,
.prompt-edit textarea:focus { border-color: var(--orange); }

/* -------------------------------------------------------- theme switcher ---- */
/* The segmented theme picker in Settings — same shape as the top nav, so it
   reuses .nav-pill via a layoutId. The wrapping card is a sticker panel. */
.theme-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  background: var(--panel);
  border: var(--hairline-2);
  border-radius: 26px;
  padding: 4px;
  box-shadow: var(--sticker-shadow-sm);
}
.theme-picker button {
  position: relative;
  flex: 1 1 auto;
  min-width: 92px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 800 0.84rem/1 var(--font-ui);
  letter-spacing: 0.02em;
  min-height: 44px;
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: none;
}
.theme-picker button.active { color: #fff; }

/* -------------------------------------------------------- iphone / pwa ------ */
/* Standalone PWA (Add to Home Screen) has no Safari chrome, so pad for the
   notch/status bar and home indicator. viewport-fit=cover is set in index.html. */
@media (display-mode: standalone) {
  .app {
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }
}

/* Larger tap targets + no text selection flash on buttons in the PWA. */
button { touch-action: manipulation; }

/* Make sure long history cards / redo rows never cause horizontal scroll. */
.result { overflow-wrap: anywhere; word-break: break-word; }
.redo-row select { max-width: 50vw; }

/* --------------------------------------------------------- reduced motion  */
@media (prefers-reduced-motion: reduce) {
  .scanline { animation: none; opacity: 0.5; }
  .mic.recording { animation: none; }
  /* The visualizer stays: it reflects live voice input (state, not decor). */
}
