/* hxn admin — same design language as hungnguyenxuan.info (roadmap.html / learning-materials.html) */
:root {
  --navy: #10263d; --navy-2: #173a57; --teal: #51aeb8; --mint: #5fe0c4;
  --ink: #173045; --body: #425569; --muted: #708497; --line: #d8e3e8; --bg: #f3f7f8; --card: #fff;
  --ok: #24724f; --ok-bg: #e1f5ea; --ok-dot: #3fcf9f;
  --warn: #8a5a00; --warn-bg: #fff3dc; --bad: #b42318; --bad-bg: #fde8e6;
  --soft: #eef1f4; --radius: 16px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.55 var(--sans); }
a { color: var(--navy-2); text-decoration-color: var(--teal); text-underline-offset: 3px; }
a:hover { color: var(--teal); }
code { font-family: var(--mono); font-size: .88em; background: var(--soft); padding: .05em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: .5rem; top: .5rem; background: var(--card); padding: .4rem .7rem; z-index: 10; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------------------------------------------------------------- site bar */
header.top { background: var(--navy); color: #d9e8ef; border-bottom: 1px solid #ffffff1e; position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1220px; margin: 0 auto; min-height: 63px; padding: 0 30px; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-size: 22px; font-weight: 700; color: #fff; text-decoration: none; white-space: nowrap; }
.brand::after { content: "admin"; font-family: var(--sans); font-size: 10.5px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--mint); margin-left: 8px; vertical-align: 3px; }
.brand:hover { color: #fff; }
nav.main { display: flex; gap: 4px 20px; flex-wrap: wrap; flex: 1; font-size: 12.5px; font-weight: 650; }
nav.main a { color: #c5d7e0; text-decoration: none; padding: 6px 0; }
nav.main a:hover { color: #fff; }
nav.main a[aria-current="page"] { color: #fff; text-decoration: underline; text-decoration-color: var(--teal);
  text-decoration-thickness: 2px; text-underline-offset: 8px; }
header.top button.sm { background: transparent; color: #e7f6f6; border-color: #6faab4; border-radius: 4px; padding: 6px 12px; font-size: 12px; }
header.top button.sm:hover { background: #ffffff14; border-color: var(--mint); }

/* ---------------------------------------------------------------- layout + headings */
main { max-width: 1220px; margin: 0 auto; padding: 34px 30px 60px; }
h1 { font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.15; color: var(--navy); margin: 0 0 22px; letter-spacing: -.01em; }
main > h1:first-of-type::before { content: "Learning journey · admin"; display: block; font-family: var(--sans); font-size: 10.5px;
  font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--teal); margin-bottom: 8px; }
h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; color: var(--navy); margin: 30px 0 12px; }
h3 { font-size: 15px; font-weight: 750; color: var(--ink); margin: 0; }

/* ---------------------------------------------------------------- cards, stats */
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px; overflow: hidden; transition: box-shadow .25s, border-color .25s; }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--teal); }
.card:hover { box-shadow: 0 14px 34px #10263d14; border-color: #c4d6dd; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 22px; }
.stat { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; border-radius: 14px; padding: 18px 20px;
  box-shadow: 0 12px 28px #10263d22; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, #5fe0c433, transparent 70%); }
.stat .n { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 12.5px; color: #a9c3d0; margin-top: 4px; }
.stat .l a { color: var(--mint); }

/* ---------------------------------------------------------------- flash */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; border: 1px solid; font-weight: 600; font-size: .92rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe6d1; }
.flash.err { background: var(--bad-bg); color: var(--bad); border-color: #f5c2bd; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink); background: #fbfdfd; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; min-width: 0; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px #51aeb833; background: #fff; }
textarea { min-height: 5rem; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1 1 170px; min-width: 0; }
.row > .fix { flex: 0 0 auto; }
.stack > * + * { margin-top: 12px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: .92rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink); }
.check input { accent-color: var(--teal); width: 16px; height: 16px; }

/* ---------------------------------------------------------------- buttons */
button, .btn { font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; border: 1px solid var(--line); background: #fff;
  color: var(--navy); border-radius: 8px; padding: 8px 14px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .2s, box-shadow .2s, border-color .2s, background .2s; }
button:hover, .btn:hover { border-color: var(--teal); color: var(--navy); transform: translateY(-1px); box-shadow: 0 6px 16px #10263d14; }
button.primary { background: var(--mint); color: #08263a; border-color: var(--mint); }
button.primary:hover { box-shadow: 0 10px 24px #5fe0c455; }
button.danger { color: var(--bad); border-color: #f0c4bf; background: #fff; }
button.danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
button.sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
button:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
form.inline { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 800; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; background: #f8fbfb; }
tr:hover td { background: #f8fbfb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- badges (same as roadmap cards) */
.badge { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  border-radius: 999px; padding: 4px 10px; white-space: nowrap; background: var(--soft); color: #6c7d8c; }
.badge::before { content: "◌ "; }
.badge.ready, .badge.succeeded, .badge.done, .badge.replied { background: var(--ok-bg); color: var(--ok); }
.badge.ready::before, .badge.succeeded::before, .badge.done::before, .badge.replied::before { content: "● "; color: var(--ok-dot); }
.badge.building, .badge.doing, .badge.running, .badge.new { background: var(--warn-bg); color: var(--warn); }
.badge.building::before, .badge.doing::before, .badge.running::before, .badge.new::before { content: "◐ "; }
.badge.failed, .badge.spam { background: var(--bad-bg); color: var(--bad); }
.badge.failed::before, .badge.spam::before { content: "✕ "; }

/* ---------------------------------------------------------------- disclosure */
details { border-top: 1px solid var(--line); padding: 12px 0; }
details > summary { cursor: pointer; font-weight: 700; font-size: .95rem; color: var(--navy); list-style: none; display: flex; gap: 8px; align-items: center; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; color: var(--teal); font-size: 18px; line-height: 1; transition: transform .2s; }
details[open] > summary::before { transform: rotate(90deg); }
details.plain { border: 0; padding: 0; }
.card > details:first-child, .card > details:only-child { border-top: 0; padding-top: 4px; }

/* ---------------------------------------------------------------- roadmap editor */
.phase { margin-top: 30px; padding-left: 22px; border-left: 3px solid var(--line); position: relative; }
.phase::before { content: ""; position: absolute; left: -9px; top: 6px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--teal); box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--teal); }
.phase-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.phase-head form.rename { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.step-head { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.num { font-variant-numeric: tabular-nums; }
.step-no { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; color: var(--teal); background: #eaf6f7;
  border-radius: 999px; padding: 4px 10px; }
.links { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.links li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
ul.clean { list-style: none; margin: 0; padding: 0; }

/* ---------------------------------------------------------------- tabs (CV sections, filters) */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs a { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-size: 12.5px;
  font-weight: 650; color: var(--body); background: #fff; transition: border-color .2s, color .2s; }
.tabs a:hover { border-color: var(--teal); color: var(--navy); }
.tabs a[aria-current="page"] { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------------------------------------------------------------- progress bars + chart */
.bar { height: 7px; background: #dfe8ec; border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--mint)); border-radius: 99px; }
.chart { width: 100%; height: auto; max-width: 720px; }
.chart text { fill: var(--body); font-size: 11px; font-family: var(--sans); }
.chart .bar-fill { fill: var(--teal); }
.chart .val { fill: var(--muted); }
.hidden-row { opacity: .55; }
.msg-body { white-space: pre-wrap; margin: 8px 0; color: var(--body); }
pre.err { white-space: pre-wrap; font-size: .8rem; font-family: var(--mono); }

/* ---------------------------------------------------------------- login / TOTP (no session: navy hero background) */
body:not([hx-headers]) { min-height: 100vh;
  background: radial-gradient(circle at 78% 18%, #1f5f75 0, transparent 42%), radial-gradient(circle at 12% 88%, #234a6b 0, transparent 40%),
    radial-gradient(#ffffff10 1px, transparent 1px) 0 0 / 22px 22px, var(--navy); }
body:not([hx-headers]) main { padding-top: 0; }
.login { max-width: 400px; margin: 13vh auto 0; padding: 30px 30px 28px; box-shadow: 0 30px 70px #0008; border-color: #ffffff22; }
.login::before { background: linear-gradient(90deg, var(--teal), var(--mint)); }
.login h1 { margin-top: 0; font-size: 28px; }
.login h1::before { content: "NXH. · admin"; display: block; font-family: var(--serif); font-size: 15px; font-weight: 700;
  letter-spacing: 0; text-transform: none; color: var(--teal); margin-bottom: 10px; }
.login button.primary { width: 100%; justify-content: center; padding: 11px 18px; }
body:not([hx-headers]) .flash { max-width: 400px; margin: 6vh auto -9vh; }

@media (max-width: 720px) {
  html { font-size: 14px; }
  .top-in { padding: 8px 16px; gap: 10px 16px; }
  main { padding: 22px 16px 40px; }
  h1 { font-size: 28px; }
  .row > div { flex: 1 1 100% !important; }
  .row > .fix { flex: 0 0 auto !important; }
  .phase { padding-left: 16px; }
}

/* ---------------------------------------------------------------- roadmap: collapsible phases and steps */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.c-found { --c: #2f9a72; } .c-cont { --c: #1f8a96; } .c-cloud { --c: #2f6fb3; } .c-deliv { --c: #c07a22; }
.c-obs { --c: #3d6fd0; } .c-sec { --c: #7457c0; } .c-plat { --c: #b8891a; } .c-go { --c: #d08a2a; }
.rm-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: -6px 0 8px; }
.rm-total { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); font-weight: 650; }
.rm-total strong { color: var(--navy); font-size: 15px; }
.rm-total .bar { width: 180px; }

details.rm-phase { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  margin: 0 0 14px; overflow: hidden; position: relative; transition: box-shadow .25s, border-color .25s; }
details.rm-phase::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c, var(--teal)); }
details.rm-phase, details.rm-step { scroll-margin-top: 84px; }
.rm-step-body .row { align-items: flex-start; }
details.rm-phase:hover, details.rm-phase[open] { box-shadow: 0 14px 34px #10263d12; border-color: #c4d6dd; }
details.rm-phase > summary { padding: 16px 20px 16px 22px; gap: 16px; }
details.rm-phase > summary::before, details.rm-step > summary::before { display: none; }
.rm-node { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--c); color: #fff;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--c) 40%, transparent); }
.rm-node svg { width: 24px; height: 24px; }
.rm-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rm-title small { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--c); }
.rm-name { font-family: var(--serif); font-weight: 400; font-size: 21px; color: var(--navy); line-height: 1.2; }
.rm-dots { display: flex; gap: 5px; }
.rm-dots i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--c); background: #fff; }
.rm-dots i.ready { background: var(--c); }
.rm-dots i.building { background: linear-gradient(90deg, var(--c) 50%, #fff 50%); }
.rm-meter { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-weight: 650; white-space: nowrap; }
.rm-meter .bar { width: 110px; } .rm-meter .bar > i { background: var(--c); }
.rm-chevron { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--soft);
  transition: transform .25s, background .2s; }
.rm-chevron::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--navy); border-bottom: 2px solid var(--navy);
  transform: rotate(45deg) translate(-1px, -1px); }
details[open] > summary .rm-chevron { transform: rotate(180deg); background: #e3eef1; }
summary:hover .rm-chevron { background: #e3eef1; }

.rm-body { padding: 4px 20px 18px 22px; border-top: 1px solid var(--line); background: #fbfdfd; }
.rm-phase-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 0; }
.rm-phase-tools form.rename { display: flex; gap: 8px; flex: 1; min-width: 240px; max-width: 520px; }

details.rm-step { --s: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0; margin: 0 0 10px;
  transition: border-color .2s, box-shadow .2s; }
details.rm-step.ready { --s: var(--c); } details.rm-step.building { --s: #c9902a; }
details.rm-step:hover { border-color: #c4d6dd; }
details.rm-step[open] { border-color: var(--c); box-shadow: 0 10px 26px #10263d10; }
details.rm-step > summary { padding: 12px 14px; gap: 14px; font-weight: 400; }
.rm-icon { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--s) 13%, #fff); color: var(--s); }
.rm-icon svg { width: 22px; height: 22px; }
details.rm-step.planned .rm-icon { background: #f0f3f5; color: #8a9aa8; }
.rm-step-title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.rm-step-title small { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--teal); }
.rm-step-title span { font-weight: 750; color: var(--ink); font-size: 15px; }
.rm-step-title em { font-style: normal; font-size: 12.5px; color: var(--muted); }
.rm-facts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.rm-fact { font-size: 11.5px; font-weight: 700; color: var(--body); background: var(--soft); border-radius: 999px; padding: 3px 9px; }
.rm-fact.empty { color: #b0bcc6; }
.rm-step .rm-chevron { width: 24px; height: 24px; }
.rm-step-body { padding: 4px 16px 16px; border-top: 1px dashed var(--line); }
.rm-step-body > form { padding-top: 14px; }
.rm-move { margin-top: 12px; }
.rm-links li { padding: 6px 0; }
.rm-deck { color: var(--teal); font-weight: 800; }
.rm-add { margin-top: 8px; }
.rm-add > summary { font-size: 12.5px; font-weight: 700; color: var(--teal); }
.rm-add > summary::before { display: none; }
.rm-add > form { margin-top: 10px; }

@media (max-width: 720px) {
  .rm-dots, .rm-meter .bar { display: none; }
  details.rm-phase > summary { padding: 14px; gap: 12px; }
  .rm-node { width: 38px; height: 38px; }
  .rm-name { font-size: 18px; }
  .rm-facts .rm-fact { display: none; }
}

/* ---------------------------------------------------------------- progress: course cards */
.stat .n small { font-size: 15px; font-weight: 600; color: #a9c3d0; }
.tab-n { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--soft); color: var(--body); font-size: 11px; text-align: center; }
.tabs a[aria-current="page"] .tab-n { background: #ffffff26; color: #fff; }
.courses { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
a.course { position: relative; display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--ink); overflow: hidden;
  transition: transform .25s, box-shadow .25s, border-color .25s; }
a.course::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c, var(--teal)); }
a.course:hover { transform: translateY(-4px); box-shadow: 0 18px 40px #10263d18; border-color: color-mix(in srgb, var(--c) 45%, var(--line)); color: var(--ink); }
.course-top { display: flex; justify-content: space-between; align-items: flex-start; }
.course-icon { flex: none; width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c, var(--teal)) 13%, #fff); color: var(--c, var(--teal)); }
.course-icon svg { width: 26px; height: 26px; }
.course-step { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--c); margin-bottom: -6px; }
a.course h3 { font-family: var(--serif); font-weight: 400; font-size: 20px; line-height: 1.25; color: var(--navy); min-height: 50px; }
.course-ring { position: absolute; right: 20px; top: 74px; width: 54px; height: 54px; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #e6eef1 0); display: grid; place-items: center; }
.course-ring span { width: 42px; height: 42px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; color: var(--navy); }
a.course h3, .course-step { padding-right: 66px; }
.course-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); }
.course-meta b { color: var(--ink); }
a.course .bar > i { background: var(--c); }
.course-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.course-cta { margin-top: 4px; font-size: 13px; font-weight: 750; color: var(--c); }
a.course.todo .course-icon { background: #f0f3f5; color: #8a9aa8; }
a.course.done::after { content: "✓"; position: absolute; right: 16px; bottom: 14px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ok-bg); color: var(--ok); font-weight: 800; font-size: 13px; }

/* ---------------------------------------------------------------- progress: study screen */
.back-link { display: inline-block; font-size: 12.5px; font-weight: 700; text-decoration: none; color: var(--muted); margin-bottom: 14px; }
.back-link:hover { color: var(--teal); }
.study-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; }
.study-head .course-icon { width: 58px; height: 58px; border-radius: 16px; background: var(--c, var(--teal)); color: #fff;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--c) 40%, transparent); }
.study-title { flex: 1; min-width: 240px; }
.study-title h1 { margin: 0 0 6px; font-size: 30px; }
.study-title h1::before { display: none; }
.study-progress { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.study-progress b { color: var(--ink); }
.study-progress .bar { width: 220px; } .study-progress .bar > i { background: var(--c); }

.study { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 22px; align-items: start; }
.toc { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px; }
details.toc-ch { border: 0; border-bottom: 1px solid var(--line); padding: 6px 4px; }
details.toc-ch:last-child { border-bottom: 0; }
details.toc-ch > summary { font-size: 13.5px; gap: 8px; padding: 4px 0; }
details.toc-ch.back > summary { color: var(--muted); }
.toc-no { flex: none; font-family: var(--serif); color: var(--teal); font-size: 13px; min-width: 22px; }
.toc-t { flex: 1; min-width: 0; }
.toc-count { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 1px 7px; }
li.sec { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; padding: 3px 4px 3px 6px; border-radius: 8px; }
li.sec.current { background: #eaf6f7; box-shadow: inset 3px 0 0 var(--teal); }
li.sec.done .sec-go { color: var(--muted); }
.sec-go { all: unset; cursor: pointer; font-size: 12.5px; line-height: 1.35; color: var(--ink); display: flex; gap: 6px; padding: 3px 0; }
.sec-go:hover { color: var(--teal); }
.sec-go:focus-visible { outline: 2px solid var(--teal); border-radius: 4px; }
.sec-state { display: flex; gap: 2px; }
.sec-state .dot { all: unset; cursor: pointer; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; font-size: 12px; color: #b3c0c9; }
.sec-state .dot:hover { background: var(--soft); color: var(--navy); }
.sec-state .dot.doing[aria-pressed="true"] { color: #c9902a; background: var(--warn-bg); }
.sec-state .dot.done[aria-pressed="true"] { color: var(--ok-dot); background: var(--ok-bg); }
.sec-state .dot.todo[aria-pressed="true"] { color: var(--navy); }
.sec-note { grid-column: 1 / -1; margin: 0 0 2px; font-size: 11.5px; color: var(--muted); font-style: italic; }

.viewer-wide { margin-bottom: 22px; }
.viewer-wide .viewer-bar { margin-bottom: 10px; }
.study-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.study-side .card h2 { margin-top: 0; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; }
#viewer { display: block; width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 14px; background: #0b1b2a;
  box-shadow: 0 18px 44px #10263d1f; }
.note-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }

ul.log li { display: flex; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.log li:last-child { border-bottom: 0; }
.log-day { font-family: var(--serif); color: var(--teal); min-width: 54px; }
ul.log li form { margin-left: auto; }

@media (max-width: 960px) {
  .study { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; order: 2; }
}

/* ---------------------------------------------------------------- study screen: done tick, notes, vocabulary */
.sec-done { display: contents; }
.tick { all: unset; cursor: pointer; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid #c3d0d8; display: grid; place-items: center;
  font-size: 12px; font-weight: 900; color: transparent; transition: background .15s, border-color .15s, color .15s; }
.tick:hover { border-color: var(--teal); color: #b7dbe0; }
.tick[aria-pressed="true"] { background: var(--ok-dot); border-color: var(--ok-dot); color: #fff; }
.tick:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
li.sec.done .sec-go { text-decoration: line-through; text-decoration-color: #c3d0d8; }
details.sec-note-edit { border: 0; padding: 0; position: static; }
details.sec-note-edit > summary { list-style: none; cursor: pointer; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  font-size: 12px; color: #a6b4be; }
details.sec-note-edit > summary::before { display: none; }
details.sec-note-edit > summary:hover, details.sec-note-edit[open] > summary { background: var(--soft); color: var(--navy); }
li.sec:has(.sec-note) details.sec-note-edit > summary { color: var(--teal); }
.note-inline { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px; }
details.sec-note-edit[open] { display: contents; }
details.sec-note-edit[open] > form { grid-column: 1 / -1; }
.toc-count.all { background: var(--ok-bg); color: var(--ok); }

.now { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: inset 4px 0 0 var(--teal); }
.now-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.now-label { display: flex; flex-direction: column; min-width: 0; }
.now-label small { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); }
.now-label b { font-family: var(--serif); font-weight: 400; font-size: 19px; color: var(--navy); }
.note-main { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.note-main textarea { min-height: 3.6rem; }

.vocab-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.vocab-head h2 { margin: 0; }
.vocab-head input[type=search] { max-width: 240px; border-radius: 999px; padding: 7px 14px; }
.vocab-form { background: #f8fbfb; border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.vocab-list li { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.vocab-list li:last-child { border-bottom: 0; }
.vw-main { display: flex; flex-direction: column; min-width: 0; }
.vw-term { font-size: 15px; color: var(--navy); }
.vw-meaning { font-size: 13.5px; color: var(--body); }
.vw-example { font-size: 12.5px; color: var(--muted); font-style: italic; }
.vw-side { display: flex; gap: 10px; align-items: center; flex: none; }
.vw-sec { font-size: 11px; font-weight: 700; color: var(--teal); background: #eaf6f7; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }

/* ---------------------------------------------------------------- study screen: full-width slides */
/* the viewer breaks out of main's 1220px column and uses the whole window width */
.viewer-wide { width: 100vw; position: relative; left: 50%; margin-left: -50vw; padding: 10px 16px 14px; margin-bottom: 18px;
  background: var(--bg); box-sizing: border-box; }
.viewer-wide .viewer-bar { max-width: none; }
.viewer-wide #viewer { width: 100%; height: auto; aspect-ratio: 16 / 9; max-height: none; border-radius: 10px; }
.viewer-wide.pinned { position: sticky; top: 63px; z-index: 4; left: auto; margin-left: calc(50% - 50vw);
  box-shadow: 0 14px 16px -14px #10263d40; }
.viewer-wide.pinned #viewer { aspect-ratio: auto; height: 60vh; }
body:has(.viewer-wide.pinned) .toc { position: static; max-height: none; }
body:has(.viewer-wide.pinned) .study [id], body:has(.viewer-wide.pinned) .study-side > * { scroll-margin-top: calc(63px + 60vh + 80px); }
body { overflow-x: hidden; }
#pin-toggle[aria-pressed="false"] { opacity: .75; }
@media (max-width: 720px), (max-height: 640px) {
  .viewer-wide.pinned { position: relative; box-shadow: none; }
  .viewer-wide.pinned #viewer { aspect-ratio: 16 / 9; height: auto; }
}

/* ---------------------------------------------------------------- study timer */
.timer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timer-clock { font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: .02em; color: var(--navy);
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px 12px; min-width: 112px; text-align: center;
  font-variant-numeric: tabular-nums; }
.timer-state { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border-radius: 999px; padding: 4px 10px; background: var(--soft); }
.timer-break { font-size: 12px; color: #a26a12; font-weight: 650; }
.timer[data-state="learning"] .timer-clock { color: var(--ok); border-color: #9fdcc2; box-shadow: 0 0 0 3px #3fcf9f26; }
.timer[data-state="learning"] .timer-state { background: var(--ok-bg); color: var(--ok); }
.timer[data-state="learning"] .timer-state::before { content: "● "; color: var(--ok-dot); animation: blink 1.4s ease-in-out infinite; }
.timer[data-state="break"] .timer-clock { color: #a26a12; border-color: #f0d49c; }
.timer[data-state="break"] .timer-state { background: var(--warn-bg); color: var(--warn); }
@keyframes blink { 50% { opacity: .25; } }
.finish-form { background: var(--ok-bg); border: 1px solid #bfe6d1; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.finish-sum { margin: 0 0 8px; color: var(--ok); font-size: 14px; }
.manual-log > summary { font-size: 12.5px; font-weight: 700; color: var(--teal); margin-bottom: 8px; }
.manual-log > summary::before { display: none; }
.manual-log[open] > form { margin-bottom: 12px; }
@media (prefers-reduced-motion: reduce) { .timer[data-state="learning"] .timer-state::before { animation: none; } }

/* ---------------------------------------------------------------- study screen: slides + contents in one full-width row */
.viewer-row { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: stretch; }
.viewer-row #viewer { min-width: 0; }
.viewer-row .toc { position: static; top: auto; max-height: none; height: 0; min-height: 100%; overflow: auto; }
.viewer-wide.pinned .viewer-row .toc { height: 60vh; min-height: 0; }
.no-file { display: grid; place-items: center; aspect-ratio: 16 / 9; border: 1px dashed var(--line); border-radius: 10px; background: #fff; }
.study { display: block; }
@media (max-width: 960px) {
  .viewer-row { grid-template-columns: 1fr; }
  .viewer-row .toc { height: auto; min-height: 0; max-height: 50vh; }
}

/* ---------------------------------------------------------------- roadmap ↔ study links */
a.rm-study { font-size: 11.5px; font-weight: 750; text-decoration: none; color: var(--c, var(--teal)); border: 1px solid currentColor;
  border-radius: 999px; padding: 3px 10px; white-space: nowrap; transition: background .15s, color .15s; }
a.rm-study:hover { background: var(--c, var(--teal)); color: #fff; }
a.rm-study.done { background: var(--ok-bg); color: var(--ok); border-color: #bfe6d1; }
.crumbs { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- study screen: note + vocabulary side by side */
.study-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.study-pair > .now, .study-pair > .vocab { margin: 0; height: 100%; }
.study-pair .now-top { align-items: flex-start; }
.study-pair .note-main textarea { min-height: 9.5rem; }
.study-pair .vocab .row > div { flex-basis: 100% !important; }
.study-pair .vocab .row > .fix { flex-basis: auto !important; }
.study-pair .vocab-list { max-height: 360px; overflow: auto; }
@media (max-width: 960px) { .study-pair { grid-template-columns: 1fr; } }
.study-pair > .now { display: flex; flex-direction: column; }
.study-pair .note-main { flex: 1; }
.study-pair .note-main textarea { flex: 1; resize: vertical; }

/* ---------------------------------------------------------------- words page */
.words-filter .tabs { margin-bottom: 14px; }
.word-day { margin-top: 26px; }
.word-day h2 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; }
.word-date { font-family: var(--sans); font-size: 12.5px; color: var(--muted); font-weight: 600; }
.word-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.word-card { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 12px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: inset 0 3px 0 var(--teal); transition: box-shadow .2s, transform .2s; }
.word-card:hover { transform: translateY(-2px); box-shadow: inset 0 3px 0 var(--teal), 0 12px 26px #10263d14; }
.wc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.word-card h3 { font-family: var(--serif); font-weight: 400; font-size: 21px; color: var(--navy); }
.wc-top form button { padding: 2px 8px; opacity: .45; }
.word-card:hover .wc-top form button { opacity: 1; }
.wc-meaning { margin: 0; color: var(--body); font-size: 14px; }
.wc-example { margin: 0; color: var(--muted); font-size: 12.5px; font-style: italic; }
.wc-foot { margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.wc-foot a { font-weight: 700; text-decoration: none; }
.wc-time { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty-words { text-align: center; padding: 30px; }
