@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

@font-face {
    font-family: 'BrandMark Sans';
    src: url('/static/fonts/BrandMarkSans.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ── Tokens ──
   Same palette as Kaempferi (raw brand colours + rust/orange accent) so the two apps
   read as one family. Components only reference the semantic aliases. */
:root {
    /* Raw brand palette — locked */
    --carbon-black: #1e2019;
    --space-indigo: #2c2754;
    --white-smoke: #f2f4f3;
    --blue-energy: #3f8efc;
    --electric-sapphire: #2667ff;

    /* Accent set: rust is the header wash, crab-orange the accent, molten-amber its lift. */
    --rust: #5a2412;
    --crab-orange: #e8622c;
    --molten-amber: #ff8a4d;

    /* Semantic: surfaces */
    --bg-primary: var(--carbon-black);
    --bg-card: var(--bg-primary);
    --bg-input: #2a2420;
    --bg-input-border: #5a3a2a;
    --border-card: rgba(232, 98, 44, 0.35);
    --divider: rgba(232, 98, 44, 0.20);
    --bg-header: linear-gradient(90deg, var(--rust) 0%, #3d1c0f 55%, #2a1a14 100%);

    /* Semantic: text */
    --text-primary: var(--white-smoke);
    --text-secondary: rgba(242, 244, 243, 0.55);
    --text-muted: rgba(242, 244, 243, 0.35);
    /* carbon-black on #e8622c is 4.9:1 (AA); white-smoke on it is only 3.4:1. */
    --text-on-accent: var(--carbon-black);

    /* Semantic: accent */
    --accent-primary: var(--crab-orange);
    --accent-hover: var(--molten-amber);
    --accent-tint-soft: rgba(232, 98, 44, 0.12);
    --accent-tint: rgba(232, 98, 44, 0.20);
    --accent-tint-strong: rgba(232, 98, 44, 0.45);
    --accent-glow: rgba(232, 98, 44, 0.42);

    /* Semantic: feedback states */
    --success-bg: #0f3d1a;   --success-text: #4ade80;
    --warn-bg:    #3d2e0f;   --warn-text:    #facc15;
    --error-bg:   #3d0f0f;   --error-text:   #f87171;

    /* Radii */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Fonts */
    --font-brand: 'BrandMark Sans', system-ui, sans-serif;
    --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;

    --header-height: 72px;
}

/* ── Reset ── */

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

html {
    -webkit-text-size-adjust: 100%;
    scrollbar-width: thin;
    scrollbar-color: rgba(242, 244, 243, 0.25) transparent;
}

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background-color: rgba(242, 244, 243, 0.2);
    border-radius: var(--radius-full);
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(242, 244, 243, 0.38); }
::-webkit-scrollbar-corner { background: transparent; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }

/* ── Typography ── */

h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1.25rem; }
h2 { font-size: 1.1rem; font-weight: 500; margin-bottom: 0.75rem; color: var(--text-secondary); }
p { margin-bottom: 0.5rem; }

a {
    color: var(--accent-hover);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover { color: var(--accent-primary); text-decoration: underline; }

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: rgba(242, 244, 243, 0.06);
    padding: 0.1em 0.35em;
    border-radius: var(--radius-xs);
}

/* ── App header (signed-in pages) ── */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
    background: var(--bg-header);
    border-bottom: 1px solid var(--accent-tint-strong);
}

.app-header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    min-width: 0;
}
.app-header-brand:hover { text-decoration: none; color: var(--text-primary); }

.app-header-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    flex-shrink: 0;
}

.app-header-wordmark {
    font-family: var(--font-brand);
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

/* Avatar + name + sign out, right side of the header. */
.app-header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.app-header-user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.app-header-user form { display: contents; }

/* ── Layout ── */

.page-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-header h1 { margin: 0; }

.page-header-status {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    min-height: 1.5rem;
}
.page-header-status .msg { margin: 0; }
.page-header-status:empty { display: none; }

/* Server-config banner (bot token / client id mismatch), above the cards. */
.app-check { margin-bottom: 1rem; }
.app-check .msg { margin: 0; line-height: 1.45; }
.app-check:empty { display: none; }

/* ── Cards ── */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-card);
}

