:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece5;
  --ink: #14161b;
  --muted: #5d6270;
  --line: #e2ded5;
  --accent: #e8622c;
  --accent-ink: #ffffff;
  --accent-soft: #fbe4d9;
  --ok: #2f7d4f;
  --warn: #a15c07;
  --err: #b42318;
  --shadow: 0 1px 2px rgba(20, 22, 27, .05), 0 4px 16px rgba(20, 22, 27, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --ink: #f1eee8; --muted: #9aa0ac;
    --line: #2a2f38; --accent: #f0743f; --accent-ink: #14161b; --accent-soft: #3a2218;
    --ok: #5cc28a; --warn: #e3a54a; --err: #f07a6f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --ink: #f1eee8; --muted: #9aa0ac;
  --line: #2a2f38; --accent: #f0743f; --accent-ink: #14161b; --accent-soft: #3a2218;
  --ok: #5cc28a; --warn: #e3a54a; --err: #f07a6f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
h1, h2, h3, .brand { font-family: "Space Grotesk", Inter, sans-serif; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .35rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.25rem; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.mark { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
#nav { display: flex; gap: .2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
#nav a {
  white-space: nowrap; padding: .4rem .7rem; border-radius: 999px; color: var(--muted);
  text-decoration: none; font-size: .9rem; font-weight: 500;
}
#nav a:hover { color: var(--ink); background: var(--surface-2); }
#nav a.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.top-actions { display: flex; gap: .4rem; align-items: center; }

main { max-width: 980px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; outline: none; }
.page-head { margin-bottom: 1.25rem; }

/* surfaces */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.25rem; box-shadow: var(--shadow);
}
.stack > * + * { margin-top: .9rem; }
.grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.hero { position: relative; overflow: hidden; }
.hero::after {
  content: ""; position: absolute; right: -90px; bottom: -90px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%); pointer-events: none;
}
.headline { font-family: "Space Grotesk", sans-serif; font-size: 1.35rem; font-weight: 600; line-height: 1.3; margin: .4rem 0 .8rem; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; }
.stat .num { font-family: "Space Grotesk", sans-serif; font-size: 2rem; font-weight: 600; line-height: 1; }
.cols { display: grid; gap: .9rem; grid-template-columns: 1fr 1fr; }
ul.clean { margin: 0; padding-left: 1.1rem; }
ul.clean li + li { margin-top: .3rem; }

/* timeline */
.timeline { display: flex; gap: 0; overflow-x: auto; padding: .3rem 0 .2rem; scrollbar-width: thin; }
.tl-item { flex: 0 0 170px; position: relative; padding: 1.1rem .8rem 0 0; }
.tl-item::before { content: ""; position: absolute; top: .38rem; left: 0; right: 0; height: 2px; background: var(--line); }
.tl-item::after {
  content: ""; position: absolute; top: 0; left: 0; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--muted);
}
.tl-item.now::after { background: var(--accent); border-color: var(--accent); }
.tl-item .when { font-size: .78rem; color: var(--muted); }
.tl-item .what { font-size: .88rem; }

/* chips, pills */
.pill {
  display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 500; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }
.pill.off::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px;
  padding: .3rem .75rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* forms */
label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; }
.field + .field { margin-top: .8rem; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .75rem; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; font-size: .9rem;
  padding: .55rem 1rem; border-radius: 10px; cursor: pointer; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: .35rem .7rem; font-size: .82rem; }
.btn.block { width: 100%; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 10px; width: 34px; height: 34px; cursor: pointer; }
button:focus-visible, a:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
details > summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
details[open] > summary { margin-bottom: .6rem; }

/* auth */
.auth-wrap { min-height: calc(100vh - 4rem); display: grid; place-items: center; }
.auth { width: 100%; max-width: 400px; }
.auth .brand { font-size: 1.15rem; margin-bottom: 1.4rem; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: .75rem; margin: .8rem 0; }
.qr img { width: 190px; height: 190px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; word-break: break-all; background: var(--surface-2); padding: .4rem .6rem; border-radius: 8px; }
.otp { letter-spacing: .4em; font-size: 1.3rem; text-align: center; font-family: ui-monospace, Menlo, monospace; }

/* states */
.center { display: grid; place-items: center; min-height: 40vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.error { color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; }
.skeleton { height: 90px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
#toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .9rem;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 2rem);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--err); color: #fff; }

.thread-replies { border-left: 2px solid var(--line); padding-left: .9rem; margin-top: .8rem; }
.reply + .reply { margin-top: .6rem; }
.meta { font-size: .8rem; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 1rem 0; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: .6rem 1rem; gap: .5rem; }
  #nav { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  main { padding: 1.25rem 1rem 3rem; }
  .cols { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.45rem; }
}
a.stat { color: inherit; text-decoration: none; transition: border-color .15s; }
a.stat:hover { border-color: var(--accent); }
.icon-btn { display: inline-grid; place-items: center; }
