:root {
  color-scheme: light dark;

  --chrome: #f5f5f7;
  --chrome-border: #d9d9de;
  --sidebar: #eeeef1;
  --sidebar-border: #d9d9de;
  --content: #ffffff;
  --panel: #fafafa;
  --panel-border: #e3e3e6;
  --grid-line: #f0f0f2;
  --alt-row: #f8f8fa;
  --control: #ffffff;
  --control-border: #d4d4d8;
  --segment: #e4e4e8;
  --chip: #ececef;
  --text: #1d1d1f;
  --text-2: #3a3a3f;
  --muted: #5f5f66;
  --faint: #8e8e93;
  --type: #a1a1a6;
  --accent: #1f4e5f;
  --accent-text: #1f4e5f;
  --keyword: #7a3e9d;
  --number: #a8560d;
  --prod: #d64545;
  --staging: #e0a500;
  --local: #8e8e93;

  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --rail: 232px;
  --right: 268px;
  --radius: 7px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --chrome: #2b2b2e;
    --chrome-border: #1a1a1c;
    --sidebar: #252528;
    --sidebar-border: #3f3f44;
    --content: #1e1e20;
    --panel: #232326;
    --panel-border: #333336;
    --grid-line: #2e2e31;
    --alt-row: #232326;
    --control: #1e1e20;
    --control-border: #4a4a50;
    --segment: #3a3a3f;
    --chip: #333336;
    --text: #e6e6e8;
    --text-2: #c8c8cc;
    --muted: #a0a0a6;
    --faint: #8a8a90;
    --type: #7a7a80;
    --accent: #7fb3c4;
    --accent-text: #7fb3c4;
    --keyword: #c792ea;
    --number: #e0a060;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: color-mix(in srgb, var(--chrome) 70%, #8f8f94);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  body { background: #151517; }
}

a { color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono { font-family: var(--mono); font-size: 12px; }

.grow { flex-grow: 1; }

.quiet { color: var(--muted); }

.glyph { color: var(--faint); font-size: 12px; }

/* Window */

.app {
  width: min(1320px, calc(100vw - 48px));
  height: min(860px, calc(100vh - 48px));
  margin: 24px auto;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--right);
  grid-template-rows: 52px minmax(0, 1fr) 34px;
  grid-template-areas:
    'title title title'
    'sidebar center record'
    'status status status';
  background: var(--content);
  border: 1px solid var(--chrome-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

/* Title bar */

.titlebar {
  grid-area: title;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-border);
}

.lights { display: flex; gap: 8px; margin-right: 4px; }

.lights i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5f57;
}

.lights i:nth-child(2) { background: #febc2e; }

.lights i:nth-child(3) { background: #28c840; }

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  text-decoration: none;
  font-size: 13px;
}

.pill, .search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: var(--control);
  border: 1px solid var(--control-border);
  color: var(--muted);
  white-space: nowrap;
}

.pill b { color: var(--text); font-weight: 600; }

.search { width: 200px; color: var(--faint); }

.key {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  margin-left: auto;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--local); flex-shrink: 0; }

.dot.prod { background: var(--prod); }

.dot.staging { background: var(--staging); }

.lock, .modes {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--segment);
}

.seg {
  height: 22px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--muted);
}

.seg.on {
  background: var(--control);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}

.titlebar-cta {
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

@media (prefers-color-scheme: dark) {
  .titlebar-cta { color: #10272f; }
}

/* Sidebar */

.sidebar {
  grid-area: sidebar;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  padding: 10px 8px;
  overflow: auto;
}

.filter {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--control);
  border: 1px solid var(--control-border);
  color: var(--faint);
}

.group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  padding: 0 8px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.rows { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
}

.row:hover { background: color-mix(in srgb, var(--control) 60%, transparent); }

.row.on {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .row.on { color: #10272f; }
}

.row.on .glyph { color: rgba(255, 255, 255, 0.75); }

.row.muted { color: var(--muted); }

.aside-note {
  margin: 14px 8px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* Center */

.center {
  grid-area: center;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--content);
}

.tabs {
  display: flex;
  align-items: stretch;
  height: 34px;
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-border);
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  color: var(--muted);
  text-decoration: none;
  border-right: 1px solid var(--chrome-border);
  font-size: 12px;
}

.tab.on {
  background: var(--content);
  color: var(--text);
  font-weight: 600;
  font-style: italic;
}

.tab-plus { display: flex; align-items: center; padding: 0 12px; color: var(--faint); }

.filterbar, .wherebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--content);
}

.filterbar { height: 36px; }

.wherebar { height: 30px; }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--control-border);
  background: var(--control);
  color: var(--text-2);
  font-size: 12px;
}

.chip.dashed { border-style: dashed; color: var(--muted); }

