/* ============================================================ Teme */
:root {
  --bg: #f6f7fb;
  --bg2: #eef0f7;
  --card: #ffffff;
  --text: #1d2233;
  --muted: #5d6479;
  --line: #e1e4ee;
  --brand: #5b5bf6;
  --brand2: #8b5cf6;
  --brand-soft: #ecebff;
  --ok: #12a150;
  --ok-soft: #e3f7ea;
  --bad: #e5484d;
  --bad-soft: #fde8e8;
  --warn: #d97706;
  --warn-soft: #fff3db;
  --gold: #f5b301;
  --a: #2f7cf6;
  --a-soft: #e6f0ff;
  --b: #8b4cf0;
  --b-soft: #f1e9ff;
  --c: #0ea672;
  --c-soft: #e2f7ef;
  --code-bg: #1e2233;
  --code-text: #e8eaf4;
  --code-line: #2c3147;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.06), 0 4px 16px rgba(20, 24, 40, 0.06);
  --shadow-lg: 0 10px 40px rgba(20, 24, 40, 0.16);
  --radius: 14px;
  --radius-sm: 9px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', Ubuntu, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #12141c;
    --bg2: #191c27;
    --card: #1b1e2b;
    --text: #e7e9f3;
    --muted: #a0a6bd;
    --line: #2d3245;
    --brand: #8584ff;
    --brand2: #a98bff;
    --brand-soft: #262849;
    --ok: #3ccf7c;
    --ok-soft: #173426;
    --bad: #ff6b70;
    --bad-soft: #3a1d22;
    --warn: #f2a93b;
    --warn-soft: #3a2c14;
    --a: #66a3ff;
    --a-soft: #1b2a45;
    --b: #b18cff;
    --b-soft: #2a2145;
    --c: #39d09b;
    --c-soft: #163329;
    --code-bg: #0f1119;
    --code-line: #23283a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #12141c;
  --bg2: #191c27;
  --card: #1b1e2b;
  --text: #e7e9f3;
  --muted: #a0a6bd;
  --line: #2d3245;
  --brand: #8584ff;
  --brand2: #a98bff;
  --brand-soft: #262849;
  --ok: #3ccf7c;
  --ok-soft: #173426;
  --bad: #ff6b70;
  --bad-soft: #3a1d22;
  --warn: #f2a93b;
  --warn-soft: #3a2c14;
  --a: #66a3ff;
  --a-soft: #1b2a45;
  --b: #b18cff;
  --b-soft: #2a2145;
  --c: #39d09b;
  --c-soft: #163329;
  --code-bg: #0f1119;
  --code-line: #23283a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ============================================================ Osnova */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.2em 0 0.5em; }
h1 { font-size: 1.9rem; margin-top: 0.2em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.18rem; }
p { margin: 0.6em 0; }
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg2);
  border: 1px solid var(--line);
  padding: 0.05em 0.35em;
  border-radius: 6px;
}
pre { margin: 0; }
mark { background: #fff1a8; color: #222; padding: 0 0.15em; border-radius: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
table { border-collapse: collapse; }
img, svg { max-width: 100%; }
button { font: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 0.88em; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.ovl { display: inline-block; border-top: 1.6px solid currentColor; padding-top: 1px; line-height: 1.15; }
.expr { font-family: 'Cambria Math', 'STIX Two Math', Cambria, Georgia, serif; font-size: 1.12em; white-space: nowrap; }
.expr i { font-style: italic; }

/* ============================================================ Raspored */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px;
  flex: 0 0 252px;
  background: var(--card);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 12px 30px;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.08rem;
  text-decoration: none;
  color: var(--text);
  padding: 4px 8px 14px;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  box-shadow: 0 4px 12px rgba(91, 91, 246, 0.35);
}
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 0.78rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sec { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 14px 10px 4px; font-weight: 700; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 550;
  font-size: 0.95rem;
}
.nav a .ic { width: 24px; text-align: center; font-size: 1.05rem; }
.nav a:hover { background: var(--bg2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.top-stats { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-weight: 650;
  font-size: 0.88rem;
  white-space: nowrap;
}
.chip.gold { color: #9a6b00; background: #fff6d6; border-color: #f6e2a0; }
:root[data-theme='dark'] .chip.gold { color: #ffd45e; background: #3a2f10; border-color: #5a4714; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .chip.gold { color: #ffd45e; background: #3a2f10; border-color: #5a4714; } }
.xpbar { width: 120px; height: 8px; border-radius: 99px; background: var(--bg2); overflow: hidden; border: 1px solid var(--line); }
.xpbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ff8a00); border-radius: 99px; transition: width 0.6s; }
.content { padding: 26px 28px 80px; max-width: 1060px; width: 100%; margin: 0 auto; }
.content.wide { max-width: 1320px; }
.footer { padding: 24px 28px 40px; color: var(--muted); font-size: 0.85rem; text-align: center; }
.scrim { display: none; }

@media (max-width: 920px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.25s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 25; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 8px 14px; }
  .content { padding: 18px 16px 70px; }
  .xpbar { width: 70px; }
  h1 { font-size: 1.55rem; }
}
@media (max-width: 520px) {
  .top-stats .chip.lvl-name { display: none; }
  body { font-size: 16px; }
}

/* ============================================================ Gumbi i kartice */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
  transition: transform 0.06s, background 0.15s, border-color 0.15s;
  user-select: none;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg2); }
