:root {
  --bg: #141210;
  --surface: #1c1917;
  --surface-2: #292524;
  --surface-3: #44403c;
  --line: rgba(255, 248, 240, 0.08);
  --line-strong: rgba(255, 248, 240, 0.13);
  --text: #fafaf9;
  --muted: #a8a29e;
  --subtle: #78716c;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.14);
  --preview-stage: #100e0c;
  --chip-bg: #1f1c1a;
  --nav-w: 220px;
  --work-w: minmax(480px, 560px);
  --drawer-w: 420px;
  --radius: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 400 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

[data-tip] {
  position: relative;
}
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 60;
  left: 50%;
  top: calc(100% + 7px);
  transform: translateX(-50%);
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
}
[data-tip][data-tip-pos="left"]::after {
  left: auto;
  right: calc(100% + 7px);
  top: 50%;
  transform: translateY(-50%);
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: var(--nav-w) var(--work-w) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
.shell--no-preview {
  grid-template-columns: var(--nav-w) 1fr;
}
.shell--no-preview .preview-pane { display: none; }
.shell--no-work {
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
}
.shell--no-work .work-panel { display: none; }
.shell--no-preview.shell--no-work {
  grid-template-columns: var(--nav-w) 1fr;
}

.topnav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.topnav__left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.topnav__views {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 0 8px;
}
.topnav__view {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--subtle);
  white-space: nowrap;
}
.topnav__view-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}
.topnav__view:hover {
  color: var(--muted);
  background: var(--surface-2);
}
.topnav__view.is-active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.topnav__panel-toggle {
  padding-left: 8px;
  padding-right: 8px;
}
.topnav__brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.topnav__brand:hover { text-decoration: none; opacity: 0.9; }
.topnav__sep { color: var(--subtle); font-size: 13px; }
.topnav__site { font-size: 13px; color: var(--muted); white-space: nowrap; }
.topnav__page {
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topnav__stats {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--subtle);
  white-space: nowrap;
}
.topnav__stats span strong {
  color: var(--muted);
  font-weight: 500;
}
.topnav__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.topnav__link {
  font-size: 12px;
  color: var(--subtle);
  text-decoration: none;
  padding: 6px 8px;
}
.topnav__link:hover { color: var(--text); text-decoration: none; }

/* —— Nav panel —— */
.nav-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.nav-panel__search-wrap { padding: 12px 14px 10px; }
.nav-panel__search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.nav-panel__search:focus {
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.nav-panel__tree {
  flex: 1;
  overflow: auto;
  padding: 6px 10px 16px;
}
.nav-panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--subtle);
}
.nav-panel__foot-stats { color: var(--subtle); }

.tree-section { margin-bottom: 4px; }
.tree-section__toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.tree-section__toggle:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.tree-section__chevron {
  width: 14px;
  color: var(--subtle);
  transition: transform 0.15s ease;
}
.tree-section.is-open .tree-section__chevron { transform: rotate(90deg); }
.tree-section__count {
  margin-left: auto;
  font-size: 11px;
  color: var(--subtle);
}
.tree-section__items {
  display: none;
  padding-left: 8px;
}
.tree-section.is-open .tree-section__items { display: block; }
.tree-section--nested {
  margin-top: 2px;
  margin-left: 10px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}
