/* Look: dark, violet-pink accents, glass top bar (the "Midnight" design). Tokens first, base components, then polish. */
:root {
    color-scheme: dark;
    --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --font-head: var(--font);
    --bg: #0a0c13;
    --surface: #12151f;
    --surface-2: #181c29;
    --input-bg: #0e1119;
    --text: #eceef6;
    --muted: #8e95ab;
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .14);
    --accent: #a78bfa;
    --accent-soft: rgba(167, 139, 250, .14);
    --accent-strong: #c4b5fd;
    --accent-text: #ffffff;
    --btn-primary-bg: linear-gradient(135deg, #7c3aed, #db2777);
    --btn-shadow: 0 6px 20px rgba(124, 58, 237, .35);
    --error: #fb7185;
    --error-soft: rgba(251, 113, 133, .12);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .10);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, .08);
    --radius: 16px;
    --radius-sm: 10px;
    --btn-radius: 10px;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .02), 0 12px 32px rgba(0, 0, 0, .35);
    --shadow-xs: none;
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
    --topbar-bg: rgba(10, 12, 19, .65);
    --topbar-text: #ffffff;
    --topbar-border: rgba(255, 255, 255, .07);
    --nav-text: #a1a8bd;
    --nav-hover-bg: rgba(255, 255, 255, .05);
    --nav-active-bg: rgba(255, 255, 255, .08);
    --nav-active-text: #ffffff;
    --hero-text: linear-gradient(90deg, #c4b5fd, #f0abfc 50%, #fda4af);
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar nav { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.topbar .mainnav { margin-right: auto; }
.topbar button.link { white-space: nowrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; color: var(--text); }
.brand-mark { width: 30px; height: 30px; flex: none; display: block; }
.nav-link { display: inline-flex; align-items: center; gap: 8px; }
.nav-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round; display: none; }

main { max-width: 960px; margin: 0 auto; padding: 32px 16px; }
main.narrow { max-width: 420px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.muted { color: var(--muted); }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.check { display: flex; gap: 8px; font-weight: 400; align-items: flex-start; }
input[type=text], input[type=email], input[type=password] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.field-error { color: var(--error); font-size: 0.9rem; margin: 4px 0 0; }

.button, button {
    display: inline-block;
    padding: 10px 18px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.button.small { padding: 6px 12px; }
.wide { width: 100%; text-align: center; margin-top: 16px; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; }
form.inline { display: inline; }

.divider { text-align: center; color: var(--muted); margin: 16px 0 0; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--border); }
.alert.error { color: var(--error); }
.alert.success { color: var(--success); }
.alert.warning { background: var(--warning-bg); }

.limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.limit { border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.limit strong { display: block; font-size: 1.4rem; }

.hero { text-align: center; padding: 48px 0; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 560px; margin: 0 auto 24px; }

.footer { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; align-items: center; padding: 24px 16px; color: var(--muted); font-size: 0.9rem; }
.footer .made-by { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; }
.footer .made-by:hover { color: var(--text); }

table.list { width: 100%; border-collapse: collapse; }
table.list td { padding: 12px 8px; border-top: 1px solid var(--border); vertical-align: top; }
table.list tr:first-child td { border-top: 0; }
td.actions { text-align: right; white-space: nowrap; }
.small { font-size: 0.85rem; }
.status { font-size: 0.85rem; font-weight: 600; }
.status.ok { color: var(--success); }
.status.bad { color: var(--error); }
.platforms { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.platforms { align-items: flex-start; }
.platforms summary { list-style: none; cursor: pointer; }
.platforms summary::-webkit-details-marker { display: none; }
.secondary-button { background: transparent; color: var(--text); border: 1px solid var(--border); }

/* Posts: calendar, post page, composer */
main.wide-main { max-width: 1280px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.week-nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.week-nav a { text-decoration: none; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 900px) { .week { grid-template-columns: 1fr; } }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.day.today { border-color: var(--accent); }
.day h2 { font-size: 0.95rem; margin: 0 0 8px; }
.post-card { display: block; border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 8px; color: var(--text); text-decoration: none; font-size: 0.9rem; }
.post-card:hover { border-color: var(--accent); }
.post-card p { margin: 4px 0; overflow-wrap: anywhere; }
.post-card-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.thumb { width: 100%; max-height: 120px; object-fit: cover; border-radius: 6px; margin-top: 4px; }
ul.targets { list-style: none; padding: 0; margin: 4px 0 0; }
ul.targets li { display: flex; justify-content: space-between; gap: 4px; font-size: 0.8rem; margin-top: 2px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--bg); border: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.chip.s-published { color: var(--success); border-color: var(--success); }
.chip.s-failed, .chip.s-at_risk, .chip.s-partial { color: var(--error); border-color: var(--error); }
.chip.s-cancelled, .chip.s-skipped { color: var(--muted); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.error-text { color: var(--error); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.media-grid img, .media-grid video { width: 100%; border-radius: 6px; }
ul.events { list-style: none; padding: 0; margin: 0; }
ul.events li { padding: 6px 0; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
ul.events li:first-child { border-top: 0; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.row-form label { margin: 0; }
input[type=url], input[type=datetime-local], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text); font: inherit;
}
.row-form input[type=datetime-local] { width: auto; }
.channel-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.channel-pick { display: flex; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin: 0; font-weight: 400; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar.placeholder { display: inline-flex; align-items: center; justify-content: center; background: var(--border); font-weight: 700; }
.uploads { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.upload { position: relative; }
.upload img, .upload video { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; display: block; }
.upload .remove { position: absolute; top: 4px; right: 4px; padding: 0 8px; border-radius: 50%; }
.counters { margin-top: 4px; }
ul.checks { list-style: none; padding: 0; margin: 8px 0 0; }
.tiktok-account { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.indent { margin-left: 24px; }
.submit-row { display: flex; justify-content: flex-end; margin-bottom: 32px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Public pages */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.features .card { margin: 0; }
.features p { margin: 0; color: var(--muted); }
.legal { max-width: 720px; margin: 0 auto; }
.legal h2 { margin-top: 24px; }
.legal li { margin-bottom: 4px; }
.danger-button { background: var(--error); }

/* Back office */
.table-scroll { overflow-x: auto; }
.search-form input[type=search] { width: auto; flex: 1 1 240px; }
input[type=search] { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text); }

/* Platform logos */
.pl-logo { width: 20px; height: 20px; flex: none; vertical-align: middle; border-radius: 5px; }
.avatar-wrap { position: relative; display: inline-flex; flex: none; }
.pl-badge { position: absolute; right: -4px; bottom: -4px; width: 16px; height: 16px; border-radius: 4px;
    box-shadow: 0 0 0 2px var(--surface); background: var(--surface); }
.channel-cell { display: flex; gap: 12px; align-items: center; }
.channel-title { display: flex; align-items: center; gap: 8px; }
.platform-button { display: inline-flex; align-items: center; gap: 8px; }
.platform-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.platform-list li { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.platform-list .pl-logo { width: 28px; height: 28px; border-radius: 7px; }
.target-name { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.target-name .pl-logo { width: 14px; height: 14px; border-radius: 3px; }
.target-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-platform { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }

/* ============================================================================================== */
/* Polish: menus, buttons, fields, badges, calendar                                               */
/* ============================================================================================== */
/* ============================================================================================== */
:root body {
    font-family: var(--font);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
:root h1,
:root h2 { font-family: var(--font-head); letter-spacing: -0.015em; }
:root h1 { font-size: 1.75rem; font-weight: 700; }
:root h2 { font-size: 1.05rem; font-weight: 650; }
:root a { color: var(--accent); text-underline-offset: 3px; }
:root main { padding-top: 32px; }

/* Top bar & menus */
:root .topbar {
    position: sticky; top: 0; z-index: 50;
    padding: 10px 24px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    color: var(--topbar-text);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    gap: 8px 24px;
}
:root .brand { color: var(--topbar-text); font-size: 1.02rem; letter-spacing: -0.01em; }
:root .topbar nav { gap: 2px; }
:root .nav-icon { display: inline-block; }
:root .nav-link,
:root button.link.nav-link {
    color: var(--nav-text);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 550;
    font-size: .93rem;
    transition: background-color .15s, color .15s;
}
:root .nav-link:hover { background: var(--nav-hover-bg); color: var(--topbar-text); }
:root .nav-link.active { background: var(--nav-active-bg); color: var(--nav-active-text); }
:root .usernav .button.small { margin-left: 6px; }

/* Cards, tables, limits */
:root .card {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 24px;
}
:root table.list td { border-top-color: var(--border); padding: 14px 10px; vertical-align: middle; }
:root table.list tr { transition: background-color .12s; }
:root table.list tr:hover td { background: var(--surface-2); }
:root table.list tr td:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
:root table.list tr td:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
:root .limit {
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 16px;
}
:root .limit strong { font-size: 1.6rem; letter-spacing: -0.02em; font-family: var(--font-head); color: var(--text); }
:root .page-head { margin-bottom: 8px; }
:root .page-head h1 { margin-bottom: 16px; }

/* Buttons */
:root .button,
:root button {
    border-radius: var(--btn-radius);
    background: var(--btn-primary-bg);
    color: var(--accent-text);
    box-shadow: var(--btn-shadow);
    padding: 10px 18px;
    font-size: .93rem;
    font-weight: 600;
    line-height: 1.3;
    transition: filter .15s, transform .15s, box-shadow .15s, background-color .15s;
}
:root .button:hover,
:root button:hover { filter: brightness(1.08); }
:root .button:active,
:root button:active { transform: translateY(1px); }
:root .button.small,
:root button.small { padding: 7px 14px; font-size: .88rem; }
:root .button.secondary,
:root .secondary-button {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-xs);
}
:root .button.secondary:hover,
:root .secondary-button:hover { filter: none; background: var(--surface-2); border-color: var(--accent); }
:root button.link {
    background: none; box-shadow: none; color: var(--accent); padding: 0; font-weight: 500; filter: none;
}
:root button.link:hover { text-decoration: underline; }
:root .danger-button { background: var(--error); box-shadow: none; }
:root .upload .remove { padding: 2px 8px; border-radius: 999px; box-shadow: var(--shadow-lg); }

/* Form fields */
:root label { font-size: .9rem; font-weight: 600; }
:root input[type=text],
:root input[type=email],
:root input[type=password],
:root input[type=url],
:root input[type=search],
:root input[type=datetime-local],
:root select,
:root textarea {
    background: var(--input-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: border-color .15s, box-shadow .15s;
}
:root input:focus,
:root select:focus,
:root textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
:root :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:root input[type=checkbox],
:root input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }

/* Alerts and status badges */
:root .alert {
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
:root .alert.error { background: var(--error-soft); border-color: var(--error); color: var(--error); }
:root .alert.success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
:root .alert.warning { background: var(--warning-bg); border-color: var(--warning); color: var(--text); }
:root .chip {
    border: 0;
    padding: 2px 9px;
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .01em;
    background: var(--accent-soft);
    color: var(--accent-strong);
}
:root .chip::before {
    content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; margin-right: 5px; vertical-align: 1px;
}
:root .chip.s-published { background: var(--success-soft); color: var(--success); }
:root .chip.s-failed,
:root .chip.s-at_risk,
:root .chip.s-partial { background: var(--error-soft); color: var(--error); }
:root .chip.s-cancelled,
:root .chip.s-skipped { background: var(--surface-2); color: var(--muted); }
:root .status.ok::before,
:root .status.bad::before {
    content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px;
}

/* Calendar and posts */
:root .week-nav a:not(.muted) {
    display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
:root .week-nav a:not(.muted):hover { border-color: var(--accent); color: var(--accent); }
:root .day { border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; min-height: 160px; }
:root .day h2 {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: var(--font);
}
:root .day.today { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
:root .day.today h2 { color: var(--accent); }
:root .post-card {
    background: var(--surface-2); border-color: var(--border); border-radius: var(--radius-sm); padding: 10px;
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
:root .post-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
:root .channel-pick {
    border-radius: var(--radius-sm); padding: 10px 12px; border-color: var(--border-strong);
    transition: border-color .15s, background-color .15s;
}
:root .channel-pick:hover { border-color: var(--accent); }
:root .channel-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
:root .avatar.placeholder { background: var(--accent-soft); color: var(--accent-strong); }

/* Public pages */
:root .hero { padding: 72px 0 56px; }
:root .hero h1 {
    font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.1; letter-spacing: -0.03em; margin-bottom: 20px;
    background: var(--hero-text); -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root .hero .button { padding: 14px 26px; font-size: 1rem; }
:root .features .card h2 { font-size: 1.05rem; }
:root main.narrow .card { padding: 32px; }
:root .footer a { color: var(--muted); text-decoration: none; }
:root .footer a:hover { color: var(--text); }

/* Glow, glass cards, gradient accents */
:root body {
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(124, 58, 237, .20), transparent 60%),
        radial-gradient(800px 500px at 100% 0%, rgba(219, 39, 119, .12), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}
:root .card,
:root .day { background: rgba(18, 21, 31, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
:root .nav-link.active { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
:root .limit strong {
    background: linear-gradient(90deg, #c4b5fd, #f0abfc); -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root .button.secondary,
:root .secondary-button { background: rgba(255, 255, 255, .04); }
input[type=file] { color: var(--muted); font: inherit; font-size: .9rem; }
input[type=file]::file-selector-button {
    margin-right: 12px; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); }
