/* ════════════════════════════════════════════════
   Native Tongues — Studio
   Premium dark theme · Cormorant Garamond + Inter
   ════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg: #111114;
  --void: #0a0a0c;
  --bg-card: #18181c;
  --bg-card-2: #1c1c22;
  --bg-input: #1f1f26;
  --border: #28282f;
  --border-strong: #3a3a44;

  /* Gold accent */
  --accent: #c4a24a;
  --accent-bright: #e0c060;
  --accent-dim: rgba(196, 162, 74, 0.14);
  --accent-glow: rgba(196, 162, 74, 0.35);

  /* Text */
  --text: #d4cfc6;
  --text-dim: #8a8580;
  --text-faint: #5f5b56;

  /* States */
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);
  --green-edge: rgba(74, 222, 128, 0.4);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --red-edge: rgba(248, 113, 113, 0.45);

  /* Depth — layered shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.45), 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 4px 16px rgba(196, 162, 74, 0.22);

  /* Radii */
  --r-control: 8px;
  --r-card: 14px;
  --r-modal: 20px;

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t: 220ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(196, 162, 74, 0.05), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button { font-family: inherit; color: inherit; cursor: pointer; }

::selection { background: var(--accent-dim); color: var(--accent-bright); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

kbd {
  font-family: ui-monospace, monospace;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 11px;
  color: var(--text-dim);
}

.subtle { color: var(--text-dim); font-size: 12px; }

/* ════════════════ Top bar ════════════════ */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 13px; }

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  filter: drop-shadow(0 0 10px rgba(196, 162, 74, 0.25));
  transition: transform var(--t) var(--ease), filter var(--t) var(--ease);
}
.brand:hover .brand-logo {
  transform: scale(1.05) rotate(-2deg);
  filter: drop-shadow(0 0 16px rgba(196, 162, 74, 0.45));
}

.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-word {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text);
}
.brand-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 1px;
}

.iconbtn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t) var(--ease);
}
.iconbtn:hover {
  background: var(--bg-card);
  color: var(--accent);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.iconbtn:active { transform: translateY(0); }

/* ════════════════ Layout ════════════════ */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 32px;
  max-width: 1380px;
  margin: 0 auto;
  padding: 32px 28px 64px;
  align-items: start;
}

.col { min-width: 0; }
.col-left { position: sticky; top: 92px; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.col-left > * { animation: riseIn 0.5s var(--ease-out) both; }
.col-left > *:nth-child(2) { animation-delay: 0.04s; }
.col-left > *:nth-child(3) { animation-delay: 0.08s; }

/* ════════════════ Mode toggle ════════════════ */

.mode-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--void);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm), inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.mode-seg {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 8px 18px;
  border-radius: 9px;
  transition: color var(--t) var(--ease), background var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
.mode-seg svg { opacity: 0.85; transition: opacity var(--t) var(--ease); }
.mode-seg:hover:not(.active) { color: var(--text); }
.mode-seg.active {
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  color: var(--accent-bright);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--accent-dim);
}
.mode-seg.active svg { opacity: 1; }

/* ════════════════ Magic box ════════════════ */

.magic-wrap {
  position: relative;
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.magic-wrap:focus-within {
  border-color: var(--accent-dim);
  box-shadow: var(--shadow), 0 0 0 3px var(--accent-dim);
}

.magic-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.magic-box {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 20px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  padding: 2px 44px 2px 2px;
  min-height: 140px;
}
.magic-box::placeholder { color: var(--text-faint); font-style: italic; }

.magic-box.listening {
  box-shadow: 0 0 0 2px var(--red);
  border-radius: 8px;
  animation: pulseRing 1.2s infinite;
}
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 2px var(--red), 0 0 14px rgba(248, 113, 113, 0.35); }
  50% { box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.25); }
}

.mic-btn {
  position: absolute;
  top: 40px;
  right: 18px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t) var(--ease);
}
.mic-btn:hover { color: var(--accent); border-color: var(--accent-dim); transform: scale(1.06); }
.mic-btn.active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  animation: micPulse 1.2s infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(248, 113, 113, 0); }
}

.magic-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.hint { color: var(--text-faint); font-size: 12px; }
.hint-center { text-align: center; margin-top: 12px; width: 100%; }

/* ════════════════ Buttons ════════════════ */

.btn {
  font-family: inherit;
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.3px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

/* Primary = the deliberate commit. Neutral, more emphasized than secondary
   by stronger border + brighter text — no gold slab, no glow, no gradient. */
.btn-primary {
  background: var(--bg-card-2);
  color: var(--text);
  border: 1px solid var(--text-dim);
  font-weight: 500;
}
.btn-primary:hover { background: var(--bg-card); border-color: var(--text); }
.btn-primary:active { background: var(--void); }
.btn-primary:disabled {
  background: var(--bg-card);
  color: var(--text-faint);
  border-color: var(--border);
  cursor: not-allowed;
}

/* Secondary = neutral action. Calm hairline outline, single-property hover. */
.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); }
.btn-secondary:active { background: var(--bg-card-2); }
.btn-secondary:disabled { color: var(--text-faint); cursor: not-allowed; }