.tree-section--nested .tree-section__toggle {
  font-size: 11px;
  padding: 5px 8px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  text-align: left;
  color: var(--muted);
}
.tree-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.tree-item.is-active {
  background: var(--accent-soft);
  color: var(--text);
}
.tree-item__label {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-item__path {
  display: none;
  font-size: 11px;
  color: var(--subtle);
}
.tree-item.is-active .tree-item__path,
.tree-item:hover .tree-item__path { display: block; }
.tree-item__dots {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.dot--p0 { background: var(--danger); }
.dot--leak { background: #c084fc; }

/* —— Work panel (center) —— */
.work-panel {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
}
.work-panel--no-sections {
  grid-template-columns: minmax(0, 1fr);
}
.work-panel__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.work-head {
  flex-shrink: 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.work-head[hidden] { display: none !important; }
.work-head__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.work-head__section {
  margin: 5px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}
.work-head__desc {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--subtle);
  line-height: 1.5;
}
.work-head__desc[hidden] { display: none !important; }

.section-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.section-rail[hidden] { display: none !important; }
.section-rail__head {
  padding: 12px 12px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--subtle);
}
.section-rail__list {
  display: flex;
  flex-direction: column;
  padding: 0 0 12px;
}
.section-rail__item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  gap: 0 8px;
  width: 100%;
  padding: 9px 10px 9px 8px;
  text-align: left;
  border-left: 2px solid transparent;
  color: var(--muted);
}
.section-rail__item:hover {
  background: rgba(255, 248, 240, 0.04);
  color: var(--text);
}
.section-rail__item.is-active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.section-rail__num {
  font: 600 10px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--subtle);
  padding-top: 1px;
}
.section-rail__item.is-active .section-rail__num { color: var(--muted); }
.section-rail__label {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.section-rail__dots {
  display: flex;
  gap: 3px;
  padding-top: 4px;
}
.section-detail__head {
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.section-detail__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.section-detail__meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--subtle);
}

.preview-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  grid-row: 2;
  grid-column: 3;
}
.preview-pane[hidden] { display: none !important; }
.preview-pane__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--surface);
}
.preview-pane__url {
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.preview-pane__viewport {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.preview-pane__controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.preview-pane__stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--preview-stage);
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
}
.preview-pane__slot {
  flex: none;
  height: 100%;
  min-height: 100%;
  transform-origin: top center;
}
.preview-pane__slot[data-viewport="xl"] { width: 1920px; }
.preview-pane__slot[data-viewport="lg"] { width: 1440px; }
.preview-pane__slot[data-viewport="md"] { width: 768px; }
.preview-pane__slot[data-viewport="sm"] { width: 390px; }
.preview-pane__frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  border: none;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
}
.seg--viewport .seg__btn { min-width: 36px; padding: 4px 6px; font-size: 11px; font-variant-numeric: tabular-nums; }
.seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.seg__btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--subtle);
}
.seg__btn.is-active {
  background: var(--surface-2);
  color: var(--text);
}
.btn--sm { padding: 5px 10px; font-size: 12px; }

.nav-panel { grid-row: 2; grid-column: 1; }
.work-panel { grid-row: 2; grid-column: 2; }

.content-pane {
  display: contents;
}

