:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1c1f24;
  --muted: #5f6672;
  --border: #dde0e5;
  --grid: #e8eaee;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, .12);
  --accent-text: #ffffff;
  --good: #15803d;
  --warn-bg: #fff4e0;
  --warn-text: #8a4b00;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1b1e24;
    --surface-2: #252932;
    --text: #e8eaee;
    --muted: #a3aab5;
    --border: #2f343e;
    --grid: #2a2e37;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, .18);
    --accent-text: #ffffff;
    --good: #4ade80;
    --warn-bg: #3a2a10;
    --warn-text: #fcd34d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1; min-width: 0; }

.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; }

.profile { display: flex; align-items: center; gap: 14px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
#handle { text-decoration: none; }
#handle:hover { text-decoration: underline; }

.btn {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 999px;
  padding: 10px 18px;
  background: var(--accent); color: var(--accent-text);
  cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }

.status { margin: 12px 0 0; font-size: .95rem; }
.banner {
  margin: 12px 0 0; padding: 10px 14px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-text); font-size: .95rem;
}

.tiles {
  display: grid; gap: 12px; margin: 18px 0;
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.tile .label { color: var(--muted); font-size: .95rem; }
.tile .value { font-size: 2.1rem; font-weight: 700; line-height: 1.15; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.tile .delta { font-size: .9rem; color: var(--muted); }
.tile .delta b { color: var(--good); font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button {
  font: inherit; font-size: .95rem; border: 0; background: none; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.chart { position: relative; min-height: 220px; }
.chart svg { display: block; width: 100%; height: 260px; overflow: visible; }
.chart .empty { padding: 50px 10px; text-align: center; color: var(--muted); }
.axis text { fill: var(--muted); font-size: 12px; }
.grid line { stroke: var(--grid); }

.tip {
  position: fixed; pointer-events: none; z-index: 10;
  background: var(--text); color: var(--bg);
  padding: 6px 10px; border-radius: 8px; font-size: .9rem; white-space: nowrap;
}

.videos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.video {
  display: flex; flex-direction: column; text-decoration: none;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface);
}
.video:hover { border-color: var(--accent); }
.video .thumb { aspect-ratio: 9 / 12; background: var(--surface-2); position: relative; overflow: hidden; }
.video .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.videos .more { grid-column: 1 / -1; justify-self: center; }
.video .views-badge {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0,0,0,.65); color: #fff; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; font-size: .95rem;
}
.video .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.video .title { font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: .88rem; color: var(--muted); }
.video .stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.video .week { font-size: .85rem; color: var(--muted); }
.video .week b { color: var(--good); }

.foot { text-align: center; margin-top: 8px; }

.accounts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.acc {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 14px 4px 4px; cursor: pointer;
}
.acc img, .acc .ph { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.acc small { color: var(--muted); }
.acc.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); font-weight: 600; }
.acc.add { padding: 4px 14px; color: var(--accent); font-weight: 600; min-height: 40px; }

.add-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 18px;
}
.add-form label { display: block; font-weight: 600; margin-bottom: 8px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-row input {
  flex: 1; min-width: 180px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
}
.add-form p { margin: 8px 0 0; }
.add-form p.err { color: var(--warn-text); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.link { font: inherit; background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px; margin-top: 6px; }
body.empty .profile, body.empty .tiles, body.empty .card, body.empty .foot, body.empty #error { display: none; }
.acc.editing { border-style: dashed; }
.acc .x {
  display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 2px;
  border-radius: 50%; background: var(--warn-bg); color: var(--warn-text); font-size: .8rem; font-weight: 700;
}

.login { max-width: 420px; padding-top: 12vh; }
.login form { display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.login p { margin: 0; }
.login input {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px;
}
