/* Blueprint map: cyanotype survey sheet, drafting panels, title block. */
:root {
  --paper: #0f3b6e;
  --panel: rgba(10, 42, 82, 0.93);
  --panel-solid: #0b2c56;
  --line: rgba(222, 240, 255, 0.82);
  --line-soft: rgba(200, 226, 255, 0.34);
  --ink: #eef7ff;
  --ink-soft: rgba(214, 234, 255, 0.72);
  --accent: #ffd57e;
  --gap: #ffd57e;
  --pe: #ff9478;
  --public: #ffd57e;
  --chain: #8fd3f7;
  --hover: rgba(160, 210, 255, 0.12);
  --shadow: rgba(0, 8, 24, 0.45);
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --hand: "Architects Daughter", "Bradley Hand", cursive;
  color-scheme: dark;
}
body.white {
  --paper: #f3f0e5;
  --panel: rgba(247, 244, 236, 0.95);
  --panel-solid: #f7f4ec;
  --line: rgba(28, 56, 128, 0.78);
  --line-soft: rgba(28, 56, 128, 0.26);
  --ink: #1b3677;
  --ink-soft: rgba(27, 54, 119, 0.72);
  --accent: #c2410c;
  --gap: #b45309;
  --pe: #cc4a2c;
  --public: #a87a12;
  --chain: #3f7fbf;
  --hover: rgba(28, 56, 128, 0.07);
  --shadow: rgba(80, 64, 20, 0.18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 13px/1.45 var(--mono);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; outline: none; }
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }
#map:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* Drafting panels: double rule with registration ticks at the corners. */
.panel {
  position: fixed;
  z-index: 2;
  background: var(--panel);
  border: 1px solid var(--line);
  outline: 1px solid var(--line-soft);
  outline-offset: -5px;
  box-shadow: 0 6px 22px var(--shadow);
  padding: 14px 16px;
}
.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 0 solid var(--line);
  pointer-events: none;
}
.panel::before { top: -6px; left: -6px; border-top-width: 1px; border-left-width: 1px; }
.panel::after { bottom: -6px; right: -6px; border-bottom-width: 1px; border-right-width: 1px; }
h1, h2, h3 { font-weight: 400; }

.head { z-index: 3; top: 16px; left: 16px; width: min(400px, calc(100vw - 32px)); }
.home { font: 600 11px var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); text-decoration: none; }
.home:hover { text-decoration: underline; }
.head h1 { font: 30px/1.05 var(--hand); margin: 4px 0 6px; letter-spacing: 0.01em; }
.lede { margin: 0 0 12px; color: var(--ink-soft); font-size: 12px; }
.lede b { color: var(--gap); font-weight: 600; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: repeating-linear-gradient(90deg, transparent 0 11px, var(--line-soft) 11px 12px) bottom / 100% 3px no-repeat;
}
.search span { color: var(--ink-soft); font-size: 16px; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: 14px var(--mono);
  color: var(--ink);
  outline: none;
  padding: 4px 0;
}
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.search input::placeholder { color: var(--ink-soft); opacity: 0.8; }
#results { margin-top: 8px; max-height: 42vh; overflow: auto; border-top: 1px dashed var(--line-soft); }
#results button {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px dashed var(--line-soft);
  background: none;
  padding: 6px 4px;
}
#results button:hover, #results button:focus-visible { background: var(--hover); outline: none; box-shadow: inset 2px 0 0 var(--accent); }
#results small { grid-column: 1 / -1; color: var(--ink-soft); font-size: 11px; }
.r-tag { font-size: 10px; letter-spacing: 0.1em; padding: 0 5px; border: 1px solid currentColor; align-self: center; }
.r-tag.gap { border-style: dashed; color: var(--gap); }
#results .none { padding: 6px 4px; color: var(--ink-soft); font-size: 12px; }

