:root {
  --bg:        #eceae3;
  --card:      #faf9f5;
  --panel:     #f2f1ec;
  --ink:       #1f1e1c;
  --muted:     #74716a;
  --line:      rgba(31, 30, 28, 0.15);
  --line-soft: rgba(31, 30, 28, 0.08);
  --accent:      #4f6b86;
  --accent-2:    #6d8aa6;
  --accent-soft: rgba(79, 107, 134, 0.12);
  --done:        #5f7356;
  --done-soft:   rgba(95, 115, 86, 0.14);
  --ring-track:  rgba(31, 30, 28, 0.10);
  --shadow:    0 1px 2px rgba(31, 30, 28, 0.04), 0 4px 14px rgba(31, 30, 28, 0.05);
  --shadow-lift: 0 2px 6px rgba(31, 30, 28, 0.06), 0 10px 26px rgba(31, 30, 28, 0.09);
  --ui:    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono:  ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 28px; }

h1, h2, h3, h4 { font-weight: 600; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 1.7rem; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 0.3rem; }
h2 { font-size: 1rem; margin: 0; letter-spacing: -0.005em; }
h3 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); font-weight: 700; margin: 1.6rem 0 0.6rem;
  padding-bottom: 0.35rem; border-bottom: 1px solid var(--line-soft);
}
h4 { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 700; margin: 0 0 0.55rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.mono { font-family: var(--mono); }
code, .num, .overall-num { font-family: var(--mono); }

/* ---- top bar ---- */
.topbar { border-bottom: 1px solid var(--line); background: rgba(236, 234, 227, 0.88); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; padding-top: 13px; padding-bottom: 2px; }
.wordmark { font-family: var(--mono); font-size: 0.9rem; font-weight: 700; letter-spacing: 0.08em; color: var(--ink); text-transform: uppercase; }
.wordmark:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: var(--muted); padding: 5px 10px; border-radius: 6px; font-size: 0.82rem; }
.topbar nav a:hover { color: var(--ink); background: var(--accent-soft); text-decoration: none; }
.topbar nav a.active { color: var(--ink); background: var(--accent-soft); font-weight: 600; }
.overall { display: flex; align-items: center; gap: 12px; padding-bottom: 11px; padding-top: 7px; }
.overall-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); white-space: nowrap; }
.overall-num { font-size: 0.8rem; white-space: nowrap; letter-spacing: 0.02em; }
.overall-num b { font-size: 0.92rem; }

/* ---- progress bars ---- */
.bar { flex: 1; height: 6px; background: var(--ring-track); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.45s cubic-bezier(.4,0,.2,1); }
.bar.lg { height: 8px; }
.bar.small { height: 5px; width: 64px; flex: none; }
.bar.sec-bar { height: 4px; margin: 5px 0 8px; }

/* ---- progress ring (svg) ---- */
.ring { width: var(--rs, 84px); height: var(--rs, 84px); display: block; }
.ring-track { fill: none; stroke: var(--ring-track); stroke-width: 2.8; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 2.8; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dasharray 0.6s cubic-bezier(.4,0,.2,1), stroke 0.3s;
}
.ring-text { fill: var(--ink); font: 700 8.5px/1 var(--ui); text-anchor: middle; dominant-baseline: central; }
.ring.hero .ring-text { font-size: 8px; }
.ring.is-done .ring-fill { stroke: var(--done); }
.ring.is-done .ring-text { fill: var(--done); }
.ring.pulse { animation: ringpop 0.6s ease; }
@keyframes ringpop { 0%{transform:scale(1)} 35%{transform:scale(1.07)} 100%{transform:scale(1)} }

