:root {
  --bg: #f5f3ec;
  --surface: #fffdf8;
  --ink: #17231f;
  --muted: #5d6a64;
  --line: #e2ddd0;
  --brand: #14322e;
  --brand-ink: #f5f3ec;
  --accent: #1f7a68;
  --accent-soft: #d9ece6;
  --gate: #c07a22;
  --gate-soft: #f6e6cf;
  --good: #2f8a4f;
  --warn: #b2442f;
  --amber: #c78a1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1716; --surface: #16211f; --ink: #e6ebe7; --muted: #9aa8a2; --line: #26332f;
    --brand: #0b1211; --brand-ink: #e6ebe7; --accent: #4fb9a0; --accent-soft: #1d3a33;
    --gate: #e0a24f; --gate-soft: #3a2d1a; --good: #5cc07d; --warn: #e07a64; --amber: #e0b04f;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
code { font-family: var(--mono); font-size: .88em; background: var(--accent-soft); padding: .1em .35em; border-radius: 5px; word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.lead { font-size: 1.08rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 600; color: var(--accent); margin-bottom: .4em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Raspored */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: var(--brand-ink); padding: 22px 16px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: var(--gate); color: #1b1408; font: 700 .85rem/1 var(--sans); letter-spacing: .04em; flex: none; }
.brand-mark.big { width: 64px; height: 64px; font-size: 1.1rem; border-radius: 16px; margin-bottom: 14px; }
.brand-text { font: 600 1.15rem/1.15 var(--serif); }
.brand-text small { display: block; font: 400 .75rem/1.3 var(--sans); opacity: .7; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none; opacity: .8; }
.nav a:hover { background: rgba(255,255,255,.07); opacity: 1; }
.nav a.active { background: rgba(255,255,255,.12); opacity: 1; font-weight: 600; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sync { margin-top: auto; display: flex; gap: 8px; align-items: center; font-size: .8rem; opacity: .85; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-gray { background: #8a9590; } .dot-green { background: #5cc07d; } .dot-amber { background: #e0b04f; } .dot-red { background: #e07a64; }
main { padding: 32px clamp(16px, 4vw, 48px) 96px; max-width: 920px; width: 100%; outline: none; }
.tabbar { display: none; }

/* Kartice i elementi */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.grid .card { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row input[type=password], .row input[type=text] { flex: 1 1 220px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 .95rem var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.warn { border-color: var(--warn); color: var(--warn); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 42px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.notes { width: 100%; resize: vertical; line-height: 1.5; }
.notes.sm { margin-top: 10px; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; flex: none; width: 100%; min-width: 60px; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s ease; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .85rem; }
.page-head { margin-bottom: 22px; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 14px; }
.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; font-weight: 600; font-size: .9rem; }

/* Pregled */
.hero { display: flex; gap: 28px; align-items: center; margin-bottom: 22px; }
.hero-ring { position: relative; width: 128px; height: 128px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.hero-pct { position: absolute; inset: 0; display: grid; place-content: center; grid-auto-flow: column; align-items: baseline; }
.hero-pct b { font: 600 2.2rem var(--serif); }
.hero-pct span { color: var(--muted); margin-left: 2px; }
.hero h1 { font-size: clamp(1.35rem, 3.4vw, 1.9rem); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 26px; }
.stat { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.stat b { font: 600 1.5rem var(--serif); font-variant-numeric: tabular-nums; }
.phases { margin-bottom: 18px; }
.phase { position: relative; }
.phase.current { border-color: var(--accent); }
.phase-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.phase-head h3 { margin-bottom: 2px; }
.phase-head p { margin: 0; }
.phase-num { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font: 700 .9rem var(--sans); flex: none; }
.phase-num.sm { width: 26px; height: 26px; font-size: .8rem; margin-right: 10px; vertical-align: 2px; }
.mini { display: grid; grid-template-columns: 70px 1fr 48px; gap: 10px; align-items: center; font-size: .85rem; margin: 6px 0; }
.mini.wide { grid-template-columns: 80px 1fr 56px; max-width: 460px; margin-top: 12px; }
.mini .num { text-align: right; }
.gate { display: flex; gap: 10px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); font-weight: 600; font-size: .92rem; cursor: pointer; }
.gate input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.diamond { width: 16px; height: 16px; transform: rotate(45deg); border: 2px solid var(--gate); border-radius: 3px; flex: none; margin: 0 4px; }
.gate input:checked + .diamond { background: var(--gate); }
.gate input:focus-visible + .diamond { outline: 2px solid var(--accent); outline-offset: 3px; }
.phase.passed, .plan-phase.passed { background: linear-gradient(0deg, var(--gate-soft), var(--surface) 70%); }
.case-card { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 8px; }
.case-card:hover { border-color: var(--accent); }
.case-top { display: flex; justify-content: space-between; gap: 8px; }
.case-top h3 { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.num { white-space: nowrap; }
.case-card .bar { margin-top: auto; }
.case-card p { margin: 0; }

/* Lekcije */
.phase-title { display: flex; align-items: center; margin: 26px 0 12px; }
.lesson-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.lesson-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none; }
.lesson-row:hover { border-color: var(--accent); }
.lr-main { display: flex; flex-direction: column; }
.lr-meta { text-align: right; white-space: nowrap; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); }
.lesson-row.done .check { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--surface); }
.keys ul { margin: 0; padding-left: 1.2em; }
.keys li { margin: 4px 0; }
.keys { border-left: 4px solid var(--accent); }
.prose { margin: 22px 0; font-size: 1.02rem; }
.prose h3 { margin-top: 1.4em; font-size: 1.15rem; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 5px 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: .92rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-weight: 600; background: var(--accent-soft); }
.note { background: var(--gate-soft); border-left: 4px solid var(--gate); padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 16px 0; }
.quiz fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.quiz legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; cursor: pointer; }
.opt input { min-height: 0; margin-top: 4px; accent-color: var(--accent); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.q.right .explain { color: var(--good); }
.q.wrong .explain { color: var(--warn); }
.explain { font-size: .9rem; margin: 6px 0 0; }
.quiz-result { margin: 0; font-weight: 600; }
.task { border-left: 4px solid var(--gate); }
.links ul { padding-left: 1.2em; }
.links li { margin: 6px 0; }
.lesson-foot { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 24px; }
.lesson-foot .btn.ghost { font-weight: 500; font-size: .85rem; white-space: normal; line-height: 1.25; padding: 8px 12px; }
.lesson-foot > :last-child { justify-self: end; text-align: right; }

/* Studije */
.facts dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
.facts dt { font-weight: 600; color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; }
.verdict { border-left: 4px solid var(--accent); }
.item { border-top: 1px solid var(--line); padding: 10px 0; }
.item:first-of-type { border-top: 0; }
.item summary { display: flex; gap: 12px; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.item summary::-webkit-details-marker { display: none; }
.item-t { flex: 1; }
.item.has-note .item-t::after { content: " ✎"; color: var(--muted); }
.status { min-height: 36px; padding: 5px 8px; font-size: .85rem; font-weight: 600; flex: none; }
.st-doing { border-color: var(--amber); color: var(--amber); }
.st-done { border-color: var(--good); color: var(--good); }
.st-na { color: var(--muted); }

/* Plan */
.week { font-family: var(--sans); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; }
.week.now { color: var(--accent); }
.task-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task-row label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.task-row input { min-height: 0; width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.task-row a { white-space: nowrap; }

/* Ostalo */
.search { width: 100%; margin-bottom: 14px; }
.glossary { display: grid; grid-template-columns: minmax(130px, 220px) 1fr; gap: 10px 18px; margin: 0; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--muted); }
.danger { border-color: var(--warn); }
.welcome { max-width: 520px; margin: 8vh auto; text-align: center; padding: 34px 28px; }
.welcome .row { justify-content: center; margin: 18px 0 10px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--brand); color: var(--brand-ink); padding: 10px 18px; border-radius: 99px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* Mobitel */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 14px 16px; flex-direction: row; align-items: center; justify-content: space-between; }
  .nav { display: none; }
  .sync { margin: 0; }
  .sync span:last-child { max-width: 140px; }
  main { padding: 20px 16px 110px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; color: var(--muted); text-decoration: none; padding: 4px 0; }
  .tabbar a.active { color: var(--accent); font-weight: 600; }
  .hero { flex-direction: column; align-items: flex-start; gap: 16px; }
  .hero-ring { width: 104px; height: 104px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .lesson-row { grid-template-columns: 24px 1fr; }
  .lr-meta { grid-column: 2; text-align: left; }
  .facts dl, .glossary { grid-template-columns: 1fr; gap: 2px; }
  .facts dd, .glossary dd { margin-bottom: 10px; }
  .item summary { flex-direction: column; align-items: stretch; }
  .lesson-foot { grid-template-columns: 1fr; }
  .lesson-foot > :last-child { justify-self: stretch; text-align: left; }
  .toast { bottom: 84px; }
}
