:root {
  --ink: #171717;
  --muted: #5f5f5f;
  --paper: #ffffff;
  --surface: #f6f6f4;
  --line: #d8d8d4;
  --orange: #e77500;
  --orange-dark: #b85600;
  --max: 1080px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; }
a { color: inherit; }
button, input, select { font: inherit; }
.skip-link { position: absolute; left: 16px; top: -60px; z-index: 20; background: var(--ink); color: white; padding: 10px 14px; }
.skip-link:focus { top: 12px; }

.site-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.header-inner { max-width: var(--max); min-height: 68px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; background: var(--orange); color: white; font-weight: 750; }
.brand strong, .brand small { display: block; line-height: 1.15; }
.brand strong { font-size: 18px; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
nav { display: flex; align-items: center; gap: 24px; }
nav a { color: #333; font-size: 14px; font-weight: 600; text-decoration: none; }
nav a:hover, nav a:focus-visible, nav a[aria-current="page"] { color: var(--orange-dark); text-decoration: underline; text-underline-offset: 5px; }

main { min-height: calc(100vh - 180px); }
.view { max-width: var(--max); margin: 0 auto; padding: 64px 24px 80px; outline: 0; }
.eyebrow { margin: 0 0 10px; color: var(--orange-dark); font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3 { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(38px, 6vw, 56px); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: 10px; font-size: 30px; line-height: 1.15; letter-spacing: -.02em; }
h3 { margin-bottom: 0; font-size: 18px; line-height: 1.3; }
.lede { max-width: 710px; margin: 0; color: var(--muted); font-size: 19px; line-height: 1.6; }

.home-intro { padding: 20px 0 48px; }
.home-intro h1 { max-width: 760px; }
.module-grid { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.module-panel { min-height: 255px; padding: 28px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; color: inherit; text-decoration: none; transition: background-color 120ms ease, box-shadow 120ms ease; }
.module-panel:hover, .module-panel:focus-visible { position: relative; background: var(--surface); box-shadow: inset 4px 0 var(--orange); }
.module-number { margin-bottom: 30px; color: var(--orange-dark); font-size: 12px; font-weight: 750; }
.module-panel p { max-width: 430px; margin: 0; color: var(--muted); line-height: 1.55; }
.module-footer { margin-top: auto; padding-top: 28px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 13px; }
.module-footer span:last-child { color: var(--ink); font-weight: 700; }

.back-link { display: inline-flex; gap: 7px; align-items: center; margin-bottom: 40px; color: var(--muted); font-size: 14px; font-weight: 650; text-decoration: none; }
.back-link:hover, .back-link:focus-visible { color: var(--orange-dark); text-decoration: underline; text-underline-offset: 4px; }
.module-header { margin-bottom: 40px; display: grid; grid-template-columns: minmax(280px, .85fr) minmax(320px, 1fr); gap: 56px; align-items: end; }
.module-header h1 { margin: 0; }
.module-header > p { margin: 0; color: var(--muted); line-height: 1.6; }

.library-note { margin-bottom: 28px; padding: 18px 20px; border: 1px solid var(--line); display: flex; gap: 16px; align-items: flex-start; background: var(--surface); }
.library-note strong { display: block; margin-bottom: 3px; }
.library-note p { margin: 0; color: var(--muted); font-size: 14px; }
.hf-mark { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 5px; background: #ff9d00; color: #241500; font-size: 12px; font-weight: 800; }
.library-toolbar { margin-bottom: 20px; }
.library-search { max-width: 520px; display: grid; gap: 7px; color: #333; font-size: 14px; font-weight: 650; }
.library-search input { width: 100%; min-height: 44px; border: 1px solid #bdbdb7; border-radius: 3px; padding: 9px 12px; background: white; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 10px; }
.filter { min-height: 38px; border: 1px solid var(--line); border-radius: 3px; padding: 7px 12px; background: white; color: #333; font-size: 14px; cursor: pointer; }
.filter:hover, .filter:focus-visible { border-color: #777; }
.filter.active { border-color: var(--ink); background: var(--ink); color: white; }
.result-count { margin: 0; color: var(--muted); font-size: 13px; }
.catalog-list { border-top: 1px solid var(--line); }
.catalog-card { display: grid; grid-template-columns: minmax(260px, 1.15fr) minmax(230px, .85fr) minmax(170px, .55fr); gap: 24px 36px; padding: 28px 0; border-bottom: 1px solid var(--line); }
.catalog-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.catalog-card p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.catalog-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; font-size: 13px; }
.catalog-card dt { color: var(--muted); }
.catalog-card dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.dataset-materials { margin-top: 16px; }
.dataset-materials strong { font-size: 13px; }
.catalog-card .dataset-materials p { margin-top: 4px; color: var(--ink); }
.status { flex: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; color: #444; font-size: 10px; font-weight: 750; letter-spacing: .05em; line-height: 1.4; text-transform: uppercase; white-space: nowrap; }
.tag-list { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 5px; }
.tag-list span { padding: 3px 7px; border-radius: 3px; background: var(--surface); color: var(--muted); font-size: 11px; }
.library-actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.library-actions > small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.library-action { min-height: 38px; border: 1px solid var(--ink); border-radius: 3px; padding: 8px 11px; display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--ink); font-size: 13px; font-weight: 700; text-align: center; text-decoration: none; }
.library-action.primary { background: var(--ink); color: white; }
.library-action:hover, .library-action:focus-visible { border-color: var(--orange-dark); color: var(--orange-dark); }
.library-action.primary:hover, .library-action.primary:focus-visible { background: var(--orange-dark); color: white; }
.release-state { min-height: 38px; border: 1px dashed #aaa9a3; border-radius: 3px; padding: 8px 10px; display: grid; place-items: center; color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; }
.file-downloads { border-top: 1px solid var(--line); padding-top: 8px; font-size: 12px; }
.file-downloads summary { cursor: pointer; font-weight: 700; }
.file-downloads ul { margin: 8px 0 0; padding: 0; list-style: none; }
.file-downloads li + li { margin-top: 6px; }
.file-downloads a { display: flex; justify-content: space-between; gap: 10px; }
.file-downloads a span { color: var(--muted); }
.library-actions code { padding: 8px; background: var(--surface); font-size: 10px; white-space: normal; overflow-wrap: anywhere; }
.loading, .catalog-error { margin: 0; padding: 24px 0; color: var(--muted); border-bottom: 1px solid var(--line); }
.catalog-error { color: #8c2f20; }

.prediction-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 48px; padding: 28px; border: 1px solid var(--line); background: var(--surface); }
.prediction-form { display: grid; gap: 20px; }
.prediction-form label { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 14px; font-weight: 650; }
.prediction-form label span { color: var(--muted); font-weight: 500; }
.prediction-form label small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; font-weight: 400; }
.prediction-form select, .prediction-form input { grid-column: 1 / -1; width: 100%; }
.prediction-form select { min-height: 42px; border: 1px solid #bdbdb7; border-radius: 3px; padding: 8px 10px; background: white; }
.prediction-form input { accent-color: var(--orange-dark); }
.prediction-output { min-width: 0; }
.waveform-chart { padding: 10px; border: 1px solid var(--line); background: white; }
.waveform-chart canvas { width: 100%; height: auto; display: block; }
.waveform-summary { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.prediction-results { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.loss-card { min-width: 0; padding: 18px; border: 1px solid var(--line); background: white; }
.loss-card h2 { margin: 0 0 16px; font-size: 16px; }
.loss-card strong { display: block; font-size: clamp(25px, 3vw, 34px); line-height: 1.2; overflow-wrap: anywhere; }
.loss-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.loss-card p { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.bh-loop-section { margin-top: 28px; }
.bh-loop-section h2 { margin-bottom: 12px; font-size: 20px; }
.bh-loop-chart { border: 1px solid var(--line); background: white; }
.bh-loop-chart svg { display: block; width: 100%; height: auto; }
.bh-axis { stroke: #b7b7b2; stroke-width: 1.5; }
#bh-loop-path { stroke: var(--orange-dark); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#bh-loop-start { fill: var(--ink); }
.bh-loop-chart text { fill: var(--muted); font-size: 13px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
.bh-loop-chart .bh-axis-label { fill: var(--ink); font-size: 15px; font-weight: 650; }
.bh-loop-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.button { min-height: 44px; border: 1px solid var(--ink); border-radius: 3px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; background: white; color: var(--ink); font-weight: 700; text-decoration: none; cursor: pointer; }
.button.primary { background: var(--ink); color: white; }
.button:hover, .button:focus-visible { border-color: var(--orange-dark); color: var(--orange-dark); }
.button.primary:hover, .button.primary:focus-visible { background: var(--orange-dark); color: white; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.learning-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); counter-reset: steps; }
.learning-list li { min-height: 72px; padding: 20px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 36px minmax(190px, .7fr) 1fr; gap: 18px; align-items: start; counter-increment: steps; }
.learning-list li::before { content: counter(steps, decimal-leading-zero); color: var(--orange-dark); font-size: 12px; font-weight: 750; }
.learning-list span { color: var(--muted); }
.resource-links { margin-top: 48px; display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.resource-links a { min-height: 120px; padding: 22px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; text-decoration: none; }
.resource-links a:hover, .resource-links a:focus-visible { background: var(--surface); }
.resource-links span { color: var(--muted); font-size: 13px; }

footer { border-top: 1px solid var(--line); padding: 32px max(24px, calc((100vw - var(--max)) / 2 + 24px)); display: flex; justify-content: space-between; gap: 28px; color: var(--muted); font-size: 13px; }
footer strong { color: var(--ink); }
footer span { margin-left: 10px; }
footer div:last-child { display: flex; flex-wrap: wrap; gap: 20px; }
footer a:hover, footer a:focus-visible { color: var(--orange-dark); }
:focus-visible { outline: 3px solid rgba(184, 86, 0, .38); outline-offset: 3px; }
.view h1[tabindex="-1"]:focus { outline: 0; }

@media (max-width: 760px) {
  .header-inner { align-items: flex-start; flex-direction: column; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
  nav { width: 100%; gap: 18px; overflow-x: auto; padding-bottom: 2px; }
  nav a { white-space: nowrap; }
  .view { padding-top: 44px; }
  .home-intro { padding-top: 6px; }
  .module-grid, .resource-links { grid-template-columns: 1fr; }
  .module-panel { min-height: 220px; }
  .module-header, .catalog-card, .prediction-layout { grid-template-columns: 1fr; }
  .module-header { gap: 14px; }
  .catalog-card { gap: 16px; }
  .library-actions { align-items: flex-start; }
  .library-action, .release-state { width: 100%; }
  .prediction-layout { gap: 32px; padding: 20px; }
  .prediction-results { grid-template-columns: 1fr; }
  .bh-loop-chart text { font-size: 25px; }
  .bh-loop-chart .bh-axis-label { font-size: 28px; }
  .learning-list li { grid-template-columns: 30px 1fr; }
  .learning-list span { grid-column: 2; }
  footer { flex-direction: column; }
  footer span { display: block; margin: 3px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .module-panel { transition: none; }
}
