:root {
  --green: #0f4c3a; --green-2: #16634c; --green-soft: #e6f0ec; --gold: #c99a2e; --gold-soft: #fbf3e0;
  --ink: #1d2623; --muted: #5f6b67; --line: #dfe5e2; --bg: #f5f7f6; --card: #ffffff;
  --red: #b3261e; --red-soft: #fbeae9; --amber: #a86400; --amber-soft: #fdf1df; --blue: #1f5fa8; --blue-soft: #e8f0fa;
  --ok: #1b7a4b; --ok-soft: #e4f4ea;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(15,76,58,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Source Sans 3", system-ui, sans-serif; font-size: 16px; color: var(--ink); background: var(--bg); line-height: 1.5; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; line-height: 1.2; margin: 0 0 .5rem; color: var(--green); }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
a { color: var(--green-2); }
button, input, select, textarea { font: inherit; }
.boot { padding: 3rem; text-align: center; color: var(--muted); }

/* layout */
.topbar { background: var(--green); color: #fff; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; position: sticky; top: 0; z-index: 20; }
.topbar .brand { font-family: Fraunces, serif; font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.topbar .brand small { display: block; font-family: "Source Sans 3", sans-serif; font-weight: 400; font-size: .78rem; opacity: .85; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; text-align: right; opacity: .95; }
.topbar button { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: .35rem .7rem; cursor: pointer; }
.nav { background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: .25rem; overflow-x: auto; padding: 0 .5rem; position: sticky; top: 52px; z-index: 19; scrollbar-width: none; }
.nav a { padding: .7rem .8rem; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.nav a.on { color: var(--green); border-color: var(--gold); }
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 4rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.tight { padding: .75rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem; }
.stat b { display: block; font-size: 1.6rem; font-family: Fraunces, serif; color: var(--green); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .88rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; } .mb0 { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: .6rem 0 .25rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid #c9d3cf; border-radius: 9px; background: #fff; color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
textarea.big { min-height: 360px; font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.fields { display: grid; gap: 0 .75rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.check input { width: auto; }
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .55rem .95rem; border-radius: 9px; border: 1px solid var(--green); background: var(--green); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--green-2); }
.btn.ghost { background: #fff; color: var(--green); }
.btn.ghost:hover { background: var(--green-soft); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.sm { padding: .3rem .6rem; font-size: .86rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.err { background: var(--red-soft); color: var(--red); border-radius: 9px; padding: .6rem .8rem; margin: .6rem 0; }
.note { background: var(--gold-soft); border-left: 4px solid var(--gold); border-radius: 8px; padding: .6rem .8rem; margin: .6rem 0; }
.info { background: var(--blue-soft); border-left: 4px solid var(--blue); border-radius: 8px; padding: .6rem .8rem; margin: .6rem 0; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfa; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--green-soft); }
tr.current td { background: var(--gold-soft); }

/* badges */
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eef1f0; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gold { background: var(--gold-soft); color: #8a6512; }
.grade { font-family: Fraunces, serif; font-weight: 700; }

/* tabs */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .85rem; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--green); border-color: var(--green); color: #fff; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--green) 0%, #0b3a2c 55%, #10291f 100%); }
.login { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 1.6rem; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login .crest { width: 54px; height: 54px; border-radius: 50%; background: var(--gold); color: #fff; display: grid; place-items: center; font-family: Fraunces, serif; font-weight: 700; font-size: 1.4rem; margin-bottom: .75rem; }
.login .btn { width: 100%; justify-content: center; margin-top: 1rem; padding: .7rem; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,30,24,.5); display: flex; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; padding: 1.2rem; margin: 2rem 0; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
#toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 9px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }

/* lesson content */
.lesson { font-size: 1.03rem; }
.lesson h1 { font-size: 1.5rem; } .lesson h2 { font-size: 1.2rem; margin-top: 1.4rem; border-bottom: 2px solid var(--gold-soft); padding-bottom: .25rem; }
.lesson h3 { margin-top: 1rem; }
.lesson table { margin: .6rem 0; } .lesson td, .lesson th { border: 1px solid var(--line); }
.lesson li { margin: .2rem 0; }
.lesson code { background: #f0f3f2; padding: 0 .25rem; border-radius: 4px; }

/* week list */
.week { display: flex; gap: .75rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line); align-items: flex-start; }
.week:last-child { border-bottom: 0; }
.week .wk { flex: 0 0 52px; text-align: center; background: var(--green-soft); color: var(--green); border-radius: 9px; padding: .25rem 0; font-weight: 700; font-size: .85rem; }
.week.now .wk { background: var(--gold); color: #fff; }
.week .body { flex: 1; min-width: 0; }
.week .body b { display: block; }

/* exam */
.exam-head { position: sticky; top: 0; background: var(--green); color: #fff; padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; z-index: 30; }
.exam-head .timer { font-family: ui-monospace, monospace; font-size: 1.2rem; font-weight: 700; background: rgba(255,255,255,.15); padding: .2rem .6rem; border-radius: 8px; }
.exam-head .timer.low { background: var(--red); }
.qnav { display: flex; flex-wrap: wrap; gap: .3rem; }
.qnav button { width: 2.2rem; height: 2.2rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; }
.qnav button.done { background: var(--green-soft); border-color: var(--green-2); color: var(--green); }
.qnav button.cur { outline: 2px solid var(--gold); }
.qtext { font-size: 1.08rem; white-space: pre-wrap; margin-bottom: .75rem; }
.opt { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: .65rem .75rem; margin: .4rem 0; cursor: pointer; background: #fff; }
.opt:hover { border-color: var(--green-2); }
.opt.sel { border-color: var(--green); background: var(--green-soft); }
.opt .l { flex: 0 0 1.7rem; height: 1.7rem; border-radius: 50%; border: 1px solid #b9c5c0; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.opt.sel .l { background: var(--green); color: #fff; border-color: var(--green); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.qcard { border-left: 4px solid var(--line); }
.qcard.right { border-left-color: var(--ok); } .qcard.wrong { border-left-color: var(--red); } .qcard.theory { border-left-color: var(--blue); }
.explain { background: #f7f9f8; border-radius: 9px; padding: .6rem .8rem; margin-top: .5rem; white-space: pre-wrap; }
.pre { white-space: pre-wrap; }

/* readiness meter */
.meter { height: 10px; background: #e8ecea; border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; }
.big-score { font-family: Fraunces, serif; font-size: 2.6rem; font-weight: 700; color: var(--green); line-height: 1; }

/* print */
#print { display: none; }
@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; }
  .slips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .slip { border: 1px dashed #777; padding: 10px; page-break-inside: avoid; font-size: 12px; }
  .slip h4 { margin: 0 0 4px; font-size: 13px; }
  .slip .cred { font-family: monospace; font-size: 14px; }
}
@media (max-width: 640px) {
  main { padding: .75rem .75rem 4rem; }
  .topbar .who span { display: none; }
  h1 { font-size: 1.35rem; }
  .hide-sm { display: none; }
}
