:root {
  --bg: #faf8f5; --surface: #ffffff; --ink: #1d1b1a; --muted: #6f6a66; --line: #e8e3dd;
  --accent: #e2725b; --accent-ink: #ffffff; --accent-soft: #fbe9e4; --danger: #c0392b;
  --ok: #2e7d5b; --warn: #b7791f; --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151413; --surface: #1f1d1c; --ink: #f2eee9; --muted: #a39d97; --line: #34302d;
    --accent-soft: #3a2621; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
a { color: var(--accent); }
.error { color: var(--danger); min-height: 1em; margin: 4px 0; font-size: 14px; }
.note { color: var(--warn); font-size: 14px; margin: 0; }
.note:empty { display: none; }

.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 14px;
  border-radius: 10px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .6; cursor: default; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; margin-top: 4px; }
label { display: block; margin: 10px 0; font-size: 14px; }

.logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent);
  mask: none; position: relative; }
.logo-mark::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 55%, rgba(255,255,255,.35) 55%); border-radius: inherit; }
.logo-mark.sm { width: 28px; height: 28px; border-radius: 8px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; }
.auth-card h1 { margin: 16px 0 4px; font-size: 24px; }
.auth-card .btn.primary { width: 100%; margin-top: 8px; padding: 11px; }
.auth:not(.signup) .signup-only { display: none; }

.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px;
  background: var(--surface); position: sticky; top: 0; height: 100vh; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--ink); text-decoration: none; padding: 9px 10px; border-radius: 8px; }
.sidebar nav a.active, .sidebar nav a:hover { background: var(--accent-soft); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; word-break: break-all; }
main { padding: 20px 28px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.topbar h2 { margin: 0; }
.topbar-actions { display: flex; gap: 8px; }
.topbar-actions select { margin: 0; width: auto; }

.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head h3 { margin: 0 8px; min-width: 160px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--line); gap: 1px; }
.cal-dow { background: var(--surface); padding: 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.cal-day { background: var(--surface); min-height: 108px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.cal-day.other { opacity: .45; }
.cal-day.today .num { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; }
.cal-day .num { font-size: 12px; align-self: flex-start; }
.chip { font-size: 12px; padding: 4px 6px; border-radius: 6px; background: var(--accent-soft); border-left: 3px solid var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.chip.draft { opacity: .7; border-left-style: dashed; }
.chip.needs_connection { border-left-color: var(--warn); }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-list .chip { max-width: 260px; }
.drafts { margin-top: 18px; }

.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  display: flex; gap: 12px; align-items: center; cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 12px; height: 12px; border-radius: 999px; flex: none; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.badge.scheduled { color: var(--ok); } .badge.needs_connection { color: var(--warn); }

.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column;
  align-items: center; gap: 4px; cursor: pointer; background: var(--surface); margin: 0; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.media-grid.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); max-height: 55vh; overflow: auto; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); border: 2px solid transparent; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.selected { border-color: var(--accent); }
.tile .x { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 6px;
  padding: 2px 7px; cursor: pointer; }
.tile .name { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; color: #fff; padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

dialog { border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin-top: 0; }
.platforms { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
#platform-boxes { display: flex; flex-wrap: wrap; gap: 14px; }
#platform-boxes label { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
#platform-boxes input { width: auto; margin: 0; }
.ai-row { display: flex; gap: 8px; align-items: center; }
.ai-row input { margin: 0; }
.media-pick { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.picked { display: flex; gap: 6px; flex-wrap: wrap; }
.picked .tile { width: 64px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 10px; }
  .sidebar nav { flex-direction: row; overflow-x: auto; width: 100%; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .sidebar-foot .muted { display: none; }
  main { padding: 16px; }
  .cal-day { min-height: 64px; }
  .cal-day .chip { font-size: 0; padding: 3px; height: 6px; }
}
