:root {
  --bg: #f6f1e8; --panel: #fffdf8; --ink: #2b2620; --muted: #7a6f62; --line: #e4dccd;
  --olive: #6b7247; --olive-soft: #e9ebdc; --terra: #b5643f; --terra-soft: #f6e3d9;
  --gold: #b8954a; --gold-soft: #f4ead2; --blue-soft: #e3e9ef; --blue: #4a6a85;
  --radius: 10px; --serif: 'Cormorant Garamond', Georgia, serif; --sans: 'DM Sans', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a16; --panel: #26221d; --ink: #efe8dc; --muted: #a89c8c; --line: #3a342c;
    --olive: #a9b07f; --olive-soft: #33362a; --terra: #e0906b; --terra-soft: #3f2a20;
    --gold: #d8b66c; --gold-soft: #3a3222; --blue-soft: #263039; --blue: #93b2cc;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0 0 .4em; }
h1 { font-size: 2rem; } h2 { font-size: 1.6rem; } h3 { font-size: 1.25rem; }
.muted { color: var(--muted); }
.err { color: var(--terra); }
.small { font-size: .85em; }

.btn { font: 500 14px var(--sans); border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--olive); border-color: var(--olive); color: #fff; }
.btn.danger { color: var(--terra); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

input, textarea, select { font: 14px var(--sans); color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
label > input, label > textarea, label > select { margin-top: 4px; color: var(--ink); }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }
.check input { width: auto; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.login .card { width: min(360px, 100%); }
.login .btn { margin-top: 14px; width: 100%; }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center; padding: 10px 20px;
  background: var(--bg); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font: 600 1.5rem var(--serif); text-decoration: none; }
.brand em { color: var(--olive); }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a { text-decoration: none; padding: 6px 10px; border-radius: 999px; color: var(--muted); }
nav a.on { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
main { padding: 20px; max-width: 1300px; margin: 0 auto; }

.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.bar .grow { flex: 1; }

/* calendar */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 220px; padding: 8px; }
.day.today { border-color: var(--olive); }
.day h4 { margin: 0 0 6px; font: 600 13px var(--sans); color: var(--muted); display: flex; justify-content: space-between; }
.day h4 button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month .day { min-height: 110px; }
.month .day.other { opacity: .45; }
.item { display: block; width: 100%; text-align: left; border: 1px solid var(--line); border-left: 4px solid var(--muted);
  border-radius: 6px; background: var(--bg); padding: 5px 7px; margin-bottom: 5px; cursor: pointer; font: 12px/1.35 var(--sans); color: var(--ink); }
.item b { font-weight: 600; }
.item .plats { color: var(--muted); }
.s-draft { border-left-color: var(--muted); }
.s-approved { border-left-color: var(--blue); }
.s-publishing { border-left-color: var(--gold); }
.s-posted { border-left-color: var(--olive); }
.s-partial, .s-failed { border-left-color: var(--terra); }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--line); }
.chip.draft { background: var(--line); }
.chip.approved, .chip.pending { background: var(--blue-soft); color: var(--blue); }
.chip.publishing, .chip.processing { background: var(--gold-soft); color: var(--gold); }
.chip.posted { background: var(--olive-soft); color: var(--olive); }
.chip.partial, .chip.failed { background: var(--terra-soft); color: var(--terra); }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }

/* media */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile { position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--panel); cursor: pointer; }
.tile video, .tile img { width: 100%; aspect-ratio: 9/16; object-fit: cover; display: block; background: #000; }
.tile .cap { font-size: 11px; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.sel { border-color: var(--olive); }
.tile .num { position: absolute; top: 6px; left: 6px; background: var(--olive); color: #fff; border-radius: 999px; width: 22px; height: 22px;
  display: grid; place-items: center; font-size: 12px; font-weight: 600; }

/* channels */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cards .card h3 { display: flex; justify-content: space-between; align-items: center; }

/* composer */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  background: var(--bg); color: var(--ink); }
dialog::backdrop { background: rgba(20, 16, 12, .5); }
.cmp { display: grid; grid-template-columns: 1fr 340px; min-height: 70vh; }
.cmp-main { padding: 20px; overflow: auto; max-height: calc(100vh - 100px); }
.cmp-side { padding: 20px; border-left: 1px solid var(--line); background: var(--panel); overflow: auto; max-height: calc(100vh - 100px); }
.cmp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tabs { display: flex; gap: 6px; margin: 16px 0 4px; flex-wrap: wrap; }
.tab { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 14px; }
.tab.on { border-color: var(--olive); box-shadow: inset 0 0 0 1px var(--olive); }
.tab input { width: auto; margin: 0; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.ai { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--olive-soft); color: var(--olive); }
.count { float: right; font-size: 12px; color: var(--muted); }
.count.over { color: var(--terra); font-weight: 600; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.picked { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.picked .tile { width: 80px; cursor: default; }
.picked .tile .x { position: absolute; top: 4px; right: 4px; border: 0; background: rgba(0,0,0,.6); color: #fff; border-radius: 999px; width: 22px; height: 22px; cursor: pointer; }
.rules ul { margin: 6px 0 12px; padding-left: 18px; }
.rules li { margin-bottom: 4px; font-size: 13px; }
.rules .e li { color: var(--terra); }
.rules .w li { color: var(--gold); }
.rules .ok { color: var(--olive); font-size: 14px; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.targets li { font-size: 13px; margin-bottom: 6px; list-style: none; }
.targets { padding: 0; }
.notice { font-size: 13px; background: var(--gold-soft); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; z-index: 50; max-width: calc(100vw - 32px); }

@media (max-width: 860px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .cmp { grid-template-columns: 1fr; }
  .cmp-side { border-left: 0; border-top: 1px solid var(--line); }
  .row { grid-template-columns: 1fr; }
  main { padding: 16px; }
  .top { padding: 10px 16px; }
}
