/* Redline UI. The signature red is the product: #D62828. */

:root {
  --red: #D62828;
  --red-soft: #fdecec;
  --ink: #1c1e21;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --panel-w: 380px;
}

* { box-sizing: border-box; }
/* The hidden attribute must always win, even over display: flex rules below */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; }
h1 { font-size: 22px; margin: 4px 0; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 13px; margin: 0 0 4px; text-transform: uppercase; letter-spacing: .04em; }
code { background: #eef0f2; padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.grow { flex: 1; }
.spaced { margin-top: 12px; }

.page-narrow { max-width: 560px; margin: 48px auto; padding: 0 16px; }
.page-wide { max-width: 960px; margin: 32px auto; padding: 0 16px; }

.brand-header { margin-bottom: 20px; }
.brand-mark {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid var(--red);
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.9);
  border-radius: 2px;
}
.brand-header .brand-mark { width: 26px; height: 26px; }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 16px;
}
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.row:last-child { border-bottom: none; }
.stack { display: flex; flex-direction: column; gap: 10px; }

input, textarea, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink); width: 100%;
}
textarea { resize: vertical; }
select { width: auto; }

.btn {
  font: inherit; padding: 7px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  white-space: nowrap; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: #c9ccd1; background: #fafafa; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: #b92222; border-color: #b92222; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--red); border-color: var(--red-soft); }
.btn.active { outline: 2px solid var(--red); outline-offset: 1px; }

.chip {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #eef0f2; color: var(--ink); border: 1px solid transparent;
}
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-filter { cursor: pointer; background: #fff; border-color: var(--line); }
.chip-filter.active { background: var(--red); color: #fff; border-color: var(--red); }

/* ---- viewer layout ---- */
.viewer-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.viewer-main { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.frames { flex: 1; display: flex; min-height: 0; background: #fff; }
.frames iframe { flex: 1; border: 0; min-width: 0; }
.frames iframe + iframe { border-left: 2px solid var(--red); }

.pin-hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 16px;
  background: var(--red); color: #fff; padding: 8px 16px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 5; pointer-events: none;
}

.whatif-bar {
  display: flex; gap: 8px; align-items: center; padding: 6px 10px;
  background: var(--red-soft); border-bottom: 1px solid var(--red);
}

.panel {
  width: var(--panel-w); border-left: 1px solid var(--line); background: #fff;
  display: flex; flex-direction: column; overflow-y: auto;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; z-index: 2;
}
.filters { display: flex; gap: 6px; }

.orphans { padding: 12px; background: #fff8e6; border-bottom: 1px solid #f0e0b0; }
.orphan-card {
  background: #fff; border: 1px dashed #d8b74a; border-radius: 8px;
  padding: 10px; margin-top: 8px;
}
.orphan-card img { max-width: 100%; border: 1px solid var(--line); border-radius: 4px; margin: 6px 0; }
.orphan-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

#comments { padding: 8px; }
.comment-card {
  border: 1px solid var(--line); border-left: 3px solid var(--red);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: #fff;
  cursor: pointer;
}
.comment-card.selected { outline: 2px solid var(--red); }
.comment-card.status-resolved { border-left-color: #3aa15b; opacity: .75; }
.comment-card.status-parked { border-left-color: #9ca3af; }
.comment-card.tentative { border-left-style: dashed; }
.comment-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.comment-num {
  display: inline-flex; width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  align-items: center; justify-content: center; flex: none;
}
.status-resolved .comment-num { background: #3aa15b; }
.status-parked .comment-num { background: #9ca3af; }
.comment-body { margin: 6px 0; white-space: pre-wrap; }
.comment-meta { font-size: 11px; color: var(--muted); }
.comment-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.comment-actions .btn { padding: 3px 8px; font-size: 12px; }
.replies { margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--line); }
.reply { margin-bottom: 4px; }
.reply.system { color: var(--muted); font-style: italic; }
.reply-form { display: flex; gap: 6px; margin-top: 6px; }
.tentative-banner {
  background: var(--red-soft); border: 1px dashed var(--red);
  border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 12px;
}
.addressed-banner {
  background: #ecfdf3; border: 1px solid #3aa15b;
  border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 12px;
}
.context-banner {
  background: #fff8e6; border: 1px solid #d8b74a;
  border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 12px;
}
.whatif-thumb {
  display: inline-block; margin-top: 6px; border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden; max-width: 160px; vertical-align: top;
}
.whatif-thumb img { display: block; max-width: 100%; }
.whatif-thumb .verdict { font-size: 11px; padding: 2px 6px; display: block; }

/* composer floats over the stage */
.composer {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  width: min(480px, 90%); background: #fff; border: 1px solid var(--line);
  border-top: 3px solid var(--red); border-radius: 10px; padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 6;
  display: flex; flex-direction: column; gap: 8px;
}
.composer-row { display: flex; gap: 8px; align-items: center; }
.composer-target { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 20px;
  width: min(440px, 92vw); box-shadow: 0 16px 50px rgba(0,0,0,.3);
}
dialog.wide { width: min(760px, 94vw); }
dialog::backdrop { background: rgba(20,20,25,.45); }

.candidate { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.candidate input { width: auto; margin-top: 3px; }
.conflict-box {
  background: var(--red-soft); border: 1px solid var(--red); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px;
}
#prompt-text { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
