:root {
  --bg: #f4f6f0;
  --surface: #ffffff;
  --surface-alt: #eef6ee;
  --ink: #18201b;
  --muted: #647066;
  --line: #d2decf;
  --accent: #2f5d3a;
  --accent-2: #527f5b;
  --green: #2f7d4b;
  /* built/covered use a blue/amber pair instead of red/purple so the three
     classes stay distinguishable under red-green color blindness. */
  --built: #2b5c94;
  --covered: #c4821f;
  --warning: #a86516;
  --danger: #853326;
  --shadow: 0 10px 28px rgba(24, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

html:has(body[data-page="classifier"]) {
  overflow: hidden;
}

/* Desktop only, intentionally: the classifier canvas needs real screen space
   and mouse precision, so we don't ship a responsive/mobile layout. */
body {
  margin: 0;
  min-width: 1180px;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 14px;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 240, 0.95);
  backdrop-filter: blur(10px);
}

button,
.selected-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.file-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.file-trigger.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

main {
  width: 100%;
  margin: 0 auto;
  padding: 22px 28px 56px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  margin-top: 18px;
  padding: 18px;
}

body[data-page="classifier"] .topbar {
  position: static;
  min-height: var(--app-topbar-height);
  padding: 8px 16px;
  background: var(--surface);
}

body[data-page="classifier"] {
  --app-topbar-height: 54px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

body[data-page="classifier"] .topbar .eyebrow {
  margin-bottom: 2px;
  font-size: 10px;
}

body[data-page="classifier"] .topbar h1 {
  font-size: 20px;
}

.workbench-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: calc(100vh - 75px);
  padding: 10px 16px 8px;
}

body[data-page="classifier"] .workbench-main {
  height: auto;
  min-height: 0;
  overflow: hidden;
  gap: 8px;
  padding: 8px 10px 10px;
}

.workbench-main > .panel {
  margin-top: 0;
}

.classifier-setup {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr) minmax(320px, 440px);
  gap: 10px 12px;
  align-items: end;
  padding: 10px 12px;
  box-shadow: none;
}

.classifier-setup .section-head {
  align-items: flex-end;
  margin-bottom: 0;
}

.classifier-setup h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.classifier-lookup {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.classifier-lookup .lookup-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.classifier-lookup textarea {
  min-height: 50px;
  padding-top: 8px;
}

.classifier-setup .settlement-results {
  grid-column: 1 / -1;
  max-height: 42px;
  min-height: 0;
  margin: 7px 0 0;
  overflow-y: auto;
}

.classifier-setup .settlement-results:empty {
  display: none;
}

.classifier-setup .status-line {
  align-self: end;
  margin-top: 0;
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 82px;
  padding-top: 9px;
  resize: vertical;
}

.settlement-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
  margin: 12px 0 18px;
}

.settlement-results button {
  border-color: var(--line);
  background: #f7faf5;
  color: var(--ink);
}

.lookup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.status-line {
  margin-top: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfaf7;
  color: var(--muted);
  font-size: 13px;
}

.status-line[data-type="ok"] {
  border-color: #b7d4b4;
  background: #eff8ee;
  color: #24482d;
}

.status-line[data-type="error"] {
  border-color: #dfb7ae;
  background: #fff3f1;
  color: var(--danger);
}

.status-line[data-type="loading"] {
  border-color: #e3d0ad;
  background: #fff7e8;
  color: var(--warning);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.analysis-panel {
  scroll-margin-top: 96px;
}

body[data-page="classifier"] .analysis-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 12px;
  overflow: hidden;
}

.analysis-panel .section-head {
  align-items: center;
  margin-bottom: 10px;
}

body[data-page="classifier"] .analysis-panel .section-head {
  margin-bottom: 8px;
}

.analysis-panel h2 {
  margin-bottom: 0;
}

.analysis-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.phase-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 6px;
  margin-bottom: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.phase-button {
  justify-content: center;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.phase-button.active {
  border-color: var(--accent);
  background: #eaf4e8;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.analysis-panel[data-phase="align"] [data-phase-panel="classify"],
.analysis-panel[data-phase="classify"] [data-phase-panel="align"] {
  display: none !important;
}

.analysis-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

body[data-page="classifier"] .analysis-layout {
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  gap: 10px;
  overflow: hidden;
}

.analysis-controls {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(200px, 250px) minmax(470px, 900px) minmax(145px, 170px);
  gap: 10px;
  align-items: start;
  justify-content: start;
}

.analysis-panel[data-phase="align"] .analysis-controls {
  grid-template-columns: minmax(470px, 900px) minmax(145px, 170px);
}

.tool-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfaf7;
}

.tool-block h3 {
  margin-bottom: 6px;
  font-size: 14px;
}

.tool-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 9px;
}

