:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --brand: #14213d;
  --brand-ink: #ffffff;
  --gold: #a87b14;
  --up: #006300;
  --down: #d03b3b;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --radius: 10px;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --brand: #c9d6f2;
    --brand-ink: #0d0d0d;
    --gold: #d9a93a;
    --up: #0ca30c;
    --down: #e66767;
    --series-1: #3987e5;
    --series-2: #d95926;
    --warn-bg: #3a2e10;
    --warn-ink: #f3d68a;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --brand: #c9d6f2;
  --brand-ink: #0d0d0d;
  --gold: #d9a93a;
  --up: #0ca30c;
  --down: #e66767;
  --series-1: #3987e5;
  --series-2: #d95926;
  --warn-bg: #3a2e10;
  --warn-ink: #f3d68a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--series-1); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0; }
h2 { font-size: 1.25rem; margin-bottom: 12px; }
h3 { font-size: 1.05rem; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.up { color: var(--up); }
.down { color: var(--down); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
header.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 40px; height: 40px; border-radius: 50%; flex: none; display: block; }
.login .brand-mark { width: 56px; height: 56px; }
.brand-name { font-family: var(--serif); font-weight: 700; line-height: 1.1; }
.brand-name small { display: block; font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
nav.tabs a {
  white-space: nowrap; text-decoration: none; color: var(--ink-2); padding: 6px 10px; border-radius: 6px; font-size: 14px;
}
nav.tabs a:hover { background: var(--surface-2); }
nav.tabs a.on { background: var(--brand); color: var(--brand-ink); }
nav.tabs .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--down); color: #fff; font-size: 11px; text-align: center; }
.who { font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.who button { font-size: 13px; }

main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { margin: 4px 0 18px; }
.page-head h1 { font-size: 1.7rem; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  min-width: 0;
}
.grid { display: grid; gap: 16px; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tile .value { font-family: var(--serif); font-size: 1.75rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.banner {
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; background: var(--warn-bg); color: var(--warn-ink);
  display: flex; gap: 10px; align-items: flex-start;
}
.banner a { color: inherit; font-weight: 600; }

/* ---------- forms ---------- */
button, .btn {
  font: inherit; font-size: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
  padding: 7px 14px; border-radius: 7px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover { filter: brightness(0.97); }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
button.danger { color: var(--down); }
button.link { background: none; border: none; padding: 0; color: var(--series-1); }
button:disabled { opacity: 0.55; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axis); border-radius: 7px; padding: 7px 10px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
label.field { display: block; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); }
label.field > input, label.field > select, label.field > textarea { margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.error { color: var(--down); font-size: 14px; margin-top: 8px; }
.okmsg { color: var(--up); font-size: 14px; margin-top: 8px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: auto; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
td { padding: 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
.sym { font-weight: 700; }
.weight-bar { height: 4px; border-radius: 2px; background: var(--series-1); margin-top: 4px; }

/* ---------- trip meter ---------- */
.meter { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin: 10px 0 6px; }
.meter > div { height: 100%; background: var(--gold); border-radius: 6px; }

/* ---------- chart ---------- */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; }
.legend i.dash { border-top-style: dashed; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart .s1 { stroke: var(--series-1); }
.chart .s2 { stroke: var(--series-2); }
.chart .s3 { stroke: var(--muted); stroke-dasharray: 4 4; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end-label { font-size: 12px; font-family: var(--sans); fill: var(--ink-2); }
.chart .hair { stroke: var(--axis); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.s1 { fill: var(--series-1); }
.chart .dot.s2 { fill: var(--series-2); }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); min-width: 150px; z-index: 5;
}
.tooltip .t-date { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row b { font-variant-numeric: tabular-nums; }
.tooltip .t-row i { display: inline-block; width: 12px; border-top: 2px solid; }
.tooltip .t-row span { color: var(--ink-2); }

/* ---------- feed / threads ---------- */
.feed-item { border-bottom: 1px solid var(--grid); padding: 12px 0; }
.feed-item:last-child { border-bottom: none; }
.feed-top { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); }
.pill.buy { background: color-mix(in srgb, var(--series-1) 16%, transparent); color: var(--series-1); }
.pill.sell { background: color-mix(in srgb, var(--series-2) 18%, transparent); color: var(--series-2); }
.pill.blocked { background: var(--down); color: #fff; }
.pill.allowed { background: var(--up); color: #fff; }
.pill.open { background: var(--gold); color: #fff; }
.note { margin-top: 6px; font-size: 13px; background: var(--surface-2); padding: 6px 10px; border-radius: 6px; border-left: 3px solid var(--gold); }
.thread { margin-top: 8px; }
.reacts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.react { padding: 2px 8px; font-size: 13px; border-radius: 12px; background: var(--surface-2); border: 1px solid transparent; }
.react.mine { border-color: var(--series-1); }
.react-picker { position: relative; }
.react-menu { position: absolute; top: 100%; left: 0; z-index: 6; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; display: flex; gap: 2px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.react-menu button { border: none; background: none; font-size: 18px; padding: 4px 6px; }
.comment { padding: 8px 0 0; font-size: 14px; }
.comment .meta { font-size: 12px; color: var(--muted); }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form textarea { min-height: 38px; height: 38px; }
.comment-form button { align-self: flex-end; }
.toggle-thread { font-size: 13px; }
.report-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; }

/* ---------- hall of shame ---------- */
.shame { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.shame .card { margin: 0; }
.shame .portrait { font-size: 40px; line-height: 1; }
.shame blockquote { margin: 10px 0 0; font-family: var(--serif); font-style: italic; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; margin-top: 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 420px; }
.login .brand { margin-bottom: 16px; }
.login h1 { font-size: 1.5rem; margin-bottom: 6px; }
.login p { color: var(--ink-2); margin: 0 0 16px; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.sync-line { font-size: 12px; color: var(--muted); margin-top: -6px; margin-bottom: 14px; }

@media (max-width: 640px) {
  .top-inner { gap: 8px; }
  nav.tabs { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .page-head h1 { font-size: 1.4rem; }
  .tile .value { font-size: 1.3rem; }
  .tile { padding: 12px; }
  .grid.tiles { gap: 10px; }
  .card { padding: 14px; }
  .hide-sm { display: none; }
}

/* Sign in with Google (follows Google's button guidelines: G mark, plain light/dark surface) */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 10px 14px; font-weight: 500; background: #ffffff; color: #1f1f1f; border: 1px solid #747775;
}
.google-btn:hover { filter: brightness(0.97); }
.google-btn svg { flex: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .google-btn { background: #131314; color: #e3e3e3; border-color: #8e918f; }
}
:root[data-theme="dark"] .google-btn { background: #131314; color: #e3e3e3; border-color: #8e918f; }
.or-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; border-top: 1px solid var(--grid); }
#google-msg { margin: 0 0 12px; }
.login.privacy { max-width: 640px; }
.privacy h2 { font-size: 1.05rem; margin: 18px 0 6px; }
.privacy ul { color: var(--ink-2); margin: 0 0 12px; padding-left: 20px; }
.privacy li { margin-bottom: 4px; }
.login-foot { margin-top: 18px; font-size: 13px; color: var(--muted); }
.login-foot a { color: inherit; }

/* ---------- news ---------- */
.news-item h3 { margin: 0 0 4px; line-height: 1.35; }
.news-item h3 a { color: var(--ink); text-decoration: none; }
.news-item h3 a:hover { text-decoration: underline; }
.news-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sym-pill.pending { color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, transparent); }
.sym-pill { text-decoration: none; color: var(--series-1); background: color-mix(in srgb, var(--series-1) 12%, transparent); }
.news-summary { margin: 6px 0 0; color: var(--ink-2); font-size: 14px; }

/* ---------- charter ---------- */
.banner.ok { background: color-mix(in srgb, var(--up) 14%, var(--surface)); color: var(--ink); }
.charter { line-height: 1.6; overflow-wrap: anywhere; }
.charter h2 { font-family: var(--serif); font-size: 1.5rem; margin: 0 0 14px; }
.charter h3 { font-size: 1.1rem; margin: 22px 0 8px; padding-top: 14px; border-top: 1px solid var(--grid); }
.charter p, .charter ul, .charter ol { margin: 0 0 12px; }
.charter ul, .charter ol { padding-left: 22px; }
.charter li { margin-bottom: 6px; }
.charter li > ul, .charter li > ol { margin: 6px 0 0; }
.charter table { margin-bottom: 12px; }
.charter td, .charter th { vertical-align: top; }
.charter-edit { min-height: 420px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; margin-bottom: 10px; }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: 12px; }
