:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --border: #dedede;
  --text: #111111;
  --muted: #5e5e5e;
  --accent: #2417b8;
  --accent-contrast: #ffffff;
  --bw-blue: #2417b8;
  --bw-pink: #db4bb7;
  --bw-yellow: #ffdf3f;
  --bw-mint: #d9efd4;
  --badge-uploaded: #c59c00;
  --badge-in_review: #db4bb7;
  --badge-resolved: #387348;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #ffffff;
    --panel: #ffffff;
    --border: #dedede;
    --text: #111111;
    --muted: #5e5e5e;
    --accent: #2417b8;
    --accent-contrast: #ffffff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  /* Without this, .topbar nav's own flex-wrap only wraps its LINKS —
     the topbar row itself (brand + nav + identity) stays a single,
     non-wrapping flex row, and a nav item's intrinsic min-width keeps
     the whole header wider than the viewport on a narrow screen
     (confirmed as a real horizontal-overflow bug before this rule
     existed). Wrapping the topbar itself lets identity drop to its own
     line instead of forcing a scrollbar. */
  flex-wrap: wrap;
}

.brand {
  display:inline-flex;
  align-items:center;
  gap:.45rem;
  text-decoration: none;
}
.brand img { display:block; width:clamp(125px, 13vw, 155px); height:38px; object-fit:contain; object-position:left center; }
.brand span { color:#111; border-left:1px solid var(--border); padding-left:.45rem; font-weight:800; letter-spacing:.08em; }

.topbar nav {
  display: flex;
  gap: .8rem;
  flex: 1;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
}

.topbar nav a { color: var(--text); text-decoration: none; }
.topbar nav a:hover { color: var(--accent); }
.topbar nav .soon {
  color: var(--muted);
  font-size: 0.85rem;
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}

.identity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.identity button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  color: var(--text);
}

@media (max-width: 640px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem 1rem;
    padding: 0.75rem 1rem;
  }
  .topbar .brand { grid-column: 1; grid-row: 1; align-self: center; }
  .topbar .brand img { width:122px; height:32px; }
  .topbar .identity { grid-column: 2; grid-row: 1; font-size: 0; }
  .topbar .identity button { font-size: 0.82rem; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; gap: 0.55rem 1rem; font-size: 0.9rem; }
  .topbar nav a[href="/users"], .topbar nav a[href="/admin/releases"] { display: none; }
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

h1 { margin-top: 0; }

.hint {
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 60ch;
}

.box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin: 1.25rem 0;
}

.stack { display: flex; flex-direction: column; gap: 0.75rem; max-width: 480px; }
.stack label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
.stack label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }

input, select, textarea, button {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

textarea { min-height: 4.5rem; resize: vertical; }

button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  font-weight: 600;
}
button:hover { opacity: 0.9; }

.button, a.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); color: var(--accent); }
.file-name { font-size: 0.85rem; color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1.5rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  /* A long unbroken value (a permission list, a long id) must wrap
     inside its own cell rather than overflow into neighboring columns
     or buttons below — confirmed as a real bug on the Meta connection
     page before this rule existed (marketing.css's own .meta-panel had
     no equivalent, which is exactly what broke there). Safe to apply to
     every table on the site: it only ever affects how an unusually long
     word wraps, never a table's overall column sizing. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
table.meta { table-layout: fixed; }
table.meta th { color: var(--muted); width: 10rem; }

/* A field whose value must never be shown in full even though it isn't
   secret (e.g. a long permission list or id) — visually distinct from
   an ordinary value, and from .masked-value below (genuinely sensitive,
   never rendered at all). */
.long-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

/* A placeholder for a value this app must NEVER render, at any length —
   an access token, a secret, anything password-like. No template in
   this app currently has a real value to put here (the actual token is
   never passed into any template context — see app/main.py's Meta
   routes), but this exists so any future field that might be tempted to
   show one has an explicit, honest "masked" treatment instead of
   silently printing it. */
.masked-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  letter-spacing: 0.15em;
}

code {
  overflow-wrap: anywhere;
  word-break: break-word;
  background: rgba(122, 59, 46, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 1rem 0;
}
/* Explanatory text directly under a row of buttons needs real
   separation, not just line-height — confirmed as a real overlap bug
   on the Meta connection page (the hint paragraph sat flush against
   the button row above it) before this margin existed. */
.button-row + .hint { margin-top: -0.25rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #fff;
  text-transform: capitalize;
}
.badge-uploaded { background: var(--badge-uploaded); }
.badge-in_review { background: var(--badge-in_review); }
.badge-resolved { background: var(--badge-resolved); }

.fact {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.fact-confirmed { border-left-color: var(--badge-resolved); }
.fact-rejected { border-left-color: #a3453d; opacity: 0.75; }
.fact-pending { border-left-color: var(--badge-in_review); }

.fact-text { font-size: 1rem; }
.flag { font-weight: 600; margin-bottom: 0.25rem; }
.dest, .meta-line, .decided { color: var(--muted); font-size: 0.85rem; }
.conflict-details {
  background: rgba(122, 59, 46, 0.08);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.decide-form { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; max-width: 480px; }
.decide-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.decide-buttons .reject { background: transparent; color: var(--text); border: 1px solid var(--border); }

/* Marketing Creative Studio + Inspiration Library */
.badge-draft { background: var(--muted); }
.badge-package_in_review, .badge-cuts_in_review { background: var(--badge-in_review); }
.badge-approved_for_production, .badge-approved_to_publish, .badge-published { background: var(--badge-resolved); }
.badge-changes_requested { background: #a3453d; }
.badge-in_production { background: var(--badge-uploaded); }

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0;
}
legend { padding: 0 0.4rem; color: var(--muted); font-size: 0.85rem; }
fieldset .checkbox { margin-bottom: 0.35rem; }

.handoff-box {
  width: 100%;
  min-height: 22rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
}
/* Clerk-backed front door */
.auth-shell { max-width: 980px; margin: 5rem auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); gap: 3rem; align-items: start; }
.auth-intro h1 { max-width: 12ch; }
.auth-shell #clerk-sign-in { min-height: 420px; }
@media (max-width: 760px) { .auth-shell { margin: 2rem auto; grid-template-columns: 1fr; gap: 1.5rem; } }