.tool-button {
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  cursor: pointer;
}

.tool-button.active {
  border-color: var(--accent);
  background: #eaf4e8;
  font-weight: 600;
}

.undo-button {
  margin-top: 9px;
  width: 100%;
}

/* Primary action of the alignment step, so it reads as the thing to do. */
.register-button {
  width: 100%;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #2f4a3e;
  border-radius: 8px;
  background: #2f4a3e;
  color: #f4f8f2;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.register-button:hover:not(:disabled) { background: #263d33; }

.register-button:disabled {
  border-color: #d2decf;
  background: #eef2ec;
  color: #8a968a;
  cursor: not-allowed;
}

.register-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.background-manual > summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 0;
  list-style-position: inside;
}

.background-manual > summary:hover { color: #2f4a3e; }

.background-manual[open] > summary { margin-bottom: 6px; }

.nudge-group {
  display: grid;
  justify-items: center;
  gap: 4px;
  align-content: start;
}

.nudge-side {
  display: grid;
  gap: 2px;
  justify-items: center;
  width: 100%;
}

.nudge-side .background-step {
  width: 100%;
}

.offset-readout {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.offset-readout span {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.class-buttons,
.action-grid {
  display: grid;
  gap: 7px;
}

.class-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.class-button[data-class="covered"] {
  grid-column: 1 / -1;
}

.class-button {
  justify-content: flex-start;
  min-height: 34px;
  border-color: var(--line);
  padding: 6px 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.class-button.active {
  border-color: var(--accent);
  background: #eaf4e8;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.swatch {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 1px solid rgba(24, 32, 27, 0.25);
  border-radius: 3px;
}

.swatch-green { background: rgba(47, 125, 75, 0.75); }
.swatch-built { background: rgba(43, 92, 148, 0.78); }
.swatch-covered { background: rgba(196, 130, 31, 0.78); }

.tool-block label {
  min-width: 0;
  margin-top: 0;
  gap: 5px;
  font-size: 11px;
}

.tool-block label span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.tool-block input {
  min-height: 32px;
  font-size: 12px;
}

input[type="range"] {
  padding: 0;
}

.tool-block input[type="range"] {
  min-height: 22px;
}

.paint-block {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.brush-control {
  align-self: end;
}

/* The alignment panel leads with the one action that does the whole job in
   four clicks. Everything else is fine-tuning, folded away so a first-time
   user is not met with seven equally-weighted controls. Plain stacking, so no
   child can land in an implicit row and drop below the fold. */
.background-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-content: start;
}

/* Two columns rather than stacked rows: the controls area has a fixed height,
   so a full-width nudge row pushed the arrow pad permanently below the fold
   at every window size. The pad sits beside the sliders instead. */
.background-manual-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "opacity  nudge"
    "width    nudge"
    "rotation nudge";
  gap: 6px 10px;
  align-items: end;
}

.background-opacity { grid-area: opacity; }
.background-width { grid-area: width; }
.background-rotation { grid-area: rotation; }
.nudge-group { grid-area: nudge; }

/* Label and value share a line: the controls area has a fixed height, and
   every row saved here is a row of fine-tuning that stays above the fold. */
.background-manual-body .background-opacity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 6px;
  row-gap: 2px;
}

.background-manual-body .background-opacity input[type="range"] {
  grid-column: 1 / -1;
}

.background-file-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.background-file-actions > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.background-file-actions > div {
  display: flex;
  gap: 6px;
}

.background-file-actions button,
.background-file-actions .file-trigger {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.background-nudges {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 28px);
  gap: 4px;
  justify-content: center;
  align-self: end;
}

.background-nudges button {
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  font-size: 12px;
}

.nudge-up { grid-column: 2; grid-row: 1; }
.nudge-left { grid-column: 1; grid-row: 2; }
.nudge-reset { grid-column: 2; grid-row: 2; }
.nudge-right { grid-column: 3; grid-row: 2; }
.nudge-down { grid-column: 2; grid-row: 3; }

.actions-block {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.action-grid {
  align-self: stretch;
}

.analysis-canvas-wrap {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid #c4d2c0;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(210, 222, 207, 0.25) 1px, transparent 1px),
    linear-gradient(0deg, rgba(210, 222, 207, 0.25) 1px, transparent 1px),
    #f8faf6;
  background-size: 28px 28px;
}

body[data-page="classifier"] .analysis-canvas-wrap {
  min-height: 0;
  height: 100%;
}

.analysis-canvas-wrap.is-drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(47, 93, 58, 0.28);
}

.analysis-canvas-wrap.is-drop-target::after {
  content: "PNG betöltése";
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(47, 93, 58, 0.55);
  border-radius: 7px;
  background: rgba(244, 250, 242, 0.78);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
}

.png-drop-hint {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: none;
  width: min(520px, calc(100% - 96px));
  min-height: 150px;
  transform: translate(-50%, -50%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 2px dashed rgba(47, 93, 58, 0.72);
  border-radius: 8px;
  padding: 20px 24px;
  background: rgba(251, 250, 247, 0.9);
  color: var(--accent);
  box-shadow: 0 12px 34px rgba(24, 32, 27, 0.16);
  text-align: center;
}

.png-drop-hint:hover {
  background: rgba(244, 250, 242, 0.96);
  box-shadow: 0 16px 40px rgba(24, 32, 27, 0.2);
}

.png-drop-hint strong {
  font-size: 26px;
  line-height: 1.1;
}

.png-drop-hint span {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.png-drop-hint small {
  max-width: 38ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.analysis-panel[data-phase="align"] .analysis-canvas-wrap.has-grid:not(.has-background) .png-drop-hint {
  display: flex;
}

.analysis-canvas-wrap.is-drop-target .png-drop-hint {
  opacity: 0;
}

.canvas-phase-note {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  display: none;
  max-width: min(390px, calc(100% - 160px));
  border: 1px solid rgba(47, 93, 58, 0.34);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(251, 250, 247, 0.9);
  box-shadow: 0 6px 18px rgba(24, 32, 27, 0.12);
  color: var(--ink);
  line-height: 1.25;
}

.canvas-phase-note strong {
  display: block;
  color: var(--accent);
  font-size: 13px;
}

.canvas-phase-note span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.analysis-panel[data-phase="align"] .analysis-canvas-wrap.has-grid .align-phase-note {
  display: block;
}

.canvas-zoom-control {
  position: absolute;
  z-index: 3;
  right: 12px;
  bottom: 12px;
  display: none;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  min-height: 36px;
  padding: 6px 7px;
  border: 1px solid rgba(47, 93, 58, 0.22);
  border-radius: 7px;
  background: rgba(251, 250, 247, 0.82);
  box-shadow: 0 6px 18px rgba(24, 32, 27, 0.12);
  backdrop-filter: blur(8px);
}

.analysis-panel[data-phase="classify"] .analysis-canvas-wrap.has-grid .canvas-zoom-control {
  display: flex;
}

.canvas-zoom-control span {
  flex: 0 0 42px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.canvas-zoom-control input[type="range"] {
  width: clamp(110px, 12vw, 180px);
  min-width: 110px;
  min-height: 22px;
  height: 22px;
}

.canvas-zoom-control button {
  justify-content: center;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}

#analysisCanvas {
  display: block;
  width: 100%;
  height: clamp(460px, calc(100vh - 430px), 1600px);
  touch-action: none;
  cursor: crosshair;
}

/* Pointer feedback (brush ring, lasso rubber band) lives on its own layer so
   following the cursor costs one clear plus a few strokes, instead of
   redrawing every raster cell, the fine grid and all parcel boundaries. It
   never takes pointer events -- #analysisCanvas below stays the event target.

   Its box is positioned and sized from JS in resizeAnalysisCanvas, mirroring
   #analysisCanvas exactly. Do not give it its own width/height here: being
   absolutely positioned it escapes the layout that sizes the main canvas, so
   a second declaration silently diverges, the shared backing store gets
   scaled into a different-sized box, and the drawn cursor drifts away from
   the real pointer. */
#interactionCanvas {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  pointer-events: none;
}

.analysis-panel[data-phase="align"] #analysisCanvas {
  cursor: default;
}

#analysisCanvas[data-panning="true"] {
  cursor: grabbing;
}

.analysis-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}

.analysis-empty.is-hidden {
  display: none;
}

.surface-summary {
  display: grid;
  grid-template-columns: minmax(500px, 620px);
  gap: 10px;
  justify-content: start;
}

.surface-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfaf7;
}

