:root {
  --bg: #0b1220;
  --bg-soft: #0f1728;
  --panel: #131c2e;
  --panel-2: #1a2438;
  --line: #26334d;
  --line-soft: #1e2a41;
  --text: #eef3fb;
  --muted: #9fb0cc;
  --accent: #35bdf7;
  --accent-ink: #04121e;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 6px 20px rgba(0, 0, 0, .28);
  --maxw: 1680px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #16233c 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  font: 15px/1.6 "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif;
  font-feature-settings: "kern" 1;
  text-rendering: optimizeLegibility;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px clamp(14px, 2.2vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 25, 42, .92);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: .2px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px rgba(53, 189, 247, .16);
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

select, input, textarea {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font: inherit; width: 100%;
}
select:focus, input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
#brandSelect { width: auto; min-width: 190px; }

.pill {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; white-space: nowrap;
}
.pill.live { border-color: var(--danger); color: var(--danger); }
.pill.mock { border-color: var(--ok); color: var(--ok); }
.pill.warn { border-color: var(--warn); color: var(--warn); }

/* ------------------------------------------------------------------ tabs */
.tabs {
  display: flex; gap: 6px; padding: 10px clamp(14px, 2.2vw, 32px) 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  overflow-x: auto; scrollbar-width: thin;
}
.tabs button {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  border-bottom: none; padding: 10px 16px; border-radius: 10px 10px 0 0;
  cursor: pointer; font-size: 14px; white-space: nowrap;
}
.tabs button.active { background: var(--panel); color: var(--text); border-color: var(--line); }
.tabs button:hover { color: var(--text); }

/* ------------------------------------------------------------------ main */
main {
  width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: clamp(16px, 2vw, 28px) clamp(14px, 2.2vw, 32px) 80px;
}
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
h2 { font-size: 20px; margin: 2px 0 10px; letter-spacing: .2px; }
h3 { font-size: 15px; margin: 14px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 9px 15px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
  transition: border-color .15s, background .15s, transform .05s;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label input, label textarea { margin-top: 5px; color: var(--text); }

/* ----------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0 18px; }
.stat {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 15px;
}
.stat .v { font-size: 22px; font-weight: 650; letter-spacing: .2px; }
.stat .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

/* ----------------------------------------------------------------- cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: border-color .15s, transform .12s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #0a1020; display: block; }
.card .body { padding: 11px 13px; font-size: 13px; }
.card .body .title { font-weight: 620; margin-bottom: 5px; word-break: break-word; line-height: 1.35; }
.card .body .meta { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------ post cards */
.post {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; display: flex; gap: 18px;
  box-shadow: var(--shadow); transition: border-color .15s;
}
.post:hover { border-color: var(--line); }
.post img {
  width: 168px; height: 168px; object-fit: cover; border-radius: 10px;
  background: #0a1020; flex: 0 0 auto; cursor: zoom-in;
}
.post .info { flex: 1; min-width: 0; }
.post .info .headline { font-weight: 640; font-size: 16.5px; line-height: 1.35; margin-bottom: 6px; }
.post .info .caption {
  color: #c6d3e8; font-size: 14px; white-space: pre-wrap;
  max-height: 112px; overflow: hidden; position: relative;
}
.post .info .caption::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34px;
  background: linear-gradient(180deg, rgba(19,28,46,0), var(--panel));
}
.post .info .meta { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.post .side { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; flex: 0 0 auto; }

.badge {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); white-space: nowrap; letter-spacing: .02em;
}
.badge.draft { color: var(--accent); border-color: var(--accent); }
.badge.approved, .badge.scheduled, .badge.scheduled_local { color: var(--warn); border-color: var(--warn); }
.badge.published { color: var(--ok); border-color: var(--ok); }
.badge.rejected, .badge.failed, .badge.uncertain { color: var(--danger); border-color: var(--danger); }
.badge.hold { color: var(--muted); }

/* pipeline stepper */
.stepper { display: flex; align-items: center; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.stepper .step {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-soft); color: var(--muted); background: var(--bg-soft);
}
.stepper .step.done { color: var(--ok); border-color: rgba(52, 211, 153, .5); }
.stepper .step.current { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 650; }
.stepper .step.blocked { color: var(--danger); border-color: rgba(248, 113, 113, .5); }
.stepper .arrow { color: var(--line); font-size: 11px; }

/* ------------------------------------------------------------------ news */
.cols { display: grid; grid-template-columns: 1fr; gap: 26px; }
@media (min-width: 1100px) { .cols { grid-template-columns: 1fr 1fr; } }

.news-item {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px;
}
.news-item.breaking { border-left-color: var(--danger); }
.news-item.evergreen { border-left-color: var(--accent); }
.news-item.unverified { opacity: .62; }
.news-item .nhead { font-weight: 620; line-height: 1.4; margin-bottom: 6px; }
.news-item .nrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.tag {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg-soft);
}
.tag.breaking { color: var(--danger); border-color: rgba(248,113,113,.5); }
.tag.evergreen { color: var(--accent); border-color: rgba(53,189,247,.45); }
.tag.fresh { color: var(--ok); border-color: rgba(52,211,153,.45); }
.tag.warn { color: var(--warn); border-color: rgba(251,191,36,.5); }
.tag.unverified { color: var(--muted); }