/* Ghost = lightweight, repeatable, free action (Parse). Reads as a quiet link-button. */
.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding-left: 12px;
  padding-right: 12px;
}
.btn-ghost:hover { color: var(--accent); }
.btn-ghost:disabled { color: var(--text-faint); cursor: not-allowed; }

.btn-large { padding: 13px 24px; font-size: 14px; }

.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  transition: color var(--t) var(--ease);
}
.link-btn:hover { color: var(--accent-bright); text-decoration: underline; }

/* ════════════════ Fields card ════════════════ */

.fields-card {
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 24px;
  margin-top: 18px;
  box-shadow: var(--shadow);
  animation: riseIn 0.4s var(--ease-out) both;
}
.fields-card[hidden] { display: none; }

.fields-head {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.fields-head h3 {
  margin: 0 0 3px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.field-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.field-row-block { display: block; }
.field-row-block label { margin-bottom: 8px; }

.field-row label {
  flex: 0 0 118px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field-row-block label { display: flex; justify-content: space-between; align-items: center; }

.counter { font-size: 11px; color: var(--text-faint); font-weight: 400; }

.field-row select,
.field-row textarea,
.field-row-block select,
.field-row-block textarea,
.text-input {
  flex: 1;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--r-control);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  resize: vertical;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.field-row select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8580' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field-row select:focus,
.field-row textarea:focus,
.field-row-block textarea:focus,
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.seg-control {
  display: flex;
  gap: 4px;
  background: var(--void);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--r-control);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
.seg {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  transition: all var(--t) var(--ease);
}
.seg.active {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--text-dim);
  box-shadow: var(--shadow-sm);
}
.seg:hover:not(.active) { color: var(--text); }

/* ════════════════ Chip input ════════════════ */

.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 9px;
  min-height: 44px;
  cursor: text;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.chip-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

@keyframes chipPop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  border: 1px solid rgba(196, 162, 74, 0.3);
  color: var(--accent-bright);
  padding: 3px 4px 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  animation: chipPop 0.18s var(--ease-out) both;
}
.chip .chip-x {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.chip .chip-x:hover { background: rgba(196, 162, 74, 0.25); color: var(--accent-bright); }

.chip-text {
  flex: 1;
  min-width: 130px;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  font-size: 13px;
  padding: 4px;
}
.chip-text::placeholder { color: var(--text-faint); }

/* ════════════════ Suggest dropdown ════════════════ */

.suggest {
  position: relative;
  background: var(--bg-card-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-control);
  margin-top: 6px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow);
  animation: riseIn 0.16s var(--ease-out) both;
}
.suggest[hidden] { display: none; }
.suggest-item { padding: 9px 13px; font-size: 13px; cursor: pointer; color: var(--text); transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.suggest-item:hover, .suggest-item.active { background: var(--accent-dim); color: var(--accent-bright); }

/* ════════════════ Generate row ════════════════ */

.generate-row { display: flex; gap: 10px; margin-top: 24px; }
.generate-row .btn-primary { flex: 1; }

/* ════════════════ Right column ════════════════ */

.right-header { padding: 0 2px 14px; }
.right-header h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.3px;
}

.empty-state {
  background:
    radial-gradient(400px 200px at 50% 0%, rgba(196, 162, 74, 0.04), transparent 70%),
    var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-card);
  padding: 28px 24px;
  text-align: center;
}
.empty-state[hidden] { display: none; }
.empty-icon {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: var(--accent-dim);
  color: var(--accent);
}
.empty-state h3 {
  margin: 0 0 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.recent-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  transition: all var(--t) var(--ease);
}
.recent-item:hover {
  border-color: var(--accent-dim);
  background: var(--bg-input);
  transform: translateX(3px);
}
.recent-item .ri-title { font-weight: 600; }
.recent-item .ri-meta { color: var(--text-faint); font-size: 11px; white-space: nowrap; }
.recent-placeholder { padding: 14px; text-align: center; }

/* ════════════════ Draft cards ════════════════ */

.drafts-container { display: flex; flex-direction: column; gap: 20px; }

.draft-card {
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 22px;
  position: relative;
  box-shadow: var(--shadow);
  animation: riseIn 0.5s var(--ease-out) both;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.draft-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }

.draft-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 12px; }
.draft-titles { flex: 1; min-width: 0; }
.draft-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  margin: 0;
  line-height: 1.15;
  color: var(--text);
}
.draft-eng-title { font-size: 12px; color: var(--text-faint); margin-top: 3px; font-style: italic; }

.draft-version-chip {
  display: inline-flex;
  align-items: center;
  background: var(--accent-dim);
  border: 1px solid rgba(196, 162, 74, 0.3);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-bright);
  margin-left: 8px;
}

.draft-copy-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t) var(--ease);
}
.draft-copy-btn:hover { border-color: var(--accent-dim); color: var(--accent); transform: translateY(-1px); }

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.stats-strip .sep { color: var(--text-faint); }
.coverage { font-weight: 700; }
.coverage.good { color: var(--green); }
.coverage.partial { color: var(--accent); }
.coverage.bad { color: var(--red); }

