/* ChannelPulse web dashboard. Mobile first; two panes from 1000px. */

:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f7f7fa;
  --text: #1c1c1e;
  --text-2: #6c6c70;
  --text-3: #a1a1a6;
  --separator: rgba(60, 60, 67, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --accent: #0a66ff;
  --accent-soft: rgba(10, 102, 255, 0.12);
  --green: #1f9d4c;
  --green-soft: rgba(31, 157, 76, 0.14);
  --orange: #e8730c;
  --orange-soft: rgba(232, 115, 12, 0.14);
  --red: #e5322d;
  --pink: #e8457e;
  --yellow: #d79b00;
  --blue: #2f7cf6;
  --gray: #8e8e93;
  --warn-bg: rgba(255, 196, 0, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.03);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #232326;
    --text: #f2f2f7;
    --text-2: #98989f;
    --text-3: #636368;
    --separator: rgba(84, 84, 88, 0.55);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --accent: #3d8bff;
    --accent-soft: rgba(61, 139, 255, 0.2);
    --green: #32c665;
    --green-soft: rgba(50, 198, 101, 0.18);
    --orange: #ff9f0a;
    --orange-soft: rgba(255, 159, 10, 0.2);
    --warn-bg: rgba(255, 196, 0, 0.16);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- App bar ---------- */

.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid transparent;
}
.appbar.scrolled { border-bottom-color: var(--separator); }
.appbar .title { flex: 1; min-width: 0; }
.appbar h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .status { font-size: 12px; color: var(--text-2); }
.appbar select.ws {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; padding: 0 16px 0 0;
  font-size: 17px; font-weight: 650; max-width: 60vw; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: right 5px top 55%, right 0 top 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.iconbtn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--fill); color: var(--text); flex: none;
}
.iconbtn:active { background: var(--fill-2); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); border: 0; background: none; padding: 6px 4px 6px 0; font-size: 16px; }
.back svg { width: 20px; height: 20px; }

/* ---------- Layout ---------- */

.layout { max-width: 640px; margin: 0 auto; padding: 0 16px calc(24px + var(--safe-bottom)); }
.split { display: block; }
.pane-detail { display: none; }
@media (min-width: 1000px) {
  .layout.wide { max-width: 1240px; }
  .split { display: grid; grid-template-columns: minmax(380px, 460px) 1fr; gap: 24px; align-items: start; }
  .split .pane-detail { display: block; position: sticky; top: 64px; max-height: calc(100vh - 72px); overflow: auto; padding-bottom: 24px; border-radius: var(--radius); scrollbar-width: thin; }
  .split .pane-detail .detail-back { display: none; }
  .split .pane-list .row.selected { background: var(--accent-soft); }
}

.section-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 4px 8px; }
.section-header h2 { margin: 0; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); }
.section-header .aside { font-size: 12px; color: var(--text-2); text-align: right; }
.section-header .aside button { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 0; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 14px 16px; }
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > * + * { border-top: 0.5px solid var(--separator); }
.empty-note { padding: 14px 16px; font-size: 13px; color: var(--text-2); }

/* ---------- Segmented control ---------- */

.segmented { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; }
.segmented button {
  flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 4px; font-size: 13px; font-weight: 550;
  color: var(--text); white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 0.5px rgba(0,0,0,.04); }
