/* PIF Follow-Up Review. Light theme, brand colors only: navy and ink carry the page, gold is
   reserved for the primary action and the selected-block outline. Mobile first (375px). */
:root {
  --navy: #00387b;
  --navy-deep: #02244d;
  --gold: #ffbf00;
  --ink: #0d1b2a;
  --muted: #5b6675;
  --line: #e3e8ef;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ok: #1d6b3a;
  --ok-bg: #e6f3ea;
  --add: #dff3e4;
  --del: #fbe3e1;
  --radius: 10px;
  --font: Montserrat, "Helvetica Neue", Arial, sans-serif;
  --bar-h: 0px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
button, input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
a { color: var(--navy); }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ---------- top header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 84px; height: auto; display: block; }
.brand span { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.who-label { display: none; font-size: 12px; color: var(--muted); padding: 0 6px 0 8px; }
.who button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; min-height: 32px; }
.who button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.who.unset { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(0, 56, 123, .12); }
.note { margin: 0; padding: 10px 16px; background: #fff8e0; border-bottom: 1px solid #f1e2a8; font-size: 13px; }
.loading { padding: 40px 16px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 50; box-shadow: 0 6px 24px rgba(13, 27, 42, .25); }

/* ---------- buttons ---------- */
.btn { border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; font-weight: 700; font-size: 14px; cursor: pointer; min-height: 40px; white-space: nowrap; }
.btn.sm { padding: 7px 12px; font-size: 13px; min-height: 36px; }
.btn.navy { background: var(--navy); color: #fff; }
.btn.gold { background: var(--gold); color: var(--navy-deep); }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost:not(:disabled):hover { border-color: var(--navy); }

/* ---------- chips ---------- */
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip.original { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.edited { background: #e8eef7; color: var(--navy); }
.chip.approved { background: var(--ok-bg); color: var(--ok); }

/* ---------- gallery ---------- */
.gallery { max-width: 1180px; margin: 0 auto; padding: 16px; }
.gallery-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tabs button { border: 0; background: transparent; padding: 8px 14px; border-radius: 7px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--muted); min-height: 38px; }
.tabs button[aria-selected="true"] { background: var(--navy); color: #fff; }
.tally { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }
.cards { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.card:hover, .card:focus-visible { border-color: var(--navy); box-shadow: 0 6px 20px rgba(0, 56, 123, .10); }
.thumb { position: relative; height: 320px; overflow: hidden; background: #fafafa; border-bottom: 1px solid var(--line); }
.thumb::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 48px; background: linear-gradient(rgba(250, 250, 250, 0), #fafafa); pointer-events: none; }
.thumb iframe { position: absolute; top: 0; left: 0; width: 600px; height: 1600px; border: 0; transform-origin: 0 0; pointer-events: none; }
.card-body { padding: 14px 16px 16px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.round { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.subj { margin: 8px 0 4px; font-size: 16px; line-height: 1.35; font-weight: 700; }
.card .headline { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }

/* ---------- detail action bar ---------- */
.bar { position: relative; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); padding: 8px 16px; display: flex; flex-direction: column; gap: 8px; }
.bar-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.back { font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.back::before { content: "\2039\00a0"; }
.bar-title { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-r { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pn { display: flex; gap: 6px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 7px 10px; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 36px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.save-state { font-size: 12px; color: var(--muted); margin-right: auto; }
.bar-act { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(13, 27, 42, .06); }
body.has-actbar { padding-bottom: 72px; }
body.has-actbar .toast { bottom: 84px; }
.save-state.dirty { color: var(--navy); font-weight: 700; }

/* ---------- detail layout ---------- */
.detail { display: flex; flex-direction: column; gap: 16px; padding: 16px; max-width: 1240px; margin: 0 auto; }
.canvas { background: #fafafa; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
#preview { display: block; width: 100%; min-height: 600px; border: 0; background: #fafafa; }
.rail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.rail-note { margin: 0 0 14px; padding: 10px 12px; background: #e8eef7; border-radius: 8px; font-size: 13px; }
.group { padding: 12px; margin: 0 -12px 6px; border-radius: 8px; border: 2px solid transparent; transition: border-color .15s, background .3s; }
.group.sel { border-color: var(--gold); }
.group.flash { background: #fff8e0; }
.group-title { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--ink); text-transform: none; }
.field { display: block; margin-bottom: 10px; }
.lbl { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 16px; line-height: 1.5; background: #fff; }
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field textarea:focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 3px rgba(0, 56, 123, .12); }
.field input:disabled, .field textarea:disabled { background: var(--bg); color: var(--muted); }
.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.warn { display: block; font-size: 12px; color: #9a3412; margin-top: 4px; }
.photo-slot { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.slot-thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); flex: none; }
.slot-thumb.wide { width: 144px; height: auto; }
.picker { margin: 0 0 12px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.picker-head { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.picker-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 420px; overflow: auto; }
.pick { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 2px solid transparent; border-radius: 8px; background: var(--card); cursor: pointer; text-align: left; }
.pick img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; display: block; }
.pick span { font-size: 11px; line-height: 1.3; color: var(--muted); }
.pick.on, .pick:hover { border-color: var(--navy); }
.rail-actions { display: flex; justify-content: flex-end; padding: 6px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }

/* ---------- what changed ---------- */
.changes { border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; margin-bottom: 16px; }
.changes summary { cursor: pointer; padding: 12px 0; font-weight: 700; font-size: 14px; }
.count { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 6px; }
.changes .empty { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.chg { padding: 10px 0; border-top: 1px solid var(--line); }
.chg-h { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.by { font-weight: 500; color: var(--muted); font-size: 12px; }
.tag { font-size: 11px; font-weight: 700; color: var(--navy); background: #e8eef7; padding: 1px 6px; border-radius: 4px; }
.chg-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.col-l { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.txt { font-size: 13px; line-height: 1.5; background: var(--bg); border-radius: 6px; padding: 8px; overflow-wrap: anywhere; }
.txt img { display: block; width: 100%; border-radius: 4px; margin-bottom: 4px; }
.txt span { font-size: 12px; color: var(--muted); }
del { background: var(--del); text-decoration: line-through; text-decoration-color: rgba(154, 52, 18, .5); }
ins { background: var(--add); text-decoration: none; }
.changes h4 { margin: 12px 0 6px; font-size: 12px; color: var(--muted); }
.history { list-style: none; margin: 0 0 12px; padding: 0; font-size: 12px; }
.history li { padding: 3px 0; }

/* ---------- comments ---------- */
.comments .thread { list-style: none; margin: 0 0 12px; padding: 0; }
.thread li { padding: 10px 0; border-top: 1px solid var(--line); }
.thread li.empty { color: var(--muted); font-size: 13px; }
.c-meta { margin: 0 0 4px; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.c-text { margin: 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ctx { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; font-size: 11px; font-weight: 600; padding: 2px 8px; cursor: pointer; color: var(--navy); }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-row .hint { margin: 0; }
.x { border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; color: var(--muted); padding: 0 4px; }

/* ---------- wider screens ---------- */
@media (max-width: 419px) {
  .brand span { display: none; }
}
@media (max-width: 639px) {
  .bar-l { flex-wrap: wrap; row-gap: 2px; }
  .bar-title { white-space: normal; }
}
@media (min-width: 640px) {
  .who-label { display: inline; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .picker-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .cards { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .bar { position: sticky; top: 0; flex-direction: row; align-items: center; justify-content: space-between; padding: 10px 20px; }
  .bar-act { position: static; padding: 0; background: none; border: 0; box-shadow: none; }
  .save-state { margin-right: 0; }
  body.has-actbar { padding-bottom: 0; }
  body.has-actbar .toast { bottom: 20px; }
  .detail { flex-direction: row; align-items: flex-start; padding: 20px; gap: 20px; }
  .canvas { flex: none; width: 602px; }
  #preview { width: 600px; }
  .rail { flex: 1; min-width: 0; position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow: auto; }
}