.btn.sm { padding: 5px 11px; font-size: 0.88rem; border-radius: 8px; }
.btn.lg { padding: 12px 22px; font-size: 1.05rem; border-radius: 12px; }
.btn.icon { padding: 6px 9px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid > .card + .card { margin-top: 0; }
.tile {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform 0.12s, border-color 0.15s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--brand); }
.tile .ic { font-size: 1.8rem; }
.tile h3 { margin: 6px 0 4px; font-size: 1.06rem; }
.tile p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--bg2);
  color: var(--muted);
  border: 1px solid var(--line);
  vertical-align: middle;
}
.pill.a { background: var(--a-soft); color: var(--a); border-color: transparent; }
.pill.b { background: var(--b-soft); color: var(--b); border-color: transparent; }
.pill.c { background: var(--c-soft); color: var(--c); border-color: transparent; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.progress { height: 10px; background: var(--bg2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); border-radius: 99px; transition: width 0.5s; }
.progress.a > i { background: var(--a); }
.progress.b > i { background: var(--b); }
.progress.c > i { background: var(--c); }
.progress.ok > i { background: var(--ok); }

/* Callouti u lekcijama */
.callout {
  border-radius: var(--radius-sm);
  padding: 12px 16px 12px 48px;
  margin: 14px 0;
  position: relative;
  background: var(--brand-soft);
  border: 1px solid transparent;
}
.callout::before { position: absolute; left: 14px; top: 11px; font-size: 1.2rem; }
.callout.tip { background: var(--ok-soft); }
.callout.tip::before { content: '💡'; }
.callout.warn { background: var(--warn-soft); }
.callout.warn::before { content: '⚠️'; }
.callout.exam { background: var(--b-soft); }
.callout.exam::before { content: '🎯'; }
.callout.info::before { content: 'ℹ️'; }
.callout.story { background: var(--a-soft); }
.callout.story::before { content: '📖'; }
.callout.link { background: var(--bg2); border-color: var(--line); }
.callout.link::before { content: '🔗'; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

/* ============================================================ Kod */
.tk-k { color: #c792ea; font-weight: 600; }
.tk-b { color: #82aaff; }
.tk-f { color: #82aaff; }
.tk-s { color: #c3e88d; }
.tk-n { color: #f78c6c; }
.tk-c { color: #7f87a8; font-style: italic; }
pre.code-static, .codebox pre {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  tab-size: 4;
}
pre.code-static { margin: 10px 0; }
pre.code-static code, .codebox code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
.codepair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.codepair.single { grid-template-columns: 1fr; }
.codebox { min-width: 0; }
.codebox .lang { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px 2px; }
@media (max-width: 700px) { .codepair { grid-template-columns: 1fr; } }

/* Uređivač koda */
.editor {
  position: relative;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.55;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--code-line);
}
.editor .gutter {
  padding: 10px 8px 10px 10px;
  text-align: right;
  color: #5d6584;
  user-select: none;
  background: rgba(255, 255, 255, 0.03);
  border-right: 1px solid var(--code-line);
  min-width: 38px;
  white-space: pre;
}
.editor .area { position: relative; flex: 1; min-width: 0; overflow: auto; }
.editor pre, .editor textarea {
  margin: 0;
  padding: 10px 12px;
  font: inherit;
  line-height: inherit;
  white-space: pre;
  tab-size: 4;
  border: 0;
  min-height: 100%;
  letter-spacing: normal;
  word-spacing: normal;
}
.editor pre { pointer-events: none; }
.editor textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #fff;
  outline: none;
  overflow: hidden;
}
.editor textarea::selection { background: rgba(130, 170, 255, 0.35); color: transparent; }
.editor .hl-line, .editor .prev-line, .editor .err-line { display: inline-block; margin-left: -12px; padding-left: 12px; width: calc(100% + 12px); }
.editor .hl-line { background: rgba(255, 214, 102, 0.18); box-shadow: inset 3px 0 0 #ffd666; }
.editor .prev-line { background: rgba(124, 214, 145, 0.12); box-shadow: inset 3px 0 0 #6fd28d; }
.editor .err-line { background: rgba(255, 92, 92, 0.2); box-shadow: inset 3px 0 0 #ff6b6b; }
.editor.readonly textarea { display: none; }
.editor.readonly pre { pointer-events: auto; }
.symbar { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.symbar button { font-family: var(--mono); padding: 3px 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 0.88rem; }
@media (hover: hover) and (pointer: fine) { .symbar.mobile-only { display: none; } }

.runner { margin: 14px 0; }
.runner .toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.runner .io { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 8px; }
@media (max-width: 700px) { .runner .io { grid-template-columns: 1fr; } }
.io label { font-size: 0.78rem; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.io textarea {
  width: 100%;
  min-height: 74px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.9rem;
  resize: vertical;
}
.console {
  background: #0b0d14;
  color: #d7f5d2;
  font-family: var(--mono);
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-height: 74px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.console .err { color: #ff9c9c; }
.console .hint { color: #ffd98a; }
.console .sys { color: #8f97b6; font-style: italic; }
.loader-line { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.spinner { width: 16px; height: 16px; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Vizualizator */
.viz { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; margin: 12px 0; }
@media (max-width: 760px) { .viz { grid-template-columns: 1fr; } }
.viz .vars { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.92rem; }
.viz .vars th, .viz .vars td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.viz .vars th { font-family: var(--font); font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }
.viz .vars tr.changed td { background: var(--warn-soft); animation: flash 0.6s; }
@keyframes flash { from { background: #ffe08a; } }
.viz .controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.viz input[type='range'] { flex: 1; min-width: 120px; }
.viz .stepinfo { font-size: 0.85rem; color: var(--muted); }
.viz .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.viz .panel h4 { margin: 0 0 6px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.trace-table { border-collapse: collapse; font-family: var(--mono); font-size: 0.9rem; margin: 8px 0; }
.trace-table th, .trace-table td { border: 1px solid var(--line); padding: 4px 10px; text-align: center; min-width: 46px; }
.trace-table th { background: var(--bg2); font-family: var(--font); }
.trace-table input { width: 64px; text-align: center; font-family: var(--mono); padding: 3px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); }
.trace-table input.ok { border-color: var(--ok); background: var(--ok-soft); }
.trace-table input.bad { border-color: var(--bad); background: var(--bad-soft); }

/* ============================================================ Pitanja */
.q {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 16px 0;
  box-shadow: var(--shadow);
  position: relative;
}
.q.inline-q { border-left: 4px solid var(--brand); }
.q .q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.8rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.q .q-text { font-size: 1.02rem; }
.q .q-text > :first-child { margin-top: 0; }
.q .options { display: grid; gap: 8px; margin: 12px 0 4px; }
.q .opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 9px 12px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.12s, background 0.12s;
}
.q .opt:hover:not(:disabled) { border-color: var(--brand); }
.q .opt .lt { flex: 0 0 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-weight: 800; background: var(--bg2); font-size: 0.85rem; }
.q .opt .ot { flex: 1; min-width: 0; }
.q .opt .ot pre { margin: 4px 0; font-size: 0.84rem; }
.q .opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.q .opt.right { border-color: var(--ok); background: var(--ok-soft); }
.q .opt.right .lt { background: var(--ok); color: #fff; }
.q .opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q .opt.wrong .lt { background: var(--bad); color: #fff; }
.q .opt:disabled { cursor: default; }
.q .answer-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.q .answer-row input[type='text'] {
  padding: 8px 11px;
  border-radius: 9px;
  border: 1.5px solid var(--line);
  background: var(--card);
  min-width: 170px;
  font-family: var(--mono);
  font-size: 1rem;
}
.q .answer-row input.ok { border-color: var(--ok); background: var(--ok-soft); }
.q .answer-row input.bad { border-color: var(--bad); background: var(--bad-soft); }
.q .feedback { margin-top: 12px; padding: 10px 14px; border-radius: 10px; display: none; }
.q .feedback.show { display: block; animation: pop 0.25s; }
.q .feedback.ok { background: var(--ok-soft); }
.q .feedback.bad { background: var(--bad-soft); }
.q .feedback > :first-child { margin-top: 0; }
.q .feedback > :last-child { margin-bottom: 0; }
.q .xp-pop { position: absolute; right: 16px; top: 12px; font-weight: 800; color: var(--gold); animation: rise 1.2s forwards; }
@keyframes rise { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-24px); } }
@keyframes pop { from { transform: scale(0.98); opacity: 0.4; } }
.q .parts > .part { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 10px; }
.q .parts > .part:first-child { border-top: 0; padding-top: 0; }
.q .part-label { font-weight: 750; margin-right: 6px; }
.q .hint-box { margin-top: 10px; padding: 8px 12px; border-radius: 9px; background: var(--warn-soft); display: none; }
.q .hint-box.show { display: block; }
.q.exam-q { box-shadow: none; }
.q .q-num { font-weight: 800; color: var(--brand); margin-right: 4px; }
.q .pts { margin-left: auto; font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }

.truth { border-collapse: collapse; margin: 10px 0; font-family: var(--mono); }
.truth th, .truth td { border: 1px solid var(--line); padding: 5px 12px; text-align: center; min-width: 42px; }
.truth th { background: var(--bg2); font-family: var(--font); }
.truth td.y { cursor: pointer; background: var(--brand-soft); font-weight: 800; user-select: none; }
.truth td.y.empty { color: var(--muted); font-weight: 400; }
.truth td.y.ok { background: var(--ok-soft); color: var(--ok); }
.truth td.y.bad { background: var(--bad-soft); color: var(--bad); }
.truth td.mid { color: var(--muted); }

.order-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.order-list li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--card); }
.order-list li .grow { font-family: var(--mono); }
.order-list li.ok { border-color: var(--ok); background: var(--ok-soft); }
.order-list li.bad { border-color: var(--bad); background: var(--bad-soft); }
.match-row { display: flex; gap: 10px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.match-row .l { flex: 1 1 200px; font-weight: 600; }
.match-row select { flex: 1 1 220px; padding: 7px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--card); }
.match-row select.ok { border-color: var(--ok); background: var(--ok-soft); }
.match-row select.bad { border-color: var(--bad); background: var(--bad-soft); }

/* ============================================================ Lekcija */
.lesson-head { margin-bottom: 18px; }
.lesson-head .crumbs { font-size: 0.88rem; color: var(--muted); }
.lesson-head .crumbs a { color: var(--muted); }
.lesson-body { font-size: 1.02rem; }
.lesson-body > .block { margin: 18px 0; }
.lesson-body h2 { border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.lesson-body table.tbl, .tbl { border-collapse: collapse; margin: 10px 0; font-size: 0.95rem; width: auto; max-width: 100%; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.tbl th { background: var(--bg2); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); }
.tbl-wrap { overflow-x: auto; max-width: 100%; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 30px; flex-wrap: wrap; }
.objectives { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.objectives h3 { margin: 0 0 6px; font-size: 1rem; }
.objectives ul { margin: 0; padding-left: 20px; }
.finish-box { text-align: center; padding: 26px 20px; border-radius: var(--radius); background: linear-gradient(135deg, var(--brand-soft), var(--b-soft)); margin-top: 26px; }
.finish-box .big { font-size: 2.6rem; }
.widget { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 18px 0; box-shadow: var(--shadow); }
.widget > .w-title { font-weight: 800; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.widget > .w-title .ic { font-size: 1.2rem; }
.widget .w-desc { color: var(--muted); font-size: 0.92rem; margin-top: -4px; margin-bottom: 10px; }
.kbd { font-family: var(--mono); background: var(--bg2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; font-size: 0.85em; }
details.more { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px; margin: 12px 0; background: var(--card); }
details.more summary { cursor: pointer; font-weight: 700; }
details.more[open] summary { margin-bottom: 6px; }

/* ============================================================ Widgeti */
.lamps { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.lamp {
  width: 58px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--bg2);
  padding: 8px 0 6px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
}
.lamp:active { transform: scale(0.95); }
.lamp .bulb { font-size: 1.6rem; filter: grayscale(1) opacity(0.45); transition: filter 0.15s; }
.lamp.on { background: #fff4c2; border-color: #f5c400; box-shadow: 0 0 18px rgba(255, 200, 0, 0.55); }
:root[data-theme='dark'] .lamp.on { background: #4a3d0a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .lamp.on { background: #4a3d0a; } }
.lamp.on .bulb { filter: none; }
.lamp .bit { font-family: var(--mono); font-weight: 800; font-size: 1.15rem; }
.lamp .w { font-size: 0.72rem; color: var(--muted); font-family: var(--mono); }
@media (max-width: 520px) { .lamp { width: 36px; padding: 5px 0 4px; } .lamp .bulb { font-size: 1.1rem; } .lamp .w { font-size: 0.6rem; } }
.bigval { font-size: 1.8rem; font-weight: 800; font-family: var(--mono); }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.stat { background: var(--bg2); border-radius: 12px; padding: 8px 14px; text-align: center; min-width: 110px; }
.stat .l { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.stat .v { font-family: var(--mono); font-weight: 800; font-size: 1.25rem; word-break: break-all; }
.steps { font-family: var(--mono); font-size: 0.92rem; background: var(--bg2); border-radius: 10px; padding: 10px 14px; overflow-x: auto; }
.steps .st { padding: 2px 0; white-space: pre; }
.steps .st.hl { color: var(--brand); font-weight: 800; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 0.78rem; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.field input, .field select, input.inp, select.inp {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1.5px solid var(--line);
  background: var(--card);
  min-width: 0;
}
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1 1 130px; }
.game-bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.timer { font-family: var(--mono); font-weight: 800; font-size: 1.1rem; }
.pix-grid { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); width: fit-content; margin: 8px auto; }
.pix-grid div { width: 22px; height: 22px; }
.swatch { width: 100%; height: 90px; border-radius: 12px; border: 1px solid var(--line); }
.tree { font-family: var(--mono); font-size: 0.95rem; line-height: 1.9; }
.tree .node { cursor: pointer; padding: 1px 6px; border-radius: 6px; }
.tree .node:hover { background: var(--bg2); }
.tree .node.sel { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.tree ul { list-style: none; margin: 0; padding-left: 22px; border-left: 1px dashed var(--line); }
.tree > ul { padding-left: 4px; border-left: 0; }
.pathbar { font-family: var(--mono); background: var(--bg2); border-radius: 9px; padding: 8px 12px; word-break: break-all; }
.mail { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.mail .mrow { display: flex; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.mail .mrow b { width: 70px; color: var(--muted); }
.person { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); cursor: pointer; font-size: 0.9rem; margin: 2px; }
.person.to { background: var(--a-soft); border-color: var(--a); }
.person.cc { background: var(--c-soft); border-color: var(--c); }
.person.bcc { background: var(--b-soft); border-color: var(--b); }
.inbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.inbox { border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 0.88rem; background: var(--bg2); }
.inbox.none { opacity: 0.45; }
.sheet { border-collapse: collapse; font-family: var(--mono); font-size: 0.88rem; }
.sheet th { background: var(--bg2); color: var(--muted); font-weight: 600; padding: 3px 6px; border: 1px solid var(--line); min-width: 34px; }
.sheet td { border: 1px solid var(--line); padding: 0; min-width: 84px; height: 28px; background: var(--card); }
.sheet td input { width: 100%; height: 100%; border: 0; padding: 3px 6px; background: transparent; font: inherit; }
.sheet td.sel { outline: 2px solid var(--brand); outline-offset: -2px; }
.sheet td.inrange { background: var(--brand-soft); }
.sheet td .val { padding: 3px 6px; display: block; white-space: nowrap; overflow: hidden; }
.formula-bar { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-family: var(--mono); }
.formula-bar .addr { min-width: 54px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; text-align: center; background: var(--bg2); }
.formula-bar input { flex: 1; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); font-family: var(--mono); }
.cc-toggle { display: flex; gap: 10px; flex-wrap: wrap; }
.cc-toggle label { display: flex; gap: 8px; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; background: var(--card); flex: 1 1 220px; }
.cc-badge { display: inline-flex; gap: 6px; align-items: center; font-family: var(--mono); font-weight: 800; font-size: 1.3rem; padding: 6px 14px; border-radius: 10px; background: var(--code-bg); color: #fff; }
.sort-items { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.sort-item { padding: 6px 12px; border-radius: 99px; background: var(--card); border: 1.5px solid var(--line); cursor: pointer; font-weight: 600; user-select: none; }
.sort-item.picked { border-color: var(--brand); background: var(--brand-soft); }
.sort-bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.sort-bin { border: 2px dashed var(--line); border-radius: 12px; padding: 10px; min-height: 90px; cursor: pointer; background: var(--bg2); }
.sort-bin h4 { margin: 0 0 6px; font-size: 0.9rem; }
.sort-bin .sort-item { cursor: default; font-size: 0.88rem; display: inline-block; margin: 2px; }
.sort-item.ok { border-color: var(--ok); background: var(--ok-soft); }
.sort-item.bad { border-color: var(--bad); background: var(--bad-soft); }
canvas.turtle-canvas { width: 100%; max-width: 520px; aspect-ratio: 1; background: #fffdf6; border-radius: 12px; border: 1px solid var(--line); display: block; margin: 0 auto; touch-action: none; }
.turtle-wrap { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .turtle-wrap { grid-template-columns: 1fr; } }
.numline { width: 100%; height: 90px; }
.gate-svg { width: 100%; max-width: 420px; height: auto; display: block; margin: 6px auto; }
.flash-card { perspective: 1000px; max-width: 560px; margin: 16px auto; cursor: pointer; }
.flash-inner { position: relative; min-height: 220px; transition: transform 0.45s; transform-style: preserve-3d; }
.flash-card.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 18px; padding: 24px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 1.15rem; }
.flash-face.back { transform: rotateY(180deg); background: linear-gradient(135deg, var(--brand-soft), var(--card)); font-size: 1rem; }
.flash-face .ft { font-size: 1.5rem; font-weight: 800; }
.boxes { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.boxes .bx { text-align: center; background: var(--bg2); border-radius: 10px; padding: 6px 10px; min-width: 64px; font-size: 0.8rem; }
.boxes .bx b { display: block; font-size: 1.15rem; }

/* ============================================================ Plan i početna */
.hero {
  border-radius: 20px;
  padding: 26px 26px;
  background: linear-gradient(135deg, #5b5bf6 0%, #8b5cf6 55%, #c056e8 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.hero h1 { margin: 0 0 6px; }
.hero p { margin: 4px 0; opacity: 0.95; }
.hero .btn { border-color: rgba(255, 255, 255, 0.7); }
.hero .btn:not(.primary) { background: rgba(255, 255, 255, 0.16); color: #fff; }
.hero .btn.primary { background: #fff; color: #4a3fe0; border-color: #fff; }
.hero .deco { position: absolute; right: -10px; bottom: -24px; font-size: 7rem; opacity: 0.18; transform: rotate(-12deg); pointer-events: none; font-family: var(--mono); font-weight: 900; }
.ring { width: 96px; height: 96px; }
.ring circle { fill: none; stroke-width: 10; }
.ring .bg { stroke: var(--bg2); }
.ring text { font-weight: 800; font-size: 20px; fill: var(--text); }
.week { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin: 12px 0; overflow: hidden; box-shadow: var(--shadow); }
.week > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; align-items: center; gap: 12px; }
.week > summary::-webkit-details-marker { display: none; }
.week .wnum { flex: 0 0 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; background: var(--bg2); font-size: 1.05rem; }
.week.current .wnum { background: var(--brand); color: #fff; }
.week.done .wnum { background: var(--ok); color: #fff; }
.week .wtitle { font-weight: 800; }
.week .wsub { color: var(--muted); font-size: 0.88rem; }
.week .wbody { padding: 0 18px 16px; }
.lesson-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--text); border: 1px solid transparent; }
.lesson-link:hover { background: var(--bg2); border-color: var(--line); }
.lesson-link .st { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); font-size: 0.8rem; }
.lesson-link.done .st { background: var(--ok); border-color: var(--ok); color: #fff; }
.lesson-link .lt { flex: 1; min-width: 0; }
.lesson-link .lm { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { text-align: center; padding: 12px 8px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.badge .bi { font-size: 2rem; }
.badge.locked { opacity: 0.4; filter: grayscale(1); }
.badge .bn { font-weight: 800; font-size: 0.9rem; }
.badge .bd { font-size: 0.78rem; color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; }
.cal div { aspect-ratio: 1; border-radius: 4px; background: var(--bg2); }
.cal div.l1 { background: #c7d2fe; }
.cal div.l2 { background: #8b9cf9; }
.cal div.l3 { background: #5b5bf6; }

/* ============================================================ Ispit */
.exam-top { position: sticky; top: 57px; z-index: 15; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
.exam-top .timer.low { color: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.5; } }
.qnav { display: flex; gap: 4px; flex-wrap: wrap; }
.qnav a { width: 30px; height: 28px; display: grid; place-items: center; border-radius: 7px; font-size: 0.8rem; font-weight: 700; text-decoration: none; color: var(--text); background: var(--bg2); border: 1px solid var(--line); }
.qnav a.ans { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.qnav a.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.qnav a.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.qnav a.part { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.exam-sec { margin-top: 26px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--bg2); font-weight: 700; }
.grade-big { font-size: 4rem; font-weight: 900; line-height: 1; }
.rubric label { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }

/* ============================================================ Obavijesti */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 12px; padding: 10px 14px; font-weight: 650; display: flex; gap: 10px; align-items: center; animation: slidein 0.3s; max-width: 340px; pointer-events: auto; }
.toast .ti { font-size: 1.4rem; }
.toast.xp { border-color: #f6e2a0; }
.toast.badge { border-color: var(--brand); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
.modal-back { position: fixed; inset: 0; background: rgba(10, 12, 20, 0.5); z-index: 90; display: grid; place-items: center; padding: 16px; animation: fadein 0.2s; }
.modal { background: var(--card); border-radius: 18px; padding: 22px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 920px; }
@keyframes fadein { from { opacity: 0; } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 120; }

/* Ispis */
@media print {
  .sidebar, .topbar, .toasts, .lesson-nav, .btn { display: none !important; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; }
}

/* Matematičke formule */
.math { font-family: 'Cambria Math', 'STIX Two Math', Cambria, Georgia, serif; font-size: 1.15em; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; }
.frac > span { padding: 0 3px; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; }
.sqrt { display: inline-flex; align-items: stretch; }
.sqrt::before { content: '√'; font-size: 1.15em; margin-right: 1px; }
.sqrt > span { border-top: 1.5px solid currentColor; padding: 0 2px; }
.flow { max-width: 100%; height: auto; display: block; margin: 8px auto; }
