/* Twitch live follower counter page. Self contained on purpose: no Bootstrap or icon
   font, so nothing render blocking comes from other hosts and the layout never jumps
   when a late stylesheet arrives. */
:root {
    --bar: #6f2bd9;
    --brand: #772ce8;
    --brand-ink: #ffffff;
    --accent: #772ce8;
    --bg: #f2f4f7;
    --card: #ffffff;
    --text: #1b1f24;
    --muted: #57606a;
    --line: #dde1e6;
    --field: #f7f8fa;
    --hover: #eef1f4;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Roboto, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a { color: #0b5ed7; }
img, svg { vertical-align: middle; }
h1, h2, h3, p { margin-top: 0; }
button, input, select { font: inherit; color: inherit; }

.ic { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.skip {
    position: absolute; left: 8px; top: -60px; z-index: 100;
    background: #fff; color: #000; padding: 8px 12px; border-radius: 6px;
}
.skip:focus { top: 8px; }

:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }

/* ---------- top bar and menu ---------- */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    height: 56px; display: flex; align-items: center; gap: 8px;
    padding: 0 12px; background: var(--bar); color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.topbar-title {
    margin: 0 auto; font-size: 1.2rem; font-weight: 700; line-height: 1.2;
    display: flex; align-items: center; gap: 10px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 100px);
}
.topbar-title .logo { width: 28px; height: 28px; flex: 0 0 auto; }
.menu-btn {
    display: none; width: 44px; height: 44px; border: 0; border-radius: 8px;
    background: transparent; color: #fff; cursor: pointer; align-items: center; justify-content: center;
}
.menu-btn:hover { background: rgba(255, 255, 255, .15); }

.sidebar {
    position: fixed; top: 56px; bottom: 0; left: 0; z-index: 40; width: 230px;
    overflow-y: auto; background: var(--card); border-right: 1px solid var(--line); padding: 8px 0 24px;
}
.side-h {
    margin: 18px 20px 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted);
}
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list a {
    display: flex; align-items: center; gap: 12px; padding: 10px 20px;
    color: var(--text); text-decoration: none; font-size: 15px;
}
.side-list a:hover, .side-list a:focus-visible { background: var(--hover); }
.side-foot { margin: 24px 20px 0; font-size: 13px; color: var(--muted); }
.side-foot a { color: inherit; }
.scrim { position: fixed; inset: 56px 0 0 0; z-index: 35; background: rgba(0, 0, 0, .45); }

/* ---------- page ---------- */
.main { margin-left: 230px; padding: 72px 20px 40px; }
.wrap { max-width: 1100px; margin: 0 auto; }

.card { background: var(--card); border-radius: 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .1); }

.banner-wrap {
    height: 150px; border-radius: 12px 12px 0 0; overflow: hidden;
    background: linear-gradient(120deg, var(--bar), var(--accent));
}
.banner { display: block; width: 100%; height: 100%; object-fit: cover; }

.counter-card {
    display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 16px;
    padding: 16px 20px; border-radius: 0 0 12px 12px;
}
.avatar {
    width: 150px; height: 150px; border-radius: 50%; object-fit: cover; background: var(--field);
    border: 4px solid var(--accent); box-shadow: 0 0 16px rgba(0, 0, 0, .18);
}
.counter-body { min-width: 0; text-align: center; }
.channel {
    display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0;
    min-height: 1.5em; font-size: 1.5rem; font-weight: 500;
}
.channel .username { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .logo { width: 30px; height: 30px; flex: 0 0 auto; }
.verified { margin-left: 4px; }
.count-wrap { height: 1.25em; font-size: calc(30px + 3vw); line-height: 1.25; overflow: hidden; contain: layout paint; }
.main-odometer { font-weight: 400; }
.count-label {
    margin: 4px 0 0; font-size: 14px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--muted);
}

