:root {
  --bg: #071a2f;
  --navy: #0d3461;
  --navy-2: #0a2a50;
  --panel: #0b2747;
  --line: #1f4b7e;
  --text: #e6eef8;
  --muted: #9fb3cc;
  --accent: #4fa3ff;
  --ad: #2fd08a;
  --cn: #ef7d61;
  --mci: #8c8fd9;
  --warn-bg: #3a2c0b;
  --warn-line: #b5892a;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
code { font-size: .92em; background: rgba(255,255,255,.07); padding: .05em .35em; border-radius: 4px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* top bar */
.topbar { background: var(--navy); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-name { font: italic 600 26px/1 Georgia, "Times New Roman", serif; letter-spacing: .3px; }
.brand-sub { color: var(--muted); font-size: 14px; border-left: 1px solid var(--line); padding-left: 10px; }
.links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.links a { color: var(--text); text-decoration: none; opacity: .9; }
.links a:hover { opacity: 1; text-decoration: underline; }
.pill { background: var(--accent); color: #04172c !important; padding: 5px 11px; border-radius: 999px; font-weight: 600; }
.pill.ghost { background: transparent; border: 1px solid var(--accent); color: var(--text) !important; }

/* intro */
.intro { padding-top: 28px; padding-bottom: 12px; }
.intro h1 { font-size: clamp(22px, 3vw, 32px); line-height: 1.2; margin: 0 0 10px; max-width: 900px; }
.intro p { color: var(--muted); max-width: 900px; margin: 0 0 14px; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 10px 14px; font-size: 15px; max-width: 900px; }

/* app frame */
.app { padding-top: 14px; }
.app-frame {
  display: grid; grid-template-columns: 300px 1fr; gap: 14px;
  background: var(--navy); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.app-frame.second { margin-top: 14px; grid-template-columns: 220px 1fr; }
.app-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
select {
  font: inherit; color: var(--text); background: var(--navy-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
.case-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 13px; }
.case-meta dt { color: var(--muted); }
.case-meta dd { margin: 0; overflow-wrap: anywhere; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.panel h3, .app-frame h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.donut-wrap { max-width: 210px; margin: 0 auto; }
#donut { width: 100%; height: auto; display: block; }
.legend { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.legend .val { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend .name { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

.cases-chart svg, .slice-chart svg { width: 100%; height: auto; display: block; }
.cases-chart .bar { cursor: pointer; }
.cases-chart .bar.sel rect.frame { stroke: #fff; stroke-width: 1.5; }

/* views */
.app-main { min-width: 0; }
.views { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #000; border: 2px solid var(--line); border-radius: 6px; padding: 6px; }
.view { margin: 0; background: #000; display: flex; flex-direction: column; min-width: 0; position: relative; }
.view figcaption { position: absolute; top: 6px; left: 8px; font-size: 12px; color: #cfe0f5; z-index: 2; pointer-events: none; text-shadow: 0 1px 2px #000; }
.view figcaption .idx { color: var(--muted); margin-left: 6px; }
.canvas-box { aspect-ratio: 1 / 1; width: 100%; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.canvas-box canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; cursor: crosshair; display: block; }
.view input[type=range] { margin: 0; width: 100%; background: var(--navy); padding: 10px 14%; }
.loading { color: var(--muted); font-size: 13px; position: absolute; }
.toolbar3d { display: flex; gap: 14px; justify-content: center; background: var(--navy); padding: 6px; font-size: 13px; min-height: 37px; align-items: center; }
#three-box canvas { cursor: grab; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 10px 2px 0; font-size: 14px; }
.toolbar .hint { margin: 0; flex-basis: 100%; }
label input[type=checkbox] { accent-color: var(--accent); vertical-align: -2px; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 30px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: #2a6fd6; border-radius: 2px; }
input[type=range]::-moz-range-track { height: 4px; background: #2a6fd6; border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #3b8cff; border: 2px solid #cfe3ff; margin-top: -6px; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #3b8cff; border: 2px solid #cfe3ff; }

/* model input */
.input-col { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 0; }
#input-canvas { width: 100%; max-width: 220px; aspect-ratio: 1/1; background: #000; border: 1px solid var(--line); border-radius: 4px; image-rendering: pixelated; }
.input-meta { font-size: 13px; font-variant-numeric: tabular-nums; }
.input-meta .row { display: flex; justify-content: space-between; }
.slice-col { min-width: 0; }

/* sections */
.section { padding-top: 40px; }
.section h2 { font-size: 22px; margin: 0 0 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.section h3 { font-size: 16px; margin: 0 0 6px; }
.section ul, .section ol { padding-left: 20px; margin: 0; }
.section li { margin: 4px 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.note { color: var(--muted); font-size: 14px; }
.steps { max-width: 900px; }
.fig { margin: 20px 0 0; background: #fff; border-radius: 8px; padding: 10px; }
.fig img { width: 100%; height: auto; display: block; }
.fig figcaption { color: #333; font-size: 13px; padding-top: 6px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; background: var(--panel); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
tr.hl td { font-weight: 700; }
.bib { position: relative; }
.bib pre { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow-x: auto; font-size: 13px; margin: 8px 0 0; }
.bib button { position: absolute; right: 8px; top: 16px; font: inherit; font-size: 12px; background: var(--navy); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.footer { margin-top: 48px; border-top: 1px solid var(--line); background: var(--navy-2); padding: 18px 0; color: var(--muted); font-size: 14px; }
.footer p { margin: 4px 0; }

/* tooltip */
.tip { position: fixed; pointer-events: none; background: #04121f; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; z-index: 50; display: none; white-space: nowrap; }

@media (max-width: 900px) {
  .app-frame, .app-frame.second { grid-template-columns: 1fr; }
  .app-side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .app-side .field, .app-side .case-meta { grid-column: 1 / -1; }
  .cols { grid-template-columns: 1fr; }
  .input-col { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .input-col h3 { flex-basis: 100%; }
  #input-canvas { width: 150px; }
  .input-col input[type=range] { flex: 1; min-width: 120px; }
  .input-meta { flex-basis: 100%; }
}
@media (max-width: 600px) {
  .brand-sub { display: none; }
  .links { gap: 10px; font-size: 13px; }
  .links a:not(.pill) { display: none; }
  .app-side { grid-template-columns: 1fr; }
  .views { grid-template-columns: 1fr; }
  .app-frame { padding: 10px; }
  .view input[type=range] { padding: 10px 8%; }
}

.soon { margin: 4px 0 2px; font-size: 15px; }
.sprite { width: 100%; height: auto; display: block; margin-top: 10px; border: 1px solid var(--line); border-radius: 4px; background: #000; }