/* ---- dashboard hero ---- */
main { padding-top: 26px; padding-bottom: 10px; }
.dash {
  display: flex; gap: 30px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: 16px;
  padding: 24px 28px; box-shadow: var(--shadow); margin-bottom: 28px;
}
.dash-ring { flex: none; }
.dash-body { flex: 1; min-width: 280px; }
.dash-body h1 { margin-bottom: 4px; }
.dash-sub { margin: 0 0 16px; font-size: 0.88rem; max-width: 62ch; }
.dash-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 140px; background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 11px; padding: 13px 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat .n { font-family: var(--serif); font-size: 1.55rem; line-height: 1; font-weight: 600; }
.stat .n .d { font-family: var(--ui); font-size: 0.95rem; color: var(--muted); font-weight: 400; }
.stat .l { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat .bar { margin-top: 4px; }

/* ---- epic card grid (masonry via columns) ---- */
.epic-grid { columns: 310px 3; column-gap: 22px; }
.epic-card {
  break-inside: avoid; -webkit-column-break-inside: avoid; display: block;
  margin: 0 0 22px; background: var(--card); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 17px 19px 10px; box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}
.epic-card:hover { box-shadow: var(--shadow-lift); }
.epic-card.complete { border-color: var(--done-soft); background: linear-gradient(180deg, var(--done-soft), var(--card) 60px); }
.epic-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.epic-meta { min-width: 0; }
.epic-card h2 { font-family: var(--serif); }
.epic-card h2 a { color: var(--ink); }
.subtitle { margin: 3px 0 0; font-size: 0.78rem; line-height: 1.45; }

ul.modules { list-style: none; margin: 0; padding: 0; }
.module-row {
  display: grid; grid-template-columns: 18px 1fr auto; align-items: center;
  gap: 6px 11px; padding: 8px 8px; margin: 0 -8px; border-radius: 8px; color: var(--ink);
}
.module-row:hover { background: var(--accent-soft); text-decoration: none; }
.module-row.done:hover { background: var(--done-soft); }
.m-title { font-size: 0.9rem; font-weight: 500; min-width: 0; }
.module-row.done .m-title { color: var(--muted); }
.m-ref { font-size: 0.7rem; grid-column: 2; }
.m-prog { grid-column: 3; grid-row: 1 / span 2; display: flex; align-items: center; gap: 9px; }
.m-prog .num { font-size: 0.7rem; width: 34px; text-align: right; }

.glyph { grid-row: 1 / span 2; font-size: 0.95rem; text-align: center; line-height: 1; }
.glyph.done, .pill.done { color: var(--done); }
.glyph.doing, .pill.doing { color: var(--accent); }
.glyph.todo { color: var(--muted); }

/* ---- breadcrumbs ---- */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; margin: 2px 0 16px; }
.crumbs span { color: var(--line); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }

/* ---- module ticket (two-column) ---- */
.module-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 30px; align-items: start; }
.module-main { min-width: 0; }
.ticket-head { margin-bottom: 16px; }
.meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 0; font-size: 0.78rem; }
.pill { display: inline-flex; align-items: center; border: 1px solid currentColor; border-radius: 99px; padding: 1px 10px; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

.guidance {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  padding: 12px 16px; margin: 16px 0; border-radius: 0 8px 8px 0;
  font-size: 0.9rem; line-height: 1.55; color: #3c3a35;
}

/* ---- subtask sections ---- */
.task-section { margin-bottom: 18px; }
.task-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.sec-count { font-size: 0.72rem; }

ul.subtasks { list-style: none; margin: 0; padding: 0; }
ul.subtasks li { display: flex; align-items: flex-start; gap: 8px; border-radius: 7px; padding: 2px 6px; margin: 0 -6px; }
ul.subtasks li:hover { background: var(--panel); }
ul.subtasks label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; flex: 1; font-size: 0.9rem; padding: 4px 0; }
ul.subtasks input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; }
.checkmark {
  flex: none; width: 17px; height: 17px; margin-top: 2px; border: 1.5px solid var(--line);
  border-radius: 5px; background: var(--card); position: relative; transition: all 0.16s ease;
}
.checkmark::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform 0.16s ease;
}
ul.subtasks label:hover .checkmark { border-color: var(--accent); }
input:checked + .checkmark { background: var(--done); border-color: var(--done); }
input:checked + .checkmark::after { transform: rotate(45deg) scale(1); }
input:focus-visible + .checkmark { box-shadow: 0 0 0 3px var(--accent-soft); }
.task-text { transition: color 0.16s; }
ul.subtasks li.is-done .task-text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

/* ---- things to try ---- */
ul.things { list-style: none; margin: 0; padding: 0; }
ul.things li { margin: 6px 0; }
ul.things code, .module-main code[data-copy] {
  display: block; background: #2b2a27; color: #e9e7df; border: 1px solid #2b2a27;
  border-radius: 7px; padding: 9px 12px; font-size: 0.82rem; white-space: pre-wrap;
  cursor: copy; transition: box-shadow 0.15s, transform 0.05s; position: relative;
}
ul.things code:hover { box-shadow: 0 0 0 2px var(--accent); }
ul.things code:active { transform: translateY(1px); }
code.copied { box-shadow: 0 0 0 2px var(--done) !important; }
code.copied::after { content: "copied ✓"; position: absolute; right: 10px; top: 9px; font-size: 0.72rem; color: #9fd28f; }

/* ---- notes ---- */
textarea {
  width: 100%; background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 13px; font-family: var(--mono); font-size: 0.84rem;
  line-height: 1.55; resize: vertical;
}
textarea:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note-actions { display: flex; align-items: center; gap: 12px; margin-top: 9px; }
.saved { font-size: 0.76rem; color: var(--done); }

/* ---- sidebar ---- */
.module-side { position: sticky; top: 96px; align-self: start; display: flex; flex-direction: column; gap: 16px; }
.side-card { background: var(--card); border: 1px solid var(--line-soft); border-radius: 13px; padding: 16px 17px; box-shadow: var(--shadow); }
.progress-card { display: flex; align-items: center; gap: 16px; }
.progress-meta { display: flex; flex-direction: column; gap: 3px; }
.progress-meta .mono { font-size: 0.84rem; }
.progress-meta b { font-size: 1.05rem; }
ul.jump { list-style: none; margin: 0; padding: 0; }
ul.jump li { margin: 1px 0; }
ul.jump a { display: block; padding: 5px 9px; margin: 0 -9px; border-radius: 7px; color: var(--ink); font-size: 0.85rem; }
ul.jump a:hover { background: var(--accent-soft); text-decoration: none; }
.practice-line { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line-soft); }

