:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e3e1dc;
  --accent: #c98a00;
  --accent-ink: #1d1d1f;
  --accent-bg: #fff4d6;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --ok: #1e8e3e;
  --ok-bg: #e6f4ea;
  --gap-bg: #fff8e6;
  --today: #fff1c2;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);

  --bar: #9a6700;
  --s-idea: #9a9aa0;
  --s-scripting: #8e5cd9;
  --s-shooting: #2d7ff9;
  --s-editing: #e8a317;
  --s-ready: #14a3a3;
  --s-published: #1e8e3e;
  --s-cancelled: #c0392b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618; --panel: #1f1f22; --ink: #ececee; --muted: #a0a0a8; --line: #333338;
    --accent: #f5b700; --accent-bg: #3a2f10; --danger: #ff6b5e; --danger-bg: #3d1d1a;
    --ok: #4cc26f; --ok-bg: #173323; --gap-bg: #2b2516; --today: #3a3214; --bar: #b88600;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs a {
  text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap;
}
.tabs a:hover { background: var(--bg); color: var(--ink); }
.tabs a.active { background: var(--accent-bg); color: var(--ink); font-weight: 600; }
.count { background: var(--accent); color: #1d1d1f; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; margin-left: 4px; }
.me { color: var(--muted); white-space: nowrap; }

main { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1d1d1f; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.on { background: var(--accent-bg); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; }
input[type=text], input[type=password], input[type=date], input[type=url], input:not([type]), select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 10px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.checks { display: flex; gap: 10px; flex-wrap: wrap; }
.checks label { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; color: var(--ink); font-size: 13px; margin: 0; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar h2 { margin: 0 12px 0 0; font-size: 18px; }
.toolbar .spacer { flex: 1; }
.toolbar select { width: auto; }
.below-cal { margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }

/* ---------- auth ---------- */
.auth { max-width: 380px; margin: 10vh auto; }
.auth h1 { font-size: 22px; margin: 0 0 4px; }
.auth .switch { margin-top: 12px; }

/* ---------- calendar ---------- */
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; background: var(--c); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.day {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  min-height: 130px; padding: 6px; display: flex; flex-direction: column; gap: 5px;
}
.day.past { opacity: .82; }
.day.today { border-color: var(--accent); background: var(--today); }
.day.gap { background: var(--gap-bg); border-style: dashed; border-color: var(--accent); }
.day.offday { background: transparent; }
.day-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.day-head b { color: var(--ink); }
.day-head .add { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 4px; }
.day-head .add:hover { background: var(--bg); color: var(--ink); }
.gap-note { font-size: 11px; color: var(--accent); font-weight: 600; }
.dname { display: none; }

.card {
  border: 1px solid var(--line); border-left: 4px solid var(--c, var(--s-idea));
  border-radius: 8px; padding: 5px 7px; background: var(--panel); cursor: pointer; font-size: 12.5px;
  text-align: left; width: 100%;
}
.card:hover { border-color: var(--muted); border-left-color: var(--c); }
.card .t { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.card .meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 3px 6px; align-items: center; }
.card.unplanned { border-style: dashed; border-left-style: solid; }
.tag { font-size: 10.5px; padding: 0 5px; border-radius: 4px; background: var(--bg); color: var(--muted); font-weight: 600; white-space: nowrap; }
.tag.out { background: var(--ok-bg); color: var(--ok); }
.tag.late { background: var(--danger-bg); color: var(--danger); }
.tag.high { background: var(--danger-bg); color: var(--danger); }
.tag.low { opacity: .8; }
.plat { font-size: 10px; font-weight: 700; border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; color: var(--muted); }
.plat.done { background: var(--ok); border-color: var(--ok); color: #fff; }

.s-idea { --c: var(--s-idea); } .s-scripting { --c: var(--s-scripting); } .s-shooting { --c: var(--s-shooting); }
.s-editing { --c: var(--s-editing); } .s-ready { --c: var(--s-ready); } .s-published { --c: var(--s-published); }
.s-cancelled { --c: var(--s-cancelled); }

.backlog { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
details summary { cursor: pointer; color: var(--muted); margin-top: 10px; }

/* ---------- performance panel ---------- */
.perf-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.perf h3 { margin-bottom: 4px; color: var(--muted); font-weight: 600; }
.hero { font-size: 34px; font-weight: 700; line-height: 1.1; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.hero-sub { font-size: 13px; font-weight: 400; color: var(--muted); }
.chg { font-size: 13px; font-weight: 600; white-space: nowrap; }
.chg.up { color: var(--ok); } .chg.down { color: var(--danger); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 14px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tile-name { font-size: 12px; font-weight: 600; color: var(--muted); }
.tile-num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 46px; margin-top: 8px; border-bottom: 1px solid var(--line); }
.bar-hit { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bar { width: 100%; background: var(--bar); border-radius: 4px 4px 0 0; }
.bar-hit:hover .bar { opacity: .75; }
.bar.nodata { height: 2px; background: var(--line); border-radius: 0; }
.tip { position: absolute; z-index: 50; background: var(--ink); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 6px; pointer-events: none; white-space: nowrap; }
.top-head { display: flex; align-items: baseline; gap: 10px; margin-top: 16px; }
.top-head h4 { margin: 0; font-size: 14px; }
.top-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 18px; margin-top: 8px; }
.top-list { margin: 4px 0 0; padding-left: 20px; font-size: 13px; }
.top-list li { padding: 3px 0; border-bottom: 1px solid var(--line); }
.top-list li:last-child { border-bottom: 0; }
.top-title { display: block; overflow-wrap: anywhere; }
.top-title a { text-decoration: none; } .top-title a:hover { text-decoration: underline; }
.top-val { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(620px, calc(100vw - 24px));
  background: var(--panel); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 16px; }
.dlg-body { padding: 16px 18px; max-height: 70vh; overflow: auto; }
.dlg-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.dlg-foot .spacer { flex: 1; }
.releases { list-style: none; padding: 0; margin: 0 0 10px; }
.releases li { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.releases li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; }
.x:hover { color: var(--danger); }

/* ---------- feed ---------- */
.feed { display: flex; flex-direction: column; gap: 10px; max-width: 860px; }
.report { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.report.open.t-suggestion, .report.open.t-flag { border-left: 4px solid var(--accent); }
.report.p-high, .report.open.p-high { border-left: 4px solid var(--danger); }
.report-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.report-head .bot { font-weight: 700; color: var(--ink); }
.report h4 { margin: 6px 0 4px; font-size: 15px; }
.report .body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0; }
.report .links { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.report .vid { font-size: 12.5px; color: var(--muted); }
.report .vid button { font-size: 12.5px; }
.proposal { background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }
.proposal div { overflow-wrap: anywhere; }
.report-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.report-foot .spacer { flex: 1; }
.comments { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.comments div { margin-top: 2px; }
.note-row { display: flex; gap: 6px; margin-top: 6px; }

/* ---------- bots page ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.keybox { background: var(--accent-bg); border: 1px solid var(--accent); border-radius: 8px; padding: 10px; margin: 10px 0; }
.keybox code { font-size: 13px; overflow-wrap: anywhere; }
.score-good { color: var(--ok); font-weight: 600; }
.score-bad { color: var(--danger); font-weight: 600; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 8px;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 100;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); color: #fff; }

/* ---------- small screens: calendar becomes a day list ---------- */
@media (max-width: 860px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .tabs { order: 3; flex-basis: 100%; }
  main { padding: 16px; }
  .cal { grid-template-columns: 1fr; }
  .cal .dow { display: none; }
  .day { min-height: 0; }
  .day.offday:not(:has(.card)) { display: none; }
  .dname { display: inline; }
}