@media (prefers-color-scheme: dark) { .segmented button[aria-pressed="true"] { background: #636366; } }
.segmented.small button { padding: 5px 2px; font-size: 12px; }

/* ---------- Summary ---------- */

.summary { margin-top: 12px; }
.summary .top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.label { font-size: 12px; font-weight: 550; color: var(--text-2); }
.big { font: 650 32px/1.1 var(--font-round); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.medium { font: 650 20px/1.15 var(--font-round); font-variant-numeric: tabular-nums; }
.trend { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; font-weight: 550; color: var(--text-2); }
.trend.up { color: var(--green); }
.trend svg { width: 15px; height: 15px; flex: none; }
.note { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.note svg { width: 14px; height: 14px; flex: none; }

.chart { margin-top: 14px; width: 100%; }
.chart .plot { position: relative; margin-right: 36px; }
.chart .plot svg { display: block; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; }
.chart svg * { vector-effect: non-scaling-stroke; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { opacity: 0.35; }
.chart .grid { stroke: var(--separator); stroke-dasharray: 2 3; stroke-width: 1; }
.chart .ylab { position: absolute; left: 100%; margin-left: 6px; transform: translateY(-50%); font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart .xrow { position: relative; height: 16px; margin: 4px 36px 0 0; }
.chart .xlabs { position: absolute; inset: 0; }
.chart .xlabs span { position: absolute; top: 0; font-size: 10px; color: var(--text-3); white-space: nowrap; }
.chart-tip { position: absolute; inset: 0; font-size: 12px; color: var(--text); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; opacity: 0; }
.chart.picking .xlabs { opacity: 0; }
.chart.picking .chart-tip { opacity: 1; }

.splitbar { margin-top: 12px; }
.splitbar .track { display: flex; gap: 2px; height: 6px; }
.splitbar .track span { border-radius: 3px; }
.splitbar .shorts { background: var(--pink); }
.splitbar .long { background: var(--accent); flex: 1; }
.splitbar .legend { display: flex; gap: 14px; margin-top: 6px; font-size: 11px; color: var(--text-2); align-items: center; }
.splitbar .legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 2px; }
.splitbar .legend .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.splitbar .legend .spacer { flex: 1; }

.banner { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); font-size: 13px; margin-top: 10px; }
.banner svg { width: 16px; height: 16px; flex: none; color: var(--orange); margin-top: 1px; }

/* ---------- Rows ---------- */

.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 56px;
  color: inherit; background: transparent; width: 100%; border: 0; text-align: left;
}
a.row:active, button.row:active { background: var(--fill); }
@media (hover: hover) { a.row:hover, button.row:hover { background: var(--surface-2); } }
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub .warn { color: var(--orange); }
.row .name.wrap { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
@media (max-width: 420px) { .spark { width: 40px; } .row { gap: 10px; padding-left: 12px; padding-right: 10px; } }
.row .sub.wrap { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .value { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.row .value.dim { color: var(--text-2); }
.row .chev { width: 8px; color: var(--text-3); flex: none; }
.spark { width: 54px; height: 22px; flex: none; }
.spark path { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }

.avatar { position: relative; flex: none; border-radius: 50%; }
.avatar img, .avatar .ph { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .ph { display: grid; place-items: center; color: #fff; font: 650 13px var(--font-round); }
.avatar .badge {
  position: absolute; right: -2px; bottom: -2px; border-radius: 50%; border: 2px solid var(--surface);
  display: grid; place-items: center; color: #fff;
}
.avatar .badge.active { width: 13px; height: 13px; background: var(--green); }
.avatar .badge.surging { width: 17px; height: 17px; background: var(--orange); }
.avatar .badge.surging svg { width: 9px; height: 9px; }

.thumb { position: relative; flex: none; width: 72px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--fill); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .dur { position: absolute; right: 3px; bottom: 3px; background: rgba(0,0,0,.72); color: #fff; font-size: 9.5px; font-weight: 650; padding: 1px 4px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.video .title { font-size: 14px; font-weight: 560; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video .meta { font-size: 12.5px; color: var(--text-2); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.video .meta .live { color: var(--red); font-weight: 750; font-size: 11px; }
.video .meta .ic { display: inline-flex; gap: 3px; align-items: center; }
.video .meta .ic svg { width: 12px; height: 12px; }
.video .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.gain { color: var(--green); font-weight: 650; font-size: 13px; font-variant-numeric: tabular-nums; }
.pace { font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 99px; background: var(--fill); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pace.good { background: var(--green-soft); color: var(--green); }

.comment { align-items: flex-start; }
.comment .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 12px; flex: none; }
.comment .dot.on { background: var(--accent); }
.comment .head { display: flex; gap: 6px; align-items: baseline; }
.comment .head .who { font-weight: 560; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comment .head .ch { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comment .head .when { margin-left: auto; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.comment .text { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 1px; }
.comment .on-video { font-size: 12px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.event { align-items: flex-start; }
.event .icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; margin-top: 2px; }
.event .icon svg { width: 13px; height: 13px; }
.event .head { display: flex; gap: 8px; align-items: baseline; }
.event .head .who { font-weight: 560; font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event .head .when { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.event .text { font-size: 13.5px; color: var(--text-2); }

/* ---------- Detail ---------- */

.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 10px 0 4px; }
.hero h2 { margin: 6px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.hero .status { font-size: 13px; color: var(--text-2); }
.hero .status.surging { color: var(--orange); }
.hero .status.active { color: var(--green); }
.pills { display: flex; gap: 8px; margin-top: 6px; }
.pill { padding: 6px 14px; border-radius: 99px; background: var(--fill); color: var(--accent); font-size: 14px; font-weight: 560; border: 0; }

.kv { display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 48px; }
.kv .kl { flex: 1; min-width: 0; }
.kv .k { color: var(--text); }
.kv .d { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; margin-top: 1px; }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; flex: none; max-width: 55%; }
.tone-good { color: var(--green) !important; }
.tone-hot, .tone-warn { color: var(--orange) !important; }
.tone-muted { color: var(--text-2) !important; }

.launch .vid { display: flex; gap: 12px; align-items: center; color: inherit; }
.launch .vid .t { font-weight: 560; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.launch .nums { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 12px; }
.launch .nums .r { text-align: right; }
.legend-row { display: flex; gap: 14px; font-size: 11px; color: var(--text-2); margin-top: 6px; }
.legend-row span { display: inline-flex; align-items: center; gap: 5px; }
.legend-row i { width: 14px; height: 0; border-top: 2px solid var(--accent); display: inline-block; }
.legend-row i.dash { border-top: 2px dashed var(--gray); }
.chart .linechart .mine { stroke: var(--accent); stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart .linechart .typ { stroke: var(--gray); stroke-width: 1.6; fill: none; stroke-dasharray: 4 4; }
.small-note { font-size: 12px; color: var(--text-3); margin-top: 8px; }

.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.chart-head .segmented { flex: 1; max-width: 260px; min-width: 220px; }

.goal .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.goal h3 { margin: 0; font-size: 15px; font-weight: 650; }
.goal select { border: 0; background: var(--fill); border-radius: 8px; padding: 5px 8px; font-size: 13px; color: var(--accent); max-width: 60%; }
.progress { height: 6px; border-radius: 3px; background: var(--fill); margin: 12px 0 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.progress.done span { background: var(--green); }
.goal .line { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- Forms & settings ---------- */

.auth { max-width: 400px; margin: 0 auto; padding: calc(48px + var(--safe-top)) 20px 40px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 28px; text-align: center; }
.brand .logo { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(160deg, #ff4b4b, #d61f3c); color: #fff; box-shadow: 0 6px 18px rgba(214, 31, 60, .28); }
.brand .logo svg { width: 34px; height: 34px; }
.brand h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.brand p { margin: 0; color: var(--text-2); font-size: 15px; }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 550; color: var(--text-2); padding-left: 4px; }
.input, .form input, .form select, .form textarea {
  width: 100%; border: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow), inset 0 0 0 0.5px var(--separator);
  padding: 12px 14px; font-size: 16px; outline: none;
}
.form input:focus, .input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; font-size: 16px; font-weight: 600; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:disabled { opacity: .55; }
.btn.secondary { background: var(--fill); color: var(--accent); }
.btn.danger { background: transparent; color: var(--red); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.error { color: var(--red); font-size: 14px; }
.error:empty { display: none; }
.ok { color: var(--green); font-size: 14px; }
.hint { font-size: 13px; color: var(--text-2); line-height: 1.45; }

.settings .list .item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 50px; }
.settings .list .item .grow { flex: 1; min-width: 0; }
.settings .list .item .sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.settings .list .item select, .settings .list .item input[type=text], .settings .list .item input[type=password], .settings .list .item input[type=email] {
  border: 0; background: var(--fill); border-radius: 8px; padding: 7px 10px; font-size: 15px; min-width: 0; max-width: 55%;
}
.settings .list .item input.wide { max-width: none; flex: 1; }
.settings .list .stack { flex-direction: column; align-items: stretch; gap: 8px; }
.settings .list .stack .rowline { display: flex; gap: 8px; }
.settings .list .stack .rowline input { flex: 1; max-width: none; }
.settings .footnote { font-size: 12.5px; color: var(--text-2); margin: 8px 4px 0; line-height: 1.45; }
.settings .item .mini { border: 0; background: var(--fill); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); }
.settings .item .mini svg { width: 14px; height: 14px; }
.settings .item .mini.del { color: var(--red); }
.settings .item .mini:disabled { opacity: .3; }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--fill-2); transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: rgba(30, 30, 32, .92); color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 50;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.copybox { display: flex; gap: 8px; align-items: center; background: var(--fill); border-radius: 10px; padding: 8px 10px; }
.copybox code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.center-msg { text-align: center; color: var(--text-2); padding: 60px 20px; }
.center-msg h2 { color: var(--text); font-size: 20px; margin: 12px 0 6px; }
.skeleton { background: linear-gradient(90deg, var(--fill) 0%, var(--fill-2) 50%, var(--fill) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (min-width: 700px) {
  .layout { padding-left: 24px; padding-right: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
