/* Famiglot — design system and app styles */

:root {
  --bg: #f7f4ee;
  --bg-elev: #ffffff;
  --bg-sunk: #efeae1;
  --ink: #1f1c24;
  --ink-2: #4a4552;
  --ink-3: #7a7482;
  --line: #e4ddd1;
  --line-strong: #d3cab9;
  --brand: #c2412d;
  --brand-ink: #ffffff;
  --brand-soft: #fbe6e0;
  --brand-strong: #9f3020;
  --gold: #e3a32f;
  --gold-soft: #fbefd5;
  --ok: #2f8a62;
  --ok-soft: #dcf1e6;
  --bad: #c23a3a;
  --bad-soft: #f9e0de;
  --info: #2f6f9f;
  --info-soft: #ddebf6;
  --violet: #6b4fbb;
  --violet-soft: #e9e3f8;
  --shadow-1: 0 1px 2px rgb(31 28 36 / .06), 0 1px 1px rgb(31 28 36 / .04);
  --shadow-2: 0 6px 24px -8px rgb(31 28 36 / .18), 0 2px 6px rgb(31 28 36 / .06);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --sidebar: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15131a; --bg-elev: #1e1b24; --bg-sunk: #110f15;
    --ink: #f1edf5; --ink-2: #c4bdcc; --ink-3: #8f8899;
    --line: #2d2934; --line-strong: #3b3644;
    --brand: #e8644d; --brand-ink: #1a0d0a; --brand-soft: #3a1f1a; --brand-strong: #f08672;
    --gold: #f0b54a; --gold-soft: #3a2e17;
    --ok: #4cc08c; --ok-soft: #173327; --bad: #f06b6b; --bad-soft: #3a1c1c;
    --info: #6aaee0; --info-soft: #172b3a; --violet: #a993f0; --violet-soft: #272040;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 10px 30px -10px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15131a; --bg-elev: #1e1b24; --bg-sunk: #110f15;
  --ink: #f1edf5; --ink-2: #c4bdcc; --ink-3: #8f8899;
  --line: #2d2934; --line-strong: #3b3644;
  --brand: #e8644d; --brand-ink: #1a0d0a; --brand-soft: #3a1f1a; --brand-strong: #f08672;
  --gold: #f0b54a; --gold-soft: #3a2e17;
  --ok: #4cc08c; --ok-soft: #173327; --bad: #f06b6b; --bad-soft: #3a1c1c;
  --info: #6aaee0; --info-soft: #172b3a; --violet: #a993f0; --violet-soft: #272040;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 10px 30px -10px rgb(0 0 0 / .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.55 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
h1 { font: 600 clamp(1.7rem, 3.4vw, 2.3rem)/1.15 var(--font-display); letter-spacing: -.02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.es { font-family: var(--font-display); }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; padding: 22px 14px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--gold)); color: #fff;
  font: 700 1.05rem/1 var(--font-display); box-shadow: var(--shadow-1);
}
.brand-name { font: 600 1.25rem/1 var(--font-display); letter-spacing: -.02em; }
.brand-sub { display: block; font: 500 .7rem/1.2 var(--font); color: var(--ink-3); letter-spacing: .02em; margin-top: 3px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--ink-2); font-weight: 520; font-size: .95rem; position: relative;
}
.nav-link:hover { background: var(--bg-sunk); text-decoration: none; color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-1); }
.nav-link[aria-current="page"] .ico { color: var(--brand); }
.nav-link .badge { margin-left: auto; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ico { width: 20px; height: 20px; flex: none; }
.main { min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 96px; }
.page { max-width: 1080px; margin: 0 auto; }
.page-narrow { max-width: 760px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--ink-2); margin: 0; max-width: 60ch; }
.eyebrow { font-size: .75rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }

.bottom-nav { display: none; }
.topbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px 16px 108px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 30;
    background: color-mix(in srgb, var(--bg-elev) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
    font-size: .68rem; font-weight: 560; color: var(--ink-3); border-radius: 10px; position: relative;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a[aria-current="page"] { color: var(--brand); }
  .bottom-nav .ico { width: 22px; height: 22px; }
  .bottom-nav .dot { position: absolute; top: 4px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
}

/* ---------- Surfaces ---------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-1);
}
.card.flat { box-shadow: none; }
.card.sunk { background: var(--bg-sunk); box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
a.card { color: inherit; display: block; transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
a.card.row { display: flex; flex-wrap: nowrap; }
a.card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
section + section { margin-top: 32px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.section-title h2 { margin: 0; }

.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: clamp(22px, 4vw, 34px);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--gold) 38%, transparent) 0%, transparent 55%),
    linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff; box-shadow: var(--shadow-2);
}
.hero h1 { color: #fff; margin-bottom: 6px; }
.hero p { color: rgb(255 255 255 / .88); max-width: 56ch; }
.hero .btn { background: #fff; color: var(--brand-strong); border-color: #fff; }
.hero .btn.ghost { background: rgb(255 255 255 / .14); color: #fff; border-color: rgb(255 255 255 / .35); }
.hero-deco { position: absolute; right: -10px; bottom: -34px; font: 700 9rem/1 var(--font-display); color: rgb(255 255 255 / .09); pointer-events: none; user-select: none; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--bg-elev); color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: transform .08s ease, background .15s, box-shadow .15s, border-color .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--ink-3); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); box-shadow: 0 4px 14px -6px var(--brand); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg-sunk); }
.btn.sm { padding: 7px 12px; font-size: .85rem; border-radius: 10px; }
.btn.lg { padding: 14px 22px; font-size: 1.02rem; border-radius: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.icon { padding: 9px; border-radius: 11px; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.input, .textarea, .select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--bg-elev); transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }

.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px 18px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg-elev); cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
}
.choice:hover { border-color: var(--line-strong); background: var(--bg-sunk); }
.choice:active { transform: scale(.995); }
.choice .key {
  width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; background: var(--bg-sunk); color: var(--ink-2); border: 1px solid var(--line);
}
.choice.selected { border-color: var(--brand); background: var(--brand-soft); }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.correct .key { background: var(--ok); color: #fff; border-color: var(--ok); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.wrong .key { background: var(--bad); color: #fff; border-color: var(--bad); }
.choice[disabled] { cursor: default; }
.choice .big { font-size: 1.6rem; }
.choice b { display: block; }

/* ---------- Badges, chips, progress ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 650; background: var(--bg-sunk); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.badge.brand { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.badge.gold { background: var(--gold-soft); color: color-mix(in srgb, var(--gold) 60%, var(--ink)); border-color: transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.level-pill {
  display: inline-grid; place-items: center; min-width: 46px; height: 28px; padding: 0 10px; border-radius: 9px;
  font: 700 .85rem/1 var(--font); background: var(--ink); color: var(--bg);
}
.bar { height: 8px; border-radius: 99px; background: var(--bg-sunk); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--gold)); transition: width .4s ease; }
.bar.ok > i { background: var(--ok); }
.bar.gold > i { background: var(--gold); }
.ring { --p: 0; --size: 72px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--bg-sunk) 0); position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg-elev); }
.ring span { position: relative; font-weight: 700; font-size: .95rem; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font: 650 1.8rem/1.1 var(--font-display); letter-spacing: -.02em; }
.stat .lbl { font-size: .8rem; color: var(--ink-3); font-weight: 550; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat-card { padding: 16px 18px; }
.stat-card .ico-bubble { margin-bottom: 10px; }
.ico-bubble { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 1.15rem; flex: none; }
.ico-bubble.gold { background: var(--gold-soft); color: var(--gold); }
.ico-bubble.ok { background: var(--ok-soft); color: var(--ok); }
.ico-bubble.info { background: var(--info-soft); color: var(--info); }
.ico-bubble.violet { background: var(--violet-soft); color: var(--violet); }
.emoji-tile { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; background: var(--bg-sunk); flex: none; }

.spark { display: flex; align-items: flex-end; gap: 4px; height: 44px; }
.spark i { flex: 1; min-height: 3px; border-radius: 4px 4px 2px 2px; background: color-mix(in srgb, var(--brand) 30%, var(--bg-sunk)); }
.spark i.on { background: var(--brand); }
.spark i.today { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
a.list-item { color: inherit; border-radius: 10px; padding-inline: 10px; }
a.list-item:hover { background: var(--bg-sunk); text-decoration: none; }

.check {
  width: 26px; height: 26px; flex: none; border-radius: 8px; border: 2px solid var(--line-strong);
  display: grid; place-items: center; background: var(--bg-elev); cursor: pointer; transition: all .15s; color: transparent;
}
.check.working { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.check.done { border-color: var(--ok); background: var(--ok); color: #fff; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 13px; background: var(--bg-sunk); border: 1px solid var(--line); flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--ink-2); }
.tab[aria-selected="true"] { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Flashcards ---------- */
.flash-wrap { perspective: 1400px; }
.flash {
  position: relative; min-height: 340px; border-radius: 22px; transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.2,.8,.2,1); cursor: pointer;
}
.flash.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: inherit; padding: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px;
  background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-2);
}
.flash-back { transform: rotateY(180deg); }
.flash-word { font: 600 clamp(1.8rem, 6vw, 2.6rem)/1.15 var(--font-display); letter-spacing: -.02em; }
.flash-tr { font-size: 1.3rem; font-weight: 600; color: var(--brand); }
.flash-ex { color: var(--ink-2); max-width: 44ch; }
.flash-note { font-size: .88rem; padding: 8px 12px; border-radius: 10px; background: var(--gold-soft); max-width: 46ch; }
.flash-meta { position: absolute; top: 16px; left: 18px; right: 18px; display: flex; justify-content: space-between; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate .btn { flex-direction: column; gap: 0; padding: 10px 6px; font-size: .9rem; }
.rate .btn small { font-weight: 500; color: var(--ink-3); font-size: .72rem; }
.rate .again { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.rate .good { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 86%; }
.msg.you { align-self: flex-end; flex-direction: row-reverse; }
.bubble { padding: 12px 16px; border-radius: 18px; background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.msg.ai .bubble { border-top-left-radius: 6px; }
.msg.you .bubble { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); border-top-right-radius: 6px; }
.bubble .es { font-size: 1.08rem; }
.bubble .tr { font-size: .86rem; color: var(--ink-3); margin-top: 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--bg-sunk); font-size: 1.1rem; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.fix { align-self: flex-end; max-width: 86%; font-size: .88rem; padding: 10px 14px; border-radius: 12px; background: var(--gold-soft); border: 1px dashed color-mix(in srgb, var(--gold) 50%, transparent); }
.fix.good { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.composer {
  position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end; padding: 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 18px; margin-top: 16px;
}
.composer textarea { flex: 1; border: 0; background: transparent; resize: none; min-height: 44px; max-height: 160px; padding: 10px; outline: none; }
@media (max-width: 900px) { .composer { bottom: 84px; } }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.mic.on { background: var(--bad); color: #fff; border-color: var(--bad); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 50%, transparent); } 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Prose (AI explanations) ---------- */
.prose { line-height: 1.65; }
.prose p { margin: 0 0 .8em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 .9em; }
.prose li { margin: .25em 0; }
.prose h3, .prose h4 { margin: 1.1em 0 .4em; }
.prose code { background: var(--bg-sunk); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.prose strong { font-weight: 650; }

.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--info-soft); color: var(--ink); }
.callout.warn { background: var(--gold-soft); }
.callout.ok { background: var(--ok-soft); }
.callout.bad { background: var(--bad-soft); }
.callout .ico { color: var(--info); margin-top: 2px; }

.speak { border: 0; background: var(--bg-sunk); width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none; vertical-align: middle; }
.speak:hover { background: var(--brand-soft); color: var(--brand); }
.speak.big { width: 56px; height: 56px; }
.speak.big .ico { width: 26px; height: 26px; }

.dropzone { display: block; border: 2px dashed var(--line-strong); border-radius: 16px; padding: 22px; text-align: center; background: var(--bg-sunk); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs figure { margin: 0; position: relative; width: 88px; height: 88px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .6); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }

.diff del { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; border-radius: 4px; padding: 0 3px; }
.diff ins { background: var(--ok-soft); color: var(--ok); text-decoration: none; border-radius: 4px; padding: 0 3px; font-weight: 600; }

/* Stage path */
.stages { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.stage-chip {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--bg-elev); cursor: pointer; min-width: 150px; text-align: left;
}
.stage-chip[aria-selected="true"] { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.stage-chip .lvl { font: 700 .8rem/1 var(--font); padding: 6px 7px; border-radius: 8px; color: #fff; }
.stage-chip small { display: block; color: var(--ink-3); font-size: .74rem; }

/* Login */
.login {
  min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.login-art {
  position: relative; overflow: hidden; padding: 48px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(90% 70% at 85% 10%, color-mix(in srgb, var(--gold) 55%, transparent), transparent 60%),
    radial-gradient(70% 60% at 0% 100%, rgb(255 255 255 / .12), transparent 60%),
    linear-gradient(150deg, #c2412d 0%, #8f2a1c 100%);
}
.login-art h1 { color: #fff; font-size: clamp(2.2rem, 4.5vw, 3.4rem); max-width: 14ch; }
.login-art p { color: rgb(255 255 255 / .85); max-width: 42ch; font-size: 1.05rem; }
.login-words { position: absolute; inset: 0; pointer-events: none; font-family: var(--font-display); color: rgb(255 255 255 / .1); }
.login-words span { position: absolute; font-size: var(--s); left: var(--x); top: var(--y); transform: rotate(var(--r)); }
.login-panel { display: grid; place-items: center; padding: 32px 20px; }
.login-box { width: 100%; max-width: 380px; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 13px 18px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg-elev); font-weight: 600; cursor: pointer; box-shadow: var(--shadow-1); color: var(--ink); }
.gbtn:hover { text-decoration: none; box-shadow: var(--shadow-2); }
.features { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.features li { display: flex; gap: 12px; align-items: flex-start; color: rgb(255 255 255 / .92); }
.features li span:first-child { width: 30px; height: 30px; border-radius: 9px; background: rgb(255 255 255 / .16); display: grid; place-items: center; flex: none; }
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 32px 20px; min-height: 0; }
  .login-art .features { display: none; }
}

/* Toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 900px) { .toasts { left: 16px; bottom: 96px; } }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-2); font-size: .92rem; font-weight: 520; animation: rise .25s ease; max-width: 420px; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* Sheet (mobile "more" menu) and modal */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 50; animation: fade .2s; }
.sheet { position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 51; background: var(--bg-elev); border-radius: 22px; padding: 10px; box-shadow: var(--shadow-2); animation: rise .25s ease; }
.sheet .nav-link { padding: 14px; }
@keyframes fade { from { opacity: 0; } }

.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--bg-sunk), var(--line), var(--bg-sunk)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: grid; place-items: center; gap: 12px; padding: 48px 16px; color: var(--ink-3); text-align: center; }

.empty { text-align: center; padding: 36px 16px; color: var(--ink-3); }
.empty .emoji-tile { margin: 0 auto 12px; }

details.disclosure { border: 1px solid var(--line); border-radius: 14px; background: var(--bg-elev); }
details.disclosure > summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 10px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "▾"; margin-left: auto; color: var(--ink-3); transition: transform .2s; }
details.disclosure[open] > summary::after { transform: rotate(180deg); }
details.disclosure > .body { padding: 0 16px 16px; }

table.simple { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.simple th, table.simple td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.simple th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; }

::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 700px) { .hide-sm { display: none; } }
.split { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: 20px; align-items: start; }
.split > .side { position: sticky; top: 20px; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } .split > .side { position: static; } }
input[type=range], input[type=checkbox] { accent-color: var(--brand); }
button.list-item { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.divider { display: flex; align-items: center; gap: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