ul.links { list-style: none; margin: 0; padding: 0; }
ul.links li { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 0.86rem; }

.side-nav { display: flex; flex-direction: column; gap: 9px; }
.navbtn { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line-soft); border-radius: 11px; padding: 11px 14px; box-shadow: var(--shadow); }
.navbtn:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow-lift); }
.navbtn.next { text-align: right; }
.navbtn-t { font-size: 0.88rem; font-weight: 600; color: var(--ink); }

/* ---- practice page ---- */
.practice-grid { columns: 360px 3; }
ul.exercises { list-style: none; margin: 4px 0 6px; padding: 0; }
ul.exercises li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px 14px;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft);
}
ul.exercises li:last-child { border-bottom: none; }
.ex-lesson { font-size: 0.78rem; white-space: nowrap; min-width: 116px; flex: none; }
.ex-items { display: inline-flex; align-items: center; gap: 12px; }
.ex-item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; white-space: nowrap; cursor: pointer; }
.ex-item input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--done); flex: none; margin: 0; cursor: pointer; }
.ex-item.on a { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.ex-item a.lab { font-weight: 600; }
.exercises .ans { font-size: 0.78rem; white-space: nowrap; }
.ex-note { flex: 1 1 130px; min-width: 110px; font-size: 0.8rem; padding: 5px 9px; }
.source-note { margin-top: 22px; }

/* ---- forms / buttons ---- */
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row input[type=text], .add-row input[type=url] { flex: 1; min-width: 0; }
.link-add { flex-wrap: wrap; }
input[type=text], input[type=url], input[type=password] {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 11px; font-family: var(--ui); font-size: 0.84rem; color: var(--ink);
}
button {
  background: var(--ink); color: #faf9f5; border: 1px solid var(--ink); border-radius: 7px;
  padding: 8px 16px; font-family: var(--ui); font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: #34322d; }
button:active { transform: translateY(1px); }
form.inline { display: inline; margin: 0; }
button.x { background: none; border: none; color: var(--muted); padding: 0 4px; font-size: 1.05rem; line-height: 1; cursor: pointer; }
button.x:hover { background: none; color: #a4493b; transform: none; }

/* ---- resources ---- */
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.res-wide { grid-column: 1 / -1; }
table.facts { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
table.facts td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.facts tr:last-child td { border-bottom: none; }
table.facts td:first-child { width: 88px; white-space: nowrap; color: var(--muted); }
.big-links li { padding: 6px 0; font-size: 0.9rem; border-bottom: 1px solid var(--line-soft); }
.big-links li:last-child { border-bottom: none; }

/* ---- footer ---- */
footer { border-top: 1px solid var(--line-soft); margin-top: 34px; padding-top: 16px; padding-bottom: 40px; font-size: 0.74rem; font-family: var(--mono); letter-spacing: 0.02em; }

/* ---- toast / celebration ---- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(24px);
  display: flex; align-items: center; gap: 9px; background: var(--done); color: #fff;
  padding: 12px 20px; border-radius: 99px; font-size: 0.9rem; font-weight: 600;
  box-shadow: 0 8px 30px rgba(31,30,28,0.22); opacity: 0; pointer-events: none;
  transition: opacity 0.35s, transform 0.35s; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-mark { font-size: 1.05rem; }
.confetti { position: fixed; top: 0; left: 0; width: 9px; height: 14px; z-index: 55; pointer-events: none; border-radius: 1px; will-change: transform, opacity; }
@keyframes confetti-fall { to { transform: translateY(102vh) rotate(720deg); opacity: 0; } }

/* ---- login ---- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login { text-align: center; padding: 26px; background: var(--card); border: 1px solid var(--line-soft); border-radius: 16px; box-shadow: var(--shadow-lift); }
.wordmark.big { font-family: var(--mono); font-size: 1.15rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; margin: 0; }
.login .muted { font-size: 0.78rem; }
.login form { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; width: 250px; }
.login .error { color: #a4493b; font-size: 0.8rem; margin: 3px 0 0; }

/* ---- responsive ---- */
@media (max-width: 880px) {
  .module-layout { grid-template-columns: 1fr; }
  .module-side { position: static; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .dash { padding: 18px; gap: 18px; }
  .overall-label { display: none; }
  .module-row { grid-template-columns: 18px 1fr auto; }
  .m-prog .bar { display: none; }
  h1 { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