.card-title {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.card-title + .meta { margin-bottom: 0.85rem; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.card-head .card-title { margin-bottom: 0; }
.card-head + .meta { margin-top: 0.25rem; margin-bottom: 0.85rem; }

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.85rem;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem 1rem;
}
.empty-state p { margin-bottom: 0; }

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.15rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--font-body);
    font-weight: 500;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
/* inline-flex above outranks the UA sheet's [hidden] rule. */
.btn[hidden] { display: none; }

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-on-accent);
}
.btn-primary:hover { background: var(--accent-hover); color: var(--text-on-accent); }

.btn-secondary {
    background: rgba(242, 244, 243, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(242, 244, 243, 0.12);
}
.btn-secondary:hover { background: rgba(242, 244, 243, 0.14); color: var(--text-primary); }

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--accent-primary);
}
.btn-outline:hover { background: var(--accent-tint-soft); color: var(--text-primary); }

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1.05rem;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
}

/* ── Avatars ── */

.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid rgba(242, 244, 243, 0.12);
    flex-shrink: 0;
    background: rgba(242, 244, 243, 0.1);
}
.avatar--sm { width: 28px; height: 28px; }

/* ── Status chips ── */

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    background: rgba(242, 244, 243, 0.05);
    border: 1px solid rgba(242, 244, 243, 0.08);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.status-chip-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    flex-shrink: 0;
}
.status-chip--ok .status-chip-dot { background: var(--success-text); }
.status-chip--warn .status-chip-dot { background: var(--warn-text); }
.status-chip--err .status-chip-dot { background: var(--error-text); }
.status-chip--err { color: var(--error-text); }

/* ── Toggle switch (styled checkbox) ── */

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}
.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-switch-track {
    display: inline-flex;
    align-items: center;
    width: 40px;
    height: 22px;
    border-radius: var(--radius-full);
    background: rgba(242, 244, 243, 0.12);
    transition: background 0.18s ease;
    padding: 2px;
}
.toggle-switch-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-primary);
    transition: transform 0.18s ease, background 0.18s ease;
}
.toggle-switch input[type="checkbox"]:checked + .toggle-switch-track {
    background: var(--accent-primary);
}
.toggle-switch input[type="checkbox"]:checked + .toggle-switch-track .toggle-switch-thumb {
    transform: translateX(18px);
    background: var(--text-on-accent);
}
.toggle-switch input[type="checkbox"]:focus-visible + .toggle-switch-track {
    box-shadow: 0 0 0 2px var(--accent-glow);
}
.toggle-switch input[type="checkbox"]:disabled + .toggle-switch-track { opacity: 0.45; }

.toggle-row {
    padding: 0.75rem 0.85rem;
    background: rgba(242, 244, 243, 0.03);
    border: 1px solid rgba(242, 244, 243, 0.08);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0 1rem;
    flex-wrap: wrap;
}
.toggle-row-text { min-width: 0; flex: 1; }
.toggle-row-text strong { display: block; font-size: 0.95rem; font-weight: 600; }
.toggle-row-text .meta { display: block; }
.toggle-row > .msg { flex-basis: 100%; margin-top: 0.6rem; }

.field-hint { margin-top: 0.3rem; font-size: 0.78rem; color: var(--text-muted); }

/* ── Watching card: one row per platform ── */

.watch-channel { color: var(--accent-hover); font-weight: 600; }

.platform-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0.85rem;
    background: rgba(242, 244, 243, 0.03);
    border: 1px solid rgba(242, 244, 243, 0.08);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease;
}
.platform-row + .platform-row { margin-top: 0.75rem; }
.platform-row.is-live { border-color: var(--accent-tint-strong); }
.platform-main { min-width: 0; flex: 1; }
.platform-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.platform-name { font-size: 0.95rem; font-weight: 600; }
.platform-name a { color: var(--text-primary); }
.platform-name a:hover { color: var(--accent-hover); }
.platform-title {
    margin-top: 0.25rem;
    font-weight: 500;
    overflow-wrap: anywhere;
}
.platform-title:empty { display: none; }
.platform-meta { margin-top: 0.15rem; }
.platform-meta:empty { display: none; }
.platform-row .msg { margin-top: 0.5rem; }
.platform-toggle { margin-top: 0.15rem; }

