/* Review app styles (spec §6): one column on a phone with the decision bar fixed to the bottom;
   three columns (list | item | parent) wider than 1024 px. Colours pass WCAG AA contrast. */
:root {
  --bg: #f5f6f8; --card: #fff; --text: #1a1e24; --muted: #535c67; --line: #d6dbe1;
  --blue: #1f4f9e; --blue-bg: #e3ecfb; --blue-fg: #163d7a;
  --green: #146c35; --green-bg: #dff2e5; --green-fg: #0f5129;
  --red: #a3241a; --red-bg: #fbe5e2; --amber: #6e4500; --amber-bg: #fdf0cf; --grey-bg: #eceef1;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--blue); text-underline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #e0a100; outline-offset: 2px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--blue); }
.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 800; }
.mainnav { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 15px; }
.mainnav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }

.layout { padding: 12px 16px 32px; max-width: 760px; margin: 0 auto; }
.layout.three .col-list { display: none; }
.col-side { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 8px; }
@media (min-width: 1025px) {
  .layout.three { display: grid; grid-template-columns: 270px minmax(0, 1fr) 360px; gap: 22px; max-width: none; align-items: start; }
  .layout.three .col-list, .layout.three .col-side { display: block; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; margin-top: 0; border-top: 0; padding-top: 0; }
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 6px 0 8px; }
h2, .h2 { font-size: 1.15rem; font-weight: 650; margin: 18px 0 8px; }
h3 { font-size: 1rem; margin: 14px 0 6px; }
p { margin: 8px 0; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 14px; }
.muted, .reason { color: var(--muted); }
.reason { font-size: 14px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { color: var(--muted); margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.crumbs { font-size: 14px; color: var(--muted); }
.ask-text { font-size: 1.05rem; font-weight: 500; }
blockquote { margin: 6px 0; padding: 6px 10px; border-left: 4px solid #a9b3bf; background: #fff; }
blockquote footer { font-size: 14px; color: var(--muted); }

button, .btn { font: inherit; font-size: 15px; padding: 8px 14px; min-height: 40px; border-radius: 8px; border: 1px solid #9aa3ae; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:disabled { opacity: .6; cursor: default; }
button.primary, .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.approve { background: var(--green); border-color: var(--green); color: #fff; }
button.changes { color: var(--blue); border-color: var(--blue); }
button.reject { background: var(--red); border-color: var(--red); color: #fff; }
button.small { padding: 3px 10px; min-height: 32px; font-size: 14px; }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--blue); text-decoration: underline; }
button.link.danger { color: var(--red); }
[data-suggested] { outline: 3px solid #e0a100; outline-offset: 2px; }

label { display: block; font-weight: 600; font-size: 15px; margin: 10px 0 4px; }
input:not([type]), input[type=text], input[type=email], input[type=url], input[type=search], textarea, select {
  width: 100%; font: inherit; padding: 9px 10px; border: 1px solid #848d98; border-radius: 8px; background: #fff; color: var(--text);
}
textarea::placeholder { color: #5b636d; }
.attach label { font-weight: 500; font-size: 14px; margin: 6px 0 2px; }
.attach input[type=file] { font-size: 14px; max-width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.row-end { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin: 12px 0; }
.inline { display: inline-block; }
.err { color: var(--red); font-weight: 600; margin: 6px 0 0; }
.err:empty { display: none; }
.banner { padding: 10px 12px; border-radius: 8px; background: var(--grey-bg); }
.banner.warn { background: var(--amber-bg); color: var(--amber); }

.st, .badge, .count { display: inline-block; border-radius: 999px; font-size: 13px; font-weight: 650; padding: 1px 8px; background: var(--grey-bg); color: #39414b; }
.st-needs_you { background: var(--blue-bg); color: var(--blue-fg); }
.st-held, .st-session-waiting_permission, .st-session-startup_screen, .badge.amber { background: var(--amber-bg); color: var(--amber); }
.st-stalled, .badge.red { background: var(--red-bg); color: var(--red); }
.st-approved, .st-done, .st-session-working, .st-session-starting, .badge.rec { background: var(--green-bg); color: var(--green-fg); }
.tag { display: inline-block; font-size: 12px; border: 1px solid #9aa3ae; border-radius: 4px; padding: 0 6px; color: #39414b; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 8px 0; }
.fgroup { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.flabel { font-size: 13px; color: var(--muted); }
.fchip { display: inline-block; padding: 3px 10px; border: 1px solid #9aa3ae; border-radius: 999px; background: #fff; font-size: 14px; text-decoration: none; color: var(--text); }
.fchip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.row.held { border-left: 6px solid #c98f00; background: #fffaf0; }
.row.stalled { border-left: 6px solid #b93224; background: #fff6f5; }
.row.held .reason { color: var(--amber); }
.row.stalled .reason { color: var(--red); }
.row-link { display: block; text-decoration: none; color: inherit; }
.row-title { display: block; font-weight: 650; }
.row-meta { display: block; font-size: 14px; color: var(--muted); }
.rows.compact .row-link { padding: 7px 10px; border-radius: 8px; border: 1px solid transparent; }
.rows.compact .row-link[aria-current="page"] { background: var(--blue-bg); border-color: #b9cbec; }
.group details > summary { cursor: pointer; padding: 4px 0; }
.group.needs .count { background: var(--blue); color: #fff; }
.list-h { margin-top: 4px; }

.counts { display: flex; flex-wrap: wrap; gap: 8px; }
.count-link { display: inline-flex; gap: 6px; align-items: baseline; padding: 6px 10px; border-radius: 8px; background: var(--grey-bg); text-decoration: none; color: var(--text); }
.count-link .n { font-weight: 800; font-size: 1.1rem; }
.count-link.needs_you { background: var(--blue-bg); color: var(--blue-fg); }
.count-link.held { background: var(--amber-bg); color: var(--amber); }
.count-link.stalled { background: var(--red-bg); color: var(--red); }
.open-parents { padding-left: 18px; }
progress { vertical-align: middle; width: 90px; }
.plinks a + a { margin-left: 14px; }
.login { max-width: 420px; margin: 32px auto; }
.search-row { display: flex; gap: 8px; }

.media { margin: 0 0 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.media img, .media video { display: block; max-width: 100%; height: auto; border-radius: 6px; }
.media figcaption { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); margin-top: 6px; }
.media.redacted { color: var(--muted); }
.img-btn { padding: 0; border: 0; background: none; display: block; width: 100%; min-height: 0; cursor: zoom-in; }
.thumb img { max-height: 120px; }
.artifact { display: block; width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pdf-view canvas { display: block; width: 100%; margin: 0 0 8px; border: 1px solid var(--line); }
.md { overflow-wrap: anywhere; }
.md pre { white-space: pre-wrap; background: #f3f4f6; padding: 8px; border-radius: 6px; }
.menu { position: relative; display: inline-block; margin-left: auto; }
.menu summary { list-style: none; cursor: pointer; padding: 0 8px; border-radius: 6px; font-weight: 800; color: var(--text); }
.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .14); white-space: nowrap; }

.events { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ev { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.ev-user { border-left: 4px solid var(--blue); }
.ev-system { background: #f0f2f5; }
.ev-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin: 0; font-size: 14px; }
.ev-who { font-weight: 700; }
.ev-type, .ev-head time, .ev-status, .ev-pin { color: var(--muted); }
.ev-body { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ev-list { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.ev-status { margin: 6px 0 0; font-size: 13px; }
.ev-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.strip { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; }
.strip-state { margin-top: 0; }
.children { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.child { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.child a[aria-current="page"] { font-weight: 700; }
.child.blocked { background: #f1f2f4; border-style: dashed; color: #4a525c; }
.child.blocked a { color: #4a525c; }
.child.draft { border-style: dashed; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 8px; }
.tabs a { padding: 8px 14px; text-decoration: none; border-radius: 8px 8px 0 0; color: var(--text); }
.tabs a[aria-current="page"] { background: #fff; border: 1px solid var(--line); border-bottom-color: #fff; margin-bottom: -1px; font-weight: 650; }
.brief { white-space: pre-wrap; overflow-wrap: anywhere; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 14px; }
.confirm-box summary, .add-task summary { cursor: pointer; display: inline-block; padding: 8px 14px; border: 1px solid #9aa3ae; border-radius: 8px; background: #fff; }
.confirm-box[open], .add-task[open] { flex-basis: 100%; }
.confirm-box form, .add-task form { margin-top: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

.decide-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .1); padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
.decide-bar textarea { min-height: 44px; }
.bar-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; margin-top: 6px; }
.bar-buttons { display: flex; gap: 6px; margin-left: auto; }
.decide-bar .confirm { margin-top: 6px; }
body.has-bar { padding-bottom: 250px; }
@media (min-width: 1025px) {
  body.has-bar { padding-bottom: 0; }
  .decide-bar { position: sticky; bottom: 0; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 16px; }
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.chip { flex: none; border-radius: 999px; padding: 3px 12px; min-height: 32px; font-size: 14px; background: var(--blue-bg); border-color: #b9cbec; color: var(--blue-fg); }
.opts { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.opt { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; }
button.opt[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-bg); }
.opt-label { display: block; font-weight: 650; }
.opt-detail { display: block; font-size: 14px; color: var(--muted); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); top: max(10px, env(safe-area-inset-top)); z-index: 60; background: #1d2228; color: #fff; padding: 8px 16px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); display: flex; gap: 6px; align-items: center; max-width: calc(100% - 32px); }
.toast:empty { display: none; }
.toast.error { background: var(--red); }
.toast .undo { background: none; border: 0; color: #ffd666; font-weight: 800; text-decoration: underline; padding: 0 4px; min-height: 0; }

dialog { border: 0; border-radius: 12px; padding: 16px; max-width: min(560px, calc(100% - 24px)); color: var(--text); }
dialog::backdrop { background: rgba(10, 14, 20, .6); }
.warn { background: var(--amber-bg); color: var(--amber); padding: 8px 10px; border-radius: 8px; }
.viewer { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; margin: 0; padding: 12px; border-radius: 0; background: #0e1116; color: #fff; }
.viewer[open] { display: flex; flex-direction: column; gap: 8px; }
.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.viewer-cap { margin: 0; }
.viewer label { color: #fff; }
