:root {
 color-scheme: dark;
 font: 15px/1.45 system-ui, sans-serif;
 color: #f2f4f4;
 background: #151c20;
 --panel: #20292ef5;
 --muted: #bac5cc;
 --line: #53636d;
 --accent: #dce8f1;
 --bar: calc(68px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; overflow: hidden; }
#stage {
 position: fixed;
 top: env(safe-area-inset-top);
 left: env(safe-area-inset-left);
 right: env(safe-area-inset-right);
 height: calc(100vh - var(--bar) - env(safe-area-inset-top));
 height: max(0px, calc(100dvh - var(--bar) - env(safe-area-inset-top)));
 overflow: hidden;
 background: #0c1518;
}
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#rotor { position: absolute; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; }
#rotor img { position: absolute; display: block; max-width: none; max-height: none; user-select: none; -webkit-user-drag: none; }
body.sensor-active #rotor { will-change: transform; }
#calibrationMarker {
 position: absolute; width: 32px; height: 32px; border: 2px solid #fff; border-radius: 50%;
 transform: translate(-50%, -50%); box-shadow: 0 0 0 1px #15232e, 0 1px 8px #0009; pointer-events: none; z-index: 2;
}
#calibrationMarker::before, #calibrationMarker::after { content: ""; position: absolute; background: #fff; box-shadow: 0 0 0 1px #15232e; }
#calibrationMarker::before { width: 44px; height: 2px; left: -8px; top: 13px; }
#calibrationMarker::after { width: 2px; height: 44px; left: 13px; top: -8px; }
body.calibrating #stage { cursor: crosshair; touch-action: none; }
#stage.has-picture { touch-action: none; cursor: grab; user-select: none; }
#stage.has-picture:active { cursor: grabbing; }
#stage:focus-visible { outline: 2px solid #afcde7; outline-offset: -4px; }
body.calibrating #stage.has-picture { cursor: crosshair; }
body.calibrating header, body.calibrating #status { display: none; }
#calibrationGuide { position: absolute; top: 12px; left: 12px; right: 12px; margin: auto; max-width: 420px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); z-index: 3; }
#calibrationGuide p { margin: 0 0 8px; font-size: 13px; }
header { position: fixed; top: 0; left: 0; right: 0; padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(#111b22b8, transparent); pointer-events: none; }
.title-block { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 44px; pointer-events: auto; }
.home-link { font-size: 12px; line-height: 1.3; color: var(--muted); text-decoration: none; text-shadow: 0 1px 5px #000; white-space: nowrap; }
/* The title is not interactive, so the small link uses the whole block as its tap target. */
.home-link::after { content: ""; position: absolute; inset: 0; }
.home-link:hover { color: #fff; }
h1 { font-size: 15px; line-height: 1.3; font-weight: 600; margin: 0; text-shadow: 0 1px 5px #000; }
#mode { font-size: 12px; background: #18242cdd; border-radius: 5px; padding: 5px 8px; }
.header-actions { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
#mode { pointer-events: none; }
.icon-button { display: grid; place-items: center; width: 44px; padding: 9px; background: #18242cdd; }
button, .photo-button { font: inherit; font-size: 14px; min-height: 44px; border: 1px solid var(--line); border-radius: 9px; background: #2e3b44; color: inherit; padding: 9px 12px; cursor: pointer; touch-action: manipulation; white-space: nowrap; }
button:hover, .photo-button:hover { background: #3d505c; }
button:active { background: #496170; }
button:disabled, fieldset:disabled { opacity: .45; }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, .photo-button:focus-within { outline: 3px solid #afcde7; outline-offset: 2px; }
#start, #finishCalibration, #calibrate { background: var(--accent); color: #15232e; border-color: transparent; font-weight: 650; }
#start:hover, #finishCalibration:hover, #calibrate:hover { background: #fff; }
.toolbar { position: fixed; bottom: 0; left: 0; right: 0; min-height: calc(68px + env(safe-area-inset-bottom)); display: flex; justify-content: center; align-items: center; gap: 8px; padding: 10px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); background: var(--panel); z-index: 4; box-shadow: 0 -1px 0 #ffffff15; }
.photo-button { position: relative; display: block; overflow: hidden; margin: 0; }
.photo-button input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
#status { position: fixed; bottom: calc(var(--bar) + 10px); left: max(12px, env(safe-area-inset-left)); max-width: min(560px, calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))); font-size: 12px; line-height: 1.45; margin: 0; padding: 7px 10px; background: #18242ce8; border-radius: 6px; pointer-events: none; }
body.drawer-open #status { display: none; }
#drawer { position: fixed; bottom: var(--bar); left: env(safe-area-inset-left); right: env(safe-area-inset-right); max-height: min(43dvh, max(144px, calc(100dvh - var(--bar) - var(--spin-centre-y, 50dvh) - 28px))); background: var(--panel); border-radius: 16px 16px 0 0; box-shadow: 0 -1px 0 #ffffff30; display: flex; flex-direction: column; z-index: 3; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; gap: 8px; border-bottom: 1px solid #ffffff20; }
.tabs { display: flex; gap: 2px; min-width: 0; }
.tabs button { font-size: 13px; background: transparent; border-color: transparent; padding: 9px 8px; }
.tabs button[aria-pressed=true] { background: #435865; }
#close { background: transparent; }
.drawer-content { overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px 16px; min-height: 0; }
.panel { max-width: 650px; margin: auto; }
.panel p { font-size: 12px; color: var(--muted); margin: 9px 0; }
.row { display: flex; align-items: center; gap: 14px; }
.row > label { flex: 1; min-width: 0; }
.actions { flex-wrap: wrap; gap: 8px; }
label { display: block; font-size: 12px; color: #d5dfe5; margin: 5px 0; }
select { display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 8px; background: #2e3b44; color: inherit; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 13px; }
input[type=range] { display: block; width: 100%; height: 44px; margin: 0; accent-color: #b8d4e9; }
label output { float: right; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: #b8d4e9; }
fieldset { padding: 10px 0 0; border: 0; border-top: 1px solid #ffffff20; margin: 12px 0 0; min-width: 0; }
.zoom-controls { flex-wrap: wrap; gap: 8px; }
.zoom-controls > button:first-child, #zoomIn { width: 44px; padding: 6px; font-size: 22px; }
#zoomValue { min-width: 42px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
#alignImage { margin-left: auto; }
.panel .gesture-intro { font-size: 14px; color: #f2f4f4; }
summary { cursor: pointer; min-height: 44px; padding: 12px 0; font-size: 13px; color: #d5dfe5; }
.grip-controls { border-block: 1px solid #ffffff20; padding: 8px 0; margin: 10px 0; }
#pivotValue { float: right; color: #f2f4f4; }
legend { padding: 0 5px 0 0; font-size: 12px; color: #d5dfe5; }
#stats { font-size: 11px; white-space: pre-line; font-variant-numeric: tabular-nums; color: var(--muted); }
a { color: #d0e5f5; }
#phase:disabled { opacity: .4; }
body.drawer-open #status.important { display: block; z-index: 5; top: calc(60px + env(safe-area-inset-top)); bottom: auto; }
@media (min-width: 750px) {
 #drawer { left: auto; width: 390px; top: max(70px, env(safe-area-inset-top)); bottom: calc(var(--bar) + 16px); max-height: none; border-radius: 16px; right: max(16px, env(safe-area-inset-right)); }
 body.drawer-open #status { display: block; max-width: min(560px, calc(100% - 440px)); }
 body.drawer-open #status.important { top: auto; bottom: calc(var(--bar) + 10px); }
}
@media (max-width: 370px) {
 .toolbar { gap: 5px; }
 .toolbar button, .photo-button { font-size: 12px; padding: 9px 8px; }
 .tabs button { font-size: 12px; padding: 8px 5px; }
 .drawer-head { padding: 6px 9px; gap: 4px; }
 #close { padding: 9px 8px; }
 .row { gap: 8px; }
}
@media (max-height: 500px) and (max-width: 749px) {
 #drawer { max-height: calc(100dvh - var(--bar) - 42px - env(safe-area-inset-top)); }
 .drawer-head { padding: 3px 10px; }
 header { padding-top: max(8px, env(safe-area-inset-top)); }
}