.vocab-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px; }
.vocab-hit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-soft);
  border: 1px solid var(--green-edge);
  color: var(--green);
  padding: 2px 5px 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.vocab-hit.miss {
  background: var(--red-soft);
  border-color: var(--red-edge);
  color: var(--red);
  text-decoration: line-through;
}
.vocab-hit .count {
  background: rgba(0, 0, 0, 0.3);
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}

.draft-body {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 18px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  margin: 0 0 18px;
}

/* draft footer — the deliberate "commit to audio" zone */
.draft-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}
/* No extra emphasis layer — the base primary is already the loudest button. */

/* refine box */
.refine-box {
  margin-top: 16px;
  background: var(--void);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-control);
  padding: 14px;
  animation: riseIn 0.22s var(--ease-out) both;
}
.refine-box textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  color: var(--text);
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  outline: none;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.refine-box textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.refine-box-row { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }

/* ════════════════ Progress / audio state ════════════════ */

.progress-strip {
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* horizontal inset so the bar + meta text ("48s" / "Generating audio") clear the
     rounded card edge — the card itself is padding:0 / overflow:hidden, so this
     section must supply its own side padding. */
  padding: 18px 22px 16px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  animation: riseIn 0.3s var(--ease-out) both;
}

.progress-stages { display: flex; gap: 10px; }
.progress-stage {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-align: center;
  position: relative;
  transition: all var(--t) var(--ease);
}
.progress-stage.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.progress-stage.active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid var(--accent);
  animation: stageGlow 1.4s var(--ease) infinite;
}
@keyframes stageGlow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.progress-stage.done { border-color: var(--green-edge); color: var(--green); background: var(--green-soft); }

.progress-bar {
  height: 6px;
  background: var(--void);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
.progress-bar-fill {
  height: 100%;
  background: var(--text-dim);
  border-radius: 999px;
  transition: width 0.5s var(--ease);
  position: relative;
  overflow: hidden;
}
.progress-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* Fully-done state ONLY: a stage is .done AND none is still .active (mid-process
   marks earlier stages .done while a later one runs — don't go green then).
   The finished bar matches the green "done" stages and stops shimmering. */
.progress-strip:has(.progress-stage.done):not(:has(.progress-stage.active)) .progress-bar-fill {
  background: var(--green);
}
.progress-strip:has(.progress-stage.done):not(:has(.progress-stage.active)) .progress-bar-fill::after {
  display: none;
  animation: none;
}

.progress-meta { font-size: 11px; color: var(--text-faint); display: flex; justify-content: space-between; }
.progress-elapsed { font-variant-numeric: tabular-nums; }
.progress-status { color: var(--text-dim); font-weight: 500; }

.progress-error {
  background: var(--red-soft);
  border: 1px solid var(--red-edge);
  color: var(--red);
  border-radius: var(--r-control);
  padding: 12px;
  font-size: 12px;
  margin-top: 10px;
}

/* Completion celebration — gold ring around the "done" footer.
   When the audio job finishes, app.js injects a fresh .draft-footer inside
   .progress-strip with the result buttons; this styles that rewarding moment. */
.progress-strip .draft-footer {
  position: relative;
  border-top: none;
  padding-top: 0;
  margin-top: 14px;
  border-radius: var(--r-control);
  animation: doneReveal 0.5s var(--ease-out) both;
}
@keyframes doneReveal {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
/* No completion-ring animation — quiet finish is the finish. */
.progress-strip .draft-footer .copy-share,
.progress-strip .draft-footer .use-as { /* hooks present for JS */ }

/* ════════════════ Popovers / modals ════════════════ */

.popover {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.popover[hidden] { display: none !important; }
.history-panel[hidden] { display: none !important; }

.popover-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 6, 8, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.popover-panel {
  position: relative;
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border: 1px solid var(--border-strong);
  border-radius: var(--r-modal);
  width: min(640px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.26s var(--ease-out) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.popover-panel.small { width: min(440px, 90vw); }

.popover-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.popover-panel header h3 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
}
.popover-panel header .iconbtn { width: 32px; height: 32px; font-size: 14px; }
.popover-panel footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

.grammar-groups { flex: 1; overflow-y: auto; padding: 18px 22px; }
.grammar-group { margin-bottom: 20px; }
.grammar-group h4 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.grammar-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grammar-check {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 9px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--t) var(--ease);
}
.grammar-check:hover { border-color: var(--accent-dim); background: var(--bg-input); }
.grammar-check input { accent-color: var(--accent); }
.grammar-check:has(input:checked) { border-color: var(--accent); background: var(--accent-dim); color: var(--accent-bright); }

.modal-body { padding: 20px 22px; }

/* ════════════════ History panel ════════════════ */

.history-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 400px;
  max-width: 92vw;
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border-left: 1px solid var(--border-strong);
  z-index: 90;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s var(--ease-out) both;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }

.history-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.history-panel h3 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
}
.history-search { padding: 14px 20px; }
.history-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  color: var(--text);
  padding: 9px 13px;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.history-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 13px 14px;
  transition: all var(--t) var(--ease);
}
.history-item:hover { border-color: var(--accent-dim); }
.history-item .hi-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 3px;
  color: var(--text);
}
.history-item .hi-meta { font-size: 11px; color: var(--text-faint); }
.history-item .hi-actions { display: flex; gap: 8px; margin-top: 10px; }
.history-item .hi-actions .btn { padding: 5px 11px; font-size: 11px; }

