:root {
  --bg: #fbfaf7; --surface: #ffffff; --ink: #1d232b; --muted: #5d6673; --line: #e3e0d8;
  --accent: #0f6e6e; --accent-soft: #e2f0ef; --warn: #9a5b00; --warn-soft: #fbf0dc;
  --ok: #1d7a3e; --ok-soft: #e3f3e8; --bad: #a1312b; --bad-soft: #f8e4e2;
  --adv: #5b4bb3; --adv-soft: #ece9fa; --deep: #8a3f74; --deep-soft: #f6e6f1;
  --radius: 10px; --measure: 44rem;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Charter", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --surface: #1c2026; --ink: #e6e8eb; --muted: #9aa3ae; --line: #2e343c;
    --accent: #5cc3bd; --accent-soft: #173533; --warn: #e2a64a; --warn-soft: #3a2c14;
    --ok: #6fd08f; --ok-soft: #173322; --bad: #f08a83; --bad-soft: #3d1c1a;
    --adv: #a99cf0; --adv-soft: #262140; --deep: #e19acb; --deep-soft: #3a1e33;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--font); }
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.25; }
h1 { font-family: var(--serif); font-size: 2.1rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.25rem; margin-top: 2.2rem; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--muted); margin: 0; font-weight: 600; }
.lede { font-size: 1.15rem; color: var(--ink); max-width: var(--measure); }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  padding: .55rem 1rem; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.crumbs { font-size: .9rem; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--ink); text-decoration: none; }
.crumbs span { margin: 0 .3rem; }
.top-tools { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.top-link { font-size: .9rem; text-decoration: none; }
.tiers { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.tiers button { border: 0; background: none; padding: .3rem .75rem; font: inherit; font-size: .85rem; color: var(--muted); cursor: pointer; }
.tiers button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.review-toggle { font: inherit; font-size: .8rem; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: .25rem .7rem; cursor: pointer; }
body.reviewing .review-toggle { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }

.layout { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.layout.with-side { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 2.5rem; }
main { min-width: 0; max-width: var(--measure); }
.side { position: sticky; top: 4rem; align-self: start; max-height: calc(100vh - 5rem); overflow: auto; font-size: .92rem; }
@media (max-width: 860px) {
  .top { position: static; }
  .layout.with-side { display: block; }
  .side { position: static; max-height: none; margin-bottom: 1.5rem; }
  .side .rail ol { display: none; }
  .side .rail.open ol { display: block; }
}
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 1rem; border-top: 1px solid var(--line); }

/* harta poveștii */
.rail-title { font-weight: 700; text-decoration: none; color: var(--ink); display: block; margin-bottom: .5rem; }
.rail ol { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.rail li { position: relative; padding: .35rem 0 .35rem 1rem; display: flex; gap: .5rem; align-items: baseline; }
.rail li::before { content: ""; position: absolute; left: -6px; top: .85rem; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line); }
.rail li.current::before { border-color: var(--accent); background: var(--accent); }
.rail li.seen::before { border-color: var(--accent); }
.rail li.planned { color: var(--muted); }
.rail li a { text-decoration: none; color: var(--ink); }
.rail li.current a { font-weight: 650; }
.wk { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .78rem; min-width: 1.4rem; }
.done-mark { font-style: normal; color: var(--ok); }
[data-chapter].seen .done-mark::after { content: "✓"; }

/* segmente */
.seg { margin: 1.4rem 0; position: relative; }
.seg p { margin: .7rem 0; }
.seg-aside, .seg[data-tier="advanced"], .seg[data-tier="deep"] { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1.1rem; }
.seg-aside .seg-title, .seg .seg-title { margin: .1rem 0 .4rem; font-size: 1rem; }
.seg[data-tier="advanced"] { border-left: 4px solid var(--adv); }
.seg[data-tier="deep"] { border-left: 4px solid var(--deep); }
.tier-badge { float: right; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  padding: .1rem .5rem; border-radius: 999px; margin-left: .5rem; }
[data-tier="advanced"] > .tier-badge { background: var(--adv-soft); color: var(--adv); }
[data-tier="deep"] > .tier-badge { background: var(--deep-soft); color: var(--deep); }
body[data-show="essential"] .seg[data-tier="advanced"], body[data-show="essential"] .seg[data-tier="deep"],
body[data-show="advanced"] .seg[data-tier="deep"] { display: none; }
.seg-figure { text-align: center; }
.seg-figure img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.seg-figure em { display: block; color: var(--muted); font-size: .9rem; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; margin: .8rem 0; display: block; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--line); padding: .4rem .55rem; text-align: left; vertical-align: top; }
thead th { border-bottom: 2px solid var(--line); }
blockquote { margin: 1rem 0; padding: .2rem 1rem; border-left: 3px solid var(--accent); color: var(--ink); background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0; }
code { font-size: .88em; background: var(--accent-soft); padding: .05em .3em; border-radius: 4px; }
cite.src { font-style: normal; font-size: .85em; color: var(--muted); white-space: nowrap; }
cite.src::before { content: "("; } cite.src::after { content: ")"; }
a.concept { color: inherit; text-decoration: underline dotted var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a.concept:hover { background: var(--accent-soft); }
.chip { display: inline-block; font-size: .8rem; text-decoration: none !important; background: var(--accent-soft); color: var(--accent) !important;
  padding: .1rem .55rem; border-radius: 999px; margin: 0 .3rem .3rem 0; }
.twins { font-size: .9rem; background: var(--surface); border: 1px dashed var(--line); padding: .5rem .8rem; border-radius: var(--radius); }

/* activități */
.activity { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.act-head { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: .2rem; }
.act-kind { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--accent); margin-right: .4rem; }
.act-body { margin-top: .6rem; }
.act-body label.opt { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: 8px; margin: .35rem 0; cursor: pointer; }
.act-body label.opt:hover { border-color: var(--accent); }
.act-body label.opt input { margin-top: .35rem; }
.act-body label.opt p { margin: 0; }
.act-body fieldset { border: 0; padding: 0; margin: .4rem 0 .8rem; }
.act-body legend { font-weight: 650; font-size: .92rem; margin-bottom: .2rem; }
.act-body .order li { display: flex; gap: .5rem; align-items: center; border: 1px solid var(--line); border-radius: 8px;
  padding: .4rem .6rem; margin: .3rem 0; background: var(--bg); }
.act-body .order li span { flex: 1; }
.act-body .order button { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; cursor: pointer; color: var(--ink); }
.act-body ol.order { padding-left: 1.2rem; }
.act-body input[type=text] { font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; width: min(18rem, 100%);
  background: var(--bg); color: var(--ink); }
.act-body .match-row { display: flex; gap: .6rem; align-items: center; margin: .3rem 0; flex-wrap: wrap; }
.act-body .match-row span { flex: 1 1 14rem; }
.act-body select { font: inherit; padding: .3rem; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); max-width: 100%; }
.spot-text { line-height: 1.8; padding: .6rem .8rem; background: var(--bg); border-radius: 8px; border: 1px dashed var(--line); cursor: text; }
.spot-text mark { background: var(--warn-soft); color: inherit; }
button.check { margin-top: .7rem; font: inherit; font-weight: 650; background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: .5rem 1.1rem; cursor: pointer; }
button.check:disabled { opacity: .5; cursor: default; }
.act-result:empty { display: none; }
.act-result { margin-top: .8rem; border-radius: 8px; padding: .7rem .9rem; }
.act-result.ok { background: var(--ok-soft); }
.act-result.bad { background: var(--bad-soft); }
.act-result.partial { background: var(--warn-soft); }
.act-result .verdict { font-weight: 700; }
.act-result .reveal { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.dataset { font-size: .9rem; }

/* sfârșitul capitolului, paginare */
.chapter-end { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.chapter-end h4 { margin: .8rem 0 .3rem; }
.refs { font-size: .92rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; font-size: .95rem; }
.pager a { text-decoration: none; }

/* pagina cursului */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin: 1.5rem 0; }
main:has(.cards) { max-width: 60rem; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
  text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--accent); }
.card h2 { margin: .3rem 0 .4rem; font-family: var(--serif); }
.card p { color: var(--muted); margin: 0 0 .8rem; }
.card-go { color: var(--accent); font-weight: 600; font-size: .92rem; }
table.plan td.planned { color: var(--muted); }
table.plan tr.now th { color: var(--accent); }
table.plan tr.now { background: var(--accent-soft); }
.concept-list { list-style: none; padding: 0; }
.concept-list li { margin: .35rem 0; }
.definition { font-size: 1.08rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem 1.1rem; }

/* panoul de concepte */
.panel { position: fixed; right: 1rem; bottom: 1rem; width: min(24rem, calc(100vw - 2rem)); max-height: 60vh; overflow: auto; z-index: 10;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.panel h3 { margin: 0 0 .4rem; font-family: var(--serif); }
.panel .close { float: right; border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }

/* revizie */
.rv { display: none; }
body.reviewing .rv { display: block; margin-top: .4rem; }
.rv-btn { font: inherit; font-size: .78rem; border: 1px dashed var(--warn); color: var(--warn); background: none; border-radius: 6px;
  padding: .1rem .5rem; cursor: pointer; }
.rv-list { font-size: .85rem; margin: .3rem 0; padding: 0; list-style: none; }
.rv-list li { background: var(--warn-soft); border-radius: 6px; padding: .3rem .55rem; margin: .25rem 0; white-space: pre-wrap; }
.rv-form textarea { width: 100%; min-height: 4.5rem; font: inherit; font-size: .9rem; border-radius: 8px; border: 1px solid var(--warn);
  padding: .4rem .55rem; background: var(--bg); color: var(--ink); }
.rv-form button { font: inherit; font-size: .85rem; margin-top: .3rem; }
body.reviewing .seg { outline: 1px dashed transparent; }
body.reviewing .seg:hover { outline-color: var(--warn); outline-offset: 6px; }
.draft-banner { max-width: 72rem; margin: .8rem auto 0; padding: .45rem .8rem; font-size: .84rem; background: var(--warn-soft);
  border: 1px solid var(--warn); border-radius: var(--radius); width: calc(100% - 2rem); }
.time { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); }
.tier-note { position: fixed; left: 50%; top: 4.2rem; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; z-index: 20;
  background: var(--ink); color: var(--bg); padding: .45rem .9rem; border-radius: 999px; font-size: .88rem; transition: .2s; }
.tier-note.show { opacity: 1; transform: translate(-50%, 0); }

/* pagina de concepte: lista + conceptul ales */
.layout.wide main { max-width: none; }
.explorer { display: grid; grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr); gap: 2rem; align-items: start; }
.ex-list { position: sticky; top: 4rem; max-height: calc(100vh - 5rem); display: flex; flex-direction: column; min-height: 0; }
.ex-list h1 { font-size: 1.5rem; margin: 0 0 .6rem; }
.ex-count { font-size: .9rem; font-family: var(--font); font-weight: 500; }
.ex-search { font: inherit; font-size: .95rem; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); width: 100%; }
.ex-filters { display: flex; gap: .3rem; flex-wrap: wrap; margin: .5rem 0 .3rem; }
.ex-filters button { font: inherit; font-size: .78rem; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: .15rem .6rem; cursor: pointer; }
.ex-filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ex-jump { display: flex; flex-wrap: wrap; gap: .1rem .45rem; font-size: .78rem; margin-bottom: .4rem; }
.ex-jump a { text-decoration: none; font-weight: 600; }
.ex-list ul { list-style: none; margin: 0; padding: 0 .3rem 0 0; overflow: auto; flex: 1; min-height: 0; border-top: 1px solid var(--line); }
.ex-list li.letter { font-weight: 700; color: var(--muted); font-size: .8rem; padding: .7rem 0 .2rem; position: sticky; top: 0; background: var(--bg); }
.ex-list li[data-search] a { display: block; padding: .3rem .5rem; border-radius: 6px; text-decoration: none; color: var(--ink); font-size: .93rem; }
.ex-list li[data-search] .muted { display: none; }
.ex-list li[data-search] a:hover { background: var(--accent-soft); }
.ex-list li[data-search] a.on { background: var(--accent); color: #fff; font-weight: 600; }
.ex-detail { min-width: 0; max-width: var(--measure); }
.ex-detail h1 { margin-top: .2rem; }
@media (max-width: 860px) {
  .explorer { display: block; }
  .ex-list { position: static; max-height: 22rem; margin-bottom: 1.5rem; }
}

/* resursele laboratorului */
.resources { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius);
  padding: .7rem 1.1rem .4rem; margin: 1.2rem 0 1.6rem; }
