:root {
  --bg: #eef2f4;
  --bg-2: #e2e8ec;
  --ink: #152028;
  --muted: #5a6872;
  --line: rgba(21, 32, 40, 0.12);
  --accent: #0f6b5c;
  --accent-soft: rgba(15, 107, 92, 0.12);
  --rail: #101820;
  --rail-ink: #edf3f6;
  --warn: #9a4d1c;
  --shadow: 0 18px 50px rgba(21, 32, 40, 0.08);
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "DM Sans", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(15, 107, 92, 0.10), transparent 55%),
    radial-gradient(800px 400px at 95% 0%, rgba(30, 90, 120, 0.08), transparent 50%),
    linear-gradient(180deg, #f5f8fa 0%, var(--bg) 45%, #dde5ea 100%);
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--rail);
  color: var(--rail-ink);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #1aa38d, #0b4f44);
  font-family: var(--serif); font-weight: 700; font-size: 1.25rem;
}
.brand-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.brand-sub { color: rgba(244,239,228,0.55); font-size: 0.78rem; letter-spacing: 0.04em; }

.brand-sub { color: rgba(244,239,228,0.55); font-size: 0.78rem; letter-spacing: 0.04em; }

.dataset-switch {
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px; background: rgba(255,255,255,0.06); border-radius: 10px;
  max-height: 320px; overflow-y: auto;
}
.ds-btn {
  appearance: none; border: 0; background: transparent; color: rgba(244,239,228,0.65);
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font: 600 0.8rem var(--sans);
  text-align: left;
}
.ds-btn.active { background: rgba(26,163,141,0.35); color: #fff; }
.ds-btn:hover:not(.active) { color: #fff; background: rgba(255,255,255,0.05); }

.rail--movi .brand-mark { background: linear-gradient(145deg, #3d6fb8, #1a3d6e); }
.rail--movi .nav-item.active { background: rgba(61,111,184,0.28); }
.rail--movi .ds-btn.active { background: rgba(61,111,184,0.45); }

.rail--physion .brand-mark { background: linear-gradient(145deg, #c4783a, #7a3d12); }
.rail--physion .nav-item.active { background: rgba(196,120,58,0.28); }
.rail--physion .ds-btn.active { background: rgba(196,120,58,0.45); }

.rail--physion15 .brand-mark { background: linear-gradient(145deg, #b45309, #78350f); }
.rail--physion15 .nav-item.active { background: rgba(180,83,9,0.28); }
.rail--physion15 .ds-btn.active { background: rgba(180,83,9,0.45); }

.rail--posetraj .brand-mark { background: linear-gradient(145deg, #8b5cf6, #4c1d95); }
.rail--posetraj .nav-item.active { background: rgba(139,92,246,0.28); }
.rail--posetraj .ds-btn.active { background: rgba(139,92,246,0.45); }

.rail--synfmc .brand-mark { background: linear-gradient(145deg, #0ea5a4, #115e59); }
.rail--synfmc .nav-item.active { background: rgba(14,165,164,0.28); }
.rail--synfmc .ds-btn.active { background: rgba(14,165,164,0.45); }

.rail--phyco .brand-mark { background: linear-gradient(145deg, #d97706, #92400e); }
.rail--phyco .nav-item.active { background: rgba(217,119,6,0.28); }
.rail--phyco .ds-btn.active { background: rgba(217,119,6,0.45); }

.variant-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px;
}
.variant-card {
  padding: 14px; border: 1px solid var(--line); background: rgba(255,255,255,0.35);
}
.variant-card strong { display: block; margin-bottom: 4px; font-family: var(--serif); }
.variant-card span { color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.inst-table { width: 100%; font-size: 0.82rem; border-collapse: collapse; margin-top: 8px; }
.inst-table th, .inst-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.media-grid--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 1100px) { .media-grid--4 { grid-template-columns: repeat(4, 1fr); } }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  appearance: none; border: 0; background: transparent;
  color: rgba(244,239,228,0.72); text-align: left;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font: 500 0.95rem/1.2 var(--sans);
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(26,163,141,0.22); color: #fff; }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.rail-foot a {
  color: rgba(244,239,228,0.55); text-decoration: none; font-size: 0.85rem;
}
.rail-foot a:hover { color: #fff; }

.main { padding: 36px 40px 80px; max-width: 1280px; }
.view { display: none; animation: rise .35s ease; }
.view.active { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-head { margin-bottom: 28px; max-width: 820px; }
.eyebrow {
  margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 0.72rem; color: var(--muted); font-weight: 600;
}
h1 {
  margin: 0 0 12px; font-family: var(--serif); font-weight: 700;
  font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; letter-spacing: -0.02em;
}
h2 {
  margin: 0 0 8px; font-family: var(--serif); font-size: 1.25rem; font-weight: 700;
}
h3 { margin: 18px 0 8px; font-size: 0.95rem; }
.lede, .hint, .caption { color: var(--muted); line-height: 1.55; }
.lede { margin: 0; font-size: 1.05rem; }
.hint { margin: 0 0 16px; font-size: 0.9rem; }
.caption { margin: 0 0 18px; font-size: 1rem; color: var(--ink); }

.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px;
}
.stat {
  padding: 18px 16px; border-bottom: 2px solid var(--ink);
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.2));
}
.stat b {
  display: block; font-family: var(--serif); font-size: 1.7rem; letter-spacing: -0.02em;
}
.stat span { color: var(--muted); font-size: 0.82rem; }

.split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel {
  padding: 22px 22px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,0.35);
  backdrop-filter: blur(6px);
}
.note-panel { border-left: 3px solid var(--accent); }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 52px; gap: 10px; align-items: center; font-size: 0.86rem; }
.bar-track { height: 8px; background: rgba(28,25,20,0.08); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #1aa38d);
  transition: width .7s cubic-bezier(.2,.7,.2,1);
}
.bar-row em { font-style: normal; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.tree, .code {
  margin: 0; padding: 16px; overflow: auto;
  background: #17140f; color: #e8e1d2;
  font: 0.85rem/1.55 var(--mono); border-radius: 0;
}
.field-list { margin: 0; }
.field-list dt {
  font-family: var(--mono); font-size: 0.82rem; color: var(--accent); margin-top: 12px;
}
.field-list dd { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }
.layer-list, .levels { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.6; }
.layer-list li, .levels li { margin-bottom: 8px; }

.sample-toolbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.toggle { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--ink); }
.sample-layout { display: grid; grid-template-columns: 180px 1fr; gap: 18px; }
.cat-tabs { display: flex; flex-direction: column; gap: 4px; }
.cat-tab {
  appearance: none; border: 0; background: transparent; text-align: left;
  padding: 10px 12px; cursor: pointer; color: var(--muted);
  border-left: 2px solid transparent; font: 500 0.9rem var(--sans);
}
.cat-tab.active, .cat-tab:hover {
  color: var(--ink); background: var(--accent-soft); border-left-color: var(--accent);
}
.sample-list { display: flex; flex-direction: column; gap: 8px; }
.sample-item {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: center;
  padding: 12px 8px; border-bottom: 1px solid var(--line); cursor: pointer;
  transition: background .2s ease;
}
.sample-item:hover { background: rgba(255,255,255,0.45); }
.sample-item--no-video { opacity: 0.55; }
.sample-item--no-mask { opacity: 0.72; }
.sample-item--no-mask .badge { color: var(--warn); background: rgba(154, 77, 28, 0.12); }
.open-mask { display: inline-block; margin-top: 8px; font-size: 0.85rem; color: var(--accent); }
.link-btn {
  appearance: none; border: 0; background: none; color: var(--accent);
  cursor: pointer; font: inherit; text-decoration: underline; padding: 0;
}
.row-playable { background: rgba(15, 107, 92, 0.04); }
.thumb {
  width: 96px; height: 64px; object-fit: cover; background: #d9d2c3; display: block;
}
.sample-item strong { display: block; font-size: 0.95rem; margin-bottom: 4px; }
.sample-item p { margin: 0; color: var(--muted); font-size: 0.85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge {
  font-size: 0.72rem; color: var(--accent); background: var(--accent-soft);
  padding: 4px 8px; white-space: nowrap;
}

.inspector {
  margin-top: 28px; padding-top: 22px; border-top: 2px solid var(--ink);
  animation: rise .3s ease;
}
.inspector-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.ghost {
  appearance: none; border: 1px solid var(--line); background: transparent;
  padding: 8px 12px; cursor: pointer; font: 500 0.85rem var(--sans);
}
.ghost:hover { border-color: var(--ink); }
.media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
figure { margin: 0; }
figcaption {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 8px; font-weight: 600;
}
video, .frame-stage img {
  width: 100%; aspect-ratio: 16/10; object-fit: contain; display: block;
}
.frame-stage--mask,
.frame-stage--box {
  background:
    repeating-conic-gradient(#d8dee3 0 25%, #f5f7f9 0 50%) 50% / 24px 24px;
  border: 1px solid var(--line);
}
.frame-stage--mask img,
.frame-stage--box img {
  background: #fff;
}
.frame-strip {
  display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; padding-bottom: 4px;
}
.frame-strip button {
  flex: 0 0 auto; border: 2px solid transparent; padding: 0; cursor: pointer;
  background: repeating-conic-gradient(#d8dee3 0 25%, #f5f7f9 0 50%) 50% / 12px 12px;
}
.overlay-panel { margin-top: 18px; }
.overlay-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.overlay-grid canvas {
  width: 100%; display: block; background: #fff; border: 1px solid var(--line);
}
.frame-stage--mask img { min-height: 180px; }
.mask-hint { margin: 0 0 8px; font-size: 0.85rem; }
.frame-strip button.active { border-color: var(--accent); }
.frame-strip img { width: 56px; height: 36px; object-fit: cover; display: block; }
.missing { color: var(--warn); font-size: 0.88rem; }

.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select {
  border: 1px solid var(--line); background: rgba(255,255,255,0.55);
  padding: 10px 12px; font: 0.92rem var(--sans); color: var(--ink); min-width: 180px;
}
.filters input { flex: 1; min-width: 240px; }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
td.mono { font-family: var(--mono); font-size: 0.8rem; }
td.cap { max-width: 420px; color: var(--muted); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: relative; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .stat-row, .split, .sample-layout, .media-grid { grid-template-columns: 1fr; }
  .main { padding: 24px 18px 60px; }
  .bar-row { grid-template-columns: 100px 1fr 48px; }
}
