:root {
  --bg: #f5f5f9;
  --panel: #ffffff;
  --panel-2: #efeff5;
  --text: #1b1a23;
  --muted: #6a6977;
  --line: #e3e2ec;
  --accent: #6355f5;
  --accent-hover: #5346e0;
  --accent-ink: #ffffff;
  --accent-soft: #ecebff;
  --ok: #10784f;
  --ok-soft: #dcf4ea;
  --warn: #8f5f00;
  --warn-soft: #fff1c9;
  --bad: #c12b27;
  --bad-soft: #fde7e6;
  --yt: #e0002b;
  --discord: #5865f2;
  --bsky: #1185fe;
  --x: #14171a;
  --tiktok: #fe2c55;
  --instagram: #d62976;
  --hook: #0f9a94;
  --shadow: 0 1px 2px rgb(20 18 40 / .06), 0 4px 16px rgb(20 18 40 / .05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131218;
    --panel: #1c1b24;
    --panel-2: #262532;
    --text: #efeef6;
    --muted: #9c9bad;
    --line: #2f2e3c;
    --accent: #8b80ff;
    --accent-hover: #a097ff;
    --accent-ink: #14121f;
    --accent-soft: #2a2745;
    --ok: #58d3a3;
    --ok-soft: #12332a;
    --warn: #f0c060;
    --warn-soft: #3a2f10;
    --bad: #ff8a85;
    --bad-soft: #3d1a19;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 4px 16px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 550; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--panel-2); }
.btn:focus-visible, .chip:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 4px 9px; font-size: 13px; border-radius: 7px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

input[type=text], input[type=password], input[type=number], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); min-width: 0;
}
textarea { resize: vertical; min-height: 96px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
label.field .hint { font-weight: 400; color: var(--muted); }
label.field > .hint { font-size: 12.5px; }
.counter { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: auto; }
.counter.over { color: var(--bad); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 18px 14px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; padding: 0 6px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.brand .logo svg { width: 18px; height: 18px; stroke: var(--accent-ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--text); text-decoration: none; font-weight: 550;
}
.nav a svg, .btn svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--panel-2); }
.nav a[aria-current=page] { background: var(--accent-soft); color: var(--accent); }
.nav .count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.side h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 8px 6px; }
.ch-list { display: flex; flex-direction: column; gap: 2px; }
.ch-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 9px;
  border: 0; background: none; cursor: pointer; text-align: left; width: 100%;
}
.ch-item:hover { background: var(--panel-2); }
.ch-item[aria-pressed=true] { background: var(--accent-soft); }
.ch-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.ch-item.paused .name { color: var(--muted); text-decoration: line-through; }

