/* Kombatan FMA — study site. Black theme, responsive, zero dependencies. */
:root {
  --bg: #050505;
  --bg-1: #0e0e10;
  --bg-2: #151518;
  --bg-3: #1d1d22;
  --line: #2a2a30;
  --line-soft: #1f1f24;
  --tx: #ececf0;
  --tx-dim: #a4a4ad;
  --tx-faint: #6c6c75;
  --accent: #e23b3b;            /* default; overridden per level */
  --ok: #3fae5a;
  --warn: #e8a13a;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 8px 30px rgba(0,0,0,.55);
  --maxw: 960px;
  /* diagram palette */
  --dg-bg: #0b0b0d; --dg-line: #34343c; --dg-figure: #3a3a44; --dg-text: #cfcfd6;
  --dg-hi: #e23b3b; --dg-mid: #3a7bd5; --dg-low: #e8a13a; --dg-th: #3fae5a; --dg-chip: #161619;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #131318 0%, var(--bg) 60%) fixed;
  color: var(--tx);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 76px; /* room for mobile tab bar */
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: rgba(5,5,5,.82); backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .04em; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: conic-gradient(from 220deg, var(--accent), #7a1414 60%, var(--accent));
  display: grid; place-items: center; font-size: 13px; color: #fff; font-weight: 800;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset;
}
.brand small { color: var(--tx-faint); font-weight: 500; letter-spacing: .02em; }
.nav-links { margin-left: auto; display: flex; gap: 4px; }
.nav-links a {
  padding: 7px 13px; border-radius: 999px; color: var(--tx-dim); font-size: 13.5px; font-weight: 600;
}
.nav-links a.active { background: var(--bg-3); color: var(--tx); }
.nav-links a .badge {
  margin-left: 6px; background: var(--accent); color: #fff; border-radius: 999px;
  padding: 0 6px; font-size: 11px; font-weight: 700; vertical-align: 1px;
}

/* ---------------- layout ---------------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 22px 18px 60px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.muted { color: var(--tx-dim); }
.faint { color: var(--tx-faint); }
.section-title { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--tx-faint); margin: 26px 2px 12px; }
h1 { font-size: 26px; margin: 4px 0 6px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 0 0 2px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--tx-faint); margin-bottom: 14px; }
.crumbs a:hover { color: var(--tx); }
.crumbs .sep { opacity: .5; }

/* ---------------- cards ---------------- */
.card {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 18px;
}
.grid { display: grid; gap: 14px; }
.grid.levels { grid-template-columns: 1fr; }

.level-card {
  position: relative; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .12s ease, border-color .12s ease;
}
.level-card:hover { transform: translateY(-2px); border-color: var(--line); }
.level-card .head { display: flex; align-items: center; gap: 12px; }
.belt-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,.05); flex: none; }
.level-card .title { font-weight: 700; font-size: 17px; }
.level-card .belt { font-size: 12.5px; color: var(--tx-dim); }
.level-card .sum { color: var(--tx-dim); font-size: 13.5px; }
.level-card .meta { display: flex; gap: 16px; font-size: 12.5px; color: var(--tx-faint); margin-top: 2px; }
.level-card .meta b { color: var(--tx-dim); font-weight: 700; }

/* progress bar */
.bar { height: 7px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.bar.sm { height: 5px; }

/* ---------------- sections / topics ---------------- */
.sec { margin-top: 22px; }
.sec > .sec-h { display: flex; align-items: center; gap: 10px; margin: 0 2px 10px; }
.sec > .sec-h .name { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--tx-dim); font-weight: 700; }
.sec > .sec-h .line { flex: 1; height: 1px; background: var(--line-soft); }

