@font-face { font-family: Inter; src: url(/fonts/Inter-Regular.ttf) format('truetype'); font-weight: 400; font-style: normal; }
@font-face { font-family: Inter; src: url(/fonts/Inter-Italic.ttf) format('truetype'); font-weight: 400; font-style: italic; }
@font-face { font-family: Inter; src: url(/fonts/Inter-SemiBold.ttf) format('truetype'); font-weight: 600; font-style: normal; }
@font-face { font-family: Inter; src: url(/fonts/Inter-Bold.ttf) format('truetype'); font-weight: 700; font-style: normal; }

:root { --ink: #1b1f27; --muted: #5a6070; --line: #d5d9e3; --bg: #f3f4f7; --accent: #2c3a57; --warn: #8a5300; --err: #a12a2a; }
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* hidden always wins over a display rule (e.g. .consent) */
body { margin: 0; font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: #f6f7fa; border: 1px solid var(--line); padding: 8px; border-radius: 4px; }
button { font: inherit; padding: 5px 10px; border: 1px solid #b9bfcc; border-radius: 4px; background: #fff; cursor: pointer; }
button:hover:not(:disabled) { background: #eef0f6; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: #3a4b70; }
select { font: inherit; padding: 4px 8px; max-width: 100%; }

.app-header { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.stages { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.stage { padding: 5px 12px 5px 6px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; background: #fff; display: inline-flex; align-items: center; gap: 7px; }
.stage .num { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #eef0f6; font-size: 11.5px; font-weight: 700; color: var(--accent); }
.stage.active, .stage.active:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.stage.active .num { background: #fff; }
.stage.pending { color: var(--muted); border-style: dashed; }
.notice { margin: 12px 20px 0; padding: 8px 12px; background: #fff6e5; border: 1px solid #e3c48f; border-radius: 6px; color: #5c3600; }
.notice.demo { background: #eef2fb; border-color: #c3cde6; color: #26365c; }

/* Start page */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: center; background: linear-gradient(180deg, #fff 0%, #f8f9fc 100%); border: 1px solid var(--line); border-radius: 12px; padding: 28px 32px; margin-bottom: 16px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #5a6f9c; }
.hero-title { font-size: 27px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 10px; max-width: 22ch; }
.lead { font-size: 15px; color: #3d4352; margin: 0 0 18px; max-width: 62ch; }
.how { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.how li { display: flex; gap: 9px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.how .num { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.how strong { display: block; font-size: 13px; }
.how span:not(.num) { display: block; font-size: 12px; color: var(--muted); }
.hero-art { margin: 0; }
.hero-art svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 16px rgba(44, 58, 87, .12)); }
.hero-art figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 8px; }
.start-cols { align-items: flex-start; }
.side-col { width: 360px; flex: none; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.row { display: flex; gap: 6px; align-items: center; }
.row select { flex: 1; min-width: 0; }
.sop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 10px; }
.sop { display: flex; flex-direction: column; gap: 6px; text-align: left; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; transition: border-color .12s, box-shadow .12s; }
.sop:hover { border-color: #9aa8c8; box-shadow: 0 2px 8px rgba(44, 58, 87, .1); }
.sop h3 { margin: 0; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.sop .doc-icon { flex: none; width: 18px; height: 22px; }
.sop p { margin: 0; font-size: 12.5px; color: var(--muted); }
.sop .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.sop .tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #eef0f6; color: #3d4a66; }
.sop .actions { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 4px; }
.sop .actions button { white-space: nowrap; }
.quota { font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #eef6f0; border: 1px solid #b9d6bf; color: #24543a; white-space: nowrap; }
.quota.used { background: #f4f5f8; border-color: var(--line); color: var(--muted); }
.consent { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 10px; padding: 10px 12px; background: #f8f9fc; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.consent input { margin-top: 3px; flex: none; }
.drop.disabled { opacity: .55; cursor: not-allowed; }
.drop.disabled input { pointer-events: none; }
.sop .actions a { font-size: 12.5px; color: #3a4b70; white-space: nowrap; }
main { padding: 12px 20px 40px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; margin-bottom: 12px; }
.cols { display: flex; gap: 12px; align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.error-text { color: var(--err); }
.warn { background: #fffaf0; border: 1px solid #e3c48f; border-left: 4px solid var(--warn); padding: 8px 12px; border-radius: 3px; margin: 8px 0; }
.warn ul { margin: 4px 0 0 18px; padding: 0; }
.ok { background: #f2f8f3; border: 1px solid #b9d6bf; padding: 6px 10px; border-radius: 3px; margin: 8px 0; }
.info { background: #f4f6fb; border: 1px solid var(--line); padding: 6px 10px; border-radius: 3px; margin: 8px 0; }

.drop { display: block; border: 2px dashed #b9bfcc; border-radius: 6px; padding: 22px; text-align: center; cursor: pointer; background: #fafbfd; }
.drop.over { border-color: var(--accent); background: #eef1f8; }
.drop input { display: block; margin: 0 auto 8px; }

fieldset { border: 1px solid var(--line); border-radius: 4px; margin: 10px 0; }
.proc { display: block; padding: 3px 0; }
.source-view { max-height: 75vh; overflow: auto; }
.blk { padding: 3px 0; border-bottom: 1px solid #f0f1f4; }
.blk.h { font-weight: 600; margin-top: 8px; }
.bid { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; }
.blk table { border-collapse: collapse; width: 100%; margin-top: 4px; font-weight: 400; }
.blk td { border: 1px solid var(--line); padding: 3px 5px; vertical-align: top; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.spacer { flex: 1; }
.diagram-cols { align-items: flex-start; }
#panel { width: 360px; flex: none; position: sticky; top: 10px; max-height: calc(100vh - 20px); overflow: auto; }
.page-wrap { margin: 0 0 18px; }
.page-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.page-head button { font-size: 12px; padding: 2px 8px; }
.page { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); aspect-ratio: 297 / 210; }
.page svg { display: block; width: 100%; height: auto; }
.page g.node, .page g.edge { cursor: pointer; }
/* Selection highlight exists only in the on-screen preview; exports are generated separately. */
.page g.selected { filter: drop-shadow(0 0 1.2px #1a73e8) drop-shadow(0 0 1.2px #1a73e8); }
.badge { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line); background: #f4f5f8; }
.b-source { background: #eef6f0; border-color: #b9d6bf; }
.b-inferred { background: #fff6e5; border-color: #e3c48f; }
.b-unresolved { background: #fdecec; border-color: #e7b0b0; }
.evidence { border-left: 3px solid var(--line); padding: 2px 0 2px 8px; margin: 6px 0; }
blockquote { margin: 4px 0; font-style: italic; }
.steps { padding-left: 20px; }
.steps li { margin: 3px 0; }

.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.save-state { font-size: 13px; color: var(--muted); }
.narrow { max-width: 760px; }
.buttons { display: flex; gap: 6px; flex-wrap: wrap; }
button.danger { color: var(--err); border-color: #e0b4b4; }
.form { display: grid; gap: 8px; margin: 8px 0; }
.form label { display: grid; gap: 3px; font-size: 13px; font-weight: 600; }
.form input, .form textarea, .form select, .conn input, .conn select, .roles input { font: inherit; font-weight: 400; padding: 4px 6px; border: 1px solid #b9bfcc; border-radius: 4px; width: 100%; min-width: 0; }
.conn { display: flex; gap: 4px; align-items: center; margin: 4px 0; }
.conn > span { color: var(--muted); width: 14px; flex: none; }
.conn select { flex: 1.4; } .conn input { flex: 1; }
.conn button { flex: none; }
.roles { list-style: none; padding: 0; margin: 0; }
.roles li { display: flex; gap: 4px; align-items: center; margin: 4px 0; }
.roles li input { flex: 1; }
.roles li .muted { font-size: 12px; white-space: nowrap; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { margin: 4px 0; }
.versions li { display: flex; justify-content: space-between; gap: 8px; align-items: center; border-bottom: 1px solid #f0f1f4; padding: 4px 0; }
.projects { list-style: none; padding: 0; margin: 0; }
.projects li { border-bottom: 1px solid #f0f1f4; padding: 8px 0; display: grid; gap: 3px; }
.question { border-bottom: 1px solid #f0f1f4; padding: 4px 0; }
.question p { margin: 4px 0; }
.b-reviewer { background: #eef2fb; border-color: #b9c6e3; }
details summary { cursor: pointer; margin: 6px 0; }

.export-cols { align-items: flex-start; }
.export-side { width: 380px; flex: none; position: sticky; top: 10px; }
.preview-head { display: flex; align-items: baseline; gap: 12px; }
.preview-head h2 { margin: 0; }
#preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; margin-top: 10px; }
.pv { margin: 0; cursor: zoom-in; }
.pv:focus-visible .page { outline: 3px solid #1a73e8; outline-offset: 2px; }
.pv figcaption { font-size: 13px; color: var(--muted); margin-top: 5px; text-align: center; }
#lightbox { position: fixed; inset: 0; background: rgba(20, 24, 33, .78); z-index: 50; display: flex; flex-direction: column; align-items: center; padding: 12px; gap: 10px; }
#lightbox[hidden] { display: none; }
.lb-bar { display: flex; gap: 10px; align-items: center; color: #fff; }
.lb-bar span { min-width: 220px; text-align: center; }
.lb-page { width: min(96vw, calc((100vh - 80px) * 297 / 210)); }

@media (max-width: 1000px) { .cols { flex-direction: column; } #panel, .export-side, .side-col { width: 100%; position: static; max-height: none; } .hero { grid-template-columns: 1fr; } .how { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { main { padding: 10px 12px 32px; } .hero { padding: 18px; } .hero-title { font-size: 22px; } .how { grid-template-columns: 1fr; } .app-header { padding: 10px 12px; gap: 12px; } }

@media print {
  @page { size: 297mm 210mm; margin: 0; }
  body { background: #fff; }
  .app-header, .notice, .toolbar, #panel, .page-head, #view-upload, #view-extracted, #view-export, #edit-msg, #lightbox { display: none !important; }
  #view-diagram { display: block !important; } /* print the diagram from any view */
  main { padding: 0; }
  .page-wrap { margin: 0; break-after: page; }
  .page-wrap:last-child { break-after: auto; }
  .page { box-shadow: none; width: 297mm; height: 210mm; overflow: hidden; }
  .page svg { width: 297mm; height: 210mm; }
  .page g.selected { filter: none; }
}