/* calendar */
.cal-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 14px; margin-bottom: 8px; flex-wrap: wrap;
}
.cal-item .cal-date { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 96px; }
.cal-item .cal-name { flex: 1 1 260px; font-weight: 560; }
.cal-item .cal-actions { display: flex; gap: 8px; align-items: center; }
.prio { font-weight: 700; font-size: 12px; }
.prio.A { color: var(--danger); }
.prio.B { color: var(--warn); }
.prio.C { color: var(--muted); }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line-soft); }
th { color: var(--muted); font-weight: 560; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: rgba(53, 189, 247, .04); }

/* --------------------------------------------------------------- dialog */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 16px; max-width: 1180px; width: min(96vw, 1180px); padding: 0;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
dialog::backdrop { background: rgba(3, 8, 18, .74); backdrop-filter: blur(3px); }
.dialog-body { padding: 20px 22px; }
.dialog-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 900px) { .dialog-grid { grid-template-columns: 400px 1fr; } }
#dialogImage {
  width: 100%; border-radius: 12px; border: 1px solid var(--line);
  background: #0a1020; display: block;
}
.dialog-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); }

/* lightbox for full-size preview */
#lightbox {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; padding: 3vh 3vw;
  background: rgba(3, 8, 18, .92);
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 100%; max-height: 94vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; right: 18px; bottom: 18px; max-width: min(520px, 92vw);
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 16px; font-size: 13.5px;
  opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none;
  white-space: pre-wrap; box-shadow: var(--shadow); z-index: 70;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

.empty { color: var(--muted); padding: 22px 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }

/* stacking for narrow screens */
@media (max-width: 760px) {
  .post { flex-direction: column; padding: 14px; }
  .post img { width: 100%; height: auto; aspect-ratio: 1; }
  .post .side { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; }
  .topbar { padding: 10px 14px; }
  #brandSelect { min-width: 140px; }
  h2 { font-size: 18px; }
  .cal-item { align-items: flex-start; }
  .cal-item .cal-actions { width: 100%; }
}

/* --- login page (served before a session exists) --------------------------- */
/* --- Hook & Cover engine -------------------------------------------------- */
.cover-box {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cover-options { display: flex; flex-direction: column; gap: 6px; }

.cover-option {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
}
.cover-option:hover { border-color: var(--accent); }
.cover-option.recommended { border-color: var(--ok); }
.cover-kind { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.cover-text { flex: 1; font-weight: 600; }
.cover-badge { color: var(--ok); font-size: 11px; }
/* --- library picker ------------------------------------------------------- */
.library-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: var(--panel-2);
}

.library-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
}
.library-item:hover { border-color: var(--accent); }
.library-item.current { border-color: var(--ok); }
.library-item img { width: 100%; height: 64px; object-fit: cover; border-radius: 4px; }
.library-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
}

.login-card h1 { margin: 0 0 8px; font-size: 20px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin: 18px 0 12px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}
.login-card button { margin-top: 4px; }