.topic {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: var(--bg-1); border: 1px solid var(--line-soft); border-radius: var(--radius-s);
  padding: 13px 14px; margin-bottom: 9px; transition: border-color .12s, background .12s;
}
.topic:hover { border-color: var(--line); background: var(--bg-2); }
.topic .chk {
  width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line);
  flex: none; display: grid; place-items: center; color: transparent; font-size: 13px;
  transition: all .12s;
}
.topic.done .chk { background: var(--ok); border-color: var(--ok); color: #04140a; }
.topic .tx { flex: 1; min-width: 0; }
.topic .tt { font-weight: 600; font-size: 14.5px; }
.topic.done .tt { color: var(--tx-dim); }
.topic .tags { display: flex; gap: 7px; margin-top: 4px; flex-wrap: wrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); color: var(--tx-dim); display: inline-flex; align-items: center; gap: 4px; }
.pill.v { color: #cfe0ff; background: #16243d; }
.pill.c { color: #ffd9d9; background: #3a1a1a; }
.pill.d { color: #d9ffe6; background: #15301f; }
.pill.n { color: #f2e6cf; background: #322713; }
.topic .arrow { color: var(--tx-faint); flex: none; }

/* ---------------- topic detail ---------------- */
.video {
  position: relative; background: #000; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 12px;
}
.video video { width: 100%; display: block; max-height: 62vh; background: #000; }
.video .vcap { padding: 10px 14px; font-size: 13.5px; color: var(--tx-dim); border-top: 1px solid var(--line-soft); display: flex; gap: 8px; align-items: center; }
.video .vcap .seq { color: var(--tx-faint); font-variant-numeric: tabular-nums; }
.video-missing { padding: 22px 16px; text-align: center; color: var(--tx-faint); font-size: 13px; }
.video-missing code { color: var(--tx-dim); background: var(--bg-2); padding: 2px 6px; border-radius: 6px; font-size: 12px; word-break: break-all; }

.vid-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.vid-tab { padding: 7px 11px; border-radius: 999px; background: var(--bg-1); border: 1px solid var(--line-soft); color: var(--tx-dim); font-size: 12.5px; font-weight: 600; }
.vid-tab.active { background: var(--accent); border-color: transparent; color: #fff; }
.vid-tab .n { opacity: .7; margin-right: 5px; font-variant-numeric: tabular-nums; }

.note { display: flex; gap: 11px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--bg-1); border: 1px solid var(--line-soft); margin-bottom: 9px; }
.note .ic { flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.note.pdf .ic { background: #16243d; color: #9cc0ff; }
.note.personal .ic { background: #2c1d3a; color: #d6a9ff; }
.note.class .ic { background: #1d3323; color: #8fe0a8; }
.note .body { flex: 1; }
.note .body .src { font-size: 11px; color: var(--tx-faint); margin-top: 5px; letter-spacing: .02em; }
.note .body .src b { color: var(--tx-dim); font-weight: 600; }

/* diagram block */
.diagram { background: var(--dg-bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.diagram h3 { margin: 0 0 10px; font-size: 14px; color: var(--tx); }
.diagram .dg { width: 100%; height: auto; max-height: 320px; display: block; }
.diagram .cap { margin-top: 10px; font-size: 12.5px; color: var(--tx-dim); }

/* svg diagram primitives */
.dg-figure { fill: none; stroke: var(--dg-figure); stroke-width: 2; stroke-linejoin: round; }
.dg-stroke { stroke-width: 3; fill: none; stroke-linecap: round; }
.dg-head { fill: var(--dg-line); }
.dg-hi { stroke: var(--dg-hi); }   .dg-num.dg-hi { fill: var(--dg-hi); stroke: none; }
.dg-mid { stroke: var(--dg-mid); } .dg-num.dg-mid { fill: var(--dg-mid); stroke: none; }
.dg-low { stroke: var(--dg-low); } .dg-num.dg-low { fill: var(--dg-low); stroke: none; }
.dg-th { stroke: var(--dg-th); }   .dg-num.dg-th { fill: var(--dg-th); stroke: none; }
.dg-num { }
.dg-numtext { fill: #06060a; font: 700 11px sans-serif; text-anchor: middle; }
.dg-cap { fill: var(--dg-text); font: 700 12px sans-serif; text-anchor: middle; letter-spacing: .08em; }
.dg-small { fill: var(--tx-dim); font: 500 10.5px sans-serif; text-anchor: middle; }
.dg-axis { stroke: var(--dg-line); stroke-width: 1; stroke-dasharray: 4 4; }
.dg-band { fill: rgba(255,255,255,.03); stroke: var(--dg-line); stroke-width: 1; rx: 8; }
.dg-band.b1 { fill: rgba(226,59,59,.08); } .dg-band.b2 { fill: rgba(58,123,213,.08); } .dg-band.b3 { fill: rgba(232,161,58,.08); }
.dg-tri { fill: rgba(255,255,255,.025); stroke: var(--dg-line); stroke-width: 1.5; }
.dg-tri.alt { stroke-dasharray: 5 4; }
.dg-chip { fill: var(--dg-chip); stroke: var(--line-soft); stroke-width: 1; }

/* ---------------- flashcards ---------------- */
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.review-head .count { font-size: 13px; color: var(--tx-dim); }
.fc-wrap { max-width: 600px; margin: 0 auto; }
.flashcard {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 26px 22px; min-height: 230px; display: flex; flex-direction: column;
}
.flashcard .deck { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--tx-faint); }
.flashcard .q { font-size: 20px; font-weight: 700; margin: 10px 0 4px; line-height: 1.35; }
.flashcard .a { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 16px; }
.flashcard .a ul { margin: 0; padding-left: 18px; }
.flashcard .a li { margin: 6px 0; }
.flashcard .a.hidden { display: none; }
.fc-actions { margin-top: 20px; }
.btn {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-3); font-weight: 700; font-size: 15px; transition: filter .12s, transform .05s;
}
.btn:active { transform: scale(.99); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.grade { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade button { padding: 12px 6px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg-2); font-weight: 700; font-size: 13px; display: flex; flex-direction: column; gap: 3px; align-items: center; }
.grade button small { font-weight: 500; font-size: 11px; color: var(--tx-faint); }
.grade .g0 { box-shadow: inset 0 -2px 0 #c0392b; }
.grade .g3 { box-shadow: inset 0 -2px 0 #e8a13a; }
.grade .g4 { box-shadow: inset 0 -2px 0 #3a7bd5; }
.grade .g5 { box-shadow: inset 0 -2px 0 #3fae5a; }
.fc-empty { text-align: center; padding: 50px 20px; color: var(--tx-dim); }
.fc-empty .big { font-size: 40px; margin-bottom: 8px; }
.fc-progress { height: 4px; background: var(--bg-3); border-radius: 999px; margin-bottom: 18px; overflow: hidden; }
.fc-progress > i { display: block; height: 100%; background: var(--accent); }

/* deck list */
.deck-row { display: flex; align-items: center; gap: 13px; padding: 13px 14px; background: var(--bg-1); border: 1px solid var(--line-soft); border-radius: var(--radius-s); margin-bottom: 9px; }
.deck-row:hover { border-color: var(--line); }
.deck-row .nm { flex: 1; font-weight: 600; }
.deck-row .due { font-size: 12px; color: var(--tx-faint); }
.deck-row .due b { color: var(--accent); }

/* ---------------- progress dashboard ---------------- */
.stat { text-align: center; padding: 18px 10px; }
.stat .num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.stat .lbl { font-size: 12px; color: var(--tx-faint); margin-top: 2px; }
.stats3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.lvl-prog { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.lvl-prog .nm { width: 92px; font-size: 13px; font-weight: 600; flex: none; }
.lvl-prog .bar { flex: 1; }
.lvl-prog .pct { width: 40px; text-align: right; font-size: 12px; color: var(--tx-dim); font-variant-numeric: tabular-nums; flex: none; }

/* ---------------- mobile bottom tabs ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: none;
  background: rgba(8,8,9,.92); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px; color: var(--tx-faint); font-size: 10.5px; font-weight: 600; position: relative; }
.tabbar a.active { color: var(--tx); }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a .dot { position: absolute; top: 0; right: 50%; margin-right: -16px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.empty { text-align: center; color: var(--tx-faint); padding: 30px; }

/* ---------------- responsive ---------------- */
@media (min-width: 720px) {
  .grid.levels { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  body { padding-bottom: 86px; }
  .nav-links { display: none; }
  .tabbar { display: flex; }
  .wrap { padding: 16px 14px 40px; }
  h1 { font-size: 22px; }
  .flashcard .q { font-size: 18px; }
  .topbar { padding: 11px 14px; }
}
@media (max-width: 380px) {
  .grade { grid-template-columns: repeat(2,1fr); }
}

/* focus visibility for keyboard / a11y */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.kbd-hint { font-size: 11px; color: var(--tx-faint); text-align: center; margin-top: 12px; }
.kbd-hint kbd { background: var(--bg-3); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 11px; }
