/* Iridescent app. Layout: a result/setup column beside a dark radiograph viewer. */

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
  padding: 10px clamp(14px, 3vw, 28px); padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent); border-bottom: 1px solid var(--line);
}
.tabbar { display: flex; gap: 2px; margin-right: auto; }
.tabbar a { padding: 7px 12px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.tabbar a:hover { color: var(--ink); background: var(--surface-2); }
.tabbar a.on { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }

main { padding: clamp(14px, 2.4vw, 24px) clamp(14px, 3vw, 28px) 64px; max-width: 1360px; margin: 0 auto; }
.view.narrow { max-width: 760px; margin: 0 auto; }
.view-head { margin: 8px 0 18px; }
.view-head h1 { font-size: 24px; }
.view-head p { margin: 4px 0 0; }

.notice { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--possible-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--possible) 35%, transparent); font-size: 14px; }
.notice.offline { background: var(--note-soft); border-color: color-mix(in srgb, var(--note) 35%, transparent); }

/* ---------------------------------------------------------------- workspace */
.workspace { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 16px; align-items: start; }
.side { display: grid; gap: 16px; position: sticky; top: 72px; }

/* setup */
.setup { padding: 20px; display: grid; gap: 18px; }
.setup h1 { font-size: 19px; }
.field { display: grid; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg { display: flex; padding: 3px; gap: 3px; background: var(--surface-2); border-radius: var(--radius-sm); }
.seg button { flex: 1; min-height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }

.drop { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm); cursor: pointer; color: var(--ink-2); transition: border-color 0.15s, background-color 0.15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop span { display: grid; }
.drop strong { color: var(--ink); font-weight: 600; font-size: 14px; }
.drop small { font-size: 12.5px; color: var(--ink-3); }
.file { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.file img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--stage); }
.file > div { flex: 1; min-width: 0; display: grid; }
.file strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file small { font-size: 12.5px; color: var(--ink-3); }

.options { border-top: 1px solid var(--line); padding-top: 12px; }
.options summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px; }
.options summary::-webkit-details-marker { display: none; }
.options summary::before { content: ""; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; }
.options[open] summary::before { transform: rotate(45deg); }
.options[open] { display: grid; gap: 14px; }
.checks { display: flex; gap: 8px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }
.go { width: 100%; min-height: 46px; font-size: 15px; }

/* result */
.result { padding: 0; overflow: hidden; }
.result > * { padding: 16px 20px; margin: 0; }
.result > * + * { border-top: 1px solid var(--line); }
.file-bar { display: flex; align-items: center; gap: 12px; padding: 10px 20px !important; background: var(--surface-2); }
.file-bar img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; background: var(--stage); }
.file-bar > div { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.file-bar strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-bar small { font-size: 12px; color: var(--ink-3); }

.verdict { border-left: 4px solid var(--c, var(--ink-3)); }
.verdict h2 { font-size: 24px; color: var(--c, var(--ink)); }
.verdict p { margin: 4px 0 0; color: var(--ink-2); font-size: 14.5px; }
.verdict[data-status="finding"] { --c: var(--finding); background: var(--finding-soft); }
.verdict[data-status="possible"], .verdict[data-status="borderline"] { --c: var(--possible); background: var(--possible-soft); }
.verdict[data-status="negative"] { --c: var(--clear); background: var(--clear-soft); }
.verdict[data-status="none"] { --c: var(--ink-2); }

/* probability scale with the decision threshold marked */
.scale-track { position: relative; height: 10px; border-radius: 5px; margin-top: 6px; background: linear-gradient(90deg, var(--clear-soft) 0 var(--thr), var(--finding-soft) var(--thr) 100%); box-shadow: inset 0 0 0 1px var(--line-2); }
.scale-thr { position: absolute; left: var(--thr); top: -5px; bottom: -5px; width: 2px; background: var(--ink-2); transform: translateX(-1px); }
.scale-pt { position: absolute; left: var(--p); top: 50%; width: 16px; height: 16px; border-radius: 50%; background: var(--c, var(--ink)); border: 2.5px solid var(--surface); box-shadow: 0 0 0 1px var(--ink-3); transform: translate(-50%, -50%); }
.scale-axis { position: relative; display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--ink-3); height: 16px; }
.scale-axis #scaleThrLabel { position: absolute; left: var(--thr); transform: translateX(-50%); color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.scale-caption { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }

/* 14-finding scores */
.scores { list-style: none; display: grid; gap: 12px; }
.scores li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.scores li b { font-weight: 650; }
.scores li small { color: var(--ink-3); font-size: 12px; grid-column: 1 / -1; }
.scores .bar { position: relative; grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); }
.scores .bar em { position: absolute; left: var(--t); top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); z-index: 1; }
.scores .bar i { display: block; height: 100%; width: var(--w); background: var(--ink-3); border-radius: 3px; }
.scores li.top .bar i { background: var(--finding); }
.scores li.top b { color: var(--finding); }
.scores-note { font-size: 12.5px; color: var(--ink-3); }

.where { display: grid; grid-template-columns: 92px 1fr; gap: 16px; align-items: center; }
.result h3 { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 4px; letter-spacing: 0; }
.where p { margin: 0; font-size: 14.5px; }
.where .advice { margin-top: 6px; color: var(--ink-2); font-size: 13.5px; }
.lungs { width: 92px; height: auto; }
.lungs .zone { stroke: var(--line-2); stroke-width: 0.8; }
.lungs text { font: 700 8px var(--sans); fill: var(--ink-3); }

.checks-list ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.checks-list li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; font-size: 14px; line-height: 1.45; }
.checks-list li .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.checks-list li .ic svg { width: 12px; height: 12px; }
.checks-list li.ok .ic { background: var(--clear-soft); color: var(--clear); }
.checks-list li.note .ic { background: var(--note-soft); color: var(--note); }
.checks-list li.caution .ic { background: var(--possible-soft); color: var(--possible); }
.checks-list li strong { font-weight: 600; display: block; }
.checks-list li .d { color: var(--ink-3); font-size: 13px; }

.model-facts p { margin: 0; font-size: 13px; color: var(--ink-2); }
.disclaimer { font-size: 12.5px; color: var(--ink-3); }
.result .disclaimer { background: var(--surface-2); }

