:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --text: #1d1b18;
  --muted: #6b655c;
  --line: #e2dcd2;
  --accent: #3b6fd8;
  --good: #1d7f4e;
  --bad: #c0392b;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140f; --surface: #1f1d18; --surface-2: #2a2721; --text: #f1ece3;
    --muted: #a59d90; --line: #36322b; --good: #4cc38a; --bad: #ef6b5b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.6 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
a { color: inherit; }
button { font: inherit; cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-family: Fraunces, serif; font-size: .9rem;
}
.brand-logo { width: 34px; height: 34px; display: block; border-radius: 10px; box-shadow: 0 2px 8px rgb(47 95 208 / .3); }
.brand-text { font-family: Fraunces, Georgia, serif; font-size: 1.15rem; letter-spacing: .01em; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 4px 10px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); font-size: .85rem; white-space: nowrap;
}

.view { max-width: 1080px; margin: 0 auto; padding: 28px 20px 120px; }

.hero { display: grid; gap: 24px; grid-template-columns: 1.4fr 1fr; align-items: center; margin-bottom: 32px; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 52ch; }
.hero-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.hero-card h3 { font-size: 1.05rem; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 14px; }
.section-title h2 { font-size: 1.4rem; margin: 0; }
.muted { color: var(--muted); }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; text-decoration: none; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--c, var(--accent)); }
.card .top { display: flex; align-items: center; gap: 12px; }
.card .emoji {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; font-size: 1.4rem;
  background: color-mix(in srgb, var(--c) 16%, transparent);
}
.card h3 { margin: 0; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }
.avatars { display: inline-flex; flex: none; }
.avatars .avatar + .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.lesson-row .avatar.sm { flex: none; }
.card .guide-line { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); margin-top: auto; }
.card .progress > span { background: var(--c); }

.avatar {
  --c: var(--accent);
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  font-family: Fraunces, serif; font-weight: 700; color: #fff; font-size: 1rem;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 60%, color-mix(in srgb, var(--c) 70%, #000));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent);
}
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; box-shadow: none; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; }

.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.cat-head {
  display: flex; gap: 18px; align-items: center; padding: 22px; margin-bottom: 22px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  border-left: 6px solid var(--c); box-shadow: var(--shadow);
}
.cat-head blockquote { margin: 6px 0 0; color: var(--muted); font-style: italic; }

.lesson-list { display: grid; gap: 12px; }
.lesson-row {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.lesson-row:hover { border-color: var(--c); }
.lesson-row .num {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); font-weight: 600; flex: none;
}
.lesson-row.done .num { background: var(--good); color: #fff; }
.lesson-row .grow { flex: 1; }

.lesson { max-width: 760px; margin: 0 auto; }
.lesson .intro { font-size: 1.15rem; color: var(--muted); }
.point { padding: 16px 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 10px; }
.point h3 { font-family: Inter, sans-serif; font-size: 1rem; margin: 0 0 4px; color: var(--c); }
.point p { margin: 0; }
.box { padding: 16px 18px; border-radius: 14px; margin: 18px 0; }
.box.example { background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.box.task { border: 2px dashed var(--c); }
.box strong { display: block; margin-bottom: 4px; }
.guide-say { display: flex; gap: 12px; align-items: flex-start; margin: 22px 0; }
.bubble {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px;
  padding: 12px 14px; flex: 1;
}

.quiz { margin-top: 30px; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.q p.question { font-weight: 600; margin: 0 0 10px; }
.opts { display: grid; gap: 8px; }
.opt {
  text-align: left; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
}
.opt:hover:not(:disabled) { border-color: var(--c); }
.opt.correct { background: color-mix(in srgb, var(--good) 20%, var(--surface)); border-color: var(--good); }
.opt.wrong { background: color-mix(in srgb, var(--bad) 18%, var(--surface)); border-color: var(--bad); }
.opt:disabled { cursor: default; }
.why { margin: 10px 0 0; font-size: .92rem; color: var(--muted); }
.more { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--c, var(--accent)) 6%, var(--surface)); }
.more summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: .92rem; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "▸ "; color: var(--c, var(--accent)); }
.more[open] summary::before { content: "▾ "; }
.more-body { padding: 0 14px 6px; white-space: pre-wrap; font-size: .95rem; line-height: 1.6; }
.more-body p { margin: 0; }
.more-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 12px; }
.more-actions a.chip { text-decoration: none; }
.result { text-align: center; padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }

.btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 500;
}
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

.calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.calc label { font-size: .85rem; color: var(--muted); display: grid; gap: 4px; }
.calc input, .chat-form input {
  font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); width: 100%;
}
.calc-out { margin-top: 12px; font-size: 1.05rem; }
.calc-out b { font-size: 1.3rem; }

/* Pohyblivé pozadie a postavičky z hviezdneho prachu */
.backdrop { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; }
.view { position: relative; z-index: 1; }
.stage { display: block; width: 100%; border-radius: 14px; background: #03060b; cursor: pointer; }
.hero-stage { height: 250px; margin-bottom: 10px; }
.hero-who { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; font-size: .9rem; }
.hero-who strong { font-family: Fraunces, serif; font-size: 1.05rem; }
.cat-stage { width: 190px; height: 220px; flex: none; }
.guide-stage { height: 210px; border-radius: 0; flex: none; }
.lesson .guide-say .mini-stage { width: 84px; height: 100px; flex: none; border-radius: 12px; }

/* Veľký kvíz */
.big-quiz-cta {
  display: flex; align-items: center; gap: 16px; margin-top: 28px; padding: 18px 20px; text-decoration: none;
  border-radius: var(--radius); color: #fff; box-shadow: var(--shadow);
  background: linear-gradient(120deg, #3b6fd8, #7a4fd6 45%, #c23b7a);
}
.big-quiz-cta .grow { flex: 1; }
.big-quiz-cta strong { font-family: Fraunces, serif; font-size: 1.25rem; }
.big-quiz-cta span span, .big-quiz-cta .grow > span { opacity: .9; font-size: .92rem; }
.big-quiz-cta .btn.primary { background: #fff; color: #1d1b18; border-color: #fff; }
.bq-icon { font-size: 2.2rem; }
.bq { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
.bq-side { position: sticky; top: 80px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.bq-stage { height: 290px; }
.bq-who { margin: 10px 4px 6px; }
.bq-say { margin: 0 4px 4px; padding: 10px 12px; border-radius: 4px 14px 14px 14px; background: var(--surface-2); font-size: .95rem; min-height: 2.6em; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.quiz-head h2 { margin: 0; }
.bq-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.bq-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bq-cats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.bq-cat { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--c); text-decoration: none; font-size: .88rem; background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
@media (max-width: 760px) {
  .bq { grid-template-columns: 1fr; }
  .bq-side { position: static; display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; }
  .bq-stage { height: 150px; grid-row: span 2; }
  .big-quiz-cta { flex-wrap: wrap; }
}

/* Tmavé scény (vesmír, matrix): text mimo kariet je svetlý, karty ostávajú čitateľné */
body[data-scene="dark"] .view { color: #eef0ff; }
body[data-scene="dark"] .view .muted, body[data-scene="dark"] .crumbs, body[data-scene="dark"] .lesson .intro { color: #b9bdd8; }
body[data-scene="dark"] .topbar { background: rgba(5, 8, 20, .7); border-color: rgba(255,255,255,.08); color: #eef0ff; }
body[data-scene="dark"] .brand-mark { background: #eef0ff; color: #070818; }
body[data-scene="dark"] :is(.point, .q, .cat-head, .lesson-row, .box, .bubble, .result, .card, .hero-card, .pill) { color: var(--text); }
body[data-scene="dark"] :is(.point, .q, .cat-head, .lesson-row, .box, .bubble, .result) .muted { color: var(--muted); }
body[data-scene="dark"] .box.task { background: var(--surface); }
body[data-scene="dark"] .btn:not(.primary) { color: var(--text); }

/* Guide panel */
.guide-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 20;
  display: flex; align-items: center; gap: 8px; padding: 8px 16px 8px 8px;
  border-radius: 999px; border: none; background: var(--text); color: var(--bg);
  box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 600;
}
.guide {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; width: min(420px, 100vw);
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(0,0,0,.15); transform: translateX(100%); transition: transform .25s ease;
}
.guide.open { transform: none; }
.guide-head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.guide-id { flex: 1; display: grid; }
.guide-id small { color: var(--muted); }
.icon-btn { border: none; background: var(--surface-2); color: var(--text); width: 34px; height: 34px; border-radius: 50%; }
.guide-mode { font-size: .8rem; padding: 6px 16px; color: var(--muted); background: var(--surface-2); }
.chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.bot { background: var(--surface-2); border-top-left-radius: 4px; align-self: flex-start; }
.msg.me { background: var(--text); color: var(--bg); border-top-right-radius: 4px; align-self: flex-end; }
.msg.typing { color: var(--muted); font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .82rem; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.chat-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.voice-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: .78rem; }
.voice-bar .chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.mic-btn { flex: none; width: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: 1.1rem; }
.mic-btn.rec { background: #d6455d; border-color: #d6455d; animation: micPulse 1s infinite; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(214,69,93,.5); } 50% { box-shadow: 0 0 0 8px rgba(214,69,93,0); } }
.read-btn { margin-left: 8px; vertical-align: middle; }
.disclaimer { margin: 0; padding: 0 16px 12px; font-size: .75rem; color: var(--muted); }

.challenge { margin-top: 32px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .view { padding: 20px 16px 110px; }
  .topbar { padding: 10px 16px; }
  .fab-label { display: none; }
  .guide-fab { padding: 8px; }
  .cat-head { flex-direction: column; align-items: flex-start; }
  .cat-stage { width: 100%; height: 220px; }
  .guide-stage { height: 170px; }
}
@media (max-width: 480px) {
  .brand-text { display: none; }
  .stats { gap: 4px; flex-wrap: nowrap; }
  .pill { padding: 3px 8px; font-size: .78rem; }
}

/* ---------- Účet, kartičky, rebríček ---------- */
.pill.link { text-decoration: none; color: inherit; cursor: pointer; }
.pill.link:hover { border-color: var(--accent); }
.pill.acct { background: var(--text); color: var(--bg); border-color: var(--text); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius, 16px); padding: 22px 24px; margin: 8px 0 22px; }
.panel.auth { max-width: 460px; margin-inline: auto; }
.prose { max-width: 70ch; } .prose h3 { margin-top: 1.2em; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); margin-bottom: 14px; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font: inherit; cursor: pointer; color: var(--muted); }
.tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); font-weight: 600; }
.auth-form { display: grid; gap: 12px; }
.auth-form label { display: grid; gap: 5px; font-size: .9rem; color: var(--muted); }
.auth-form input:not([type=checkbox]) { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth-form .check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); }
.form-err { color: var(--bad, #c0392b); min-height: 1.2em; margin: 0; font-size: .9rem; }
.account-hint { margin: 10px 0 0; }
.profile { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.lb-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
table.lb { width: 100%; border-collapse: collapse; margin: 8px 0 14px; }
table.lb th, table.lb td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); }
table.lb th { font-size: .8rem; color: var(--muted); font-weight: 500; }
table.lb td:nth-child(3), table.lb th:nth-child(3), table.lb td:nth-child(4), table.lb th:nth-child(4) { text-align: right; }
table.lb tr.me td { background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }
.tcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 12px 0 24px; }
.tcard { position: relative; display: grid; justify-items: center; gap: 6px; text-align: center; padding: 16px 10px 26px; border-radius: 14px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c, #888) 16%, var(--surface)), var(--surface)); border: 2px solid color-mix(in srgb, var(--c, #888) 45%, var(--line)); }
.tcard strong { font-size: .92rem; line-height: 1.2; } .tcard small { color: var(--muted); font-size: .75rem; line-height: 1.3; }
.tcard em { position: absolute; bottom: 7px; font-style: normal; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tcard.rare { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgb(139 92 246 / .15); }
.tcard.rare em { color: #8b5cf6; }
.tcard.gold { --c: #e0a100; border-color: #e0a100; background: linear-gradient(160deg, #fff4cc, var(--surface)); }
.tcard.gold em { color: #b07d00; }
.tcard .tc-icon { font-size: 1.8rem; width: 48px; height: 48px; display: grid; place-items: center; }
.tcard.locked { filter: grayscale(1); opacity: .5; border-style: dashed; box-shadow: none; }
.tcard.locked .tc-icon { font-size: 1.4rem; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.danger-zone { margin-top: 30px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; transition: .35s; z-index: 1000;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgb(0 0 0 / .25); text-decoration: none; max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
@media (max-width: 600px) { .pill.link.acct { max-width: 120px; overflow: hidden; text-overflow: ellipsis; } }
