/* CPS Social Studio — neutral black-on-white UI (P-01). No CPS brand chrome here;
   branding lives inside the posts, not the tool. */
:root {
  --ink: #0a0a0a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #f6f7f8;
  --accent: #0a0a0a;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --warn: #b45309;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
textarea, input, select { font-family: inherit; font-size: inherit; color: var(--ink); }

.app { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }

/* Sidebar / history */
.sidebar { border-right: 1px solid var(--line); overflow-y: auto; background: var(--bg-soft); }
.sidebar h1 { font-size: 15px; font-weight: 650; padding: 18px 18px 10px; margin: 0; letter-spacing: -0.01em; }
.sidebar .sub { padding: 0 18px 12px; color: var(--muted); font-size: 12px; }
.run-list { list-style: none; margin: 0; padding: 0 10px 24px; }
.run-item {
  display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 10px; cursor: pointer; margin-bottom: 2px;
}
.run-item:hover { background: #eceef0; }
.run-item.active { background: #e6e8ea; }
.run-item .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #dde0e3; }
.run-item .meta { min-width: 0; }
.run-item .date { font-weight: 600; }
.run-item .line2 { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.draft { background: #eef0f2; color: var(--muted); }
.badge.scheduled { background: var(--ok-bg); color: var(--ok); }
.badge.posted { background: #eef2ff; color: #3730a3; }

/* Main */
.main { overflow-y: auto; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(1.2) blur(6px); border-bottom: 1px solid var(--line);
  padding: 16px 24px; display: flex; align-items: baseline; gap: 14px; }
.topbar h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.topbar .when { color: var(--muted); }

/* Week strip (P-02) */
.week { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 16px 24px; }
.day { border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px; min-height: 64px; background: var(--bg-soft); }
.day h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.day .pinned { font-weight: 600; font-size: 13px; }
.day.filled { border-style: solid; background: #fff; }

/* Toolbar (reorder + auto-schedule) */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 4px 24px 0; }
.toolbar .hint { color: var(--muted); font-size: 12px; }
.toolbar .spacer { flex: 1; }
.btn.small { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

.content { padding: 8px 24px 120px; display: flex; flex-direction: column; gap: 12px; }

/* Job card — collapsible accordion, drag to reorder */
.job { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.job.dragging { opacity: 0.5; }
.job.drop-target { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(10,10,10,0.12); }
.job-head { display: grid; grid-template-columns: 20px 56px 1fr auto 16px; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; }
.job.open .job-head { border-bottom: 1px solid var(--line); }
.job-head img, .job-head .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #eee; }
.job-head .head-main { min-width: 0; }
.job-head .title { font-weight: 650; letter-spacing: -0.01em; }
.job-head .title .rank { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-right: 8px; padding: 0 5px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; }
.job-head .meta { color: var(--muted); font-size: 12px; }
.job-head .sched-summary { color: var(--muted); }
.job-head .drag { cursor: grab; color: var(--muted); font-size: 16px; text-align: center; user-select: none; line-height: 1; }
.job-head .drag:active { cursor: grabbing; }
.job-head .chev { color: var(--muted); font-size: 12px; text-align: center; }
.job-sched { display: flex; align-items: center; gap: 6px; }
.job-sched .lbl { color: var(--muted); font-size: 12px; }
.job-sched input[type="date"], .job-sched select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 12px; }

.job-body { display: none; grid-template-columns: 1.3fr 1fr; gap: 18px; padding: 16px; }
.job.open .job-body { display: grid; }
@media (max-width: 900px) { .job.open .job-body { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border: 1px solid var(--line); background: #fff; border-radius: 999px; color: var(--muted); }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab .dot { color: var(--ok); margin-left: 6px; }
.tab.locked { opacity: 0.65; }

.editor textarea { width: 100%; min-height: 160px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; line-height: 1.5; }
.editor textarea:disabled { background: var(--bg-soft); color: var(--muted); }
.editor .row { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.editor .count { color: var(--muted); font-size: 12px; }
.editor input[type="date"], .editor input[type="time"] { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; }
.approve { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.live { color: #3730a3; text-decoration: none; font-size: 12px; }
.live:hover { text-decoration: underline; }

/* Photos */
.photos { display: flex; flex-direction: column; gap: 8px; }
.photos h4 { margin: 0 0 2px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 4/5; border-radius: 8px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: #eee; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.sel { border-color: var(--ink); }
.photo .check { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; display: none; align-items: center; justify-content: center; }
.photo.sel .check { display: flex; }
.photo[draggable] { cursor: grab; }
.photo.dragging { opacity: 0.5; }
.photo.drop-target { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(10,10,10,0.18); }
.photo .lead-badge { position: absolute; bottom: 4px; left: 4px; padding: 1px 6px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }

/* Bottom bar */
.bottombar { position: fixed; bottom: 0; left: 280px; right: 0; background: rgba(255,255,255,0.95);
  backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 12px 24px; display: flex; gap: 10px; align-items: center; }
.bottombar .spacer { flex: 1; }
.btn { padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600; }
.btn:hover { background: var(--bg-soft); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #222; }
.btn:disabled { opacity: 0.5; cursor: default; }
.status-note { color: var(--muted); font-size: 13px; }
.dirty-dot { color: var(--warn); }

.empty { padding: 60px 24px; color: var(--muted); max-width: 560px; }
.empty code { background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; }

/* Hosted (Supabase) variant: status, archive, login, sign-out */
.badge.to_be_scheduled { background: #fff7ed; color: var(--warn); }
.topbar .spacer { flex: 1; }
.btn.small.danger { color: #b91c1c; border-color: #f1c7c7; }
.btn.small.danger:hover { background: #fef2f2; }
.signout { margin: 14px 18px; }
.login { padding: 48px 24px; max-width: 360px; }
.login h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); margin: 0 0 20px; }
.login label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.login input { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; box-sizing: border-box; }
.login .btn { width: 100%; margin-top: 6px; }
.login-err { color: var(--warn); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