.page-header { display: none; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); text-decoration: none; }
.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: white;
}
.btn--primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn--ghost { background: transparent; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 20px 32px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(248, 113, 113, 0.22);
  background: var(--danger-soft);
  color: #fecaca;
  font-size: 13px;
}
.alert strong { color: #fff; font-weight: 600; }
.alert__action {
  margin-left: auto;
  flex-shrink: 0;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 0 16px;
}
.toolbar__right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.toolbar__collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--subtle);
}
.toolbar__collapse:hover {
  color: var(--muted);
  background: var(--surface-2);
}
.toolbar__collapse .toolbar__icon { width: 14px; height: 14px; }
.preview-pane__show-work[hidden] { display: none !important; }
.preview-pane__show-work {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--subtle);
}
.preview-pane__show-work:hover {
  color: var(--muted);
  background: var(--surface-2);
}
.preview-pane__show-work .toolbar__icon { width: 14px; height: 14px; }
.toolbar--filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 0;
  overflow: visible;
}
.toolbar--filters[hidden] { display: none !important; }
.toolbar__tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.toolbar__tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  color: var(--subtle);
}
.toolbar__icon {
  width: 16px;
  height: 16px;
  display: block;
}
.ui-icon {
  width: 14px;
  height: 14px;
  display: block;
}
.icon-label {
  display: inline-flex;
  align-items: center;
  color: var(--subtle);
}
.toolbar__tab:hover { color: var(--muted); }
.toolbar__tab.is-active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.toolbar__actions { display: flex; gap: 8px; }
.toolbar__count { font-size: 12px; color: var(--subtle); }

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow: visible;
}
.chip {
  padding: 5px 11px;
  border-radius: 6px;
  border: none;
  background: var(--chip-bg);
  font-size: 12px;
  font-weight: 500;
  color: var(--subtle);
}
.chip:hover { color: var(--muted); background: var(--surface-2); }
.chip.is-active {
  background: var(--surface-2);
  color: var(--text);
}
.chip--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
}
.chip[data-filter="p0"].is-active { color: #f87171; }
.chip[data-filter="leak"].is-active { color: #c084fc; }
.chip[data-filter="wired"].is-active { color: #4ade80; }
.chip[data-filter="video"].is-active { color: #93c5fd; }
.chip[data-filter="p0"].is-active .ui-icon,
.chip[data-filter="leak"].is-active .ui-icon,
.chip[data-filter="wired"].is-active .ui-icon,
.chip[data-filter="video"].is-active .ui-icon { color: inherit; }

.page-body {
  flex: 1;
  overflow: auto;
  padding: 12px 16px 24px;
}

.copy-doc {
  --copy-num: 22px;
  --copy-gap: 12px;
}
.copy-doc__head {
  padding-bottom: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.copy-doc__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.copy-doc__desc {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.copy-doc__sections {
  display: flex;
  flex-direction: column;
}
.copy-section {
  display: grid;
  grid-template-columns: var(--copy-num) 1fr;
  column-gap: var(--copy-gap);
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.copy-section:last-child { border-bottom: none; padding-bottom: 0; }
.copy-section__num {
  text-align: right;
  font: 600 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--subtle);
}
.copy-section__content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.copy-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.copy-section__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}
.copy-section__flags {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.section-flag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtle);
}
.section-flag--leak { color: #c084fc; }
.section-flag--p0 { color: #f87171; }
.copy-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.copy-group--stats { gap: 4px; }
.copy-group--actions { gap: 8px; }
.copy-eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.copy-heading {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}
.copy-subhead {
  margin: 0;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
}
.copy-body {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.copy-stat {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.copy-stat span {
  color: var(--text);
  font-weight: 600;
}
.copy-cta {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ok);
  line-height: 1.4;
}
.copy-cta--leak { color: #c084fc; }
.copy-cta__link {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 400;
  color: var(--subtle);
}

.copy-doc--single .copy-section {
  border-bottom: none;
  padding-top: 0;
  grid-template-columns: 1fr;
}
.copy-doc--single .copy-section__num,
.copy-doc--single .copy-section__head { display: none; }

.summary {
  display: flex;
  flex-direction: column;
}
.summary-group {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.summary-group:first-child { padding-top: 0; }
.summary-group:last-child { border-bottom: none; padding-bottom: 0; }
.summary-group__label {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
}
.summary-group__line {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.summary-group__line strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.summary__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.summary-pill {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--chip-bg);
  color: var(--subtle);
}
.summary-pill:hover { filter: brightness(1.08); }
.summary-pill--leak { color: #c084fc; }
.summary-pill--p0 { color: #f87171; }
.summary-pill--wired { color: #4ade80; }
.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.summary-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}
.summary-list__row + .summary-list__row { border-top: 1px solid rgba(255,255,255,0.04); }
.summary-list__label {
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.summary-list__row--leak .summary-list__label { color: #c084fc; }
.summary-list__row--wired .summary-list__label { color: #4ade80; }
.summary-list__row--p0 .summary-list__label { color: #fbbf24; }
.summary-list__n {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--subtle);
  font-size: 12px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel__head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--subtle);
}
.panel__body { padding: 0; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}
.metric {
  padding: 18px 20px;
  background: var(--surface);
}
.metric__value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.metric__label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--subtle);
}

.table { width: 100%; border-collapse: collapse; }
.table th,
.table td {
  padding: 11px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--subtle);
  background: var(--surface-2);
}
.table tr:last-child td { border-bottom: none; }
.table td:last-child,
.table th:last-child { text-align: right; width: 72px; }

.media-table .media-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.media-table .media-row:last-child { border-bottom: none; }
.media-table .media-row:hover { background: rgba(255,255,255,0.02); }
.media-table .media-row.is-selected { background: var(--accent-soft); }
.media-thumb {
  width: 56px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--line);
}
.media-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--subtle);
}
.media-main__title { font-weight: 500; color: var(--text); }
.media-main__sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 520px;
}
.media-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  border: none;
  background: var(--chip-bg);
  color: var(--subtle);
  white-space: nowrap;
}
.tag--p0 { color: #f87171; background: var(--chip-bg); }
.tag--wired { color: #4ade80; background: var(--chip-bg); }
.tag--leak { color: #c084fc; background: var(--chip-bg); }

.copy-section { max-width: none; }
.copy-section + .copy-section { margin-top: 28px; }
.copy-line--title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border-bottom: none;
  padding-bottom: 4px;
}
.copy-line {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.55;
}
.copy-line strong {
  display: inline-block;
  min-width: 28px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
}

.page-meta {
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.page-meta__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.page-meta__desc {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 640px;
}
.page-meta__count {
  margin-top: 10px;
  font-size: 12px;
  color: var(--subtle);
}

.section-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: none;
}
.section-list--flat .section-line:first-child { padding-top: 0; }
.section-card,
.section-card__head,
.section-card__body,
.section-card__label,
.section-card__headline,
.section-card__module,
.section-card__tags { display: none; }
.section-list--flat .section-line {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}
.section-list--flat .section-line:last-child { border-bottom: none; }
.section-list--flat .section-line--h1,
.section-list--flat .section-line--h2 { color: var(--text); font-weight: 500; }
.section-list--flat .section-line--body { padding-left: 0; color: var(--muted); }

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--subtle);
}

/* Drawer */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 30;
}
.drawer-scrim[hidden],
.palette[hidden] { display: none !important; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--drawer-w), 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.drawer.is-open { transform: translateX(0); }
.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.drawer__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.drawer__close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 18px;
  line-height: 1;
  color: var(--subtle);
}
.drawer__close:hover { background: var(--surface-2); color: var(--text); }
.drawer__body {
  flex: 1;
  overflow: auto;
  padding: 18px 20px 28px;
}
.drawer__preview {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  margin-bottom: 18px;
}
.drawer__preview img,
.drawer__preview video {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}
.field { margin-bottom: 16px; }
.field__label {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--subtle);
}
.field__value { color: var(--muted); line-height: 1.5; word-break: break-word; }
.field__brief {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  line-height: 1.55;
}

/* Palette */
.palette {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  background: rgba(0,0,0,0.55);
}
.palette__panel {
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
  overflow: hidden;
}
.palette__input {
  width: 100%;
  padding: 16px 18px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.palette__list {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: 360px;
  overflow: auto;
}
.palette__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
}
.palette__item:hover,
.palette__item.is-active { background: rgba(255,255,255,0.05); color: var(--text); }
.palette__item-path { font-size: 12px; color: var(--subtle); font-family: ui-monospace, monospace; }

@media (max-width: 1100px) {
  .topnav__stats { display: none; }
}

@media (max-width: 860px) {
  .topnav__view {
    padding: 0 8px;
    gap: 0;
    width: 32px;
    justify-content: center;
    font-size: 0;
  }
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: var(--nav-w) 1fr;
    grid-template-rows: auto 1fr minmax(320px, 42vh);
  }
  .shell--no-preview { grid-template-rows: auto 1fr; }
  .preview-pane {
    grid-column: 2;
    grid-row: 3;
    border-top: 1px solid var(--line);
  }
  .work-panel { grid-column: 2; grid-row: 2; border-right: none; }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr minmax(280px, 38vh); }
  .topnav__stats { display: none; }
  .nav-panel {
    position: fixed;
    inset: 48px auto 0 0;
    width: var(--nav-w);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    grid-row: auto;
    grid-column: auto;
  }
  .nav-panel.is-open { transform: translateX(0); }
  .work-panel { grid-column: 1; grid-row: 2; }
  .preview-pane { grid-column: 1; grid-row: 3; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-body, .toolbar, .alert { padding-left: 16px; padding-right: 16px; }
  .alert { margin-left: 16px; margin-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .nav-panel { transition: none; }
}
