:root {
  --navy: #0d2c47;
  --blue: #1c73cc;
  --ink: #1b2733;
  --muted: #5b6875;
  --line: #d9dee4;
  --page: #f2f4f7;
  --panel: #ffffff;
  --radius: 10px;
  --font-body: 'Nunito Sans', 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Baloo 2', 'Nunito Sans', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

.bar { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--navy); color: #fff; }
.bar h1 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 700; white-space: nowrap; }
.bar h1 span { font-weight: 600; opacity: 0.7; }
.scan-name { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0.85; }
.tabs { display: flex; gap: 6px; }
.tab { font: inherit; font-weight: 600; color: #fff; background: transparent; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: var(--radius); padding: 7px 14px; cursor: pointer; }
.tab.is-active { background: #fff; color: var(--navy); border-color: #fff; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px 1fr; }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 6px 16px 24px; }
.side section { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.side section:last-child { border-bottom: 0; }
.side h2 { margin: 0 0 2px; font-family: var(--font-display); font-size: 17px; color: var(--navy); }
.side #export-2d, .side #export-3d { display: grid; gap: 8px; }

.btn { font: inherit; font-weight: 600; color: var(--navy); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px; cursor: pointer; text-align: center; }
.btn:hover { border-color: var(--navy); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #165fa9; border-color: #165fa9; }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(28, 115, 204, 0.45); outline-offset: 1px; }

.hint { margin: 0; color: var(--muted); font-size: 13px; }
.hint code { font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.passes { display: grid; gap: 6px; padding-top: 6px; }
.tools, .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool { padding: 8px 6px; }
.tool.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { border-color: var(--line); }
.sheet.is-tool { touch-action: none; }
.sheet.is-tool svg { cursor: crosshair; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input[type='text'], select { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; min-width: 0; width: 100%; }

.level-name { margin: 8px 0 4px; font-weight: 700; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.room-row { display: grid; grid-template-columns: 1fr 104px; gap: 6px; margin-bottom: 6px; }

#notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: grid; gap: 6px; }

.stage { min-width: 0; min-height: 0; position: relative; }
/* Both views are a 4:3 sheet, the same shape as the downloads, as large as the stage allows. */
.view { position: absolute; inset: 0; padding: 20px; display: flex; align-items: center; justify-content: center; container-type: size; }
.sheet, .canvas-3d { flex: none; width: min(100cqw, 100cqh * 4 / 3); aspect-ratio: 4 / 3; background: #fff; box-shadow: 0 2px 14px rgba(13, 44, 71, 0.16); }
.sheet svg { display: block; width: 100%; height: 100%; }

.canvas-3d { position: relative; overflow: hidden; }
.canvas-3d canvas { display: block; width: 100%; height: 100%; }
.tools-3d { position: absolute; z-index: 2; top: 30px; left: 30px; display: flex; gap: 8px; }
.tools-3d select { width: auto; font-weight: 600; }
#three-missing { position: absolute; left: 14px; bottom: 14px; }

.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); padding: 24px; }
.empty h2 { margin: 0 0 6px; font-family: var(--font-display); color: var(--navy); font-size: 24px; }
.empty p { margin: 0; }
body.is-dragging .stage::after { content: 'Drop the scan file'; position: absolute; inset: 14px; display: grid; place-content: center; border: 3px dashed var(--blue); border-radius: var(--radius); background: rgba(255, 255, 255, 0.9); color: var(--blue); font-family: var(--font-display); font-size: 24px; z-index: 5; }

body.login { align-items: center; justify-content: center; background: var(--navy); padding: 20px; }
.login-card { width: min(360px, 100%); background: var(--panel); border-radius: var(--radius); padding: 26px 24px; display: grid; gap: 14px; }
.login-card h1 { margin: 0 0 4px; font-family: var(--font-display); font-size: 26px; color: var(--navy); }
.login-card h1 span { font-weight: 600; opacity: 0.7; }
.login-card input { padding: 9px 10px; font-size: 16px; }
input[type='password'] { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0; width: 100%; }
.login-error { margin: 0; color: #b3261e; font-size: 14px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(60vh, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .bar { flex-wrap: wrap; gap: 8px 16px; }
}
