/* Variant B — Datasheet: black rules, condensed caps, tables */
:root {
  --bg: #ffffff;
  --bg-2: #f4f4f2;
  --bg-3: #e9e9e6;
  --ink: #111111;
  --ink-2: #3c3c3c;
  --ink-3: #74746f;
  --line: #cfcfca;
  --ozu-blue: #00338d;
  --ozu-magenta: #a30050;
  --accent: var(--ozu-magenta);
  --link: var(--ozu-blue);
  --cond: 'IBM Plex Sans Condensed', 'Arial Narrow', sans-serif;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --bar-h: 64px;
  --tree-w: 280px;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15.5px/1.55 var(--sans); display: flex; flex-direction: column; min-height: 100dvh; }
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
kbd { font: 12px var(--mono); border: 1px solid var(--ink-3); padding: 0 5px; border-radius: 2px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---------- bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 50;
  height: var(--bar-h); padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg); border-bottom: 3px solid var(--ink);
}
.bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text b { font: 700 21px/1 var(--cond); letter-spacing: .02em; }
.brand-text .b-ozu { color: var(--ozu-magenta); }
.brand-text .b-courses { color: var(--ozu-blue); }
.brand-by { margin-top: 4px; font: 500 12.5px/1.1 var(--cond); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 400px) { .brand-text b { font-size: 19px; } .brand-by { font-size: 11px; letter-spacing: .04em; } }
.bar-actions { display: flex; align-items: center; gap: 8px; }
.search-btn {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px 0 12px;
  background: var(--bg); border: 1px solid var(--ink); border-radius: 0; cursor: pointer; font-size: 14px; color: var(--ink-2);
}
.search-btn:hover { background: var(--bg-2); color: var(--ink); }
.search-btn svg, .gh svg { width: 16px; height: 16px; flex: none; }
.search-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-btn kbd { color: var(--ink-3); border-color: var(--line); }
.gh { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; background: var(--ink); color: #fff; font: 500 14px var(--sans); }
.gh svg { fill: currentColor; }
.gh:hover { background: var(--accent); }

/* ---------- layout ---------- */
.shell { flex: 1; display: grid; grid-template-columns: 1fr; }
.tree { display: none; }
.view { min-width: 0; padding: 24px var(--gutter) 64px; }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ink); font: 12px var(--sans); color: var(--ink-3);
}
.foot span:first-child { font: 700 12px var(--cond); color: var(--ink); letter-spacing: .04em; }
.foot a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }

@media (min-width: 1024px) {
  :root { --gutter: 32px; }
  .shell { grid-template-columns: var(--tree-w) minmax(0, 1fr); }
  .tree {
    display: block; position: sticky; top: var(--bar-h); height: calc(100dvh - var(--bar-h));
    overflow: auto; border-right: 1px solid var(--ink); padding: 16px 0 40px; background: var(--bg);
  }
  .view { padding: 32px 48px 80px; max-width: 1180px; }
  body[data-view="file"] .view { max-width: none; }
}