/* Survey status */
.status { left: 16px; bottom: 34px; width: 400px; padding: 12px 14px 12px; }
.status-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.status h2 { margin: 0; font: 600 11px var(--mono); letter-spacing: 0.18em; text-transform: uppercase; }
#scope { font-size: 11px; color: var(--ink-soft); }
.cols, #rows button { display: grid; grid-template-columns: 48px 1fr 40px 62px; align-items: center; gap: 6px; }
.cols span { white-space: nowrap; }
.cols { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); padding: 5px 4px 2px; }
.cols span:nth-child(n + 3) { text-align: right; }
#rows button {
  width: 100%;
  border: 0;
  background: none;
  padding: 2px 4px;
  text-align: left;
  font-size: 11.5px;
}
#rows button:hover { background: var(--hover); }
#rows button[aria-pressed="false"] { opacity: 0.4; }
#rows button[aria-pressed="false"] .label { text-decoration: line-through; }
.syms { display: flex; gap: 2px; }
.syms canvas { display: block; }
.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.n.gap { color: var(--gap); }
.n.gap::after { content: " ?"; font-weight: 400; opacity: 0.7; }
.share { position: relative; height: 7px; margin: 8px 4px 3px; border: 1px dashed var(--gap); }
.share span { position: absolute; inset: -1px auto -1px -1px; background: var(--ink); transition: width 0.4s; }
.status-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: 12px; margin: 0 4px; }
.share-text { margin: 0; font-size: 11px; color: var(--ink-soft); }
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  padding: 3px 0;
  border: 0;
  background: none;
  font-size: 12px;
}
.knob { position: relative; width: 30px; height: 14px; border: 1px solid var(--line); flex: none; }
.knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; background: var(--ink-soft); transition: left 0.2s; }
.switch[aria-pressed="true"] .knob { border-color: var(--gap); }
.switch[aria-pressed="true"] .knob::after { left: 18px; background: var(--gap); }
.switch[aria-pressed="true"] { color: var(--gap); }
.key { display: flex; align-items: center; gap: 6px; margin: 8px 4px 0; }
.key canvas { width: 60px; height: 22px; flex: none; }
.key p { margin: 0; display: grid; font-size: 10.5px; line-height: 11px; color: var(--ink-soft); }
.fine { margin: 8px 4px 0; font-size: 10.5px; line-height: 1.45; color: var(--ink-soft); border-top: 1px dashed var(--line-soft); padding-top: 7px; }
.fine b { color: var(--ink); font-weight: 600; }
.fine.short { display: none; }

.controls { position: fixed; z-index: 2; right: 16px; top: 50%; transform: translateY(-50%); display: grid; gap: 6px; }
.controls button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  outline: 1px solid var(--line-soft);
  outline-offset: -4px;
  background: var(--panel);
  font: 500 20px/1 var(--mono);
  box-shadow: 0 3px 10px var(--shadow);
}
.controls button:hover { background: var(--hover); }
.controls button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Title block */
.titleblock { right: 16px; bottom: 30px; width: 330px; padding: 0; font-size: 11px; outline: none; }
.titleblock::before, .titleblock::after { display: none; }
.tb-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--line-soft); }
.tb-main { border-bottom: 1px solid var(--line); padding: 7px 10px; }
.tb-main a { font: 600 13px var(--mono); letter-spacing: 0.16em; text-transform: uppercase; text-decoration: none; }
.tb-main a:hover { text-decoration: underline; }
.tb-main span { font: 14px var(--hand); color: var(--accent); }
.tb-grid { display: grid; grid-template-columns: 1fr 1fr; }
.tb-grid div { display: flex; flex-direction: column; padding: 4px 10px 5px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.tb-grid div:nth-child(2n) { border-right: 0; }
.tb-grid div:nth-last-child(-n + 2) { border-bottom: 0; }
.k { font-size: 8.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft); }
.tb-row .k { flex: none; }
.tb-row span:last-child { text-align: right; }