.surface-card > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.surface-breakdown-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 118px 140px;
  gap: 10px;
  align-items: baseline;
  min-height: 32px;
  border-left: 5px solid var(--line);
  border-radius: 5px;
  padding: 6px 8px;
  background: #fff;
}

.surface-breakdown-row span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.surface-breakdown-row strong {
  margin: 0;
  font-size: 17px;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
}

.surface-breakdown-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.surface-green { border-left-color: rgba(47, 125, 75, 0.75); background: #f4fbf3; }
.surface-built { border-left-color: rgba(43, 92, 148, 0.78); background: #f2f7fc; }
.surface-covered { border-left-color: rgba(196, 130, 31, 0.78); background: #fdf6ea; }

body[data-page="classifier"] #analysisCanvas {
  height: 100%;
}

body[data-page="classifier"] .analysis-panel[data-phase="align"] #analysisCanvas {
  height: 100%;
}

@media (min-width: 1700px) {
  .analysis-panel[data-phase="classify"] .analysis-layout {
    grid-template-columns:
      minmax(260px, 320px)
      minmax(200px, 260px)
      minmax(270px, 300px)
      minmax(460px, 1fr);
    grid-template-areas:
      "category paint actions summary"
      "canvas canvas canvas canvas";
    gap: 12px 10px;
    align-items: start;
  }

  body[data-page="classifier"] .analysis-panel[data-phase="classify"] .analysis-layout {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .analysis-panel[data-phase="align"] .analysis-layout {
    grid-template-columns: minmax(1040px, 1fr) minmax(270px, 300px);
    grid-template-areas:
      "background actions"
      "canvas canvas";
    gap: 12px 10px;
    align-items: start;
  }

  body[data-page="classifier"] .analysis-panel[data-phase="align"] .analysis-layout {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .analysis-controls {
    display: contents;
  }

  .category-block { grid-area: category; }
  .paint-block { grid-area: paint; }
  .background-block { grid-area: background; }
  .actions-block { grid-area: actions; }

  .surface-summary {
    grid-area: summary;
    grid-template-columns: minmax(500px, 620px);
    align-self: stretch;
  }

  .analysis-canvas-wrap {
    grid-area: canvas;
  }

  #analysisCanvas {
    height: clamp(600px, calc(100vh - 395px), 1660px);
  }

  body[data-page="classifier"] #analysisCanvas {
    height: 100%;
  }

  /* Wide screens have room to spread the fine-tuning controls across one row
     instead of stacking them; the lead action and the disclosure stay put. */
  body[data-page="classifier"] .analysis-panel[data-phase="align"] .background-manual-body {
    grid-template-columns: minmax(150px, 1fr) minmax(120px, 0.7fr) auto;
    grid-template-areas: "opacity width nudge" "rotation rotation nudge";
    align-items: end;
  }

  body[data-page="classifier"] .analysis-panel[data-phase="align"] .background-nudges {
    grid-template-columns: repeat(3, 30px);
    grid-template-rows: repeat(3, 24px);
    gap: 3px;
  }

  body[data-page="classifier"] .action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

body[data-page="classifier"] {
  --workbench-sidebar-width: clamp(360px, 25vw, 430px);
  display: block;
}

body[data-page="classifier"] .workbench-main {
  display: block;
  height: 100vh;
  padding: 8px;
}

body[data-page="classifier"] .analysis-panel {
  display: grid;
  grid-template-columns: var(--workbench-sidebar-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 8px;
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  scroll-margin-top: 0;
}

body[data-page="classifier"] .workbench-sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

body[data-page="classifier"]:not(.has-active-grid) .workbench-sidebar {
  grid-template-rows: auto auto minmax(0, 1fr);
}

body[data-page="classifier"]:not(.has-active-grid) .workflow-panel,
body[data-page="classifier"]:not(.has-active-grid) .workbench-actions {
  display: none;
}

body[data-page="classifier"] .topbar {
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 2px 4px 6px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

body[data-page="classifier"] .topbar .eyebrow {
  display: none;
}

body[data-page="classifier"] .topbar h1 {
  font-size: 20px;
  line-height: 1.05;
}

body[data-page="classifier"] .tool-slogan {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

body[data-page="classifier"] .classifier-setup,
body[data-page="classifier"] .workflow-panel,
body[data-page="classifier"] .workbench-actions {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body[data-page="classifier"] .classifier-setup {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  padding: 0 4px;
}

body[data-page="classifier"] .classifier-setup .section-head,
body[data-page="classifier"] .workflow-panel > .section-head {
  display: grid;
  gap: 6px;
  align-items: start;
  margin-bottom: 0;
}

body[data-page="classifier"] .classifier-setup .section-head {
  display: none;
}

body[data-page="classifier"] .classifier-setup h2,
body[data-page="classifier"] .workflow-panel h2 {
  margin-bottom: 0;
  font-size: 17px;
}

body[data-page="classifier"] .classifier-setup .eyebrow {
  display: none;
}

body[data-page="classifier"] .selected-pill {
  width: 100%;
  min-height: 0;
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

body[data-page="classifier"] .classifier-lookup {
  display: grid;
  grid-template-columns: minmax(92px, 0.38fr) minmax(0, 1fr);
  grid-template-areas:
    "settlement lots"
    "action action";
  gap: 8px 10px;
  align-items: start;
}

body[data-page="classifier"] .classifier-lookup .lookup-form {
  display: contents;
}

body[data-page="classifier"] .classifier-lookup > label {
  grid-area: settlement;
}

body[data-page="classifier"] .classifier-lookup .lookup-form label {
  grid-area: lots;
}

body[data-page="classifier"] .classifier-lookup label {
  gap: 5px;
  min-width: 0;
  color: #617066;
  font-size: 11px;
  line-height: 1.15;
}

body[data-page="classifier"] .classifier-lookup input,
body[data-page="classifier"] .classifier-lookup textarea {
  min-height: 38px;
  border-color: #c8d7c5;
  border-radius: 5px;
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

body[data-page="classifier"] .classifier-lookup textarea {
  min-height: 56px;
  max-height: 56px;
  resize: none;
}

body[data-page="classifier"] .lookup-form button {
  grid-area: action;
  justify-content: center;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

body[data-page="classifier"] .classifier-setup .settlement-results {
  max-height: 34px;
  margin-top: 0;
}

body[data-page="classifier"] .classifier-setup .status-line {
  max-height: 72px;
  overflow-x: hidden;
  overflow-y: auto;
  margin-top: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}

body[data-page="classifier"] .classifier-setup .status-line:empty {
  display: none;
}

body[data-page="classifier"] .classifier-setup .status-line[data-type="ok"],
body[data-page="classifier"] .classifier-setup .status-line[data-type="loading"],
body[data-page="classifier"] .classifier-setup .status-line[data-type="error"] {
  border: 0;
  background: transparent;
}

body[data-page="classifier"] .classifier-setup .status-line[data-type="ok"] {
  color: #24482d;
}

body[data-page="classifier"] .classifier-setup .status-line[data-type="loading"] {
  color: var(--warning);
}

body[data-page="classifier"] .classifier-setup .status-line[data-type="error"] {
  color: var(--danger);
}

body[data-page="classifier"] .setup-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

body[data-page="classifier"] .setup-actions button {
  justify-content: center;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.15;
  white-space: normal;
}

body[data-page="classifier"] .workflow-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 0 4px;
  overflow: hidden;
}

body[data-page="classifier"] .workflow-panel > .section-head {
  margin-bottom: 6px;
}

body[data-page="classifier"] .workflow-panel > .section-head > div:first-child {
  display: none;
}

body[data-page="classifier"] .analysis-head-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  justify-content: stretch;
}

body[data-page="classifier"] .phase-switch {
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

body[data-page="classifier"] .phase-button {
  min-height: 30px;
  padding: 5px 8px;
}

body[data-page="classifier"] .analysis-layout {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  grid-template-areas: none;
  align-content: start;
  height: auto;
  min-height: 0;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

body[data-page="classifier"] .analysis-panel[data-phase="align"] .analysis-layout,
body[data-page="classifier"] .analysis-panel[data-phase="classify"] .analysis-layout {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  grid-template-areas: none;
  align-content: start;
}

body[data-page="classifier"] .analysis-controls,
body[data-page="classifier"] .analysis-panel[data-phase="align"] .analysis-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

body[data-page="classifier"] .analysis-panel[data-phase="classify"] .analysis-controls {
  display: contents;
}

body[data-page="classifier"] .analysis-panel[data-phase="classify"] .category-block {
  order: 1;
}

body[data-page="classifier"] .analysis-panel[data-phase="classify"] .paint-block {
  order: 2;
}

body[data-page="classifier"] .analysis-panel[data-phase="classify"] .surface-summary {
  order: 3;
}

body[data-page="classifier"] .category-block,
body[data-page="classifier"] .paint-block,
body[data-page="classifier"] .background-block,
body[data-page="classifier"] .actions-block,
body[data-page="classifier"] .surface-summary,
body[data-page="classifier"] .analysis-canvas-wrap {
  grid-area: auto;
}

body[data-page="classifier"] .tool-block {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

body[data-page="classifier"] .tool-block h3 {
  font-size: 12px;
}

body[data-page="classifier"] .class-buttons {
  grid-template-columns: minmax(0, 1fr);
}

body[data-page="classifier"] .class-button[data-class="covered"] {
  grid-column: auto;
}

body[data-page="classifier"] .class-button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 11px;
}

body[data-page="classifier"] .paint-block {
  grid-template-rows: auto;
}

body[data-page="classifier"] .paint-block h3 {
  display: none;
}

body[data-page="classifier"] .action-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body[data-page="classifier"] .action-grid button {
  justify-content: center;
  min-height: 32px;
  padding: 6px;
  font-size: 12px;
}

body[data-page="classifier"] .workbench-actions {
  padding: 0 4px 2px;
}

body[data-page="classifier"] .workbench-actions h3 {
  display: none;
}

body[data-page="classifier"] .workbench-actions .action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body[data-page="classifier"] .workbench-actions button {
  justify-content: center;
  min-height: 28px;
}

body[data-page="classifier"] .background-block,
body[data-page="classifier"] .analysis-panel[data-phase="align"] .background-block {
  gap: 6px;
}

body[data-page="classifier"] .background-block h3 {
  display: none;
}

body[data-page="classifier"] .background-file-actions {
  grid-template-columns: minmax(0, 1fr) auto;
}

body[data-page="classifier"] .background-file-actions > div {
  display: flex;
  gap: 6px;
}

body[data-page="classifier"] .background-file-actions button,
body[data-page="classifier"] .background-file-actions .file-trigger {
  justify-content: center;
  min-width: 64px;
}

body[data-page="classifier"] .background-nudges {
  justify-self: center;
  grid-template-columns: repeat(3, 30px);
  grid-template-rows: repeat(3, 24px);
  gap: 3px;
}

body[data-page="classifier"] .surface-summary {
  grid-template-columns: minmax(0, 1fr);
  grid-area: auto;
}

body[data-page="classifier"] .surface-card {
  gap: 5px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

body[data-page="classifier"] .surface-card > span {
  display: none;
}

body[data-page="classifier"] .surface-breakdown-row {
  grid-template-columns: minmax(122px, 1fr) minmax(86px, auto) minmax(48px, auto);
  gap: 8px;
  min-height: 24px;
  border-radius: 0;
  padding: 3px 0 3px 7px;
  background: transparent;
}

body[data-page="classifier"] .surface-breakdown-row span,
body[data-page="classifier"] .surface-breakdown-row p {
  min-width: 0;
  font-size: 11px;
}

body[data-page="classifier"] .surface-breakdown-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-page="classifier"] .surface-breakdown-row strong {
  font-size: 13px;
}

body[data-page="classifier"] .surface-breakdown-row p {
  overflow: visible;
}

body[data-page="classifier"] .surface-green,
body[data-page="classifier"] .surface-built,
body[data-page="classifier"] .surface-covered {
  background: transparent;
}

body[data-page="classifier"] .analysis-canvas-wrap {
  grid-area: auto;
  min-height: 0;
  height: 100%;
  border-radius: 8px;
}

body[data-page="classifier"] #analysisCanvas {
  height: 100%;
}

code {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-alt);
  color: var(--accent);
}
