:root {
  --bg: #f4f5f7; --surface: #ffffff; --border: #dfe2e8; --text: #1b1f27; --muted: #667085;
  --accent: #2f5fe0; --accent-text: #ffffff; --accent-soft: #e8eefc;
  --ok: #18794e; --ok-soft: #e3f5ec; --warn: #9a5b00; --warn-soft: #fdf2dc; --bad: #c0362c; --bad-soft: #fde9e7;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --surface: #1e2127; --border: #343943; --text: #e8eaee; --muted: #9aa3b2;
    --accent: #6f93f5; --accent-text: #0e1220; --accent-soft: #263457;
    --ok: #5fd39a; --ok-soft: #173326; --warn: #f0b34c; --warn-soft: #3a2c10; --bad: #f2867c; --bad-soft: #40201d;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); flex: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
textarea { resize: vertical; min-height: 130px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; }
.error { color: var(--bad); font-size: 14px; margin-top: 8px; }

.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 14px;
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 12px 22px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.link:hover { text-decoration: underline; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 360px; display: grid; gap: 10px;
}
.login-box h1 { font-size: 22px; }
.login-box label { font-weight: 600; margin-top: 8px; }
.login-box .btn { margin-top: 8px; }

.top {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 110px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel.flat { background: none; border: 0; padding: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 14px;
}
.notice { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--muted); }

.row { display: flex; flex-wrap: wrap; gap: 18px 24px; align-items: flex-start; }
.field { display: grid; gap: 6px; min-width: 150px; }
.field.grow { flex: 1; min-width: 220px; }
.field.end { align-self: flex-end; min-width: 0; }
.label { font-weight: 600; font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.label input { font-weight: 400; color: var(--text); }
.panel > .hint { margin: -6px 0 14px; }
fieldset:disabled .segmented, fieldset:disabled .chips { opacity: .6; }
fieldset:disabled button { cursor: not-allowed; }
.inline { display: flex; gap: 8px; }
.inline input { width: auto; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 8px 12px; cursor: pointer; white-space: nowrap; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer; color: var(--muted); }
.chip::before { content: "＋ "; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.active::before { content: "✓ "; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; }
.card header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card header strong { font-size: 16px; }
.card.off .card-body { opacity: .45; }
.card.invalid { border-color: var(--bad); }
.card.done { border-color: var(--ok); }
.card-body { display: grid; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.tag { font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; color: var(--muted); }
.pills { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.pill { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 9px; background: var(--accent-soft); color: var(--accent); }
.meta { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.over { color: var(--warn); font-weight: 600; }

.drop { border: 1.5px dashed var(--border); border-radius: 8px; padding: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge { position: absolute; left: 4px; bottom: 4px; font-size: 11px; background: rgba(0, 0, 0, .7); color: #fff; padding: 0 5px; border-radius: 4px; }
.thumb .remove {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .7); color: #fff; cursor: pointer; line-height: 1; font-size: 16px;
}

.problems:empty { display: none; }
.problems p { font-size: 13px; padding: 6px 10px; border-radius: 6px; margin-top: 4px; }
.problems .block { background: var(--bad-soft); color: var(--bad); }
.problems .warn { background: var(--warn-soft); color: var(--warn); }
.status { font-size: 14px; padding: 8px 10px; border-radius: 6px; display: grid; gap: 6px; overflow-wrap: anywhere; }
.status.working { background: var(--accent-soft); color: var(--accent); }
.status.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.status.failed { background: var(--bad-soft); color: var(--bad); }
.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.fill { height: 100%; background: var(--accent); transition: width .15s; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px 20px; display: flex; justify-content: flex-end; align-items: center; gap: 18px; flex-wrap: wrap; z-index: 5;
}
.summary { color: var(--muted); }

.result { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.result.ok { background: var(--ok-soft); color: var(--ok); }
.result.partial { background: var(--bad-soft); color: var(--bad); }
.result p { font-size: 14px; margin-top: 2px; }

.day { font-size: 14px; color: var(--muted); margin: 18px 0 6px; }
.post-row { display: grid; grid-template-columns: 60px minmax(150px, 210px) 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.post-row .time { font-variant-numeric: tabular-nums; font-weight: 600; }
.post-row .who { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.post-row .snippet { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px; background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.state.PUBLISHED { background: var(--ok-soft); color: var(--ok); }
.state.ERROR { background: var(--bad-soft); color: var(--bad); }
.state.DRAFT { background: var(--bg); color: var(--muted); }
@media (max-width: 640px) {
  .post-row { grid-template-columns: 60px 1fr auto; }
  .post-row .snippet { grid-column: 1 / -1; }
}

.chapter-admin { display: grid; gap: 14px; }
.channel-list { display: grid; gap: 8px; }
.actions { display: flex; gap: 10px; justify-content: space-between; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; max-width: min(90vw, 520px); z-index: 10; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
