/* ==========================================================================
   YidKey v2 design system
   Single-file, no-framework UI: design tokens (light/dark), type scale,
   layout primitives, and every component the templates use. JS hooks live
   in static/js/yidkey.js (tabs, modals, dropdowns, nav, theme, reveal).
   ========================================================================== */

/* ---------- Tokens -------------------------------------------------------- */
:root {
  /* brand */
  --brand-1: #5433ff;
  --brand-2: #20bdff;
  --brand-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
  --brand-soft: rgba(84, 51, 255, .10);
  --brand-ring: rgba(84, 51, 255, .28);

  /* status */
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #38bdf8;

  /* surfaces (light) */
  --bg: #f6f7fc;
  --surface: #ffffff;
  --surface-2: #eef0f9;
  --text: #12142b;
  --text-2: #5b6079;
  --line: #e3e6f3;
  --shadow-sm: 0 1px 2px rgba(18, 20, 43, .05), 0 4px 16px rgba(18, 20, 43, .05);
  --shadow-md: 0 6px 24px rgba(18, 20, 43, .09);
  --shadow-lg: 0 18px 50px rgba(18, 20, 43, .16);
  --glow: 0 8px 28px rgba(84, 51, 255, .30);

  /* radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* fonts */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Sora", var(--font-ui);
  --font-hebrew: "Noto Serif Hebrew", "Frank Ruhl Libre", "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --nav-h: 68px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0b0d1c;
  --surface: #131630;
  --surface-2: #1b1f40;
  --text: #edeffd;
  --text-2: #9da3c8;
  --line: #272c55;
  --brand-soft: rgba(110, 88, 255, .16);
  --brand-ring: rgba(124, 104, 255, .40);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, .40);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  --glow: 0 8px 32px rgba(96, 70, 255, .45);
  color-scheme: dark;
}

/* ---------- Base ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-padding-top: calc(var(--nav-h) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--brand-1); color: #fff; }

img, svg { vertical-align: middle; }
a { color: var(--brand-1); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 200;
  background: var(--surface); color: var(--text);
  padding: .6rem 1rem; border-radius: var(--r-sm); box-shadow: var(--shadow-md);
}
.skip-link:focus { left: 8px; }

/* ---------- Typography ----------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -.015em;
  margin: 0 0 .6em;
  text-wrap: balance;
}
h1, .h1 { font-size: clamp(2.1rem, 4.5vw, 3.3rem); }
h2, .h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); }
h3, .h3 { font-size: clamp(1.25rem, 2vw, 1.55rem); }
h4, .h4 { font-size: 1.15rem; }
h5, .h5 { font-size: 1rem; }
p { margin: 0 0 1rem; }

.lead { font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: var(--text-2); }
.muted { color: var(--text-2); }
.small { font-size: .855rem; }
.tiny { font-size: .78rem; }
.mono { font-family: var(--font-mono); }
.fw-600 { font-weight: 600; }

.text-gradient {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .8rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--brand-1);
  background: var(--brand-soft);
  padding: .35rem .85rem; border-radius: 999px;
}
html[data-theme="dark"] .eyebrow { color: #a99dff; }

/* Yiddish / Hebrew text */
.rtl, .right-to-left {
  direction: rtl;
  text-align: right;
}
.hebrew, .transcript-text, .full-transcript, textarea.hebrew {
  font-family: var(--font-hebrew);
  font-size: 1.12em;
  line-height: 1.95;
}

/* ---------- Layout --------------------------------------------------------- */
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: clamp(1rem, 3vw, 1.75rem); }
.container-wide { max-width: 1320px; }
.container-narrow { max-width: 880px; }

.section { padding-block: clamp(3.2rem, 7vw, 5.5rem); }
.section-tint { background: var(--surface-2); }
html[data-theme="dark"] .section-tint { background: rgba(255, 255, 255, .02); }