.chip.gear { padding: 0 7px; color: var(--muted); }

.kw { color: var(--keyword); font-weight: 700; }

.ghost { color: var(--faint); }

/* The grid area holds the page content */

.grid {
  position: relative;
  flex-grow: 1;
  min-height: 0;
  overflow: auto;
  padding: 34px 38px 60px;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  .grid { scroll-behavior: auto; }
}

.doc {
  max-width: 760px;
  scroll-margin-top: 34px;
  padding-bottom: 46px;
}

.doc + .doc {
  border-top: 1px solid var(--grid-line);
  padding-top: 42px;
}

.doc:last-child { padding-bottom: 0; }

.lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.lockup-name { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

.lockup-tag { color: var(--muted); font-size: 13px; border-left: 1px solid var(--panel-border); padding-left: 12px; }

h1 {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.lede {
  margin: 0 0 22px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 62ch;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin: 0 0 28px;
}

.button {
  display: flex;
  flex-direction: column;
  padding: 9px 18px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.button small { font-weight: 400; font-size: 11px; opacity: 0.85; }

.button.ghost {
  background: var(--control);
  border: 1px solid var(--control-border);
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  .button { color: #10272f; }
  .button.ghost { color: var(--text); }
}

.rows-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}

.rows-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
  padding: 7px 12px;
  white-space: nowrap;
}

.rows-table .typ { color: var(--type); font-weight: 400; margin-left: 6px; font-size: 11px; }

.rows-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--grid-line);
  border-right: 1px solid var(--grid-line);
  vertical-align: top;
  color: var(--text-2);
}

.rows-table td:last-child { border-right: 0; }

.rows-table tr:nth-child(even) td { background: var(--alt-row); }

.rows-table tr:last-child td { border-bottom: 0; }

.key-col { color: var(--text); white-space: nowrap; }

.code {
  margin: 0 0 24px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  overflow-x: auto;
  line-height: 1.7;
  color: var(--text);
}

.code .num { color: var(--number); }

/* Record panel */

.record {
  grid-area: record;
  background: var(--panel);
  border-left: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
}

.panel-head .quiet { font-weight: 400; font-size: 12px; }

.field { padding: 8px 14px; border-bottom: 1px solid var(--panel-border); }

.fname { font-weight: 600; display: flex; align-items: center; gap: 6px; }

.ftype {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  background: var(--chip);
  border-radius: 4px;
  padding: 1px 5px;
}

.fvalue {
  margin-top: 5px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--control);
  border: 1px solid var(--control-border);
  color: var(--text);
  overflow-wrap: anywhere;
}

.changes {
  list-style: none;
  margin: 0;
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
}

.changes li { display: flex; gap: 8px; align-items: flex-start; }

.changes .ver {
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 6px;
}

.changes .ver:first-child { margin-top: 0; }

.changes .when { color: var(--faint); }

.st {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  background: var(--chip);
  color: var(--muted);
}

.st.a { background: color-mix(in srgb, #2e7d4f 18%, transparent); color: #2e7d4f; }

.st.m { background: color-mix(in srgb, #1f4e5f 16%, transparent); color: var(--accent-text); }

.st.f { background: color-mix(in srgb, #a8560d 16%, transparent); color: var(--number); }

@media (prefers-color-scheme: dark) {
  .st.a { background: rgba(127, 201, 154, 0.16); color: #7fc99a; }
}

.panel-foot { margin-top: auto; display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--panel-border); }

/* Status bar */

.statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: var(--chrome);
  border-top: 1px solid var(--chrome-border);
  color: var(--muted);
  font-size: 12px;
}

.status-left { width: calc(var(--rail) - 26px); }

.status-center { color: var(--muted); }

.box {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: var(--control);
  color: var(--text);
}

.pager { display: flex; gap: 2px; }

.pager i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 20px;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: var(--control);
  font-style: normal;
  color: var(--faint);
}

/* Narrow screens: the window becomes a page */

@media (max-width: 1100px) {
  .app { grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-areas: 'title title' 'sidebar center' 'status status'; }
  .record { display: none; }
  .search, .pill { display: none; }
}

@media (max-width: 820px) {
  body { background: var(--content); }

  .app {
    width: 100%;
    height: auto;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 52px auto auto 34px;
    grid-template-areas: 'title' 'sidebar' 'center' 'status';
  }

  .sidebar { border-right: 0; border-bottom: 1px solid var(--sidebar-border); }

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

  .aside-note, .lock, .filterbar, .wherebar, .tabs { display: none; }

  .grid { padding: 24px 18px 40px; }

  h1 { font-size: 24px; }

  .statusbar { justify-content: space-between; }

  .status-left, .status-center, .modes, .pager { display: none; }
}