/* The LIVE chip pulses gently so it reads at a glance. */
.platform-row.is-live .status-chip--ok .status-chip-dot {
    animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
    50% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .platform-row.is-live .status-chip--ok .status-chip-dot { animation: none; }
}

/* ── Messages ── */

.msg {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
    font-size: 0.85rem;
}
.msg-ok { background: var(--success-bg); color: var(--success-text); }
.msg-err { background: var(--error-bg); color: var(--error-text); }
.msg-warn { background: var(--warn-bg); color: var(--warn-text); }
.msg:empty { display: none; }

/* ── Meta / secondary text ── */

.meta { color: var(--text-secondary); font-size: 0.85rem; }
.muted { color: var(--text-muted); }

/* ── Ping list ── */

.ping-list {
    list-style: none;
    display: flex;
    flex-direction: column;
}
.ping-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--divider);
}
.ping-item:last-child { border-bottom: none; }
.ping-title {
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}
.ping-title a { color: inherit; }
.ping-title a:hover { color: var(--accent-hover); }
.ping-message {
    grid-column: 1 / -1;
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ping-side {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.ping-item.is-failed .ping-title { color: var(--error-text); }
.ping-error {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    color: var(--error-text);
}

/* Source tag ("download.sh"). */
.tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-xs);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--accent-tint);
    color: var(--accent-hover);
    white-space: nowrap;
}

/* ── Skeleton / loading ── */

.skeleton {
    height: 56px;
    margin-bottom: 0.75rem;
    background: linear-gradient(90deg, rgba(242,244,243,0.04), rgba(242,244,243,0.10), rgba(242,244,243,0.04));
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s linear infinite;
    border-radius: var(--radius-md);
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
}

/* ── Public pages (landing) ── */

.public-page {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.public-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-header);
    border-bottom: 1px solid var(--accent-tint-strong);
}

.public-header-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
}
.public-header-brand:hover { color: var(--text-primary); text-decoration: none; }

.public-header-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    flex-shrink: 0;
}

.public-header-wordmark {
    font-family: var(--font-brand);
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.landing-main {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* The hero sits flush under the header so its gradient starts at the header's
   bottom edge; centering it vertically left a band of plain background above. */
.landing-hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 1.5rem 3rem;
    text-align: center;
    background: linear-gradient(180deg, rgba(90, 36, 18, 0.45) 0%, rgba(30, 32, 25, 0) 60%);
}

.landing-hero-content {
    max-width: 560px;
    margin: 0 auto;
}

.landing-hero-logo {
    margin: 0 auto 1.25rem;
    border-radius: var(--radius-md);
    width: 96px;
    height: 96px;
    object-fit: contain;
}

.landing-hero-title {
    font-family: var(--font-brand);
    font-size: 2.5rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.landing-hero-tagline {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.landing-hero-sub {
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto 1.75rem;
    font-size: 1rem;
}

.landing-hero-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.landing-hero-note {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.public-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 1.5rem 1.5rem 2rem;
    border-top: 1px solid rgba(242, 244, 243, 0.06);
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.public-footer span[aria-hidden="true"] { color: var(--text-muted); user-select: none; }
.public-footer-brand { font-weight: 600; color: var(--text-primary); }

/* ── Responsive ── */

@media (max-width: 600px) {
    .app-header { padding: 0 1rem; }
    .app-header-user-name { display: none; }
    .page-container { padding: 1.25rem; }
    .ping-item { grid-template-columns: 1fr; }
    .ping-side { white-space: normal; }

    .public-header { flex-direction: column; gap: 0.5rem; text-align: center; }
    .landing-hero { padding: 2.5rem 1rem 2rem; }
    .landing-hero-title { font-size: 2rem; }
}