.resources h2 { margin: .2rem 0 .5rem; font-size: 1.05rem; }
.resources ul { list-style: none; padding: 0; margin: 0; }
.resources li { display: flex; flex-wrap: wrap; gap: .2rem .7rem; align-items: baseline; padding: .35rem 0; border-top: 1px solid var(--line); }
.resources li:first-child { border-top: 0; }
.resources .dl { font-weight: 650; text-decoration: none; }
.resources .muted { font-size: .85rem; }
.resources .bring { font-weight: 600; }
.res-tools { margin: .5rem 0 .3rem; }
.print-btn { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px;
  padding: .3rem .8rem; cursor: pointer; }
@media print {
  .top, .side, .foot, .draft-banner, .rv, .tiers, .pager, .res-tools, button.check, .act-result, .panel { display: none !important; }
  .layout.with-side { display: block; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .seg, .activity { break-inside: avoid; }
  a { color: #000; }
}

/* revizia și bannerul de ciornă: doar pentru profesor și administrator (rolul vine din /api/v2/me) */
.review-toggle, .draft-banner { display: none; }
body.can-review .review-toggle { display: inline-block; }
body.can-review .draft-banner { display: block; }

/* poveștile din curs (cazuri reale): un card distinct, cu întrebarea și răspunsul posibil pliat */
.seg-story { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--warn); border-radius: var(--radius);
  padding: .9rem 1.2rem .6rem; }
.seg-story .story-kicker { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--warn); }
.seg-story .seg-title { font-family: var(--serif); font-size: 1.25rem; margin: .15rem 0 .5rem; }
.seg-story blockquote { background: var(--warn-soft); border-left-color: var(--warn); font-weight: 600; }
.seg-story details { margin: .6rem 0; padding: .5rem .8rem; background: var(--bg); border-radius: 8px; border: 1px dashed var(--line); }
.seg-story summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.seg-story .story-source { font-size: .8rem; color: var(--muted); }

/* simulările încorporate */
.app-embed { margin: .8rem 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #f4f6f1; }
.app-embed iframe { display: block; width: 100%; height: 780px; border: 0; }
.app-embed .app-open { display: block; text-align: right; font-size: .82rem; padding: .3rem .7rem; background: var(--surface);
  border-top: 1px solid var(--line); text-decoration: none; }
.seg-app { margin-left: -1rem; margin-right: -1rem; }
@media (min-width: 1100px) { main:has(.seg-app) { max-width: 54rem; } }
.act-sim-hint { font-size: .9rem; color: var(--muted); }
