/* Demo page: editor, settings, progress and the on-screen report. Builds on site.css. */
.app-main { padding-top: 32px; padding-bottom: 40px; }
.app-head { margin-bottom: 22px; max-width: 800px; }
.app-head h1 { font-size: clamp(36px, 4.4vw, 50px); line-height: 1.05; margin-bottom: 8px; }
.app-head p { margin: 0; color: var(--ink-2); }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- workbench ---------- */
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: stretch; }
@media (max-width: 980px) { .workbench { grid-template-columns: minmax(0, 1fr); } }
.editor-panel { overflow: hidden; display: flex; flex-direction: column; }
.editor-tabs { display: flex; gap: 4px; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tab { border: 1px solid transparent; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font: 500 13.5px/1 var(--font-sans); color: var(--ink-2); white-space: nowrap; transition: background .12s, color .12s; }
.tab:hover { color: var(--ink); background: rgba(255, 255, 255, .7); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); border-color: var(--rule); box-shadow: 0 1px 2px rgba(14, 22, 40, .06); }
.editor-wrap { background: #fdfcfa; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-wrap textarea, .CodeMirror { height: 520px; width: 100%; flex: none; }
.editor-wrap textarea { display: block; border: 0; resize: vertical; padding: 16px; background: #fdfcfa; color: var(--ink); font: 13.5px/1.65 var(--font-mono); outline: none; tab-size: 4; }
@media (max-width: 640px) { .editor-wrap textarea, .CodeMirror { height: 380px; } }
/* light code theme */
.CodeMirror { background: #fdfcfa; color: #1f2937; font: 13.5px/1.65 var(--font-mono); padding: 6px 0; }
.CodeMirror-gutters { background: #f6f5f1; border-right: 1px solid var(--rule); }
.CodeMirror-linenumber { color: #a3a6ad; padding: 0 10px 0 6px; }
.CodeMirror-cursor { border-left: 2px solid var(--accent); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: #dbe6fb !important; }
.cm-s-default .cm-keyword { color: #7c3aed; } .cm-s-default .cm-def { color: #1d4fb0; font-weight: 500; } .cm-s-default .cm-string { color: #067647; }
.cm-s-default .cm-comment { color: #8a8f98; font-style: italic; } .cm-s-default .cm-number { color: #b54708; }
.cm-s-default .cm-builtin { color: #0e7490; } .cm-s-default .cm-variable { color: #1f2937; } .cm-s-default .cm-variable-2 { color: #1f2937; }
.cm-s-default .cm-property { color: #334155; } .cm-s-default .cm-operator { color: #64748b; } .cm-s-default .cm-meta { color: #0e7490; }
.cm-s-default .cm-bracket { color: #64748b; }
.cm-flag { background: #fdecea !important; }
.cm-flag-gutter { color: var(--fail) !important; font-weight: 700; }
.editor-foot { display: flex; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--rule);
  font-size: 12.5px; color: var(--muted); flex-wrap: wrap; background: var(--surface); }
.kbd-hint { white-space: nowrap; }
kbd { font: 500 11px/1 var(--font-mono); border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--surface); color: var(--ink-2); }

.settings { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 20px; }
.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px; }
.mode-opt { border: 0; background: transparent; border-radius: 7px; padding: 9px 8px; font: 600 13.5px/1 var(--font-sans); color: var(--ink-2); cursor: pointer; }
.mode-opt:hover { color: var(--ink); }
.mode-opt[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(14, 22, 40, .08), 0 0 0 1px var(--rule); }
.custom-fields { display: grid; gap: 20px; }
.shard-info { font-size: 13.5px; color: var(--ink-2); }
.shard-lede { margin: 0 0 12px; color: var(--ink); font-weight: 500; }
.shard-steps { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 8px; }
.shard-steps b { color: var(--ink); font-weight: 600; }
.shard-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.settings-foot { margin-top: auto; display: grid; gap: 10px; }
.field { display: grid; gap: 9px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field-label { font-weight: 600; font-size: 14px; color: var(--ink); }
.field-note { font-size: 12px; color: var(--muted); }
.assets { display: flex; flex-wrap: wrap; gap: 6px; }
.asset { border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink-2); border-radius: 7px; padding: 5px 8px;
  font: 600 12px/1 var(--font-mono); cursor: pointer; transition: all .12s; }
.asset:hover { border-color: var(--ink-2); color: var(--ink); }
.asset[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.dates { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.dates input, .cost input, #trials { width: 100%; min-width: 0; border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); border-radius: 8px; padding: 8px 9px; font: 13px var(--font-mono); }
.dates input:disabled { opacity: .45; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.cost { display: grid; grid-template-columns: 110px auto; gap: 10px; align-items: center; color: var(--ink-2); font-size: 13px; }
.run-btn { width: 100%; }
.data-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---------- progress ---------- */
.progress { margin-top: 18px; padding: 16px 20px; }
.progress-head { display: flex; align-items: center; gap: 12px; }
.progress-head b { font-weight: 600; }
.elapsed { margin-left: auto; color: var(--muted); font-size: 13px; }
.log { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--rule); max-height: 180px; overflow-y: auto; font-size: 12.5px; color: var(--ink-2); display: grid; gap: 3px; }
.log li { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px; }
.log li span:first-child { color: var(--muted); }

/* ---------- report ---------- */
.report { margin-top: 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.report > *, .findings > *, .score-row > *, .grid-2 > * { min-width: 0; }
.r-sheet { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 34px; }
@media (max-width: 640px) { .r-sheet { padding: 20px 16px; } }
.r-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px 24px; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 1px dashed var(--rule-strong); margin-bottom: 22px; }
.r-head h2 { font: 600 22px/1.3 var(--font-mono); letter-spacing: -.01em; overflow-wrap: anywhere; }
.r-meta { margin-top: 6px; font-size: 13px; color: var(--muted); }
.r-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.r-sheet h3 { font-size: 17px; margin: 30px 0 12px; }
.r-sheet h3:first-child { margin-top: 0; }
.r-lede { margin: -4px 0 14px; font-size: 14.5px; color: var(--ink-2); }

.verdict { border-left: 3px solid; border-radius: 0 12px 12px 0; padding: 14px 18px; margin-bottom: 26px; }
.verdict small { display: block; font: 600 10.5px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 7px; }
.verdict p { margin: 0; font-size: 18px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.verdict-pass { background: var(--pass-bg); border-color: var(--pass); } .verdict-pass small { color: var(--pass); }
.verdict-warn { background: var(--warn-bg); border-color: var(--warn); } .verdict-warn small { color: var(--warn); }
.verdict-fail { background: var(--fail-bg); border-color: var(--fail); } .verdict-fail small { color: var(--fail); }

.score-row { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 36px; align-items: start; }
@media (max-width: 760px) { .score-row { grid-template-columns: minmax(0, 1fr); gap: 16px; } }
.score-label { font: 600 10.5px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.score-big { font: 600 64px/1 var(--font-sans); color: var(--navy); letter-spacing: -.04em; margin: 10px 0 4px; }
.score-big span { font: 400 16px var(--font-mono); color: var(--muted); letter-spacing: 0; }
.score-band { font-weight: 600; font-size: 15px; }
.band-pass { color: var(--pass); } .band-warn { color: var(--warn); } .band-fail { color: var(--fail); }
.score-note { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.capped { margin-top: 10px; font-size: 13px; color: var(--fail); line-height: 1.5; }
.band-note { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.45; max-width: 34ch; }
.ranges { display: grid; gap: 4px; }
.rr-basis { font-size: 12px; color: var(--muted); padding-left: 162px; margin-bottom: 8px; }
@media (max-width: 480px) { .rr-basis { padding-left: 0; } }
.rr-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.rr-legend i { display: inline-block; width: 12px; height: 6px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.lg-fail { background: #f4d5d2; } .lg-warn { background: #f7e3bf; } .lg-pass { background: #cfeadb; }

.panel-tbl td:last-child, .panel-tbl th:last-child { text-align: right; width: 1%; }
.panel-tbl td:first-child { white-space: nowrap; padding-right: 20px; font-weight: 500; }
@media (max-width: 640px) { .panel-tbl td:first-child { white-space: normal; } }

.findings { display: grid; gap: 12px; }
.finding { border: 1px solid var(--rule); border-left: 3px solid var(--sevc, var(--rule-strong)); border-radius: 0 12px 12px 0; padding: 14px 18px; background: var(--surface); }
.finding.f-critical, .finding.f-high { --sevc: var(--fail); }
.finding.f-medium { --sevc: var(--warn); }
.finding.f-low { --sevc: var(--rule-strong); }
.finding-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.finding-id { font: 600 12px var(--font-mono); color: var(--muted); }
.finding-title { font-weight: 600; color: var(--ink); }
.finding-test { font-size: 12.5px; color: var(--muted); }
.finding dl { margin: 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 5px 16px; font-size: 14px; }
.finding dt { font: 600 10.5px/1.9 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.finding dd { margin: 0; color: var(--ink-2); }
.finding dd:last-of-type { color: var(--ink); }
@media (max-width: 640px) { .finding dl { grid-template-columns: minmax(0, 1fr); gap: 0; } .finding dd { margin-bottom: 6px; } }
.held { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; font-size: 14.5px; color: var(--ink-2); }
.held li { padding-left: 22px; position: relative; }
.held li::before { content: ""; position: absolute; left: 2px; top: .45em; width: 9px; height: 5px; border-left: 2px solid var(--pass); border-bottom: 2px solid var(--pass); transform: rotate(-45deg); }
.line-link { border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); font: 12px var(--font-mono); padding: 2px 7px; border-radius: 6px; cursor: pointer; }
.line-link:hover { border-color: var(--ink-2); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.chart-legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.chart-box { height: 280px; }
.chart-box.small { height: 160px; }
.caption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 40px; }
.grid-2 > div > h3:first-child { margin-top: 30px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.minis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.mini { border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; background: var(--paper); }
.mini-title { font: 600 12.5px/1.4 var(--font-mono); color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.mini-sub { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; }
.mini-range { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.mini svg { width: 100%; height: 70px; display: block; margin: 6px 0 2px; overflow: visible; }
.notes-tbl td:nth-child(1), .notes-tbl td:nth-child(2), .notes-tbl th:nth-child(1), .notes-tbl th:nth-child(2) { width: 1%; white-space: nowrap; padding-right: 24px; }
.guarantees { margin: 0; padding-left: 18px; font-size: 14px; display: grid; gap: 4px; color: var(--ink-2); }
.error-sheet h3 { color: var(--fail); }
.error-sheet pre { background: var(--code-bg); color: var(--code-ink); padding: 14px 16px; border-radius: 10px; overflow-x: auto; font: 13px/1.6 var(--font-mono); }
.r-sheet p { font-size: 14.5px; color: var(--ink-2); }
.r-sheet .verdict p { font-size: 18px; color: var(--ink); }

/* random-shard report */
.score-pm { font: 500 15px var(--font-mono); font-style: normal; color: var(--ink-2); margin-left: 10px; letter-spacing: 0; }
.shard-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 24px; align-items: end; margin: 6px 0 4px; }
@media (max-width: 760px) { .shard-grid { grid-template-columns: minmax(0, 1fr); } }
.shard-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shard-stats > div { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; display: grid; gap: 2px; }
.shard-stats span { font: 600 10.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.shard-stats b { font-size: 22px; font-weight: 600; color: var(--ink); }
.shard-stats small { font-size: 12px; color: var(--muted); }
.shard-stats > div.wide { grid-column: 1 / -1; }
.hist { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; height: 190px; align-items: end; padding-bottom: 22px; position: relative;
  border-bottom: 1px solid var(--rule-strong); }
.hist-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.hist-bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 0; opacity: .85; }
.hist-n { font: 500 11px var(--font-mono); color: var(--ink-2); margin-bottom: 4px; }
.hist-x { position: absolute; bottom: -20px; font: 11px var(--font-mono); color: var(--muted); }
.band-bg-pass { background: #0e7a48; } .band-bg-warn { background: #d08a1a; } .band-bg-fail { background: #c8453b; }
.r-verify { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.r-verify b { color: var(--ink-2); font-weight: 500; }
.score-label i { font-style: normal; color: var(--muted); letter-spacing: .08em; }
.field-help { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