.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.flex { display: flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.wrap { flex-wrap: wrap; }
.gap-1 { gap: .35rem; } .gap-2 { gap: .65rem; } .gap-3 { gap: 1rem; } .gap-4 { gap: 1.5rem; }

.text-center { text-align: center; }
.mt-1 { margin-top: .35rem; } .mt-2 { margin-top: .65rem; } .mt-3 { margin-top: 1rem; } .mt-4 { margin-top: 1.6rem; } .mt-5 { margin-top: 2.4rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .35rem; } .mb-2 { margin-bottom: .65rem; } .mb-3 { margin-bottom: 1rem; } .mb-4 { margin-bottom: 1.6rem; } .mb-5 { margin-bottom: 2.4rem; }
.mx-auto { margin-inline: auto; }
.w-100 { width: 100%; }
.hide { display: none !important; }

/* ---------- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: 600 .95rem/1 var(--font-ui);
  padding: .72rem 1.3rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease,
              border-color .16s ease, color .16s ease, opacity .16s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[disabled] { opacity: .55; pointer-events: none; }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }

.btn-primary {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(84, 51, 255, .25);
}
.btn-primary:hover { box-shadow: var(--glow); color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--brand-1); color: var(--brand-1); background: var(--brand-soft); }

.btn-soft { background: var(--brand-soft); color: var(--brand-1); }
html[data-theme="dark"] .btn-soft { color: #b4a8ff; }
.btn-soft:hover { background: var(--brand-1); color: #fff; }

.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover { background: #0ca06f; color: #fff; box-shadow: 0 8px 24px rgba(16, 185, 129, .35); }

.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-danger-ghost { background: transparent; border-color: rgba(239, 68, 68, .45); color: var(--err); }
.btn-danger-ghost:hover { background: rgba(239, 68, 68, .10); }

.btn-light { background: #fff; color: #18181b; }
.btn-light:hover { box-shadow: 0 10px 30px rgba(0, 0, 0, .22); color: var(--brand-1); }
.btn-outline-light { background: transparent; border-color: rgba(255, 255, 255, .55); color: #fff; }
.btn-outline-light:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.btn-sm { padding: .45rem .85rem; font-size: .85rem; border-radius: 10px; }
.btn-lg { padding: .95rem 1.8rem; font-size: 1.05rem; border-radius: 14px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 11px;
  border: 1px solid var(--line); background: transparent; color: var(--text-2);
  cursor: pointer; transition: all .16s ease;
}
.icon-btn:hover { color: var(--brand-1); border-color: var(--brand-1); background: var(--brand-soft); }
.icon-btn svg { width: 19px; height: 19px; }

/* theme toggle shows the scheme you'd switch TO: moon in light mode, sun in dark */
.ico-sun { display: none; }
html[data-theme="dark"] .ico-sun { display: inline; }
html[data-theme="dark"] .ico-moon { display: none; }

/* ---------- Navbar --------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { height: 100%; display: flex; align-items: center; gap: 1.2rem; }

.brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-weight: 800; font-size: 1.22rem; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; flex: none; box-shadow: 0 3px 10px rgba(84, 51, 255, .35); }

.nav-links { display: flex; align-items: center; gap: .35rem; margin-inline: auto; }
.nav-link {
  padding: .5rem .85rem; border-radius: 10px;
  color: var(--text-2); font-weight: 600; font-size: .93rem; text-decoration: none;
  transition: color .15s ease, background-color .15s ease;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-link.active { color: var(--brand-1); background: var(--brand-soft); }

.nav-actions { display: flex; align-items: center; gap: .6rem; margin-left: auto; }

.nav-burger { display: none; }

@media (max-width: 900px) {
  .nav-links, .nav-actions .btn, .nav-actions .menu-wrap { display: none; }
  .nav-burger { display: inline-flex; }
  .nav-menu {
    position: fixed; inset: var(--nav-h) 0 auto 0; z-index: 99;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    padding: 1rem clamp(1rem, 4vw, 1.6rem) 1.4rem;
    display: none; flex-direction: column; gap: .25rem;
    max-height: calc(100dvh - var(--nav-h)); overflow: auto;
  }
  .nav-menu.open { display: flex; }
  .nav-menu .nav-link { padding: .8rem 1rem; font-size: 1rem; }
  .nav-menu .btn { margin-top: .5rem; }
}
@media (min-width: 901px) { .nav-menu { display: none !important; } }

/* Dropdown menu */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 120;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: .45rem;
  display: none;
}
.menu.open { display: block; animation: pop .14s ease; }
.menu-item {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; text-align: left;
  padding: .6rem .8rem; border: 0; background: none; cursor: pointer;
  border-radius: 9px; color: var(--text); font: 500 .92rem var(--font-ui);
  text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item svg { width: 16px; height: 16px; color: var(--text-2); }
.menu-sep { height: 1px; background: var(--line); margin: .4rem .3rem; }
@keyframes pop { from { opacity: 0; transform: translateY(-5px) scale(.98); } to { opacity: 1; transform: none; } }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; text-transform: uppercase; flex: none;
}

