/* Shared chrome for every page of the site: sidebar, top bar, theme tokens.
   Colors, fonts and proportions follow Multiplex (~/code/multiplex/web/src/styles.css). */
@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face { font-family: "LM Roman"; src: url("fonts/lmroman10-regular.otf") format("opentype"); font-display: swap; }
@font-face { font-family: "LM Roman"; font-style: italic; src: url("fonts/lmroman10-italic.otf") format("opentype"); font-display: swap; }
@font-face { font-family: "LM Roman"; font-weight: bold; src: url("fonts/lmroman10-bold.otf") format("opentype"); font-display: swap; }
@font-face { font-family: "LM Roman"; font-weight: bold; font-style: italic; src: url("fonts/lmroman10-bolditalic.otf") format("opentype"); font-display: swap; }
@font-face { font-family: "LM Mono"; src: url("fonts/lmmono10-regular.otf") format("opentype"); font-display: swap; }

:root {
  --font: "Inter", -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Menlo, "DejaVu Sans Mono", monospace;
  --serif: "LM Roman", "Latin Modern Roman", "Computer Modern", Georgia, serif;
}

:root[data-theme="light"] {
  --bg: #eceef2;
  --header: #dfe2e9;
  --panel: #ffffff;
  --panel-alt: #f3f4f7;
  --text: #1b1f27;
  --text-dim: #69707d;
  --text-faint: #9aa1ad;
  --border: #dcdfe6;
  --accent: #4f7cf7;
  --accent-soft: rgba(79, 124, 247, 0.12);
  --hover: rgba(15, 23, 42, 0.05);
  --ok: #2f9e5b;
  --danger: #d23f37;
  --warn: #c27c0e;
  --code-bg: #f3f4f7;
  --scroll: rgba(15, 23, 42, 0.25);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
  --kind-a: #c4643f;
  --kind-b: #3d8a7a;
  --kind-c: #7a5fc8;
}

:root[data-theme="dark"] {
  --bg: #262e38;
  --header: #1d232b;
  --panel: #303841;
  --panel-alt: #38424e;
  --text: #d8dee9;
  --text-dim: #a6acb8;
  --text-faint: #6e7a8a;
  --border: #414c59;
  --accent: #6699cc;
  --accent-soft: rgba(102, 153, 204, 0.25);
  --hover: rgba(255, 255, 255, 0.05);
  --ok: #99c794;
  --danger: #c9524b;
  --warn: #f9ae58;
  --code-bg: #2a323b;
  --scroll: rgba(216, 222, 233, 0.2);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --kind-a: #e0906b;
  --kind-b: #6cc0ab;
  --kind-c: #a993e6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  font-size: 0.8125rem;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

::-webkit-scrollbar { width: 0.5rem; height: 0.5rem; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 0.25rem; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 15rem;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--header);
  border-right: 1px solid var(--border);
}
.sidebar-head {
  display: flex;
  align-items: center;
  padding: 0.75rem 0.75rem 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  flex: none;
}
.sidebar-list { flex: 1; min-height: 0; overflow: hidden; padding: 0.25rem; display: flex; flex-direction: column; }
.side-sec { display: flex; flex-direction: column; min-height: 0; flex: none; }
.side-sec.grow { flex: 1; }
.side-sec.grow.collapsed { flex: none; }
.side-body { overflow-y: auto; min-height: 0; padding-bottom: 0.25rem; }
.side-sec:not(.grow) .side-body { height: auto; max-height: min(23rem, 48vh); border-bottom: 1px solid var(--border); }
.side-sec.grow .side-body { flex: 1; }
.side-sec.collapsed .side-body { display: none; }
.side-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0.25rem 0.25rem 0.125rem;
  padding: 0.5rem 0.375rem;
  min-height: 2.25rem;
  border: none;
  background: none;
  color: var(--text-faint);
  font: inherit;
  cursor: pointer;
  border-radius: 0.375rem;
  text-align: left;
  flex: none;
}
.side-group:hover { background: var(--hover); }
.side-group .chev { width: 0.75rem; height: 0.75rem; flex: none; transition: transform 0.12s; }
.side-sec.collapsed .side-group .chev { transform: rotate(-90deg); }
.side-badge {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.0625rem 0.3125rem;
  border-radius: 0.25rem;
  text-transform: uppercase;
}
.side-badge.a { color: var(--kind-a); background: color-mix(in srgb, var(--kind-a) 18%, transparent); }
.side-badge.b { color: var(--kind-b); background: color-mix(in srgb, var(--kind-b) 18%, transparent); }
.side-badge.c { color: var(--kind-c); background: color-mix(in srgb, var(--kind-c) 18%, transparent); }
.side-row {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  padding: 0.3125rem 0.5rem 0.3125rem 0.625rem;
  border-radius: 0.4375rem;
  color: var(--text-dim);
  line-height: 1.3;
}
.side-row:hover { background: var(--hover); color: var(--text); }
.side-row.active { background: var(--bg); color: var(--text); }
.side-row.sub { padding-left: 1.5rem; font-size: 0.75rem; }
.side-row .num { color: var(--text-faint); font-variant-numeric: tabular-nums; flex: none; }
.side-row .dot { width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: var(--text-faint); flex: none; align-self: center; }
.side-row.active .dot { background: var(--ok); }
.sidebar-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.5rem;
  flex: none;
  border-top: 1px solid var(--border);
}
.iconbtn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.5rem;
  border-radius: 0.375rem;
  color: var(--text-dim);
}
.iconbtn:hover { background: var(--hover); color: var(--text); }
.iconbtn svg { width: 1rem; height: 1rem; display: block; }
.spacer { flex: 1; }

/* ---------- main column ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.375rem;
  padding: 0 0.75rem;
  background: var(--header);
  flex: none;
}
.topbar .title { font-weight: 600; }
.topbar .sub { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .dot { width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: var(--ok); flex: none; }
.menu-btn { display: none; }
.content { flex: 1; min-height: 0; display: flex; padding: 0.5rem; }
.panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* small controls shared by the mini apps */
.btn {
  padding: 0.25rem 0.5625rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn.on { background: var(--accent-soft); border-color: var(--accent); }
select.sel {
  padding: 0.25rem 0.375rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  background: var(--panel-alt);
}

/* ---------- narrow screens: the sidebar becomes a drawer ---------- */
@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.15s ease;
    box-shadow: 0 0 1.5rem rgba(0, 0, 0, 0.35);
  }
  #app.drawer .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 0.25rem; }
}

/* text size control in the top bar */
.zoomctl { display: inline-flex; align-items: center; gap: 0.125rem; }
.zoomctl .val { min-width: 2.75rem; text-align: center; color: var(--text-dim); font-variant-numeric: tabular-nums; }
