/* ============================================================
   AIvids Smart Links — design system
   Self-contained: no external fonts, images, or scripts (CSP).
   ============================================================ */

:root {
    /* Neutrals */
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --faint: #94a3b8;
    --line: #e2e8f0;
    --line-soft: #eef2f7;
    --paper: #ffffff;
    --wash: #f5f7fb;

    /* Brand */
    --accent: #e11d2e;
    --accent-dark: #b91324;
    --accent-soft: #fdecee;
    --accent-glow: rgba(225, 29, 46, .35);

    /* Signals */
    --green: #0f8a4f;
    --green-soft: #e5f6ec;
    --amber: #92600a;
    --amber-soft: #fdf3dc;
    --blue: #1d4ed8;
    --blue-soft: #e8eefc;

    /* Dark surfaces (sidebar, public page) */
    --night: #0b1020;
    --night-2: #111832;
    --night-line: rgba(148, 163, 184, .16);
    --night-text: #cbd5e1;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 2px 4px rgba(15, 23, 42, .04), 0 12px 24px -8px rgba(15, 23, 42, .12);
    --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .25);
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
html { color-scheme: light; font-family: var(--font); color: var(--ink); background: var(--wash); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; font-size: .95rem; line-height: 1.55; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4, p, ul, ol { margin-top: 0; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.15; letter-spacing: -.03em; margin-bottom: .35rem; font-weight: 800; }
h2 { font-size: 1.05rem; letter-spacing: -.015em; margin-bottom: .25rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { color: var(--muted); }
code { font-family: var(--mono); font-size: .85em; background: var(--line-soft); border: 1px solid var(--line); border-radius: 6px; padding: .1em .4em; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.eyebrow { color: var(--accent); font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; margin-bottom: .5rem; }
.lead { font-size: 1.02rem; line-height: 1.6; }

/* ---------- Brand lockup ---------- */

.brand-lockup { display: inline-flex; align-items: center; gap: .7rem; color: inherit; }
.brand-lockup:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; flex: none;
    background: linear-gradient(135deg, #ff4d5e 0%, var(--accent) 55%, #9f0f1e 100%);
    color: #fff; font-weight: 900; font-size: 1.05rem; letter-spacing: 0;
    box-shadow: 0 6px 16px -4px var(--accent-glow); }
.brand-lockup > span:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.brand-lockup strong { letter-spacing: -.02em; font-size: 1rem; }
.brand-lockup small { margin-top: .2rem; font-size: .62rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; opacity: .65; }

/* ---------- Buttons ---------- */

.button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .62rem 1.15rem; border-radius: 12px; border: 1px solid transparent;
    font-weight: 600; font-size: .9rem; line-height: 1.2; cursor: pointer; white-space: nowrap;
    transition: transform .12s ease, box-shadow .18s ease, background .15s ease, border-color .15s ease; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button.primary { background: linear-gradient(180deg, #f43f4f, var(--accent)); color: #fff; box-shadow: 0 8px 18px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.18); }
.button.primary:hover { background: linear-gradient(180deg, #f2303f, var(--accent-dark)); box-shadow: 0 10px 22px -6px var(--accent-glow); }
.button.secondary { background: var(--paper); color: var(--ink-2); border-color: var(--line); box-shadow: var(--shadow-sm); }
.button.secondary:hover { border-color: #cbd5e1; background: #fbfcfe; }
.button.wide { width: 100%; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.text-button { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 600; font-size: .875rem; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--accent-dark); }

/* ---------- Badges, flashes ---------- */

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .6rem; border-radius: 999px;
    font-size: .72rem; font-weight: 700; letter-spacing: .02em; background: var(--line-soft); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.badge.success { background: var(--green-soft); color: var(--green); }
.badge.success::before { background: var(--green); }
.badge.warning { background: var(--amber-soft); color: var(--amber); }
.badge.warning::before { background: var(--amber); }

.flash { padding: .85rem 1.1rem; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 1.1rem; border: 1px solid; animation: fadeUp .35s ease both; }
.flash-success { background: var(--green-soft); border-color: #bfe6cf; color: #0b5e37; }
.flash-error { background: var(--accent-soft); border-color: #f6c6cc; color: #96131f; }
.flash ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---------- Forms ---------- */

.form-stack { display: flex; flex-direction: column; gap: 1.1rem; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
legend { font-weight: 700; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: .35rem; padding: 0; }
label { display: flex; flex-direction: column; gap: .4rem; font-weight: 600; font-size: .85rem; color: var(--ink-2); }
input, select, textarea { padding: .62rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--paper); font-size: .92rem; font-weight: 400; color: var(--ink); width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease; }
input:hover, select:hover, textarea:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(225, 29, 46, .12); }
input[readonly] { background: var(--line-soft); color: var(--muted); }
textarea { resize: vertical; min-height: 90px; }
.field-help { font-weight: 400; font-size: .78rem; color: var(--faint); line-height: 1.5; }
.form-grid { display: grid; gap: .9rem; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-two { grid-column: 1 / -1; }
.checkbox-row { flex-direction: row; align-items: center; gap: .6rem; font-weight: 500; cursor: pointer; }
.checkbox-row input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); flex: none; }
.form-actions { display: flex; gap: .7rem; align-items: center; padding-top: .3rem; }

@media (max-width: 640px) {
    .form-grid.two { grid-template-columns: 1fr; }
}

/* ============================================================
   Guest shell — login & installer
   ============================================================ */

.guest-body { background: var(--night); position: relative; }
.guest-body::before { content: ""; position: fixed; inset: 0; pointer-events: none;
    background:
        radial-gradient(700px 420px at 15% -10%, rgba(225, 29, 46, .22), transparent 65%),
        radial-gradient(800px 500px at 110% 15%, rgba(29, 78, 216, .18), transparent 65%),
        radial-gradient(600px 600px at 50% 120%, rgba(225, 29, 46, .08), transparent 60%); }
.guest-shell { position: relative; max-width: 760px; margin: 0 auto; padding: clamp(1.2rem, 4vw, 3rem) 1.2rem 3rem;
    display: flex; flex-direction: column; gap: 1.6rem; }
.guest-brand { color: #fff; align-self: center; margin-top: .8rem; }
.guest-brand small { color: var(--night-text); }

.auth-card, .install-card { background: var(--paper); border-radius: 22px; box-shadow: var(--shadow-lg);
    padding: clamp(1.6rem, 4vw, 2.6rem); animation: fadeUp .45s ease both; }
.auth-card { max-width: 430px; width: 100%; align-self: center; }
.auth-card h1, .install-card h1 { font-size: clamp(1.45rem, 3vw, 1.8rem); }

.requirements { margin: 1.4rem 0; }
.requirements h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.requirement-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: .5rem; margin-top: .6rem; }
.requirement { display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; border-radius: var(--radius-sm);
    font-size: .82rem; font-weight: 600; border: 1px solid var(--line); color: var(--ink-2); }
.requirement span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: .7rem; flex: none; }
.requirement.passed span { background: var(--green-soft); color: var(--green); }
.requirement.failed { border-color: #f6c6cc; background: var(--accent-soft); }
.requirement.failed span { background: var(--accent); color: #fff; }

/* ============================================================
   Admin shell — sidebar + topbar
   ============================================================ */

.admin-body { background: var(--wash); }
.admin-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.admin-sidebar { background: linear-gradient(180deg, var(--night) 0%, var(--night-2) 100%);
    color: var(--night-text); display: flex; flex-direction: column; gap: 1.4rem;
    padding: 1.15rem .9rem; position: sticky; top: 0; height: 100vh; }
.admin-sidebar .brand-lockup { color: #fff; padding: .25rem .55rem; }

.side-nav { display: flex; flex-direction: column; gap: .18rem; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px;
    color: var(--night-text); font-weight: 600; font-size: .875rem; transition: background .15s ease, color .15s ease; }
.side-nav a:hover { background: rgba(148, 163, 184, .1); color: #fff; text-decoration: none; }
.side-nav a.active { background: linear-gradient(90deg, rgba(225, 29, 46, .22), rgba(225, 29, 46, .08)); color: #fff; position: relative; }
.side-nav a.active::before { content: ""; position: absolute; left: -.9rem; top: 20%; bottom: 20%; width: 3px; border-radius: 2px; background: var(--accent); }
.side-nav svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.side-nav a.active svg { opacity: 1; }
.nav-label { font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #64748b; padding: .9rem .75rem .3rem; }

.side-footer { border-top: 1px solid var(--night-line); padding-top: .9rem; display: flex; flex-direction: column; gap: .55rem; }
.side-user { display: flex; align-items: center; gap: .6rem; padding: 0 .55rem; min-width: 0; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
    background: rgba(148, 163, 184, .18); color: #fff; font-size: .78rem; font-weight: 700; }
.side-user > div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-user strong { color: #fff; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user small { color: #64748b; font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-footer form { display: flex; }
.nav-button { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .75rem; border: 0; border-radius: 10px;
    background: none; color: var(--night-text); font-weight: 600; font-size: .85rem; cursor: pointer; text-align: left;
    transition: background .15s ease, color .15s ease; }
.nav-button:hover { background: rgba(225, 29, 46, .14); color: #fff; }
.nav-button svg { width: 18px; height: 18px; opacity: .8; }

.admin-column { display: flex; flex-direction: column; min-width: 0; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .8rem clamp(1rem, 3vw, 2rem); background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar-title { font-size: .9rem; font-weight: 700; color: var(--ink-2); }
.topbar-actions { display: flex; align-items: center; gap: .9rem; }
.topbar-link { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
.topbar-link svg { width: 15px; height: 15px; }
.topbar-link:hover { color: var(--ink); text-decoration: none; }

.nav-toggle { display: none; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: .45rem .6rem; cursor: pointer; }
.nav-toggle svg { width: 18px; height: 18px; display: block; }

.admin-main { padding: clamp(1.2rem, 3vw, 2rem); max-width: 1220px; width: 100%; margin: 0 auto; animation: fadeUp .3s ease both; }

@media (max-width: 960px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(280px, 82vw); height: 100vh; height: 100dvh;
        transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
    body.nav-open .admin-sidebar { transform: translateX(0); }
    body.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 40; background: rgba(11, 16, 32, .45); }
    .nav-toggle { display: block; }
}

/* ---------- Page heading ---------- */

.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-heading p { margin-bottom: 0; font-size: .9rem; }
.page-heading .action-row { display: flex; gap: .6rem; }

/* ---------- Stat cards ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; margin-bottom: 1.4rem; }
.stat-card { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.05rem 1.15rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: .15rem; overflow: hidden;
    transition: box-shadow .18s ease, transform .18s ease; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card > span { font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.stat-card strong { font-size: 1.85rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-card small { color: var(--muted); font-size: .78rem; }
.stat-icon { position: absolute; top: .95rem; right: .95rem; display: grid; place-items: center; width: 34px; height: 34px;
    border-radius: 10px; background: var(--line-soft); color: var(--muted); }
.stat-icon svg { width: 17px; height: 17px; }
.stat-card.accent { border-color: #f6c6cc; background: linear-gradient(180deg, #fff 55%, var(--accent-soft)); }
.stat-card.accent .stat-icon { background: var(--accent-soft); color: var(--accent); }

/* ---------- Panels & tables ---------- */

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.35rem; margin-bottom: 1.2rem; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.panel-heading p { margin-bottom: 0; font-size: .84rem; }

.table-wrap { overflow-x: auto; margin: 0 -1.35rem; padding: 0 1.35rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint);
    padding: .55rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .8rem .75rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafbfe; }
tbody tr:last-child td { border-bottom: 0; }
td strong { display: block; font-size: .9rem; letter-spacing: -.01em; }
td small { display: block; color: var(--faint); font-size: .76rem; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

.link-cell { display: flex; align-items: center; gap: .75rem; min-width: 240px; }
.link-thumb { width: 64px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; background: var(--line-soft); border: 1px solid var(--line); }
.link-thumb-empty { display: grid; place-items: center; width: 64px; height: 36px; border-radius: 8px; flex: none;
    background: linear-gradient(135deg, var(--night), var(--night-2)); color: #fff; font-size: .7rem; }

.action-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.action-row a { font-size: .84rem; font-weight: 600; }
.action-row form { display: inline-flex; }

.pagination { margin-top: 1rem; display: flex; justify-content: flex-end; }
.pagination nav { display: flex; gap: .5rem; }
.pagination a, .pagination span { padding: .4rem .85rem; border: 1px solid var(--line); border-radius: 8px; font-size: .84rem; font-weight: 600; background: var(--paper); }
.pagination span { opacity: .5; }

.empty-state { text-align: center; padding: 2.5rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.empty-state h2, .empty-state h3 { margin-bottom: 0; }
.empty-state p { max-width: 380px; margin-bottom: .4rem; font-size: .88rem; }

.search-row { display: flex; gap: .6rem; margin-bottom: 1.1rem; }
.search-row input { max-width: 340px; }

/* ---------- Link editor ---------- */

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.2rem; align-items: start; }
.form-panel { display: flex; flex-direction: column; gap: 1.5rem; margin-bottom: 0; }
.metadata-toolbar { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.metadata-status { font-size: .8rem; color: var(--muted); }
.metadata-status.loading { color: var(--blue); }
.metadata-status.loading::before { content: ""; display: inline-block; width: .7em; height: .7em; margin-right: .4em;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -1px; }
.metadata-status.success { color: var(--green); }
.metadata-status.error { color: var(--accent-dark); }

.preview-card { position: sticky; top: 76px; background: var(--night); border-radius: var(--radius); overflow: hidden;
    color: #e2e8f0; box-shadow: var(--shadow-md); display: flex; flex-direction: column; }
.preview-card .eyebrow { padding: .9rem 1.1rem 0; color: #f87181; margin-bottom: .4rem; }
.preview-card > img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.preview-channel-row { display: inline-flex; align-items: center; gap: .45rem; }
.preview-channel-row img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex: none; }
.preview-placeholder { display: grid; place-items: center; aspect-ratio: 16 / 9; background: var(--night-2);
    color: #475569; font-weight: 700; font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; }
.preview-card > div:last-child { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .45rem; }
.preview-card small { color: #94a3b8; font-size: .74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.preview-card h2 { color: #fff; font-size: 1.02rem; margin: 0; }
.preview-card p { color: #94a3b8; font-size: .82rem; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mock-button { margin-top: .5rem; display: inline-flex; justify-content: center; padding: .55rem 1rem; border-radius: 10px;
    background: var(--accent); color: #fff; font-weight: 700; font-size: .85rem; }

@media (max-width: 1080px) {
    .editor-grid { grid-template-columns: 1fr; }
    .preview-card { position: static; max-width: 430px; }
}

/* ---------- Settings, upgrade ---------- */

.settings-content { display: flex; flex-direction: column; gap: 1rem; max-width: 560px; }
.prose-list ol { padding-left: 1.25rem; color: var(--ink-2); display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.upgrade-warning { border: 1px solid #f2d9a4; background: var(--amber-soft); border-radius: var(--radius-sm); padding: .9rem 1.1rem; font-size: .88rem; color: var(--amber); }
.upgrade-warning p { color: inherit; margin: .3rem 0 0; }

.scheduler-note { display: inline-flex; align-items: center; gap: .45rem; font-size: .78rem; color: var(--muted); }
.scheduler-note::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.scheduler-note.stale::before { background: var(--amber); }

/* ---------- Analytics ---------- */

.chart-frame { margin: .4rem 0 .6rem; }
.chart-frame svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 1.2rem; font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: .4rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-legend .key-views { background: var(--accent); }
.chart-legend .key-clicks { background: var(--blue); }

.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.breakdown-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.05rem 1.15rem; }
.breakdown-card h3 { font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); margin-bottom: .75rem; }
.meter-row { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .65rem; }
.meter-row:last-child { margin-bottom: 0; }
.meter-top { display: flex; justify-content: space-between; gap: .8rem; font-size: .82rem; }
.meter-top span:first-child { font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-bar { display: block; height: 6px; border-radius: 4px; overflow: hidden; }
.breakdown-empty { color: var(--faint); font-size: .82rem; }

/* ============================================================
   Public smart-link landing page
   ============================================================ */

.public-body { background: var(--night); color: #e2e8f0; position: relative; min-height: 100vh; }
.public-body::before { content: ""; position: fixed; inset: 0; pointer-events: none;
    background:
        radial-gradient(640px 400px at 20% -8%, rgba(225, 29, 46, .26), transparent 62%),
        radial-gradient(760px 520px at 105% 12%, rgba(29, 78, 216, .16), transparent 65%),
        radial-gradient(720px 640px at 50% 118%, rgba(225, 29, 46, .1), transparent 60%); }

.public-shell { position: relative; max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
    padding: clamp(1rem, 4vw, 2.4rem) 1.1rem 1.4rem; display: flex; flex-direction: column; gap: 1.3rem; }

.video-landing { background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .015));
    border: 1px solid rgba(148, 163, 184, .16); border-radius: 24px; overflow: hidden;
    backdrop-filter: blur(14px); box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .65); animation: fadeUp .5s ease both; }

.video-art { position: relative; aspect-ratio: 16 / 9; background: var(--night-2); overflow: hidden; }
.video-art img { width: 100%; height: 100%; object-fit: cover; }
.video-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(11, 16, 32, .55)); }
.video-placeholder { display: grid; place-items: center; height: 100%;
    background: radial-gradient(340px 200px at 50% 45%, rgba(225, 29, 46, .3), transparent 70%), var(--night-2); }
.video-placeholder span, .play-badge { display: grid; place-items: center; width: 66px; height: 66px; border-radius: 50%;
    background: rgba(225, 29, 46, .92); color: #fff; font-size: 1.35rem; padding-left: 4px;
    box-shadow: 0 0 0 10px rgba(225, 29, 46, .16), 0 14px 34px -8px rgba(225, 29, 46, .55); }
.play-badge { position: absolute; top: 50%; left: 50%; margin: -33px 0 0 -33px; z-index: 2; animation: pulse 2.6s ease-in-out infinite; }
.youtube-chip { position: absolute; left: .9rem; bottom: .8rem; z-index: 2; display: inline-flex; align-items: center; gap: .45rem;
    background: rgba(11, 16, 32, .72); border: 1px solid rgba(148, 163, 184, .25); backdrop-filter: blur(6px);
    color: #fff; font-size: .72rem; font-weight: 700; letter-spacing: .05em; padding: .35rem .7rem; border-radius: 999px; }
.youtube-chip span { color: #ff4d5e; font-size: .62rem; }

.video-content { padding: clamp(1.15rem, 3.5vw, 1.7rem); display: flex; flex-direction: column; gap: .9rem; }

.channel-row { display: flex; align-items: center; gap: .75rem; }
.channel-logo { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none;
    border: 2px solid rgba(148, 163, 184, .28); box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .5); }
.channel-logo-fallback { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-size: 1.05rem; }
.channel-row > div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.channel-row strong { color: #fff; font-size: .95rem; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-row small { color: #64748b; font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }

.public-brand { display: inline-flex; align-items: center; gap: .55rem; color: #94a3b8; font-size: .8rem; }
.public-brand:hover { color: #cbd5e1; text-decoration: none; }
.public-brand .brand-mark { width: 26px; height: 26px; border-radius: 8px; font-size: .78rem; box-shadow: none; }
.public-brand strong { font-weight: 700; letter-spacing: .01em; }

.video-content h1 { color: #fff; font-size: clamp(1.3rem, 4.5vw, 1.65rem); letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.public-description { color: #94a3b8; font-size: .92rem; line-height: 1.6; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.browser-help { border: 1px solid rgba(250, 204, 21, .28); background: rgba(250, 204, 21, .07);
    border-radius: 14px; padding: .85rem 1rem; font-size: .84rem; color: #fde68a; }
.browser-help strong { color: #fef3c7; }
.browser-help p { color: #eadfa8; margin: .3rem 0 .45rem; font-size: .82rem; }
.browser-help .text-button { color: #fde047; }

.auto-attempt { display: flex; align-items: center; gap: .8rem; border: 1px solid rgba(148, 163, 184, .2);
    background: rgba(148, 163, 184, .07); border-radius: 14px; padding: .8rem 1rem; font-size: .82rem; color: #94a3b8; }
.auto-attempt strong { display: block; color: #e2e8f0; font-size: .86rem; }
.auto-attempt small { font-size: .78rem; }
.auto-attempt-spinner { width: 20px; height: 20px; flex: none; border-radius: 50%;
    border: 2.5px solid rgba(148, 163, 184, .3); border-top-color: #f43f4f; animation: spin .8s linear infinite; }
.auto-attempt.blocked { border-color: rgba(250, 204, 21, .3); color: #eadfa8; }
.auto-attempt.blocked strong { color: #fde68a; }
.auto-attempt.blocked .auto-attempt-spinner { animation: none; border-color: rgba(250, 204, 21, .45); border-top-color: rgba(250, 204, 21, .45); }

.public-actions { display: flex; flex-direction: column; gap: .65rem; margin-top: .2rem; }
.button.youtube { padding: .95rem 1.3rem; border-radius: 14px; font-size: 1rem; font-weight: 700; color: #fff;
    background: linear-gradient(180deg, #ff3c4d, var(--accent) 60%, var(--accent-dark));
    box-shadow: 0 14px 34px -10px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .22); }
.button.youtube:hover { box-shadow: 0 18px 40px -10px rgba(225, 29, 46, .5); }
.button.youtube span { font-size: .8rem; }
.button.browser { background: rgba(148, 163, 184, .1); border: 1px solid rgba(148, 163, 184, .25); color: #e2e8f0; font-weight: 600; }
.button.browser:hover { background: rgba(148, 163, 184, .16); }

.handoff-note { text-align: center; color: #64748b; font-size: .74rem; margin: 0; }

.public-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    color: #64748b; font-size: .76rem; padding: 0 .3rem; margin-top: auto; }
.public-footer a { color: #94a3b8; }
.public-footer a:hover { color: #e2e8f0; }

/* ---------- Error page (guest shell) ---------- */

.error-card { text-align: center; padding: clamp(2rem, 6vw, 3.4rem) 1.4rem; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.error-code { font-size: 3.2rem; font-weight: 900; letter-spacing: -.05em; line-height: 1; color: var(--accent); }

/* ---------- Privacy / prose page ---------- */

.prose-card { background: var(--paper); border-radius: 22px; box-shadow: var(--shadow-lg); padding: clamp(1.6rem, 4vw, 2.6rem); }
.prose-card h2 { margin-top: 1.4rem; }
.prose-card ul { color: var(--muted); line-height: 1.7; }

/* ---------- Animation ---------- */

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 10px rgba(225, 29, 46, .16), 0 14px 34px -8px rgba(225, 29, 46, .55); }
    50% { box-shadow: 0 0 0 16px rgba(225, 29, 46, .08), 0 14px 34px -8px rgba(225, 29, 46, .55); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
    .admin-sidebar, .admin-topbar, .page-heading .action-row, .button { display: none !important; }
    .admin-layout { grid-template-columns: 1fr; }
}