/* ---------- Hero / aurora -------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: clamp(4rem, 9vw, 7.5rem) clamp(3.4rem, 7vw, 6rem);
  isolation: isolate;
}
.hero::before {
  content: "";
  position: absolute; inset: -40% -20%;
  z-index: -2;
  background:
    radial-gradient(38% 45% at 18% 28%, rgba(84, 51, 255, .32), transparent 70%),
    radial-gradient(34% 42% at 82% 18%, rgba(32, 189, 255, .26), transparent 70%),
    radial-gradient(30% 40% at 65% 80%, rgba(140, 80, 255, .18), transparent 70%);
  filter: blur(48px);
  animation: aurora 16s ease-in-out infinite alternate;
}
.hero::after {
  content: "";
  position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .035 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes aurora {
  from { transform: translate3d(-2%, -1%, 0) rotate(-1.5deg) scale(1); }
  to   { transform: translate3d(2%, 2%, 0) rotate(1.5deg) scale(1.06); }
}

.hero-letters { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero-letters span {
  position: absolute;
  font-family: var(--font-hebrew);
  font-weight: 700;
  color: var(--brand-1);
  opacity: .07;
  animation: floaty 9s ease-in-out infinite;
}
html[data-theme="dark"] .hero-letters span { opacity: .10; }
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-18px) rotate(3deg); }
}

/* waveform mock */
.wave { display: inline-flex; align-items: center; gap: 4px; height: 48px; }
.wave i {
  display: block; width: 5px; border-radius: 3px;
  background: var(--brand-grad);
  height: var(--h, 40%);
  animation: wavebar 1.3s ease-in-out calc(var(--i, 0) * .09s) infinite;
}
@keyframes wavebar {
  0%, 100% { transform: scaleY(.45); opacity: .55; }
  50% { transform: scaleY(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .hero::before, .hero-letters span, .wave i,
  .float, .progress-bar.animated { animation: none !important; }
}

/* ---------- Cards ----------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.05rem 1.4rem;
  border-bottom: 1px solid var(--line);
}
.card-h h1, .card-h h2, .card-h h3, .card-h h4, .card-h h5 { margin: 0; font-size: 1.02rem; }
.card-b { padding: 1.4rem; }
.card-f { padding: 1.05rem 1.4rem; border-top: 1px solid var(--line); }
.card-hover { transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
.card-hover:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brand-1) 35%, var(--line)); }

.icon-tile {
  width: 52px; height: 52px; border-radius: 15px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-1);
}
html[data-theme="dark"] .icon-tile { color: #b4a8ff; }
.icon-tile svg { width: 24px; height: 24px; }
.icon-tile.grad { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 18px rgba(84, 51, 255, .35); }
.icon-tile.ok { background: rgba(16, 185, 129, .12); color: var(--ok); }
.icon-tile.warn { background: rgba(245, 158, 11, .14); color: var(--warn); }

.float { animation: floaty 7s ease-in-out infinite; }

/* ---------- Pills / status badges ------------------------------------------ */
.pill {
  display: inline-flex; align-items: center; gap: .42rem;
  font-size: .78rem; font-weight: 600; line-height: 1;
  padding: .38rem .7rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-ok { background: rgba(16, 185, 129, .13); color: #0a8f63; }
.pill-warn { background: rgba(245, 158, 11, .15); color: #b45309; }
.pill-err { background: rgba(239, 68, 68, .13); color: #dc2626; }
.pill-info { background: rgba(56, 189, 248, .15); color: #0284c7; }
.pill-brand { background: var(--brand-soft); color: var(--brand-1); }
html[data-theme="dark"] .pill-ok { color: #34d399; }
html[data-theme="dark"] .pill-warn { color: #fbbf24; }
html[data-theme="dark"] .pill-err { color: #f87171; }
html[data-theme="dark"] .pill-info { color: #38bdf8; }
html[data-theme="dark"] .pill-brand { color: #b4a8ff; }
.pill.no-dot::before { display: none; }

/* ---------- Forms ------------------------------------------------------------ */
.field { margin-bottom: 1.15rem; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .42rem; }
.field .hint { font-size: .8rem; color: var(--text-2); margin-top: .35rem; }

.input, .select, .textarea {
  width: 100%;
  font: 400 .96rem var(--font-ui);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: .68rem .95rem;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
html[data-theme="dark"] .input, html[data-theme="dark"] .select, html[data-theme="dark"] .textarea { background: var(--surface-2); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: 0 0 0 4px var(--brand-ring);
}
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.textarea { resize: vertical; min-height: 110px; line-height: 1.65; }

.select {
  appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23878da8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
}

.input.is-invalid, .input-invalid { border-color: var(--err); }
.field-error { color: var(--err); font-size: .82rem; margin-top: .35rem; }

.check { display: flex; align-items: flex-start; gap: .6rem; font-size: .92rem; }
.check input[type="checkbox"], .check input[type="radio"] {
  width: 1.1rem; height: 1.1rem; margin-top: .18rem;
  accent-color: var(--brand-1); flex: none; cursor: pointer;
}
.check label { cursor: pointer; }

.input-group { display: flex; gap: .6rem; }
.input-group .input { flex: 1; }

/* segmented control (login method toggle) */
.segmented {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--surface-2); border-radius: 12px;
}
.segmented label {
  padding: .5rem 1.1rem; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: .9rem; color: var(--text-2);
  transition: all .15s ease;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + label { background: var(--surface); color: var(--brand-1); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + label { outline: 3px solid var(--brand-ring); }

/* ---------- Alerts / messages ------------------------------------------------ */
.alert {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .95rem 1.1rem;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: .93rem;
  margin-bottom: 1rem;
}
.alert > svg { width: 19px; height: 19px; flex: none; margin-top: .12rem; }
.alert-body { flex: 1; min-width: 0; }
.alert h6, .alert .alert-heading { margin: 0 0 .25rem; font-size: .95rem; font-family: var(--font-ui); font-weight: 700; }
.alert p:last-child, .alert ul:last-child { margin-bottom: 0; }

.alert-success { background: rgba(16, 185, 129, .10); border-color: rgba(16, 185, 129, .35); color: #067a55; }
.alert-info    { background: rgba(56, 189, 248, .10); border-color: rgba(56, 189, 248, .35); color: #086ca2; }
.alert-warning { background: rgba(245, 158, 11, .10); border-color: rgba(245, 158, 11, .35); color: #92610c; }
.alert-danger, .alert-error { background: rgba(239, 68, 68, .10); border-color: rgba(239, 68, 68, .35); color: #b91c1c; }
html[data-theme="dark"] .alert-success { color: #6ee7b7; }
html[data-theme="dark"] .alert-info    { color: #7dd3fc; }
html[data-theme="dark"] .alert-warning { color: #fcd34d; }
html[data-theme="dark"] .alert-danger, html[data-theme="dark"] .alert-error { color: #fca5a5; }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }

.alert-dismiss {
  background: none; border: 0; cursor: pointer; color: inherit;
  opacity: .6; padding: .15rem; line-height: 0; flex: none; border-radius: 6px;
}
.alert-dismiss:hover { opacity: 1; }
.alert.fade-out { opacity: 0; transform: translateY(-6px); transition: all .4s ease; }

.messages-region { position: relative; z-index: 60; }
.messages-region .container { padding-top: 1rem; }

/* ---------- Tables ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--line); }
.card-b > .table-wrap { border: 0; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th {
  text-align: left; font-size: .73rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-2);
  padding: .75rem 1rem; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: .85rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background-color .12s ease; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .empty { text-align: center; color: var(--text-2); padding: 2.4rem 1rem; }

/* ---------- Tabs --------------------------------------------------------------- */
.tabs {
  display: flex; gap: .25rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.3rem;
}
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  font: 600 .92rem var(--font-ui); color: var(--text-2);
  padding: .65rem 1.05rem;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-1); border-bottom-color: var(--brand-1); }
.tabpane { display: none; }
.tabpane.active { display: block; animation: fadeup .25s ease; }
@keyframes fadeup { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- Modals -------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(8, 9, 20, .55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .18s ease;
}
.modal-backdrop.show { opacity: 1; }

.modal {
  position: fixed; inset: 0; z-index: 151;
  display: none; align-items: flex-start; justify-content: center;
  padding: clamp(1rem, 6vh, 4rem) 1rem;
  overflow-y: auto;
}
.modal.open { display: flex; }
.modal-card {
  width: 100%; max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(.985); opacity: 0;
  transition: transform .2s ease, opacity .2s ease;
}
.modal.open .modal-card { transform: none; opacity: 1; }
body.modal-locked { overflow: hidden; }

/* ---------- Progress -------------------------------------------------------------- */
.progress { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-bar {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: var(--brand-grad);
  transition: width .3s ease;
}
.progress-bar.striped {
  background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%, transparent);
  background-size: 1rem 1rem;
}
.progress-bar.animated { animation: stripes .8s linear infinite; }
.progress-bar.bar-err { background: var(--err); }
@keyframes stripes { from { background-position: 1rem 0; } to { background-position: 0 0; } }

.spinner {
  width: 18px; height: 18px; flex: none;
  border: 2.5px solid var(--brand-ring);
  border-top-color: var(--brand-1);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Accordion (native details) ---------------------------------------------- */
details.faq {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: .8rem;
  overflow: hidden;
}
details.faq summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.05rem 1.25rem;
  font-weight: 600; font-size: .98rem;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after {
  content: "+";
  font-size: 1.3rem; line-height: 1; color: var(--brand-1);
  transition: transform .2s ease; flex: none;
}
details.faq[open] summary::after { transform: rotate(45deg); }
details.faq .faq-body { padding: 0 1.25rem 1.15rem; color: var(--text-2); font-size: .94rem; }

/* ---------- Dropzone -------------------------------------------------------------------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  padding: clamp(2rem, 5vw, 3.2rem);
  text-align: center;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--brand-1);
  background: var(--brand-soft);
}
.dropzone.drag { transform: scale(1.01); }
.dropzone .dz-icon { width: 58px; height: 58px; margin-inline: auto; color: var(--brand-1); }

/* ---------- App shell (dashboard) --------------------------------------------------------- */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 1.6rem; padding-block: 1.8rem 3.2rem; }
@media (max-width: 980px) { .app { grid-template-columns: 1fr; } }

.side-user { display: flex; align-items: center; gap: .8rem; padding: 1.1rem 1.2rem; border-bottom: 1px solid var(--line); }
.side-user .avatar { width: 42px; height: 42px; font-size: 1.05rem; }
.side-user .who { min-width: 0; }
.side-user .who strong { display: block; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .who span { display: block; font-size: .78rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); }
.side-stats .ss { background: var(--surface-2); border-radius: 11px; padding: .55rem .7rem; }
.side-stats .ss b { display: block; font-size: .95rem; }
.side-stats .ss span { font-size: .7rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }

.side-nav { padding: .7rem; display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .62rem .85rem; border-radius: 11px;
  color: var(--text-2); font-weight: 600; font-size: .92rem; text-decoration: none;
  transition: all .14s ease;
}
.side-link svg { width: 18px; height: 18px; flex: none; }
.side-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.side-link.active { color: var(--brand-1); background: var(--brand-soft); }
html[data-theme="dark"] .side-link.active { color: #b4a8ff; }

@media (max-width: 980px) {
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-link { padding: .5rem .75rem; }
}

/* stat tiles */
.stat { display: flex; align-items: center; gap: 1rem; padding: 1.15rem 1.3rem; }
.stat .icon-tile { width: 46px; height: 46px; border-radius: 13px; }
.stat b { display: block; font-size: 1.35rem; font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--text-2); }

/* ---------- Transcript view ----------------------------------------------------------------- */
.chunk {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.chunk:last-child { border-bottom: 0; }
.chunk:hover { background: var(--surface-2); }
.chunk.active { background: var(--brand-soft); border-left-color: var(--brand-1); }
.chunk-meta { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .3rem; }
.chunk-time { font-family: var(--font-mono); font-size: .74rem; color: var(--text-2); }
.chunk-actions { display: flex; gap: .2rem; }
.chunk-actions .icon-btn { width: 30px; height: 30px; border-radius: 8px; border-color: transparent; }
.chunk-actions .icon-btn svg { width: 15px; height: 15px; }
.transcript-text p { margin-bottom: .35rem; }
.transcript-text p:last-child { margin-bottom: 0; }

audio { width: 100%; border-radius: 12px; }
html[data-theme="dark"] audio { color-scheme: dark; }

/* ---------- Pricing ---------------------------------------------------------------------------- */
.price-card { position: relative; display: flex; flex-direction: column; height: 100%; }
.price-card .card-b { flex: 1; display: flex; flex-direction: column; }
.price-card.featured {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--brand-grad) border-box;
  box-shadow: var(--shadow-md);
}
.price-tag { font-family: var(--font-display); font-size: 2.7rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.price-tag small { font-size: .95rem; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.featured-flag {
  position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  background: var(--brand-grad); color: #fff;
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: .35rem .95rem; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(84, 51, 255, .4);
  white-space: nowrap;
}
.feature-list { list-style: none; margin: 0 0 1.4rem; padding: 0; }
.feature-list li { display: flex; align-items: flex-start; gap: .6rem; padding: .42rem 0; font-size: .93rem; }
.feature-list li svg { width: 18px; height: 18px; flex: none; margin-top: .15rem; color: var(--ok); }
.feature-list li.off { color: var(--text-2); }
.feature-list li.off svg { color: var(--text-2); opacity: .6; }

/* ---------- Auth pages --------------------------------------------------------------------------- */
.auth {
  position: relative;
  min-height: calc(100dvh - var(--nav-h));
  display: grid; place-items: center;
  padding-block: 2.6rem 3.5rem;
  overflow: hidden;
}
.auth-card { width: min(460px, 100%); position: relative; }
.auth-head { text-align: center; padding: 1.9rem 1.6rem 0; }
.auth-head .brand-mark { width: 52px; height: 52px; border-radius: 15px; margin-bottom: .9rem; }

/* ---------- Footer ---------------------------------------------------------------------------------- */
.footer {
  margin-top: 4rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 3.2rem 0 2rem;
}
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; gap: 2rem; }
@media (max-width: 880px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .footer-grid { grid-template-columns: 1fr; } }
.footer h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-2); margin-bottom: .9rem; font-family: var(--font-ui); }
.footer ul { list-style: none; margin: 0; padding: 0; }
.footer li { margin-bottom: .55rem; }
.footer a { color: var(--text-2); font-size: .92rem; }
.footer a:hover { color: var(--brand-1); }
.footer-bottom {
  margin-top: 2.4rem; padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-size: .85rem; color: var(--text-2);
}

/* ---------- Reveal on scroll -------------------------------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
.reveal-d1 { transition-delay: .08s; }
.reveal-d2 { transition-delay: .16s; }
.reveal-d3 { transition-delay: .24s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- Gradient panel (CTA) ------------------------------------------------------------------------ */
.panel-grad {
  position: relative; overflow: hidden;
  background: var(--brand-grad);
  color: #fff;
  border-radius: var(--r-xl);
  padding: clamp(2.2rem, 5vw, 3.6rem);
}
.panel-grad h2, .panel-grad h3 { color: #fff; }
.panel-grad .muted, .panel-grad p { color: rgba(255, 255, 255, .82); }
.panel-grad::after {
  content: "";
  position: absolute; right: -60px; top: -60px;
  width: 240px; height: 240px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}

/* numbered steps */
.stepnum {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  background: var(--brand-grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
  box-shadow: 0 5px 16px rgba(84, 51, 255, .35);
}

/* ---------- v3: player toolbar ------------------------------------------------ */
.player-bar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .6rem .75rem;
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.select-mini {
  width: auto; font: 600 .84rem var(--font-ui); color: var(--text);
  background-color: var(--surface);
  border: 1.5px solid var(--line); border-radius: 9px;
  padding: .35rem 1.9rem .35rem .65rem;
  appearance: none; cursor: pointer;
  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='%23878da8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center;
}
.player-bar .icon-btn { width: 34px; height: 34px; border-radius: 9px; }
.player-bar .sep { width: 1px; height: 22px; background: var(--line); margin-inline: .15rem; }

kbd {
  font: 600 .72rem var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: .12rem .4rem;
  color: var(--text-2);
}

/* per-chunk copy button appears on hover (always visible on touch) */
.chunk .copy-chunk { opacity: 0; transition: opacity .15s ease; }
.chunk:hover .copy-chunk, .chunk:focus-within .copy-chunk { opacity: 1; }
@media (hover: none) { .chunk .copy-chunk { opacity: 1; } }

/* ---------- v3: dashboard search + filter chips ------------------------------- */
.searchbox { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.searchbox svg {
  position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-2); pointer-events: none;
}
.searchbox .input { padding: .45rem .8rem .45rem 2.1rem; font-size: .88rem; border-radius: 10px; }

.filter-chip {
  appearance: none; cursor: pointer;
  font: 600 .8rem var(--font-ui); color: var(--text-2);
  background: var(--surface-2); border: 1px solid transparent;
  padding: .35rem .8rem; border-radius: 999px;
  transition: all .14s ease;
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active { background: var(--brand-soft); color: var(--brand-1); border-color: color-mix(in srgb, var(--brand-1) 35%, transparent); }
html[data-theme="dark"] .filter-chip.active { color: #b4a8ff; }

/* onboarding steps in empty states */
.onboard { display: grid; gap: .9rem; max-width: 460px; margin-inline: auto; text-align: left; }
.onboard .step { display: flex; gap: .8rem; align-items: flex-start; }
.onboard .stepnum { width: 32px; height: 32px; font-size: .85rem; }

/* ---------- v4: Yiddish on-screen keyboard ------------------------------------ */
.vkb {
  margin-top: 1rem;
  padding: 1rem;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
  user-select: none;
  -webkit-user-select: none;
  direction: ltr;               /* keys are laid out in physical-keyboard order */
  touch-action: manipulation;
  animation: fadeup .18s ease;
}
.vkb-row { display: flex; justify-content: center; gap: .45rem; margin-bottom: .45rem; }
.vkb-row:last-child { margin-bottom: 0; }
.vkb-key {
  min-width: 44px; height: 48px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-bottom-width: 3px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-hebrew);
  font-size: 1.35rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 2px rgba(0,0,0,0.03);
  transition: all 0.1s cubic-bezier(0.2, 0, 0, 1);
  display: flex; align-items: center; justify-content: center;
}
.vkb-key:hover { 
  background: var(--surface-2); 
  transform: translateY(1px);
  border-bottom-width: 2px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.03);
}
.vkb-key:active, .vkb-key.pressed {
  background: var(--brand-soft);
  border-color: var(--brand-1);
  transform: translateY(3px);
  border-bottom-width: 0px;
}
.vkb-key:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 1px; }
.vkb-key--fn {
  min-width: 72px;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
  background: color-mix(in srgb, var(--surface) 55%, var(--surface-2));
}
.vkb-key--space { flex: 1; max-width: 340px; }
@media (max-width: 560px) {
  .vkb-key { min-width: 26px; height: 40px; font-size: 1rem; }
  .vkb-key--fn { min-width: 56px; font-size: .85rem; }
  .vkb-row { gap: .2rem; }
}

/* v4: in-page audio recorder */
.rec-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--err); animation: recblink 1s ease-in-out infinite;
}
@keyframes recblink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- v5: AI word-choice resolver ------------------------------------- */
.choice-review {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  background: rgba(245, 158, 11, .07);
  border-radius: var(--r-md);
}
.choice-review-head {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-bottom: .8rem;
}
.choice-review-head svg { width: 18px; height: 18px; color: var(--warn); flex: none; }
.choice-preview {
  font-size: 1.12em;
  line-height: 2.1;
  white-space: pre-wrap;
  word-break: break-word;
}
.choice-group {
  display: inline-flex; gap: 3px; flex-wrap: wrap;
  padding: 2px 4px; margin: 0 1px;
  border-radius: 8px;
  background: rgba(245, 158, 11, .14);
  outline: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent);
  vertical-align: baseline;
}
.choice-opt {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: .05em .5em;
  transition: background-color .12s ease, border-color .12s ease, transform .06s ease;
}
.choice-opt.top { border-color: color-mix(in srgb, var(--brand-1) 45%, var(--line)); }
.choice-opt:hover { background: var(--brand-1); color: #fff; border-color: var(--brand-1); }
.choice-opt:active { transform: translateY(1px); }

/* read-only views: AI's top pick with alternatives in the tooltip */
.alt-word {
  text-decoration: underline dotted color-mix(in srgb, var(--warn) 70%, transparent);
  text-underline-offset: 3px;
  cursor: help;
}

/* ---------- v6: TTS voice cards --------------------------------------------- */
.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .65rem;
}
.voice-card { position: relative; cursor: pointer; }
.voice-card input { position: absolute; opacity: 0; pointer-events: none; }
.voice-card-body {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .8rem .9rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.voice-card:hover .voice-card-body { border-color: color-mix(in srgb, var(--brand-1) 45%, var(--line)); }
.voice-card input:checked + .voice-card-body {
  border-color: var(--brand-1);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.voice-ic { font-size: 1.2rem; }
.voice-name { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-tag { font-size: .72rem; color: var(--text-2); }
.voice-del {
  position: absolute; top: 6px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: var(--surface-2); color: var(--text-2);
  cursor: pointer; line-height: 1; font-size: 1rem;
  opacity: 0; transition: opacity .12s ease;
}
.voice-card:hover .voice-del { opacity: 1; }
.voice-del:hover { background: var(--err); color: #fff; }
input[type="range"] { accent-color: var(--brand-1); }

/* ---------- Print ------------------------------------------------------------------------------------------ */
@media print {
  .nav, .footer, .side, .no-print, .nav-menu, .player-bar, .tabs, .alert-dismiss { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; }
  .app { display: block; }
  /* print the timestamped chunk view only — the other tabs duplicate its text */
  #chunks-content { display: block !important; }
  #full-content, #edit-content { display: none !important; }
  .chunk { break-inside: avoid; }
}

/* ---------- TTS studio: single focused composer ---------- */
.tts-canvas { max-width: 780px; }
.tts-composer { box-shadow: var(--shadow-md); }
