:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --good: #006300;
  --bad: #d03b3b;
  --yt: #eb6834;
  --tt: #1baf7a;
  --ig: #2a78d6;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #252524;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --good: #0ca30c;
    --bad: #e66767;
    --yt: #d95926;
    --tt: #199e70;
    --ig: #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #252524;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --good: #0ca30c;
  --bad: #e66767;
  --yt: #d95926;
  --tt: #199e70;
  --ig: #3987e5;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }

a { color: inherit; }

.c-youtube { --c: var(--yt); }
.c-tiktok { --c: var(--tt); }
.c-instagram { --c: var(--ig); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
}

/* header */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.top-in {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top h1 { font-size: 18px; margin: 0; font-weight: 650; }

.top .status { color: var(--muted); font-size: 12px; margin-right: auto; padding-left: 4px; }
.top .status.is-off { color: var(--bad); }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}

.icon-btn svg { width: 20px; height: 20px; }

.icon-btn.spin svg { animation: spin 0.9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* sections */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 22px 0 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.section-title .count { color: var(--muted); font-weight: 500; }

.banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 14px;
}

.banner button { margin-top: 8px; }

/* account tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tile {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tile:hover { border-color: var(--axis); }

.tile-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; }

.tile-value { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap; }

.tile-delta { font-size: 12px; color: var(--muted); min-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.up { color: var(--good); }
.down { color: var(--bad); }

.spark { width: 100%; height: 26px; display: block; margin: 4px 0 2px; }
.spark-line { fill: none; stroke: var(--c); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }

.tile-foot { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-foot.is-error { color: var(--bad); }

.tile-empty { border-style: dashed; background: transparent; }
.tile-empty .tile-value { font-size: 14px; font-weight: 500; color: var(--muted); margin: 8px 0 18px; white-space: normal; }

@media (max-width: 400px) {
  .tile-value { font-size: 20px; }
}

@media (min-width: 720px) {
  .tiles { gap: 12px; }
  .tile { padding: 14px 14px 10px; }
  .tile-value { font-size: 28px; }
  .tile-head { font-size: 13px; }
  .tile-delta { font-size: 13px; }
  .spark { height: 34px; }
}

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; }
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip.on { background: var(--ink); color: var(--page); border-color: var(--ink); }


/* videos */
.vlist { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.vrow {
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
}

.vrow:first-child { border-top: 0; }
.vrow:hover { background: var(--surface-2); }

.vthumb { width: 48px; height: 64px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.vtitle { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vmeta { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; margin-top: 2px; white-space: nowrap; overflow: hidden; }
.vmeta span { overflow: hidden; text-overflow: ellipsis; }
.vstats { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.vnum { text-align: right; font-variant-numeric: tabular-nums; }
.vviews { font-size: 16px; font-weight: 650; white-space: nowrap; }
.vrate { font-size: 12px; color: var(--muted); white-space: nowrap; }
.vrate.up { color: var(--good); }

.empty { padding: 18px 14px; color: var(--muted); font-size: 14px; }

.more { display: block; margin: 10px auto 0; }

/* buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--ink); color: var(--page); border-color: var(--ink); }
.btn[disabled], .btn.is-disabled { opacity: 0.45; pointer-events: none; }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* sheets */
.sheet {
  border: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  width: 100%;
  max-width: 100%;
  max-height: 92dvh;
  margin: auto 0 0;
  border-radius: 18px 18px 0 0;
  overflow: hidden;
}

.sheet::backdrop { background: rgba(0, 0, 0, 0.45); }

.sheet-in { display: flex; flex-direction: column; max-height: 92dvh; }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.sheet-head h2 { font-size: 16px; margin: 0; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sheet-body { overflow-y: auto; padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }

@media (min-width: 720px) {
  .sheet { width: 680px; margin: auto; border-radius: 18px; max-height: 86vh; }
  .sheet-in { max-height: 86vh; }
}

.hero { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.hero img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.hero .vthumb { width: 60px; height: 80px; flex: none; }
.hero-title { font-size: 15px; font-weight: 600; }
.hero-sub { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.stat-l { font-size: 12px; color: var(--ink-2); }
.stat-v { font-size: 18px; font-weight: 650; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.err { color: var(--bad); font-size: 13px; margin: 8px 0; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: 13px; margin: 6px 0; }

/* charts */
.chart { position: relative; margin: 8px 0 4px; min-height: 60px; }
.chart svg { display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--c); opacity: 0.1; }
.chart .end { fill: var(--c); stroke: var(--page); stroke-width: 2; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 16px 0; margin: 0; }

.tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.tip-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-t { color: var(--ink-2); }

/* settings */
.set-group { margin-bottom: 18px; }
.set-group h3 { font-size: 13px; color: var(--ink-2); margin: 0 0 6px; font-weight: 600; }

.set-slot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.set-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.set-state { font-size: 13px; color: var(--ink-2); margin-right: auto; }
.set-form { display: flex; gap: 8px; margin-top: 8px; }

.input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--page);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}

.keys { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.keys .ok { color: var(--good); }
.keys .no { color: var(--muted); }

.uri { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.uri code {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  overflow-wrap: anywhere;
}

/* login */
.login {
  max-width: 320px;
  margin: 18vh auto 0;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login h1 { font-size: 22px; margin: 0 0 6px; }
.login-msg { color: var(--bad); font-size: 13px; min-height: 18px; margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--page);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 50;
  max-width: calc(100% - 32px);
}