/* ---------- browse drawer (below 1024px) ---------- */
.browse-btn {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 10px; flex: none;
  background: var(--ink); color: #fff; border: 1px solid var(--ink); cursor: pointer;
  font: 600 13px var(--cond); text-transform: uppercase; letter-spacing: .08em;
}
.browse-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.browse-btn .i-close, .tree-open .browse-btn .i-open { display: none; }
.tree-open .browse-btn .i-close { display: inline; }
.tree-scrim { display: none; }
@media (max-width: 1023px) {
  .tree {
    display: block; position: fixed; z-index: 45; left: 0; top: var(--bar-h); bottom: 0;
    width: min(88vw, 360px); overflow: auto; overscroll-behavior: contain;
    background: var(--bg); border-right: 2px solid var(--ink);
    padding: 16px 0 calc(40px + env(safe-area-inset-bottom));
    transform: translateX(-102%); transition: transform .22s ease; visibility: hidden;
  }
  .tree-open .tree { transform: none; visibility: visible; }
  .tree-scrim { display: block; position: fixed; inset: var(--bar-h) 0 0 0; z-index: 44; background: rgba(17, 17, 17, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .tree-open .tree-scrim { opacity: 1; pointer-events: auto; }
  .tree a, .tree summary { font-size: 15px; padding-top: 7px; padding-bottom: 7px; }
  .tree summary { padding: 0 0 0 8px; }
  .tree-inner > ul > li > details > summary a { font-size: 17px; }
}
@media (min-width: 1024px) { .browse-btn { display: none; } }

/* ---------- tree ---------- */
.tree::before { content: 'Contents'; display: block; font: 600 12px var(--cond); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); padding: 0 16px 10px; }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 12px; }
.tree-inner > ul { padding-left: 4px; }
.tree a, .tree summary { display: block; font: 13px/1.5 var(--sans); color: var(--ink-2); padding: 3px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree summary { padding: 0 0 0 6px; cursor: pointer; list-style: none; display: flex; align-items: center; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: ''; width: 0; height: 0; border-left: 5px solid var(--ink-3); border-top: 4px solid transparent; border-bottom: 4px solid transparent; flex: none; margin-right: 2px; transition: transform .12s; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary a { flex: 1; min-width: 0; padding-left: 6px; }
.tree a:hover { background: var(--bg-2); color: var(--ink); }
.tree a.is-active { background: var(--ozu-blue); color: #fff; }
.tree-inner > ul > li > details > summary a { font: 600 14px var(--cond); color: var(--ink); letter-spacing: .02em; }

/* ---------- home ---------- */
.ds-title { margin-bottom: 8px; }
.ds-kicker { margin: 0 0 6px; font: 600 13px var(--cond); text-transform: uppercase; letter-spacing: .14em; color: var(--accent); }
.ds-title h1 { margin: 0; font: 700 clamp(28px, 6vw, 44px)/1.05 var(--cond); letter-spacing: -.005em; }
.ds-title h1 span { display: block; font-weight: 500; font-size: .62em; color: var(--ink-2); margin-top: 6px; }

.ds-sec { margin-top: 32px; }
.ds-sec h2 { display: flex; align-items: center; gap: 10px; font: 700 19px var(--cond); margin: 0 0 12px; padding-top: 8px; border-top: 2px solid var(--ink); }
.ds-sec h2 span { display: inline-grid; place-items: center; min-width: 24px; height: 24px; background: var(--ozu-magenta); color: #fff; font: 600 13px var(--mono); }
.tbl-wrap { border: 1px solid var(--ink); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { background: var(--ink); color: #fff; font: 600 12.5px var(--cond); text-transform: uppercase; letter-spacing: .08em; text-align: left; padding: 8px 12px; white-space: nowrap; }
.tbl td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:hover { background: var(--bg-2); }
.c-pn a { font: 600 15px var(--mono); color: var(--link); white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.c-term, .c-date { white-space: nowrap; font-family: var(--mono); font-size: 13.5px; }
@media (max-width: 560px) {
  .tbl-rev th, .tbl-rev td { padding: 9px 10px; }
  .tbl-rev .c-date { font-size: 12.5px; }
}

/* ---------- crumbs ---------- */
.crumbs { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; font: 13px var(--sans); color: var(--ink-3); margin-bottom: 16px; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb { white-space: nowrap; }
a.crumb { color: var(--link); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line); }
a.crumb:hover { text-decoration-color: currentColor; }
.crumb.is-current { color: var(--ink); font-weight: 500; }
.crumb-sep { color: var(--line); }

/* ---------- course / dir ---------- */
.course-head, .dir-head { border-bottom: 1px solid var(--ink); padding-bottom: 18px; margin-bottom: 22px; }
.course-code { display: flex; align-items: center; gap: 10px; margin: 0; font: 700 clamp(36px, 8vw, 56px)/1 var(--cond); letter-spacing: .01em; }
.badge-now { font: 600 12px var(--cond); text-transform: uppercase; letter-spacing: .08em; background: var(--accent); color: #fff; padding: 4px 8px; }
.course-title { margin: 8px 0 4px; font: 500 clamp(19px, 3.6vw, 24px)/1.25 var(--cond); }
.dir-title { margin: 0; font: 700 clamp(28px, 6vw, 40px)/1.1 var(--cond); overflow-wrap: anywhere; }
.course-facts, .dir-meta { margin: 0; color: var(--ink-3); font-size: 14.5px; }
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--ink); }
.list li + li { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 50px; padding: 8px 14px; }
.row:hover { background: var(--bg-2); }
.row:hover .row-name { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.row-name { overflow-wrap: anywhere; line-height: 1.35; }
.row.is-dir .row-name { font-weight: 600; }
.row-meta { font: 13px var(--mono); color: var(--ink-3); white-space: nowrap; }
.row-tag { font: 500 11px/1 var(--mono); text-align: center; padding: 4px 0; border: 1px solid currentColor; min-width: 44px; justify-self: start; }
.t-dir { background: var(--ink); color: #fff; border-color: var(--ink); }
.t-pdf { color: var(--accent); }
.t-code, .t-md { color: var(--link); }
.t-img { color: #8a5a00; }
.t-file { color: var(--ink-3); }

/* ---------- file ---------- */
.file-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 20px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--ink); }
.file-id { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.file-title { flex-basis: 100%; order: 2; margin: 0; font: 700 clamp(22px, 5vw, 32px)/1.15 var(--cond); overflow-wrap: anywhere; }
.file-size { font: 13px var(--mono); color: var(--ink-3); }
.file-actions { display: flex; flex-wrap: wrap; gap: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; font: 500 14px var(--sans); background: var(--bg); border: 1px solid var(--ink); margin-left: -1px; cursor: pointer; }
.btn:first-child { margin-left: 0; }
.btn:hover { background: var(--bg-2); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

.pdf-frame { display: block; width: 100%; height: calc(100dvh - var(--bar-h) - 180px); min-height: 480px; border: 1px solid var(--ink); background: var(--bg-3); }
.pdf-pages { display: flex; flex-direction: column; gap: 10px; }
.pdf-page { width: 100%; background: #fff; outline: 1px solid var(--ink); }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-counter { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20; font: 500 13px var(--mono); background: var(--ink); color: #fff; padding: 6px 12px; }
.img-frame { margin: 0; border: 1px solid var(--ink); padding: 10px; display: inline-block; max-width: 100%; }
.img-frame img { display: block; max-width: 100%; max-height: 75vh; height: auto; cursor: zoom-in; }

.code { border: 1px solid var(--ink); background: var(--bg-2); }
.code pre { margin: 0; overflow: auto; font: 13px/1.6 var(--mono); padding: 14px 14px 14px 3.8em; tab-size: 4; }
.code code { font: inherit; }
.line-numbers .line-numbers-rows { border-right: 1px solid var(--line) !important; }
.line-numbers-rows > span::before { color: var(--ink-3) !important; }
.token.comment, .token.prolog { color: #6f6f68; font-style: italic; }
.token.keyword, .token.important { color: var(--accent); font-weight: 500; }
.token.string, .token.char, .token.attr-value { color: #1b6b3a; }
.token.number, .token.boolean, .token.constant { color: #8a5a00; }
.token.function, .token.class-name { color: var(--link); }
.token.operator, .token.punctuation { color: var(--ink-2); }

.prose { max-width: 46em; }
.prose code { font: 13.5px var(--mono); background: var(--bg-2); padding: 1px 4px; }
.dl-card { padding: 32px; border: 1px solid var(--ink); text-align: center; color: var(--ink-2); }

/* ---------- states ---------- */
.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-3); padding: 24px 0; font-size: 14px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--accent); padding: 24px 0; }
.error .btn { margin-top: 12px; }
.missing h1 { font: 700 40px var(--cond); margin: 0 0 8px; }

/* ---------- search ---------- */
.search { position: fixed; inset: 0; z-index: 100; background: rgba(17, 17, 17, .4); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.search[hidden] { display: none; }
.search-panel { width: 100%; max-width: 660px; max-height: 72vh; display: flex; flex-direction: column; background: var(--bg); border: 2px solid var(--ink); }
.search-field { display: flex; border-bottom: 1px solid var(--ink); }
.search-field input { flex: 1; min-width: 0; border: 0; padding: 15px 16px; font: 18px var(--sans); outline: none; background: none; color: var(--ink); }
.search-close { border: 0; border-left: 1px solid var(--ink); background: var(--bg-2); padding: 0 16px; font: 600 13px var(--cond); text-transform: uppercase; letter-spacing: .08em; cursor: pointer; }
.search-results { list-style: none; margin: 0; padding: 0; overflow: auto; }
.search-results li + li { border-top: 1px solid var(--line); }
.search-item { display: grid; grid-template-columns: 50px minmax(0, 1fr); column-gap: 12px; padding: 9px 14px; align-items: center; }
.search-item .row-tag { grid-row: span 2; min-width: 0; }
.search-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-path { font: 12px var(--mono); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item.is-sel, .search-item:hover { background: var(--bg-2); box-shadow: inset 3px 0 0 var(--accent); }
.search-hint { padding: 14px 16px; color: var(--ink-3); }

@media (max-width: 640px) {
  .search { padding: 0; align-items: stretch; }
  .search-panel { max-width: none; max-height: none; height: 100dvh; border: 0; padding-top: env(safe-area-inset-top); }
  .search-btn-label, .search-btn kbd, .gh span { display: none; }
  .search-btn { width: 40px; padding: 0; justify-content: center; }
  .gh { width: 40px; padding: 0; justify-content: center; }
}
@media (max-width: 360px) { .browse-btn span { display: none; } }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 120; background: rgba(255, 255, 255, .97); display: none; align-items: center; justify-content: center; padding: 16px; }
.lightbox.is-open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; outline: 1px solid var(--ink); }
.lightbox-x { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; font-size: 26px; background: var(--ink); color: #fff; border: 0; cursor: pointer; }

@media (max-width: 1023px) {
  .row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px; padding: 8px 12px; }
  .row-tag { min-width: 42px; }
  .file-actions { width: 100%; }
  .file-actions .btn { flex: 1; padding: 0 8px; }
  .code pre { font-size: 12px; }
  .view .code, .view .pdf-pages { margin: 0 calc(var(--gutter) * -1); }
  .view .code { border-left: 0; border-right: 0; }
}
