:root {
  color-scheme: light;
  --page: #f3f4f6;
  --surface: #ffffff;
  --surface-subtle: #f8f9fa;
  --line: #d8dce1;
  --line-strong: #bcc3cb;
  --ink: #20252b;
  --muted: #68717c;
  --accent: #315f78;
  --accent-soft: #e8f0f4;
  --success: #2f6b4f;
  --success-soft: #eaf4ee;
  --warning: #8a641f;
  --warning-soft: #f8f1df;
  --danger: #9b3d45;
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { border: 1px solid #254f66; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 650; padding: 9px 14px; cursor: pointer; }
button:hover:not(:disabled) { background: #284f65; }
button:disabled { cursor: not-allowed; opacity: .45; }
.secondary { border-color: var(--line-strong); background: var(--surface); color: #3f4852; }
.secondary:hover:not(:disabled) { background: #f0f2f4; }
.shell { width: min(1160px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 56px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(420px, 54%); gap: 24px; align-items: start; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 14px; align-items: center; padding-top: 4px; }
.number { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 7px; background: #e3e7ea; color: #40515d; font-weight: 750; }
.outflank-mark { display: block; flex: none; padding-right: 14px; border-right: 1px solid var(--line); line-height: 0; }
.outflank-logo { display: block; width: 148px; height: auto; }
.brand-copy > strong { display: block; font-size: 1.05rem; font-weight: 720; }
.brand small { display: flex; gap: 6px; align-items: center; margin-top: 1px; color: var(--muted); font-size: .72rem; font-weight: 450; }
.brand small a, .intro a, .input-popover a, .policy-footer a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.brand small a:hover, .intro a:hover, .input-popover a:hover, .policy-footer a:hover { color: #284f65; }
.intro { padding: 31px 2px 24px; }
.intro-title { display: flex; gap: 10px; align-items: center; margin: 0 0 7px; }
.intro-rain { display: block; flex: none; width: 38px; height: 37px; }
.intro h1 { max-width: 720px; margin: 0; font-size: clamp(1.55rem, 3vw, 2.15rem); line-height: 1.2; letter-spacing: -.025em; }
.intro p { margin: 0; color: var(--muted); }
.intro .intro-more { margin-top: 4px; font-size: .82rem; }
.intro .intro-warning { max-width: 820px; margin-top: 10px; padding: 8px 10px; border-left: 3px solid #c59438; border-radius: 0 6px 6px 0; background: var(--warning-soft); color: #6e531f; font-size: .78rem; }

.gpu-card { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.gpu-card summary { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 9px; align-items: center; min-height: 46px; padding: 9px 11px; cursor: pointer; list-style: none; }
.gpu-card summary::-webkit-details-marker { display: none; }
.gpu-card summary strong, .gpu-card summary small { display: block; }
.gpu-card summary strong { font-size: .79rem; }
.gpu-card summary small { color: var(--muted); font-size: .67rem; }
.gpu-result { min-width: 0; overflow: hidden; color: var(--accent); font-size: .7rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.summary-action { color: var(--muted); font-size: .7rem; }
.gpu-card[open] .summary-action { color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #a8afb7; }
.dot.running { background: #c59438; }
.dot.ready { background: #4c8b68; }
.dot.error { background: #bd5861; }
.gpu-controls { display: grid; grid-template-columns: repeat(4, minmax(100px, 1fr)); gap: 8px; padding: 11px; border-top: 1px solid var(--line); background: var(--surface-subtle); }
.gpu-card label { margin: 0; gap: 3px; font-size: .68rem; }
.gpu-card select { padding: 6px 7px; border-radius: 6px; font-size: .7rem; }
.gpu-footer { display: flex; align-items: center; gap: 10px; padding: 0 11px 11px; background: var(--surface-subtle); }
.gpu-footer .help { flex: 1; margin: 0; }
.compact-button { width: auto; flex: none; padding: 6px 9px; font-size: .7rem; }

.stage-nav-row { display: flex; gap: 10px; align-items: stretch; margin-bottom: 14px; }
.stage-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; flex: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.stage-tab { display: grid; grid-template-columns: 28px 1fr auto; gap: 9px; align-items: center; min-width: 0; border: 0; border-radius: 0; background: var(--surface); color: var(--muted); padding: 11px 13px; text-align: left; }
.stage-tab:hover:not(:disabled) { background: #f8f9fa; }
.stage-tab > span { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: #edf0f2; color: #59636d; font-size: .75rem; }
.stage-tab strong, .stage-tab small { display: block; }
.stage-tab strong { color: var(--ink); font-size: .83rem; }
.stage-tab small, .stage-tab em { font-size: .66rem; font-style: normal; }
.stage-tab em { text-align: right; }
.stage-tab.active { box-shadow: inset 0 -3px 0 var(--accent); background: #f9fbfc; }
.stage-tab.active > span { background: var(--accent-soft); color: var(--accent); }
.stage-tab.running { box-shadow: inset 0 -3px 0 #c59438; }
.stage-tab.done { box-shadow: inset 0 -3px 0 #4c8b68; }
.stage-tab.error { box-shadow: inset 0 -3px 0 #bd5861; }

.context-explainer summary { color: var(--accent); cursor: pointer; }
.context-explainer p { max-width: 850px; margin: 7px 0 0; }

.card { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 20px; }
.stage-panel { display: none; }
.stage-panel.active { display: block; }
.stage-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(285px, 34%); gap: 14px; align-items: start; margin-bottom: 14px; }
.section-title { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 18px; }
.section-title h2 { margin: 0 0 2px; font-size: 1rem; }
.section-title p { margin: 0; color: var(--muted); font-size: .82rem; }
.number { width: 30px; height: 30px; font-size: .7rem; }

.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; min-width: 0; margin: 0 0 12px; padding: 0; border: 0; }
.mode-option { position: relative; display: block; margin: 0; }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option span { display: block; min-height: 88px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); cursor: pointer; }
.mode-option strong, .mode-option small { display: block; }
.mode-option strong { margin-bottom: 5px; font-size: .84rem; }
.mode-option small { color: var(--muted); font-size: .72rem; }
.mode-option input:checked + span { border-color: #6f94a8; background: var(--accent-soft); box-shadow: inset 0 0 0 1px #6f94a8; }
.mode-option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: 6px; margin: 13px 0; color: #424a53; font-size: .83rem; }
input[type=file], textarea, select { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink); padding: 9px 10px; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
select option:disabled { color: #9299a1; }
.input-label-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 13px 0 6px; }
.input-label-row > label { display: block; margin: 0; }
.input-explainer { position: relative; flex: none; }
.input-explainer summary { color: var(--accent); font-size: .75rem; cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.input-explainer summary:hover { color: #284f65; }
.input-popover { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; width: min(720px, calc(100vw - 44px)); padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 12px 32px rgba(32, 37, 43, .16); }
.input-popover img { display: block; width: 100%; height: auto; border: 1px solid #e1e4e7; }
.input-popover p { margin: 10px 0 0; color: var(--muted); font-size: .76rem; }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; }
.check input { width: 17px; height: 17px; }
.help, .muted, .field-note { color: var(--muted); font-size: .75rem; }
.field-note { margin-top: -2px; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.activity { margin: 10px 0 0; color: var(--muted); font-size: .8rem; }
.progress-activity { margin-top: 11px; padding-top: 10px; border-top: 1px solid #e4e7ea; }
.stage-inputs { min-width: 0; margin: 0 0 14px; padding: 0; border: 0; }
.stage-inputs:disabled { opacity: .48; }
.bound-source { margin: 0 0 14px; padding: 10px 12px; border: 1px solid #a8c6b5; border-radius: 7px; background: var(--success-soft); color: #315e47; font-size: .78rem; }
.context-explainer { margin: 9px 0 14px; color: var(--muted); font-size: .75rem; }

.live-card { padding: 16px; }
.live-heading { display: flex; justify-content: space-between; gap: 8px; align-items: end; margin-top: 3px; }
.live-heading small, .live-heading strong { display: block; }
.live-heading small { color: var(--muted); font-size: .7rem; }
.live-heading strong { font-size: 1.15rem; }
.live-heading > span { max-width: 58%; color: var(--muted); font-size: .66rem; text-align: right; }
.live-track { height: 6px; margin: 9px 0 11px; overflow: hidden; border-radius: 5px; background: #e5e8eb; }
.live-track div { width: 0; height: 100%; background: var(--accent); transition: width .2s; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.metric-grid div { padding: 7px 8px; border: 1px solid #e4e7ea; border-radius: 6px; background: #fafbfb; }
.metric-grid .wide { grid-column: 1 / 3; }
.metric-grid small, .metric-grid strong { display: block; }
.metric-grid small { color: var(--muted); font-size: .61rem; }
.metric-grid strong { overflow-wrap: anywhere; font-size: .7rem; }
.transfer-status { display: grid; gap: 6px; margin-bottom: 14px; }
.transfer-step { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: #fafbfb; }
.transfer-step > span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: #e9ecef; color: #59636d; }
.transfer-step small, .transfer-step strong { display: block; }
.transfer-step > div { min-width: 0; }
.transfer-step small { color: var(--muted); font-size: .62rem; }
.transfer-step strong { font-size: .72rem; }
.transfer-track { height: 4px; margin-top: 6px; overflow: hidden; border-radius: 4px; background: #dde1e5; }
.transfer-track > div { width: 0; height: 100%; background: var(--accent); }
.transfer-step.running { border-color: #d7b86c; background: var(--warning-soft); }
.transfer-step.done { border-color: #a8c6b5; background: var(--success-soft); }
.transfer-step.done .transfer-track > div { background: var(--success); }
.transfer-step.error { border-color: #d7a9ad; background: #faeeee; }
.transfer-step.error .transfer-track > div { background: var(--danger); }
.stage-artifacts { margin-bottom: 14px; }
.artifact-list { display: grid; gap: 7px; }
.artifact { display: flex; gap: 10px; align-items: center; padding: 10px 11px; border: 1px solid #e1e4e7; border-radius: 7px; background: #fafbfb; }
.artifact strong { font-size: .79rem; }
.artifact span { flex: 1; color: var(--muted); font-size: .73rem; }
.artifact button { padding: 6px 9px; font-size: .72rem; }
.artifact.private { border-left: 3px solid #759a84; }
.artifact.uploadable { border-left: 3px solid #7198ad; }
.result { margin-top: 14px; border-color: #a8c6b5; }
.result pre { margin-bottom: 0; padding: 13px; border-radius: 7px; background: #f4f7f5; color: #285b43; font-size: .92rem; white-space: pre-wrap; word-break: break-all; }
.policy-footer { margin-top: 24px; padding: 16px 2px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.policy-footer p { max-width: 920px; margin: 0; }
.policy-footer .footer-attribution { max-width: none; margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--line); color: #4b545e; font-size: .78rem; font-weight: 500; }
.footer-attribution a { font-weight: 700; }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr; }
  .gpu-controls { grid-template-columns: 1fr 1fr; }
  .stage-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 1160px); padding-top: 12px; }
  .intro { padding-top: 23px; }
  .stage-nav-row { flex-direction: column; }
  .stage-tabs, .mode-picker { grid-template-columns: 1fr; }
  .stage-tab { grid-template-columns: 27px 1fr; }
  .stage-tab em { grid-column: 2; text-align: left; }
  .gpu-controls { grid-template-columns: 1fr; }
  .gpu-card summary { grid-template-columns: auto auto 1fr; }
  .summary-action { display: none; }
  .gpu-result { grid-column: 2 / 4; text-align: left; }
  .gpu-footer, .artifact { align-items: stretch; flex-direction: column; }
  .artifact span { flex: none; }
}