.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 10px 12px; border: 0; border-radius: 8px;
    font-size: 16px; font-weight: 500; line-height: 1.2; text-align: center;
    text-decoration: none; cursor: pointer; color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn-search { background: #0b5ed7; }
.btn-compare { background: #1e7e34; }
.btn-brand { background: var(--brand); color: var(--brand-ink); }
.btn-custom { background: #3d4756; }

.status {
    margin: 0 0 14px; padding: 10px 14px; border-radius: 8px;
    background: #fff4e5; border: 1px solid #f0cf96; color: #5f3d00;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { padding: 14px 10px; text-align: center; min-height: 104px; display: flex; flex-direction: column; justify-content: center; }
.stat-count { height: 1.3em; font-size: calc(20px + 1vw); line-height: 1.3; overflow: hidden; contain: layout paint; }
.stat-label { margin: 2px 0 0; font-size: 15px; color: var(--muted); }
.stat.is-offline .stat-count { visibility: hidden; }
.stat.is-offline .stat-label { font-weight: 500; }

.ad { margin: 20px 0; text-align: center; overflow: hidden; }
.ad-auto { min-height: 280px; }
.ad-fluid { min-height: 160px; }
.ad-rect { min-height: 280px; }
.ad-wide { min-height: 100px; }
@media (min-width: 769px) {
    .ad-auto { min-height: 100px; }
    .ad-fluid { min-height: 130px; }
    .ad-rect { min-height: 250px; }
}

.chart-card { padding: 8px; margin: 20px 0; }
.chart { height: 320px; }

.spacenode-promo-card { margin: 20px 0; }

.text-card { padding: 20px 24px; margin: 20px 0; }
.text-card h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 12px; }
.text-card h3 { font-size: 1.1rem; font-weight: 700; margin: 20px 0 8px; }
.text-card p { line-height: 1.65; margin-bottom: 12px; }
.text-card p:last-child { margin-bottom: 0; }

.share-box label { display: block; margin: 14px 0 6px; font-weight: 500; }
.share-box input + p, .share-box input + h3 { margin-top: 16px; }
.share-box input {
    width: 100%; padding: 10px 12px; border: 1px solid #b9c0c8; border-radius: 8px;
    background: var(--field); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px;
}

body.no-data .count-wrap, body.no-data .stat-count { visibility: hidden; }
body.no-data .stats { display: none; }

.social-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.social-row a {
    display: inline-block; padding: 6px 14px; border-radius: 999px; font-size: 14px;
    background: var(--field); border: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.social-row a:hover, .social-row a:focus-visible { border-color: var(--accent); }

.info-bio { white-space: pre-line; }
.info-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; }
.info-list dt { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.info-list dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.history-table th, .history-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.history-table th:first-child, .history-table td:first-child { text-align: left; }
#history-body .chart { margin-top: 12px; }

/* ---------- creator block (filled in by the server) ---------- */
.creator-spotlight {
    background: var(--card); border-radius: 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .1);
    border-left: 4px solid var(--accent); padding: 18px 22px; margin: 20px 0;
}
.creator-spotlight h2 { font-size: 1.25rem; font-weight: 700; margin: 0 0 8px; }
.creator-spotlight h3 { font-size: 1rem; font-weight: 700; color: var(--muted); margin: 14px 0 8px; }
.creator-spotlight p { line-height: 1.6; margin: 0 0 10px; }
.creator-spotlight .creator-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.creator-spotlight .creator-links a {
    display: inline-block; padding: 6px 14px; border-radius: 999px; font-size: 14px;
    background: var(--field); border: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.creator-spotlight .creator-links a:hover, .creator-spotlight .creator-links a:focus-visible { border-color: var(--accent); }

/* ---------- dialogs ---------- */
dialog {
    width: min(520px, calc(100% - 24px)); max-height: calc(100% - 48px); padding: 0;
    border: 0; border-radius: 12px; background: var(--card); color: var(--text);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 1.2rem; }
.dialog-close { width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.dialog-close:hover { background: var(--hover); }
.dialog-body { padding: 16px 20px 20px; }
.dialog-body label { display: block; margin: 0 0 6px; font-weight: 500; }
.dialog-body p { margin-bottom: 10px; }
.field-row { display: flex; gap: 8px; }
.field-row input, .dialog-body select {
    flex: 1; min-width: 0; width: 100%; padding: 10px 12px; border: 1px solid #b9c0c8; border-radius: 8px; background: var(--field);
}
.dialog-body select { margin-bottom: 14px; }
.field-row .btn { min-height: 44px; }
.muted { color: var(--muted); }
.result-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.result { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
.result:hover, .result:focus-visible { background: var(--hover); }
.result img:first-child { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--field); }
.result small { display: block; color: var(--muted); }

/* ---------- themes (?t=1 dark, ?t=2 rainbow on dark, ?t=3 rainbow on light) ---------- */
body.theme-dark {
    --bg: #121315; --card: #1c1e21; --text: #e4e6ea; --muted: #aab2bd;
    --line: #33373d; --field: #26292d; --hover: #2a2d32;
}
body.theme-dark a { color: #7cb7ff; }

/* ---------- phones ---------- */
@media (max-width: 946px) {
    .menu-btn { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 4px 0 20px rgba(0, 0, 0, .2); visibility: hidden; }
    .sidebar.open { transform: none; visibility: visible; }
    .main { margin-left: 0; padding: 68px 12px 32px; }
    .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .banner-wrap { height: 110px; }
    .counter-card { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 14px 12px; }
    .avatar { width: 96px; height: 96px; border-width: 3px; }
    .channel { font-size: 1.15rem; }
    .channel .logo { width: 22px; height: 22px; }
    .count-wrap { font-size: 34px; }
    .text-card { padding: 18px 16px; }
    .topbar-title { font-size: 1rem; }
    .topbar-title .logo { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}

/* ---------- compare pages (no sidebar) ---------- */
body.no-side .main { margin-left: 0; }
.top-back {
    display: flex; align-items: center; justify-content: center; width: 44px; height: 44px;
    border-radius: 8px; color: #fff; flex: 0 0 auto;
}
.top-back .ic { transform: rotate(180deg); }
.top-back:hover { background: rgba(255, 255, 255, .15); }
.cmp-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; padding: 16px; margin-bottom: 14px; }
.cmp-form label { display: block; margin-bottom: 6px; font-weight: 500; }
.cmp-form input { width: 100%; padding: 10px 12px; border: 1px solid #b9c0c8; border-radius: 8px; background: var(--field); }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp-side { padding: 18px 12px; text-align: center; min-width: 0; }
.cmp-avatar { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; border: 4px solid var(--accent); background: var(--field); }
.cmp-name { margin: 10px 0 0; font-size: 1.25rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.5em; }
.cmp-count .odometer, .cmp-gap .odometer { font-weight: 400; }
.cmp-count { font-size: calc(24px + 1.6vw); }
.cmp-visit { display: inline-block; margin-top: 8px; font-size: 14px; }
.cmp-gap { margin: 12px 0; padding: 16px; text-align: center; }
.cmp-gap .count-wrap { font-size: calc(26px + 1.6vw); }
.cmp-gap p { margin: 4px 0 0; }
@media (max-width: 600px) {
    .cmp-form { grid-template-columns: 1fr 1fr; }
    .cmp-form .btn { grid-column: 1 / -1; }
    .cmp-avatar { width: 72px; height: 72px; border-width: 3px; }
    .cmp-name { font-size: 1rem; }
    .cmp-count { font-size: 24px; }
}