/* ════════════════ Responsive ════════════════ */

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; gap: 24px; }
  .col-left { position: static; top: auto; }
}
@media (max-width: 520px) {
  .topbar { padding: 12px 16px; }
  .layout { padding: 20px 16px 48px; }
  .grammar-options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ════════════════ Bootcamp mode ════════════════ */

.explainer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.explainer-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-bright);
  margin-bottom: 6px;
}
.explainer p { margin: 0 0 8px; font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.explainer p:last-child { margin-bottom: 0; }
.explainer .ex { color: var(--text); font-style: italic; }
.explainer strong { color: var(--text); font-weight: 600; }

/* Lesson deck */
.lesson-warn {
  font-size: 12px;
  color: var(--accent-bright);
  background: var(--accent-dim);
  border-radius: 8px;
  padding: 7px 11px;
  margin: 10px 0 4px;
}
.lesson-deck { margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.focus-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 14px 0 5px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--border);
}
.focus-head:first-child { margin-top: 0; }
.lesson-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 120ms var(--ease);
}
.lesson-row:hover { background: var(--bg-card-2); }
.lr-target {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 16px;
  color: var(--text);
}
.lr-en { font-size: 12px; color: var(--text-faint); text-align: right; flex-shrink: 0; max-width: 45%; }

/* Mode-conditional field rows (driven by body[data-mode]) */
body[data-mode="bootcamp"] .only-stories { display: none; }
body:not([data-mode="bootcamp"]) .only-bootcamp { display: none; }

.reps-control { display: flex; align-items: center; gap: 12px; flex: 1; }
.reps-control input {
  width: 64px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 7px 10px;
  text-align: center;
}
.reps-control input:focus { outline: none; border-color: var(--accent); }
.length-hint { font-size: 13px; color: var(--accent-bright); font-weight: 500; }

/* Language-required nudge */
@keyframes nudgePulse { 0%,100% { box-shadow: 0 0 0 3px var(--accent-dim); } 50% { box-shadow: 0 0 0 5px var(--accent-dim); } }

/* Mode-aware field labels (Stories: Vocabulary/Grammar focus · Bootcamp: Content/Focus words) */
.lbl-bootcamp { display: none; }
body[data-mode="bootcamp"] .lbl-stories { display: none; }
body[data-mode="bootcamp"] .lbl-bootcamp { display: inline; }
.lbl-sub { color: var(--text-faint); font-weight: 400; font-size: 11px; }


/* ════════════════ Language dropdown (top) ════════════════ */
.lang-picker { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.lang-picker .lang-label {
  font-size: 11px; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-faint);
}
.lang-select {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: inherit; font-size: 13px;
  padding: 7px 12px; border-radius: 8px;
}
.lang-select:focus { outline: none; border-color: var(--accent); }
.lang-connector {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 0.02em;
}
/* Hide the gloss connector + select unless the parent row says we have gloss. */
.lang-picker.no-gloss .lang-connector,
.lang-picker.no-gloss .gloss-select { display: none !important; }

/* Bootcamp planner reasoning + tenses */
.plan-reasoning {
  background: var(--accent-dim);
  border: 1px solid rgba(196,162,74,0.3);
  border-radius: 10px;
  padding: 10px 13px;
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.plan-reasoning .pr-icon { color: var(--accent-bright); margin-right: 6px; }
.tenses-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tenses-chips:empty::before { content: "—"; color: var(--text-faint); }

/* Beta tag on the Bootcamp mode */
.beta-tag {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent-bright);
  background: var(--accent-dim);
  border: 1px solid rgba(196,162,74,0.3);
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: 2px;
  line-height: 1.4;
}

/* Mic transcribing state */
.mic-btn.thinking { color: var(--accent-bright); border-color: var(--accent); }
.mic-btn.thinking { animation: micPulse 0.9s ease-in-out infinite; }
@keyframes micPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ═══════════════════════════════════════════════════════════════════
   Org panels (Lessons / Classes drawers) — Studio's organization layer.
   Mirrors .history-panel structure exactly so they feel of-a-piece.
   ═══════════════════════════════════════════════════════════════════ */

.navbtn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
  transition: color 160ms ease, background 160ms ease;
}
.navbtn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.navbtn.active { color: var(--accent-bright); background: var(--accent-dim); }
.navbtn-quiet { color: var(--text-faint); }
.navbtn-inline { font-size: 12.5px; padding: 4px 10px; }
.navsep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}
.me-email {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: 10px;
  font-variant: tabular-nums;
}

.org-panel[hidden] { display: none !important; }
.org-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border-left: 1px solid var(--border-strong);
  z-index: 90;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s var(--ease-out) both;
}
.org-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.org-panel h3 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
  flex: 1;
}
.org-list { flex: 1; overflow-y: auto; padding: 8px 12px 20px; }

