/* ---------- Design tokens ---------- */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --border: #e0ddd3;
  --text: #1f2328;
  --text-2: #5b6068;
  --text-3: #8a8f96;
  --accent: #1f5f8b;
  --accent-soft: #e3eef6;
  --accent-text: #ffffff;
  --good: #2e7d4f;
  --good-soft: #e3f2e8;
  --warn: #a86a00;
  --warn-soft: #fbf0dc;
  --bad: #b23b3b;
  --bad-soft: #f8e4e4;
  --highlight: #fff1a8;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-read: Georgia, "Cambria", "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --surface: #1d2024; --surface-2: #262a2f; --border: #33383e;
    --text: #e8e6e1; --text-2: #a9adb3; --text-3: #7d828a;
    --accent: #6aa9d8; --accent-soft: #1e3343; --accent-text: #0d1a24;
    --good: #6cc28f; --good-soft: #1b3326; --warn: #e0a84a; --warn-soft: #3a2e18;
    --bad: #e07a7a; --bad-soft: #3d2222; --highlight: #5a4d12;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1d2024; --surface-2: #262a2f; --border: #33383e;
  --text: #e8e6e1; --text-2: #a9adb3; --text-3: #7d828a;
  --accent: #6aa9d8; --accent-soft: #1e3343; --accent-text: #0d1a24;
  --good: #6cc28f; --good-soft: #1b3326; --warn: #e0a84a; --warn-soft: #3a2e18;
  --bad: #e07a7a; --bad-soft: #3d2222; --highlight: #5a4d12;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
small, .muted { color: var(--text-2); }
.faint { color: var(--text-3); }
kbd { font: 12px/1 var(--font); padding: 2px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }
input, select, textarea, button { font: inherit; color: inherit; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 800; letter-spacing: .02em;
}
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a em { margin-left: auto; font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 8px; }
.sidebar-foot { margin-top: auto; padding: 10px 8px 0; font-size: 12.5px; color: var(--text-2); }
.main { flex: 1; min-width: 0; padding: 32px 40px 80px; max-width: 1120px; outline: none; }
.menu-btn { display: none; }

@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 30; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-btn {
    display: block; position: fixed; top: 12px; left: 12px; z-index: 31; width: 40px; height: 40px;
    border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  }
  .main { padding: 64px 16px 80px; }
}
