:root {
  color-scheme: light dark;
  --bg: light-dark(#f5f7fa, #0d1117);
  --surface: light-dark(#ffffff, #151b23);
  --surface-subtle: light-dark(#f0f3f7, #1b2330);
  --text: light-dark(#172033, #edf2f7);
  --muted: light-dark(#617086, #9aa7b8);
  --line: light-dark(#d7dee8, #303a49);
  --shared: light-dark(#d9e9ff, #16365c);
  --shared-strong: light-dark(#1b64b0, #6eb5ff);
  --slot: light-dark(#d9f3e5, #153f31);
  --slot-strong: light-dark(#18774e, #61d6a0);
  --voice: light-dark(#f2e4ff, #3b2852);
  --voice-strong: light-dark(#7851a9, #c79af4);
  --log: light-dark(#ffebd2, #503218);
  --log-strong: light-dark(#aa6118, #f2af61);
  --free: light-dark(#e9edf2, #252d38);
  --free-strong: light-dark(#697687, #a8b2bf);
  --focus: light-dark(#125ea9, #73b8ff);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
}

button, input, select { font: inherit; }

a { color: var(--shared-strong); }

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--shared-strong);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(25px, 4vw, 38px); line-height: 1.15; }
h2 { margin-bottom: 3px; font-size: 18px; }
h3 { margin-bottom: 2px; font-size: 15px; }

.subtitle,
.section-heading p,
.panel-range,
.updated,
.page-footer,
.panel-note { color: var(--muted); }

.subtitle { max-width: 760px; margin-bottom: 0; }

.language-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.language-switch button {
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.language-switch button[aria-pressed="true"] {
  background: var(--shared);
  color: var(--shared-strong);
}

.overview-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.overview-panel { padding: 18px; }

.section-heading,
.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.section-heading p { margin-bottom: 0; font-size: 13px; }
.updated { flex: none; font-size: 12px; }

.memory-bar {
  display: flex;
  min-height: 76px;
  margin-top: 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.memory-segment {
  min-width: 0;
  padding: 8px 5px;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.memory-segment:last-child { border-right: 0; }
.memory-segment:hover,
.memory-segment:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); outline: 0; }
.memory-segment strong,
.memory-segment span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory-segment strong { font-size: 11px; }
.memory-segment span { margin-top: 4px; font: 10px var(--mono); }

.kind-shared { background: var(--shared); }
.kind-slot { background: var(--slot); }
.kind-voice { background: var(--voice); }
.kind-log { background: var(--log); }
.kind-free { background: var(--free); color: var(--muted); }

.address-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.legend { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.detail-panel { min-width: 0; padding: 15px; scroll-margin-top: 16px; }
.detail-panel.wide { grid-column: 1 / -1; }
.detail-panel.focused { outline: 3px solid var(--focus); outline-offset: 2px; }
.panel-range { flex: none; font: 11px var(--mono); }

.map-table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.map-table th,
.map-table td {
  padding: 7px 6px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.map-table th {
  padding-top: 0;
  border-top: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.map-table th:first-child,
.map-table td:first-child { width: 31%; }
.map-table th:nth-child(2),
.map-table td:nth-child(2) { width: 17%; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.record-layout,
.slot-grid {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.record-layout { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.slot-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.record-field,
.slot-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-subtle);
}

.record-field { min-height: 58px; padding: 7px 4px; text-align: center; font-size: 10px; line-height: 1.3; }
.record-field b { display: block; margin-bottom: 4px; font: 10px var(--mono); }
.slot-card { overflow: hidden; }
.slot-card h4 { margin: 0; padding: 7px 8px; background: var(--slot); font-size: 12px; }
.slot-card dl { margin: 0; padding: 7px 8px; font: 10px/1.45 var(--mono); }
.slot-card dt { float: left; clear: left; color: var(--muted); }
.slot-card dd { margin-left: 52px; }

.panel-note {
  margin: 10px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.page-footer {
  margin-top: 20px;
  padding: 16px 2px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.page-footer p { margin-bottom: 7px; }
.page-footer ul { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 9px; padding-left: 18px; }
.mapping-note { font-style: italic; }

@media (max-width: 780px) {
  .page-shell { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .page-header { align-items: stretch; flex-direction: column; gap: 14px; }
  .language-switch { align-self: flex-start; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-panel.wide { grid-column: auto; }
  .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-layout { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .memory-segment span { display: none; }
  .memory-segment strong { writing-mode: vertical-rl; }
}

@media (max-width: 460px) {
  .overview-panel,
  .detail-panel { padding: 12px; }
  .slot-grid { grid-template-columns: 1fr; }
  .map-table { font-size: 11px; }
  .map-table th:first-child,
  .map-table td:first-child { width: 38%; }
  .map-table th:nth-child(2),
  .map-table td:nth-child(2) { display: none; }
}