/* Lesson rows in the drawer */
.org-lesson {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
  position: relative;
}
.org-lesson:hover { background: var(--bg-input); border-color: var(--border); }
.org-lesson.armed {
  background: var(--accent-dim);
  border-color: rgba(196, 162, 74, 0.45);
}
.org-lesson.armed::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.org-lesson .ol-main { min-width: 0; }
.org-lesson .ol-title {
  font-size: 14px;
  color: var(--text);
  /* Wrap to two lines, never a 15-char mid-word ellipsis. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  margin-bottom: 3px;
}
.org-lesson .ol-meta {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  align-items: center;
}
.org-lesson .ol-meta span { white-space: nowrap; }
.ol-pill {
  display: inline-block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.ol-pill.bootcamp {
  color: var(--accent-bright);
  border-color: rgba(196,162,74,0.35);
  background: rgba(196,162,74,0.08);
}
.ol-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 160ms ease; }
.org-lesson:hover .ol-actions { opacity: 1; }
/* Touch has no hover — actions must always be visible, and the row stacks
   so the title gets the full width. */
@media (hover: none), (max-width: 640px) {
  .org-lesson { grid-template-columns: 1fr; gap: 6px; align-items: start; }
  .ol-actions { opacity: 1; justify-content: flex-start; }
}
.ol-iconbtn {
  background: none;
  border: none;
  color: var(--text-dim);
  width: 26px; height: 26px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.ol-iconbtn:hover { color: var(--text); background: var(--bg-card); }
.ol-iconbtn.danger:hover { color: var(--red); }

.armed-hint {
  margin: 4px 12px 12px;
  padding: 10px 12px;
  background: rgba(196, 162, 74, 0.08);
  border: 1px solid rgba(196, 162, 74, 0.22);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.armed-hint > span { min-width: 0; line-height: 1.45; }
@media (max-width: 640px) {
  .armed-hint { flex-direction: column; align-items: flex-start; gap: 8px; }
}
.armed-hint strong { color: var(--accent-bright); font-weight: 500; }
.armed-hint em { color: var(--text); font-style: normal; font-weight: 500; }

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding: 2px 4px;
}
.link-btn:hover { color: var(--text); }
.link-btn.danger:hover { color: var(--red); }

/* Class cards in the drawer */
.org-class {
  margin-bottom: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.org-class.drop-target {
  border-color: rgba(196, 162, 74, 0.50);
  box-shadow: 0 0 0 2px rgba(196, 162, 74, 0.10);
  cursor: copy;
}
.org-class.drop-target:hover { border-color: var(--accent); }
.org-class-head {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}
.org-class-collapse {
  background: none; border: none;
  color: var(--text-dim);
  font-size: 13px;
  width: 22px; height: 22px;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
}
.org-class-collapse:hover { color: var(--text); }
.org-class-title-wrap { cursor: pointer; min-width: 0; }
.org-class-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.org-class-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}
.org-class-meta .mono { font-family: "SF Mono", ui-monospace, monospace; letter-spacing: 0.02em; color: var(--text); }
.org-class-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 160ms ease; }
.org-class:hover .org-class-actions { opacity: 1; }

.org-class-body {
  border-top: 1px solid var(--border);
  padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 14px;
  cursor: default;
}
.org-share-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.org-share-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-dim);
}
.org-share-link {
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--text);
  word-break: break-all;
  border-bottom: 1px dashed var(--border);
  text-decoration: none;
}
.org-qr { background: white; padding: 8px; border-radius: 6px; width: max-content; }
.org-qr svg { display: block; width: 160px; height: 160px; }

