/* HEARTH basement viewer: page layout, panels and controls. The palette tokens and every rule for
   the plan drawing itself live in plan.css, shared with the tape worksheet. */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--fs);
  color: var(--ink);
  background: var(--paper);
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr minmax(320px, 400px);
  grid-template-areas: "header header" "plan panel" "status status";
  height: 100vh;
}
header {
  grid-area: header;
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  padding: 8px 14px; border-bottom: 2px solid var(--ink); background: var(--paper);
}
header h1 { font-size: 18px; margin: 0; font-weight: 700; }
header .rev { font-variant-numeric: tabular-nums; color: var(--grey); }
header .notice { padding: 4px 8px; border: 2px solid var(--orange); background: var(--orange-soft); border-radius: 4px; }
header .notice.ok { border-color: var(--grey); background: var(--grey-soft); }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; align-items: center; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; border-right: 2px solid var(--ink); }
.seg button:last-child { border-right: none; }
button, .btn, select, input[type="file"]::file-selector-button {
  font: inherit; font-size: 14px; padding: 7px 12px; min-height: 36px;
  border: 2px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); cursor: pointer;
}
button:hover { background: var(--panel); }
button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button.small { padding: 4px 8px; min-height: 30px; font-size: 13px; }
a.btn { text-decoration: none; display: inline-block; line-height: 1.3; }

#planwrap { grid-area: plan; position: relative; overflow: hidden; background: #efeeea; border-right: 2px solid var(--ink); touch-action: none; }
/* Edit mode (slice 2, zones). The mode shows in three places at once: the pressed Edit button, the header
   rule turning orange, and the footer hint. */
.edit-only { display: none !important; }
body.editing .edit-only { display: inline-flex !important; }
body.editing header { border-bottom-color: var(--orange); border-bottom-width: 4px; }
body.editing #plan { cursor: default; }
#plan.editing .zone.editable { cursor: move; }
.handles rect { fill: var(--paper); stroke: var(--focus); stroke-width: 2; vector-effect: non-scaling-stroke; }
.handles .h-S, .handles .h-N { cursor: ew-resize; }
.handles .h-W, .handles .h-E { cursor: ns-resize; }
.handles .h-SW, .handles .h-NE { cursor: nwse-resize; }
.handles .h-SE, .handles .h-NW { cursor: nesw-resize; }
#plan { width: 100%; height: 100%; display: block; cursor: grab; }
#plan.measuring { cursor: crosshair; }
#plan.panning { cursor: grabbing; }
#dropzone {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center;
  background: rgba(255,255,255,0.92); padding: 24px; z-index: 5;
}
#dropzone.show { display: flex; }
#dropzone .box { max-width: 520px; border: 3px dashed var(--ink); border-radius: 10px; padding: 24px; background: var(--paper); }
#dropzone h2 { margin-top: 0; }
#dropzone code { background: var(--panel); padding: 2px 6px; border-radius: 4px; }
.plan-hud { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.plan-hud button { width: 44px; height: 44px; padding: 0; font-size: 20px; }

aside#panel { grid-area: panel; overflow: auto; background: var(--panel); display: flex; flex-direction: column; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 2px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.tabs button { flex: 1 1 auto; padding: 6px 8px; min-height: 36px; font-size: 14px; }
.tabpage { display: none; padding: 12px 14px 24px; }
.tabpage.active { display: block; }
.tabpage h2 { font-size: 16px; margin: 0 0 8px; }
.tabpage h3 { font-size: 15px; margin: 16px 0 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0; }
.kv dt { color: var(--grey); }
.kv dd { margin: 0; }
.badge { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 11px; font-size: 13px; font-weight: 700; line-height: 22px; text-align: center; border: 2px solid var(--ink); background: var(--paper); margin-right: 6px; }
.badge.measured { background: var(--ink); color: var(--paper); }
.badge.drawing { border-style: dashed; }
.badge.outstanding { background: var(--orange); border-color: var(--orange); color: var(--paper); }
.badge.derived { background: var(--grey-soft); }
.badge.pending { background: var(--orange-soft); border-color: var(--orange); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 5px 6px; border-bottom: 1px solid var(--line); }
th { background: var(--grey-soft); position: sticky; top: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--blue-soft); }
tr.selected { outline: 2px solid var(--ink); }
.muted { color: var(--grey); }
ul.plain { padding-left: 18px; margin: 6px 0; }
.form { display: grid; gap: 8px; margin-top: 8px; }
.form label { display: grid; gap: 3px; font-size: 14px; }
.form input, .form select, .form textarea { font: inherit; font-size: 15px; padding: 7px 8px; border: 2px solid var(--ink); border-radius: 6px; min-height: 36px; background: var(--paper); }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.form .hint { font-size: 13px; color: var(--grey); }
.form .error { color: var(--orange); font-weight: 600; }
.layers label { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 15px; }
.layers input[type="checkbox"] { width: 20px; height: 20px; }
.layers .row { display: grid; grid-template-columns: 28px 1fr; gap: 0 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.layers .row > label { padding: 0; }
.layers .ctl { grid-column: 2; display: flex; align-items: center; gap: 8px; padding: 2px 0 2px; }
.layers .ctl input[type="range"] { flex: 1 1 auto; min-width: 80px; height: 28px; accent-color: var(--blue); }
.layers .ctl output { min-width: 42px; text-align: right; font-size: 13px; color: var(--grey); font-variant-numeric: tabular-nums; }
.layers .actions { display: flex; gap: 6px; padding: 8px 0; }
.legend { display: grid; grid-template-columns: 56px 1fr; gap: 6px 10px; align-items: center; font-size: 14px; }
.legend svg { width: 56px; height: 26px; display: block; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; background: var(--paper); border: 1px solid var(--line); padding: 8px; border-radius: 6px; max-height: 260px; overflow: auto; }

footer#status {
  grid-area: status; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center;
  padding: 6px 14px; border-top: 2px solid var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; background: var(--paper);
}
footer#status .readout { min-width: 320px; }
footer#status .hover { color: var(--grey); }

.titleblock { display: none; }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 55vh 1fr auto; grid-template-areas: "header" "plan" "panel" "status"; height: auto; min-height: 100vh; }
  #planwrap { border-right: none; border-bottom: 2px solid var(--ink); }
  aside#panel { max-height: none; }
  footer#status .readout { min-width: 0; }
}

@media print {
  @page { size: letter portrait; margin: 12mm; }
  body { display: block; height: auto; }
  header, aside#panel, footer#status, .plan-hud, #dropzone { display: none !important; }
  #planwrap { border: none; background: #fff; height: auto; overflow: visible; }
  #plan { width: 100%; height: 215mm; }
  .titleblock { display: block; border: 2px solid #000; padding: 6px 10px; margin-top: 6px; font-size: 11px; }
  .titleblock table { width: 100%; font-size: 11px; }
  .titleblock td { border: none; padding: 2px 6px; }
}