.main { padding: 26px 32px 80px; min-width: 0; }
.page { max-width: 940px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { flex: 1; }

/* ---------- avatars, badges ---------- */
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 12px; font-weight: 750; color: #fff; background: var(--hook); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.youtube { background: var(--yt); }
.avatar.discord { background: var(--discord); }
.avatar.bluesky { background: var(--bsky); }
.avatar.x { background: var(--x); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .25); }
.avatar.tiktok { background: var(--tiktok); }
.avatar.instagram { background: linear-gradient(135deg, #feda75, #d62976 55%, #4f5bd5); }
.avatar.webhook { background: var(--hook); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 650; background: var(--panel-2); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- cards / lists ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.day { margin-bottom: 26px; }
.day > h2 { margin: 0 0 10px 2px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.day > h2 b { color: var(--text); }
.items { display: flex; flex-direction: column; gap: 10px; }
.post { display: flex; gap: 14px; padding: 12px; align-items: flex-start; }
.post .when { width: 74px; flex: none; padding-top: 2px; font-weight: 650; font-variant-numeric: tabular-nums; }
.post .when small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.thumb {
  width: 54px; height: 96px; border-radius: 8px; background: var(--panel-2); flex: none;
  object-fit: cover; display: block; border: 1px solid var(--line);
}
.thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.post .content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.post .title { font-weight: 650; overflow-wrap: anywhere; }
.post .excerpt { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.post .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.post .actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.post .actions .row { gap: 2px; }
.slot {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1.5px dashed var(--line);
  border-radius: var(--radius); background: transparent; width: 100%; cursor: pointer; text-align: left; color: var(--muted);
}
.slot:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.slot .when { width: 74px; flex: none; font-weight: 650; font-variant-numeric: tabular-nums; }
.notice { padding: 9px 12px; border-radius: 9px; font-size: 13.5px; overflow-wrap: anywhere; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 6px; font-size: 18px; }
.empty-state .btn { margin-top: 16px; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.cal .dow { padding: 8px 10px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--panel-2); }
.cal .cell { min-height: 108px; padding: 6px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; cursor: pointer; background: var(--panel); }
.cal .cell:nth-child(7n+8) { border-left: 0; }
.cal .cell:hover { background: var(--accent-soft); }
.cal .cell.out { background: var(--bg); }
.cal .cell.past .num { opacity: .5; }
.cal .num { font-size: 12px; font-weight: 650; color: var(--muted); }
.cal .cell.today .num { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 7px; align-self: flex-start; }
.cal .pill {
  display: flex; gap: 5px; align-items: center; padding: 2px 6px; border-radius: 6px; font-size: 12px;
  background: var(--panel-2); border: 0; cursor: pointer; text-align: left; width: 100%; overflow: hidden;
  border-left: 3px solid var(--hook);
}
.cal .pill.youtube { border-left-color: var(--yt); }
.cal .pill.discord { border-left-color: var(--discord); }
.cal .pill.bluesky { border-left-color: var(--bsky); }
.cal .pill.x { border-left-color: var(--text); }
.cal .pill.tiktok { border-left-color: var(--tiktok); }
.cal .pill.instagram { border-left-color: var(--instagram); }
.cal .pill.published { opacity: .65; }
.cal .pill.failed { background: var(--bad-soft); }
.cal .pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .more { font-size: 11.5px; color: var(--muted); padding-left: 4px; }

/* ---------- media grid ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-tile { padding: 8px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; text-align: left; }
.media-tile .thumb { width: 100%; height: auto; aspect-ratio: 9/16; }
.media-tile .fn { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-tile[aria-pressed=true] { outline: 2px solid var(--accent); }
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center;
  color: var(--muted); margin-bottom: 18px; background: var(--panel);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s; }

/* ---------- settings ---------- */
.section { padding: 18px; margin-bottom: 18px; }
.section > h2 { margin-bottom: 4px; }
.section > .muted { margin-bottom: 14px; }
.chan-row { padding: 14px; border-top: 1px solid var(--line); }
.chan-row:first-of-type { border-top: 0; }
.slot-grid { display: grid; grid-template-columns: 56px 1fr; gap: 6px 10px; align-items: center; margin-top: 12px; }
.slot-grid .dname { font-weight: 650; font-size: 13px; color: var(--muted); }
.time-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 13px; font-variant-numeric: tabular-nums; }
.time-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; padding: 0 5px; line-height: 1; }
.time-add { width: 92px !important; padding: 3px 6px !important; font-size: 13px; }
details.platform { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
details.platform summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
details.platform summary::-webkit-details-marker { display: none; }
details.platform summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
details.platform[open] summary::after { content: '▴'; }
.steps { margin: 4px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.panel { padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
details.help { margin-top: 12px; font-size: 14px; }
details.help summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.help ol { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }

/* ---------- dialogs ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--panel); color: var(--text);
  width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 80px rgb(0 0 0 / .35);
}
body:has(dialog[open]) { overflow: hidden; }
dialog::backdrop { background: rgb(10 8 24 / .5); backdrop-filter: blur(2px); }
dialog[open] { display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 10px; }
.dlg-head h2 { flex: 1; font-size: 17px; }
.dlg-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dlg-foot { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 99px;
  border: 1.5px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; font-size: 14px;
}
.chip[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); }
.chip[disabled] { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--panel-2); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 13px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed=true] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.picked { display: flex; gap: 12px; align-items: center; }
.picked .thumb { width: 44px; height: 78px; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; padding: 2px; }
.picker .media-tile { padding: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.code-box { font-size: 30px; font-weight: 750; letter-spacing: .12em; text-align: center; padding: 16px; border-radius: 12px; background: var(--panel-2); user-select: all; }
.video-preview { width: 100%; max-height: 60vh; border-radius: 10px; background: #000; }

/* ---------- login & toasts ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login .brand { padding: 0 0 18px; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(440px, calc(100vw - 24px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 550; overflow-wrap: anywhere; }
.toast.bad { background: var(--bad); color: #fff; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: column; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { flex: none; }
  .ch-list { flex-direction: row; overflow-x: auto; }
  .ch-item { width: auto; flex: none; }
  .side .side-channels h3 { display: none; }
  .side > .btn.primary { display: none; }
  .main { padding: 18px 14px 70px; }
  .post { flex-wrap: wrap; }
  .post .when { width: auto; }
  .post .actions { flex-direction: row; width: 100%; justify-content: flex-end; }
  .cal .cell { min-height: 76px; padding: 4px; }
  .cal .pill span { display: none; }
  .cal .pill { padding: 2px 4px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 2s !important; } }
