:root {
    color-scheme: dark;
    --bg: #08101b;
    --panel: #101b29;
    --panel-2: #152436;
    --line: #293d53;
    --text: #eef5fb;
    --muted: #95a9bc;
    --orange: #f47035;
    --blue: #27a8dc;
    --focus: #78c8ef;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 0%, rgba(39, 168, 220, .10), transparent 32rem),
        var(--bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

.back-link { display: inline-block; margin-bottom: 18px; color: var(--muted); font-size: .85rem; text-underline-offset: 3px; }
.back-link:hover { color: var(--text); }

.shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--focus);
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(1.9rem, 5vw, 3.2rem);
    line-height: 1;
    letter-spacing: -.045em;
}

h1 span { color: var(--orange); }

.subtitle {
    margin: 10px 0 0;
    color: var(--muted);
}

.status {
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    background: rgba(16, 27, 41, .75);
    font-size: .82rem;
    font-weight: 750;
}

.status.ready { color: #b7e4c7; border-color: #2f6850; }
.status.error { color: #ffc0b8; border-color: #864a45; }

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 22px;
    align-items: start;
}

.image-panel, .controls, .caveat {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(16, 27, 41, .94);
    box-shadow: 0 20px 55px rgba(0, 0, 0, .24);
}

.image-panel { padding: 14px; }

#ct-canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #000;
    border-radius: 6px;
    image-rendering: auto;
}

.readout {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 2px 8px;
    color: var(--muted);
    font-size: .86rem;
}

.slice-slider { width: 100%; }

.controls {
    display: grid;
    gap: 18px;
    padding: 18px;
}

fieldset { margin: 0; padding: 0; border: 0; }

legend, .range-label {
    width: 100%;
    margin-bottom: 8px;
    color: #d9e8f4;
    font-size: .82rem;
    font-weight: 800;
}

.segmented {
    display: grid;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #0a1420;
}

.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.view-grid { grid-template-columns: repeat(3, 1fr); }

.segmented button {
    min-height: 36px;
    padding: 7px 8px;
    border: 0;
    border-radius: 5px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-size: .79rem;
    font-weight: 750;
}

.segmented button:hover { color: var(--text); background: var(--panel-2); }
.segmented button.active { color: #06111d; background: #ddecf6; }
.segmented button:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.hint {
    margin: 8px 2px 0;
    color: var(--muted);
    font-size: .76rem;
    line-height: 1.4;
}

.range-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 -11px;
}

output { color: var(--focus); font-variant-numeric: tabular-nums; }

input[type="range"] { width: 100%; accent-color: var(--orange); cursor: ew-resize; }

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    color: #d2dfeb;
    font-size: .82rem;
    line-height: 1.35;
}

.check-row input { margin-top: 2px; accent-color: var(--orange); }

.color-key { padding: 2px 2px 14px; }
.color-key h2 { margin: 0 0 10px; font-size: .88rem; }
.color-key p { margin: 9px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .83rem; line-height: 1.45; }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { flex: 0 0 13px; width: 13px; height: 13px; border-radius: 2px; background: #a4afbc; }
.legend .higher { background: rgb(244, 112, 53); }
.legend .lower { background: rgb(39, 168, 220); }
.legend .current-edge { background: #ff6363; }
.legend .old-edge { background: #50d9df; }

input:disabled { opacity: .4; cursor: default; }

dl { display: grid; gap: 9px; margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 12px; padding-top: 9px; border-top: 1px solid var(--line); }
dt { color: var(--muted); font-size: .76rem; }
dd { margin: 0; color: #dfeaf3; font-size: .77rem; text-align: right; }

.caveat {
    margin-top: 22px;
    padding: 16px 18px;
    box-shadow: none;
}

.caveat strong { color: #ffd3be; font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; }
.caveat p { margin: 7px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.55; }

@media (max-width: 820px) {
    .shell { width: min(100vw - 16px, 580px); padding-top: 16px; }
    header { align-items: flex-start; flex-direction: column; gap: 12px; }
    .workspace { grid-template-columns: 1fr; }
    #ct-canvas { max-height: none; }
    .readout { flex-direction: column; gap: 4px; }
}

@media (max-width: 420px) {
    .view-grid { grid-template-columns: repeat(2, 1fr); }
    .controls { padding: 14px; }
}