.org-sub-head {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.org-chip-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.org-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 9px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}
.org-chip-x {
  background: none; border: none;
  color: var(--text-dim);
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.org-chip-x:hover { background: var(--red-soft, rgba(217,122,115,0.10)); color: var(--red, #d97a73); }
.org-chip-input {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  min-width: 120px;
  outline: none;
}
.org-chip-input:focus { border-color: var(--accent); background: var(--bg-card-2); }

.org-items { display: flex; flex-direction: column; gap: 5px; }
.org-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg-card-2);
  border-radius: 6px;
  font-size: 12.5px;
}
.org-item-title { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.placeholder-small {
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 0;
  font-style: italic;
}

.watch-grid-wrap-org { overflow-x: auto; }
.watch-grid-org {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}
.watch-grid-org th, .watch-grid-org td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.watch-grid-org thead th {
  text-align: left;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 500;
  white-space: nowrap;
}
.watch-grid-org .row-head { text-align: left; color: var(--text); font-weight: 500; }
.watch-grid-org .zero { color: var(--text-faint); }
.watch-grid-org .play-count {
  display: inline-block;
  min-width: 16px;
  padding: 1px 6px;
  background: var(--bg-card-2);
  color: var(--text);
  border-radius: 999px;
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}
.watch-grid-org .complete-count {
  margin-left: 5px;
  color: var(--green, #7ab37a);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ── "+ Add to class" inline picker ────────────────────────────────── */
.ol-addbtn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
  white-space: nowrap;
}
.ol-addbtn:hover {
  color: var(--accent-bright);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.assign-popover {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: -8px 8px 24px rgba(0, 0, 0, 0.6);
  padding: 10px 0;
  width: 260px;
  max-height: 60vh;
  overflow-y: auto;
  animation: popIn 140ms ease-out;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.assign-head {
  padding: 4px 14px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.assign-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 4px;
}
.assign-class {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease;
}
.assign-class:hover:not([disabled]) {
  background: var(--bg-input);
}
.assign-class[disabled] {
  cursor: default;
  opacity: 0.55;
}
.assign-class-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.assign-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-dim);
}
.assign-class.just-added .assign-tag { color: var(--green, #7ab37a); }
.assign-tag-arrow {
  font-size: 16px;
  color: var(--text-faint);
  line-height: 1;
}
.assign-class:hover:not([disabled]) .assign-tag-arrow {
  color: var(--accent-bright);
}
.assign-empty {
  padding: 14px 16px;
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
}

.assign-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 200;
}
.assign-toast.fade {
  opacity: 1;
  transform: translateY(0);
}


/* ══════════════════════════════════════════════════════════════════════
   RESKIN (Jun 2026) — CSS-ONLY, additive, loads last. No markup/JS touched.
   Bridges the Studio's variables onto tokens.css + brings the surfaces up to
   the consumer app's look (card depth, drawer scrim, cohesive cards/rows).
   ══════════════════════════════════════════════════════════════════════ */
:root {
  --bg: var(--ink); --void: var(--ink-1); --bg-card: var(--card-flat); --bg-card-2: var(--ink-2);
  --bg-input: var(--field-bg); --border: var(--line); --border-strong: var(--line-hard);
  --accent: var(--gold); --accent-bright: var(--gold-hi); --accent-dim: var(--gold-soft); --accent-glow: var(--gold-glow);
  --text-dim: var(--text-mute); --text-faint: #5e5c57;
  --shadow: var(--shadow-card); --shadow-lg: var(--shadow-lift); --shadow-gold: 0 4px 16px var(--gold-soft);
  --r-control: var(--r); --r-card: var(--r-lg); --r-modal: var(--r-xl);
}
html, body { background: radial-gradient(1200px 600px at 50% -10%, var(--gold-soft), transparent 70%), var(--ink); }

/* mode toggle → gold pill */
.mode-toggle { background: var(--field-bg); border: 1px solid var(--line-soft); border-radius: 999px; box-shadow: inset 0 1px 2px rgba(0,0,0,.25); }
.mode-seg { border-radius: 999px; color: var(--text-mute); }
.mode-seg:hover:not(.active) { color: var(--text); background: var(--gold-soft); }
.mode-seg.active { background: var(--gold-soft); color: var(--gold-hi); box-shadow: inset 0 0 0 1px var(--gold-line); }
.beta-tag { color: var(--gold-hi); background: var(--gold-soft); border: 1px solid var(--gold-line); }

/* language select + level/fields selects → framed control w/ caret */
.lang-select, .fields-card select {
  -webkit-appearance: none; appearance: none; background: var(--field-bg); color: var(--text);
  border: 1px solid var(--line-hard); border-radius: var(--r); padding: 9px 30px 9px 13px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='%23888'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.lang-select:hover, .fields-card select:hover { border-color: var(--gold-line); }
.lang-select:focus, .fields-card select:focus { border-color: var(--gold-line); box-shadow: 0 0 0 3px var(--gold-soft); }

/* magic box → hero surface, framed w/ hairline header + footer rows */
.magic-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; overflow: hidden; box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 24px 54px -30px rgba(0,0,0,.9); }
.magic-wrap:focus-within { border-color: var(--gold-line); box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 24px 54px -30px rgba(0,0,0,.9), 0 0 0 3px var(--gold-soft); }
.magic-eyebrow { margin: 0; padding: 14px 22px 13px; border-bottom: 1px solid var(--line-soft); color: var(--text-dim); letter-spacing: .16em; }
/* Right padding reserves the mic button's corner — text must never run under it. */
.magic-box { font-family: var(--serif); font-size: clamp(19px,1.5vw,22px); line-height: 1.55; padding: 18px 56px 4px 22px; min-height: 150px; }
.magic-box::placeholder { color: var(--text-dim); font-style: italic; opacity: .75; }
.magic-row { margin: 0; padding: 14px 22px; border-top: 1px solid var(--line-soft); }
.mic-btn { top: 50px; right: 16px; background: var(--field-bg); border: 1px solid var(--line-hard); color: var(--text-mute); }
.mic-btn:hover { border-color: var(--gold-line); color: var(--gold-hi); background: var(--gold-soft); }

/* buttons → gradient-paper primary, framed secondary */
.btn { border-radius: 999px; font-weight: 600; }
.btn-primary { border: 0; color: var(--ink); background: linear-gradient(180deg, color-mix(in oklab, var(--paper) 97%, #fff), color-mix(in oklab, var(--paper) 86%, #000)); box-shadow: inset 0 1.5px 0 rgba(255,255,255,.55), 0 8px 22px -12px rgba(0,0,0,.8); }
.btn-primary:hover { filter: brightness(1.03); border: 0; background: linear-gradient(180deg, color-mix(in oklab, var(--paper) 99%, #fff), color-mix(in oklab, var(--paper) 88%, #000)); }
[data-theme="jungle"] .btn-primary { color: #f2fff6; background: linear-gradient(180deg,#2f9d56,#14633a); }
[data-theme="vellum"] .btn-primary { color: #fff8e8; background: linear-gradient(180deg,#c79a2e,#8f6c14); }
.btn-secondary { border: 1px solid var(--line-hard); background: var(--field-bg); color: var(--text); }
.btn-secondary:hover { border-color: var(--gold-line); background: var(--gold-soft); }
.link-btn { color: var(--gold-hi); font-size: 12px; font-weight: 500; background: none; border: 0; padding: 0; }
.link-btn:hover { color: var(--gold); text-decoration: underline; }
.link-btn.danger { color: var(--red); }

/* fields card → framed, hairline-divided rows */
.fields-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; overflow: hidden; box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 24px 54px -30px rgba(0,0,0,.9); margin-top: 18px; }
.fields-head { padding: 18px 22px 13px; border-bottom: 1px solid var(--line-soft); }
.fields-head h3 { font-family: var(--serif); font-weight: 500; font-size: 18px; color: var(--text); }
.field-row { padding: 13px 22px; border-bottom: 1px solid var(--line-soft); margin: 0; }
.field-row:last-of-type { border-bottom: 0; }
.chip-input { background: var(--field-bg); border: 1px solid var(--line-hard); border-radius: var(--r); }
.chip-input:focus-within { border-color: var(--gold-line); box-shadow: 0 0 0 3px var(--gold-soft); }
.generate-row { padding: 18px 22px 8px; }
.hint-center { padding: 0 22px 18px; }

/* right column + generated cards → consumer card depth */
.right-header h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(22px,2.2vw,28px); color: var(--text); }
.empty-state, .draft-card, .lesson-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 1px 2px rgba(0,0,0,.3), 0 24px 54px -30px rgba(0,0,0,.9); }
.draft-card, .lesson-card { padding: 0; overflow: hidden; }
.draft-card:hover, .lesson-card:hover { border-color: var(--gold-line); }
.empty-icon { color: var(--gold-hi); background: var(--gold-soft); border: 1px solid var(--gold-line); }
.draft-head { margin: 0; padding: 18px 22px 14px; border-bottom: 1px solid var(--line-soft); align-items: center; }
.draft-title { font-size: 22px; font-weight: 500; }
.draft-eng-title { color: var(--text-dim); }
.stats-strip { margin: 0; padding: 12px 22px; border-bottom: 1px solid var(--line-soft); }
.coverage.partial { color: var(--gold-hi); }
.vocab-chips { margin: 0; padding: 14px 22px; }
.vocab-hit { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold-hi); }
.vocab-hit.miss { background: var(--red-soft); border-color: var(--red-edge); color: var(--red); }
.draft-body { padding: 18px 22px; margin: 0; }
.draft-footer { padding: 14px 22px; margin: 0; border-top: 1px solid var(--line-soft); }
.lesson-deck { padding: 6px 22px 14px; }
.focus-head { color: var(--gold-hi); letter-spacing: .14em; }
.lesson-row { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.lr-target { font-family: var(--serif); font-size: 17px; color: var(--text); }
.lr-en { color: var(--text-mute); }
.recent-item { background: var(--field-bg); border-color: var(--line-soft); }
.recent-item:hover { background: var(--gold-soft); border-color: var(--gold-line); transform: none; }
.recent-item .ri-title { font-weight: 500; color: var(--text-mute); }
.recent-item:hover .ri-title { color: var(--text); }

/* drawers → scrim + composed header */
.org-panel, .history-panel { background: var(--card-flat); border-left: 1px solid var(--line); box-shadow: -30px 0 80px -30px rgba(0,0,0,.8); }
.org-panel:not([hidden])::before, .history-panel:not([hidden])::before { content: ""; position: fixed; inset: 0 420px 0 0; background: color-mix(in oklab, var(--ink) 55%, transparent); backdrop-filter: blur(2px); z-index: -1; }
.org-panel > header, .history-panel > header { padding: 18px 22px; border-bottom: 1px solid var(--line-soft); }
.org-panel > header h3, .history-panel > header h3 { font-family: var(--serif); font-weight: 500; font-size: 21px; color: var(--text); }

/* topbar */
.topbar { padding: 13px clamp(18px,3vw,32px); background: color-mix(in oklab, var(--ink) 70%, transparent); border-bottom: 1px solid var(--line-soft); }
.brand-sub { color: var(--gold); letter-spacing: .22em; }
.navbtn { color: var(--text-mute); } .navbtn:hover { color: var(--text); }
.iconbtn { border: 1px solid var(--line-hard); color: var(--text-mute); }
.iconbtn:hover { border-color: var(--gold-line); color: var(--gold-hi); background: var(--gold-soft); }

@media (max-width: 600px) { .brand-text { display: none; } .me-email { display: none; } }

/* ── top bar: proper grouping + rhythm (was ungrouped flex flow) ── */
.topbar { height: 60px; padding: 0 clamp(20px,3vw,34px); }
.brand-word { font-size: 18px; }
.brand-sub { font-size: 9px; letter-spacing: .24em; }
.topnav { display: flex; align-items: center; gap: 6px; }
.topnav .navbtn {
  font-size: 13px; font-weight: 500; padding: 8px 14px; border-radius: 999px;
  color: var(--text-mute); background: none; letter-spacing: .01em;
}
.topnav .navbtn:hover { color: var(--text); background: var(--gold-soft); }
.topnav .navbtn.active { color: var(--gold-hi); background: var(--gold-soft); }
/* clock/history: plain circular icon, not a heavy boxed control */
.topnav .iconbtn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: none; color: var(--text-mute);
  margin-left: 4px;
}
.topnav .iconbtn:hover { border-color: var(--gold-line); color: var(--gold-hi); background: var(--gold-soft); }
.topnav .navsep { width: 1px; height: 20px; background: var(--line); margin: 0 8px; flex: 0 0 auto; }
/* account cluster: email + sign out read as one quiet unit on the right */
.me-email { color: var(--text-dim); font-size: 12.5px; margin-left: 8px; }
.navbtn-quiet { color: var(--text-mute); font-size: 12.5px; font-weight: 500; padding: 8px 12px; border-radius: 999px; }
.navbtn-quiet:hover { color: var(--text); background: var(--gold-soft); }
@media (max-width: 720px) { .me-email { display: none; } }

/* ── cohesion follow-ups (Jun 2026 visual-QA) ───────────────────────── */
/* stronger gold atmosphere behind the studio (judges: too faint/flat) */
html, body {
  background:
    radial-gradient(1100px 620px at 50% -6%, color-mix(in oklab, var(--gold) 9%, transparent), transparent 66%),
    radial-gradient(700px 420px at 88% 14%, color-mix(in oklab, var(--gold) 5%, transparent), transparent 60%),
    var(--ink) !important;
  background-attachment: fixed !important;
}
/* Parse is a PRIMARY action — give it the gradient-paper weight (was a weak dark pill) */
#parseBtn {
  border: 0; color: var(--ink);
  background: linear-gradient(180deg, color-mix(in oklab, var(--paper) 97%, #fff), color-mix(in oklab, var(--paper) 86%, #000));
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,.55), 0 8px 22px -12px rgba(0,0,0,.8);
}
#parseBtn:hover { filter: brightness(1.03); border: 0; background: linear-gradient(180deg, color-mix(in oklab, var(--paper) 99%, #fff), color-mix(in oklab, var(--paper) 88%, #000)); }
[data-theme="jungle"] #parseBtn { color: #f2fff6; background: linear-gradient(180deg,#2f9d56,#14633a); }
[data-theme="vellum"] #parseBtn { color: #fff8e8; background: linear-gradient(180deg,#c79a2e,#8f6c14); }
/* unify card depth across the generated cards + empty + drafts so they all FLOAT */
.empty-state, .draft-card, .lesson-card, .magic-wrap, .fields-card {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 1px 2px rgba(0,0,0,.3), 0 26px 58px -30px rgba(0,0,0,.9) !important;
}

/* ════════════════ Studio billing (banner · toast · modals) ════════════════ */

.billing-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(180deg, var(--accent-dim), transparent 160%);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.01em;
}
.billing-banner .billing-cta {
  flex: none;
  background: var(--accent);
  color: #141210;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
  transition: all var(--t) var(--ease);
  box-shadow: var(--shadow-sm);
}
.billing-banner .billing-cta:hover {
  background: var(--accent-bright);
  box-shadow: var(--shadow-gold);
}

.billing-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 13px 22px;
  border-radius: var(--r-card);
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.26s var(--ease-out) both;
}

.billing-body p { margin: 0 0 6px; font-size: 14px; line-height: 1.6; color: var(--text); }
.billing-body .billing-fine {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.billing-input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border-radius: var(--r-control);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--t) var(--ease);
}
.billing-input:focus { outline: none; border-color: var(--accent); }
.billing-input + .billing-input { margin-top: 10px; }
.billing-err { margin: 10px 0 0; font-size: 12px; color: var(--red); }

/* ════════════════ Mobile-first polish (Jul 4) ════════════════ */

/* Topbar on phones: one row, never wraps. History is a power feature —
   it lives in the Lessons panel anyway, so the icon yields at phone width. */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .topnav { gap: 4px; }
  .navbtn { white-space: nowrap; padding: 6px 8px; font-size: 12.5px; }
  .navsep { display: none; }
  #historyBtn { display: none; }
}

/* Recent generations: on phones the meta drops under the title instead of
   fighting it for one line. */
@media (max-width: 520px) {
  .recent-item { flex-direction: column; align-items: flex-start; gap: 3px; }
  .recent-item .ri-meta { white-space: normal; }
  .mode-toggle { width: 100%; }
  .mode-seg { flex: 1; justify-content: center; }
  .billing-banner { flex-direction: column; gap: 8px; padding: 12px 16px; text-align: center; }
}

/* Finished-lesson footer: ONE gold action, quiet links beside it. Wraps
   cleanly on phones. */
.done-footer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.done-links { display: flex; align-items: center; gap: 12px; }

/* Fields card on phones: label above control, one column, calm gaps. */
@media (max-width: 520px) {
  .field-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .field-row label { font-size: 11px; }
}