/* ---------------------------------------------------------------- stage (radiograph viewer) */
.stage { background: var(--stage); color: var(--stage-ink); border-radius: var(--radius); border: 1px solid var(--stage-line); min-height: min(76vh, 720px); display: grid; overflow: hidden; }
.stage-empty { display: grid; place-items: center; padding: 32px; text-align: center; color: #8a979a; font-size: 14px; }
.progress { align-self: center; justify-self: center; width: min(420px, 90%); padding: 24px 0; }
.progress ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.progress li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: #6f7c7f; }
.progress li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #4a5759; flex: none; }
.progress li.active { color: var(--stage-ink); }
.progress li.active::before { border-color: #3fc1aa; }
.progress li.done { color: #9aa7a9; }
.progress li.done::before { background: #3fc1aa; border-color: #3fc1aa; }
.p-hint { margin: 18px 0 0; font-size: 13px; color: #8a979a; min-height: 1.6em; }

.viewer { display: grid; grid-template-rows: auto 1fr auto auto auto; gap: 12px; padding: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { min-height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--stage-line); background: transparent; color: #a3b0b2; font-size: 13px; font-weight: 600; }
.tabs button:hover { color: var(--stage-ink); }
.tabs button.on { background: #1d2729; color: #fff; border-color: #3a4a4d; }
.tabs button small { font-weight: 500; color: #7f8c8f; margin-left: 4px; }
.film-wrap { display: grid; place-items: center; min-height: 0; }
.film { position: relative; width: min(100%, 64vh, 640px); aspect-ratio: 1; }
.film img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.film #layerImg { transition: opacity 0.15s; }
.film .side { position: absolute; top: 8px; font: 600 11px var(--sans); color: #fff; background: rgba(0, 0, 0, 0.55); padding: 1px 6px; border-radius: 4px; }
.film .side.l { left: 8px; } .film .side.r { right: 8px; }
.viewer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.slider { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #a3b0b2; }
.slider input { accent-color: #3fc1aa; width: 140px; }
.peek { min-height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--stage-line); background: transparent; color: #a3b0b2; font-size: 13px; font-weight: 600; user-select: none; -webkit-user-select: none; touch-action: none; }
.legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: #a3b0b2; }
.legend .bar { width: 110px; height: 8px; border-radius: 4px; }
.legend .sw { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.map-note { margin: 0; font-size: 12.5px; color: #8a979a; }

/* ---------------------------------------------------------------- technical details */
.tech { margin-top: 16px; padding: 0; }
.tech > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; padding: 14px 20px; flex-wrap: wrap; }
.tech > summary::-webkit-details-marker { display: none; }
.tech > summary span { font-weight: 650; }
.tech > summary small { color: var(--ink-3); font-size: 13px; }
.tech > summary::after { content: "Show"; margin-left: auto; font-size: 13px; font-weight: 600; color: var(--accent); }
.tech[open] > summary::after { content: "Hide"; }
.tech[open] > summary { border-bottom: 1px solid var(--line); }
.tech-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.tech-grid section, .tech-maps { padding: 16px 20px; }
.tech-grid section + section { border-left: 1px solid var(--line); }
.tech-maps { border-top: 1px solid var(--line); }
.tech h3 { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 10px; letter-spacing: 0; }
.tech > .hint { padding: 0 20px 16px; margin: 0; }
.zones { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.zones th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12px; padding: 0 0 6px; }
.zones td { padding: 5px 0; border-top: 1px solid var(--line); }
.zones td:not(:first-child), .zones th:not(:first-child) { text-align: right; }
.agree { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 4px; font-size: 12.5px; align-items: center; }
.agree span { text-align: center; padding: 6px 2px; }
.agree .rowh { text-align: left; color: var(--ink-3); padding-right: 6px; }
.agree .colh { color: var(--ink-3); font-weight: 600; }
.agree .cell { border-radius: 4px; background: color-mix(in srgb, var(--accent) calc(var(--v) * 100%), var(--surface-2)); color: var(--ink); font-weight: 600; }
.agree .diag { color: var(--ink-3); }
.agree .level { grid-column: 1 / -1; text-align: left; color: var(--ink-2); padding-top: 8px; }
.stats { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13.5px; }
.stats dt { color: var(--ink-2); }
.stats dd { margin: 0; font-weight: 600; text-align: right; }
.triptych { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.triptych figure { margin: 0; }
.triptych .frame { position: relative; aspect-ratio: 1; background: var(--stage); border-radius: var(--radius-sm); overflow: hidden; }
.triptych .frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.triptych figcaption { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.triptych figcaption small { color: var(--ink-3); font-weight: 500; }

.result-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------------------------------------------------------------- history + settings */
.history { display: grid; gap: 8px; }
.h-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-align: left; width: 100%; }
.h-item:hover { border-color: var(--line-2); }
.h-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; background: var(--stage); }
.h-item strong { font-size: 15px; font-weight: 650; display: block; }
.h-item small { font-size: 12.5px; color: var(--ink-3); }
.empty { padding: 28px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty p { margin: 0 0 14px; }
.clear-all { margin-top: 14px; }
.settings { padding: 4px 20px; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; }
.set + .set { border-top: 1px solid var(--line); }
.set h3 { font-size: 15px; }
.set .seg { min-width: 240px; }
.view.narrow > .disclaimer { margin-top: 16px; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ink); color: var(--bg); font-size: 14px; }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 700; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .side { position: static; }
  .stage { min-height: 0; }
  .film { width: 100%; }
  .tech-grid { grid-template-columns: 1fr; }
  .tech-grid section + section { border-left: 0; border-top: 1px solid var(--line); }
  .topbar { gap: 10px; }
  .status span:last-child { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .tabbar { order: 3; width: 100%; margin: 0; }
  .tabbar a { flex: 1; text-align: center; }
  .set { flex-direction: column; align-items: stretch; }
  .set .seg { min-width: 0; }
  .verdict h2 { font-size: 22px; }
}

/* ---------------------------------------------------------------- print: a compact report */
@media print {
  .topbar, .setup, .result-actions, .viewer-foot, .tabs, #newBtn, .toast, .notice { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .workspace { grid-template-columns: 1fr 1fr; }
  .side { position: static; }
  .stage { min-height: 0; }
  .tech > summary::after { content: ""; }
}
