:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #efebe6;
  --text: #1d1a1f;
  --muted: #6d6670;
  --border: #ddd6cf;
  --accent: #b3261e;
  --accent-text: #ffffff;
  --ok: #2e7d4f;
  --warn: #a86400;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141216;
    --surface: #1e1b21;
    --surface-2: #29252d;
    --text: #efeaf0;
    --muted: #a59ca8;
    --border: #39333e;
    --accent: #e5534b;
    --ok: #5cc28a;
    --warn: #e0a447;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--accent); }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: .5em .65em; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
textarea { resize: vertical; min-height: 5em; }
label { display: grid; gap: .3em; font-size: .9rem; color: var(--muted); }
label > :is(input, select, textarea) { color: var(--text); }

.btn { display: inline-flex; align-items: center; gap: .4em; padding: .5em 1em; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--accent); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.small { padding: .25em .6em; font-size: .85rem; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 1em; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 1.05rem; padding: 0 10px 18px; line-height: 1.25; }
.brand strong { color: var(--accent); font-size: 1.35rem; }
.sidebar a { padding: .5em .7em; border-radius: 8px; text-decoration: none; color: var(--muted); }
.sidebar a:hover { background: var(--surface-2); color: var(--text); }
.sidebar a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.logout { margin-top: auto; justify-content: flex-start; color: var(--muted); }
.view { padding: 28px clamp(16px, 4vw, 40px); max-width: 1200px; width: 100%; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat .value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin: 0; margin-right: auto; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: .55em 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; padding: .1em .55em; border-radius: 99px; font-size: .78rem; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.scheduled { background: color-mix(in srgb, #2e86ab 18%, transparent); color: #2e86ab; }
.badge.ready { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.published { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.failed { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge.publishing { background: color-mix(in srgb, #8a2be2 18%, transparent); color: #8a2be2; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

.alert { border-left: 4px solid var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.post-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; padding: 12px; }
.post-card:hover { border-color: var(--muted); }
.thumb { aspect-ratio: 1; background: var(--surface-2); border-radius: 8px; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: .85rem; text-align: center; padding: 8px; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar .dow { font-size: .8rem; color: var(--muted); text-align: center; }
.day { min-height: 110px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.day.out { opacity: .45; }
.day.today { border-color: var(--accent); }
.day .num { font-size: .8rem; color: var(--muted); }
.chip { display: block; font-size: .78rem; padding: 2px 6px; border-radius: 6px; text-decoration: none; background: var(--surface-2); border-left: 3px solid var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.editor { display: grid; gap: 16px; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); align-items: start; }
.fields { display: grid; gap: 12px; }
.fields .two { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.slide { display: grid; gap: 6px; padding: 10px; border: 1px dashed var(--border); border-radius: 8px; }
.media-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.media-item { position: relative; }
.media-item .btn { position: absolute; top: 4px; right: 4px; padding: 0 .45em; }
.counter { font-size: .78rem; color: var(--muted); text-align: right; }

.tasks-phase h3 { font-size: .95rem; color: var(--muted); margin-top: 1em; }
.task-done .grow { text-decoration: line-through; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: .45em .3em; border-bottom: 1px solid var(--border); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .7em 1.2em; border-radius: 8px; max-width: calc(100% - 32px); z-index: 10; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 16px; }
  .brand { width: 100%; padding: 0 0 8px; }
  .brand br { display: none; }
  .logout { margin-top: 0; }
  .editor { grid-template-columns: 1fr; }
  .fields .two { grid-template-columns: 1fr; }
  .day { min-height: 70px; }
  .chip { font-size: .7rem; }
  .view { padding: 20px 16px; }
}