/* Detail sheet */
#card {
  position: fixed;
  z-index: 4;
  top: 16px;
  right: 16px;
  width: min(410px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 10px 34px var(--shadow);
  overscroll-behavior: contain;
}
.card-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.card-head span:first-child { font-weight: 600; }
#card-kind { color: var(--ink-soft); flex: 1; }
#card .close { width: 30px; height: 30px; border: 1px solid var(--line-soft); background: none; font: 20px/1 var(--mono); }
#card .close:hover { background: var(--hover); }
#card-body { padding: 12px 16px 18px; }
#card .loading { color: var(--ink-soft); }
.rev { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-bottom: 10px; }
.rev th, .rev td { border: 1px solid var(--line-soft); padding: 5px 7px; vertical-align: top; text-align: left; }
.rev th { width: 92px; font-weight: 400; font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.rev td b { font-weight: 600; }
.rev td.gap b { color: var(--gap); }
.rev .sym { display: inline-block; vertical-align: middle; margin: -4px 4px -4px -2px; }
.rev .sym canvas { display: block; }
#card h2 { font: 26px/1.1 var(--hand); margin: 10px 0 2px; }
#card h3 { font: 600 10.5px var(--mono); letter-spacing: 0.18em; text-transform: uppercase; margin: 16px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--line); }
#card p { margin: 4px 0; }
#card .addr { color: var(--ink-soft); margin-bottom: 10px; font-size: 12px; }
#card .badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.04em;
}
#card .badge.pe { border-color: var(--pe); color: var(--pe); }
#card .callout, #card .claim, #card .estimate {
  margin: 10px 0 0;
  padding: 9px 11px;
  border: 1px dashed var(--line-soft);
  font-size: 12.5px;
}
#card .callout.pe { border: 1px solid var(--pe); box-shadow: inset 3px 0 0 var(--pe); }
#card .callout.public { border: 1px solid var(--public); box-shadow: inset 3px 0 0 var(--public); }
#card .callout:not(.pe):not(.public) { border-color: var(--gap); }
#card .estimate { border-style: dotted; }
#card strong { font-weight: 600; }
#card small, #card .note { display: block; margin-top: 6px; font-size: 10.5px; color: var(--ink-soft); }
#card .traits { display: grid; gap: 0; border: 1px solid var(--line-soft); }
#card .trait { display: grid; grid-template-columns: 112px 1fr; gap: 8px; font-size: 11.5px; padding: 5px 7px; border-bottom: 1px solid var(--line-soft); }
#card .trait:last-child { border-bottom: 0; }
#card .trait > span:first-child { font-weight: 600; }
#card .trait.unknown > span:last-child { color: var(--ink-soft); }
#card a { color: var(--chain); }
#card .revnote { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }

.credit {
  position: fixed;
  z-index: 1;
  right: 16px;
  bottom: 8px;
  margin: 0;
  font-size: 10.5px;
  color: var(--ink-soft);
  text-align: right;
}
#status {
  position: fixed;
  z-index: 1;
  left: 50%;
  top: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  font: 24px var(--hand);
}
#status:empty { display: none; }

@media (max-width: 1060px) and (min-width: 721px) {
  .titleblock { width: 270px; }
}
@media (max-width: 720px) {
  .head { top: 8px; left: 8px; width: calc(100vw - 16px); padding: 10px 12px 12px; }
  .head h1 { font-size: 24px; margin: 2px 0 8px; }
  .lede { display: none; }
  .status { left: 8px; right: 8px; bottom: 24px; width: auto; padding: 8px 10px 8px; }
  .cols { display: none !important; }
  #rows { margin-top: 4px; }
  .cols, #rows button { grid-template-columns: 44px 1fr 30px 44px; gap: 5px; }
  #rows button { font-size: 11px; padding: 1px 2px; }
  .n { font-size: 12px; }
  .share { margin-top: 6px; }
  .key, .fine { display: none; }
  .fine.short { display: block; margin-top: 4px; padding-top: 4px; }
  .switch { margin-top: 2px; }
  .titleblock { display: none; }
  .controls { right: 8px; top: 148px; transform: none; }
  .controls button { width: 38px; height: 38px; }
  .credit { right: 8px; left: 8px; bottom: 5px; font-size: 10px; text-align: center; white-space: nowrap; overflow: hidden; }
  .credit .wide { display: none; }
  #card { top: auto; bottom: 0; right: 0; left: 0; width: auto; max-height: 62vh; }
}
@media (prefers-reduced-motion: reduce) {
  .share span, .knob::after { transition: none; }
}
