:root { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Segoe UI", Arial, sans-serif;
  color: #1c1c1c;
  background: #efeae1;
}

button, input, textarea { font: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid #1f4e79;
  outline-offset: 2px;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: #161616;
  color: #fff;
}

.app-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.app-header p {
  margin: 2px 0 0;
  color: #cfcfcf;
  font-size: 12px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
}

.editor, .preview-column {
  min-height: 0;
  overflow: auto;
}

.editor {
  background: #f6f3ec;
  border-right: 1px solid #d5cfc3;
}

.preview-column {
  background: #d9d3c7;
  padding: 18px 16px 40px;
}

.preview-label {
  width: 210mm;
  max-width: 100%;
  margin: 0 auto 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5c564c;
}

.btn {
  border: 1px solid #1f4e79;
  background: #1f4e79;
  color: #fff;
  border-radius: 4px;
  padding: 7px 12px;
  font-weight: 700;
}

.btn.secondary, .btn.ghost {
  background: #fff;
  color: #1c1c1c;
  border-color: #c9c2b4;
}

.btn.tiny { padding: 4px 8px; font-size: 12px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.print {
  background: #ffe14a;
  color: #161616;
  border-color: #161616;
}

.btn.secondary:hover { background: #f3f0e8; }

.app-header .btn.secondary {
  background: transparent;
  color: #fff;
  border-color: #6d6d6d;
}

.app-header .btn.secondary:hover { background: #2a2a2a; }

.btn.generate {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
}

.btn.mirror {
  width: 100%;
  text-align: left;
  background: #fff;
  color: #161616;
  border: 1px solid #161616;
}

.btn.mirror[aria-pressed="true"] { background: #ffe14a; }

.text-btn {
  border: 0;
  background: none;
  color: #1f4e79;
  font-weight: 700;
  padding: 0;
  text-decoration: underline;
}

.status-wrap {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #f6f3ec;
  padding: 10px 16px 0;
}

.status {
  margin: 0;
  background: #fff4b8;
  border: 1px solid #e2cc6a;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: pre-wrap;
}

.section {
  padding: 16px 16px 18px;
  border-bottom: 3px solid #161616;
}

.section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section h2 span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #161616;
  color: #fff;
  font-size: 11px;
  letter-spacing: 0;
}

.stack { display: flex; flex-direction: column; gap: 10px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

.field span, .label { color: #3f3c36; }

.label { margin: 0 0 4px; font-size: 12px; font-weight: 700; }

.editor input[type="text"],
.editor input[type="date"],
.editor textarea {
  width: 100%;
  font-weight: 500;
  padding: 7px 8px;
  border: 1px solid #ccc5b8;
  border-radius: 4px;
  background: #fff;
  color: #1c1c1c;
}

.editor textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.35;
}

.editor textarea[readonly] { background: #f3f0e8; }

.row, .line-row, .find-row, .tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.line-row input[type="text"] { flex: 1 1 180px; }

.find-row .field { flex: 1 1 180px; }

.line-block { display: flex; flex-direction: column; gap: 6px; }

.check {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}

.check.fn-hl,
.check.fn-blue {
  align-self: flex-start;
  border-radius: 4px;
  padding: 3px 8px;
  border: 1px solid #161616;
}

.check.fn-hl {
  background: #ffe14a;
  color: #161616;
}

.check.fn-hl:has(:checked) {
  box-shadow: inset 0 0 0 1px #161616;
}

.check.fn-ul { text-decoration: underline; text-underline-offset: 2px; }

.check.fn-blue {
  background: #1d4e9e;
  color: #fff;
  font-style: italic;
}

.check.fn-blue:has(:checked) {
  box-shadow: inset 0 0 0 2px #fff;
}

.hint {
  margin: 0;
  color: #5c584f;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.streets {
  margin: 0;
  color: #1f4e79;
  font-size: 12px;
  font-weight: 700;
}

.dir-card {
  background: #fff;
  border: 1px solid #e3dccf;
  border-left: 6px solid var(--c, #d50000);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dir-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.dir-card h3 { margin: 0; font-size: 13px; }

.swatches { display: inline-flex; gap: 4px; align-items: center; }

.swatch {
  width: 18px;
  height: 18px;
  border: 1px solid #222;
  border-radius: 50%;
  padding: 0;
}

.segment { display: flex; margin: 0 0 12px; }

.segment button {
  flex: 1;
  border-radius: 0;
  background: #fff;
  color: #161616;
  border: 1px solid #161616;
  padding: 8px;
  font-weight: 700;
}

.segment button + button { margin-left: -1px; }

.segment button[aria-pressed="true"],
.tools button[aria-pressed="true"]:not(.fn) {
  background: #161616;
  color: #fff;
  border-color: #161616;
}

.tools button.fn {
  border-color: #161616;
}

.tools button.fn[aria-pressed="true"] {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #161616;
}

.tools button.fn-pan {
  background: #fff;
  color: #161616;
  border-color: #c9c2b4;
}

.tools button.fn-pan[aria-pressed="true"] {
  background: #161616;
  color: #fff;
  border-color: #161616;
}

.tools button.fn-draw {
  background: var(--line, #d50000);
  color: var(--ink, #fff);
}

.tools button.fn-work {
  background: #ffe14a;
  color: #161616;
}

.tools button.fn-closed {
  background: #d50000;
  color: #fff;
}

.tools button.fn-temp {
  background: #2e7d32;
  color: #fff;
}

.tools button.fn-label {
  background: #1f4e79;
  color: #fff;
}

.tools button.fn-zone-rect,
.tools button.fn-zone-poly,
.tools button.fn-shade {
  background: #6e6e6e;
  color: #fff;
}

.tools button.fn-hazard {
  background: repeating-linear-gradient(-45deg, #d50000 0 5px, #ffe14a 5px 10px);
  color: #161616;
  padding: 2px;
}

.tools button.fn-hazard span {
  display: inline-block;
  background: #ffe14a;
  padding: 2px 6px;
  border-radius: 2px;
}

.tools button.fn:hover:not(:disabled) { filter: brightness(0.94); }

.prompt {
  background: #fff;
  border: 1px solid #161616;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.prompt strong { display: block; font-size: 14px; margin-bottom: 4px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #c9c2b4;
  background: #fff;
  border-radius: 99px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 12px;
}

.chip.on { background: #161616; color: #fff; border-color: #161616; }

.chip i { width: 9px; height: 9px; border-radius: 50%; display: block; }

.chip:disabled { opacity: 0.7; cursor: default; }

.drop {
  border: 1px dashed #8a8172;
  background: #fff;
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.drop p { margin: 0; font-size: 13px; }

.thumb { max-width: 100%; max-height: 140px; border: 1px solid #ccc; }

.sheet {
  width: 210mm;
  max-width: 100%;
  margin: 0 auto;
  padding: 12mm 14mm 16mm;
  background: #fff;
  color: #111;
  /* Arial's lowercase l is a bare stem. PDF viewers thicken that stem, so the letter looks bold. Calibri's l has a foot, and it has a real bold. */
  font-family: Calibri, Candara, sans-serif;
  font-synthesis: none;
  font-size: 12.5px;
  line-height: 1.38;
}

.sheet p { margin: 0 0 8px; }

.org {
  font-weight: 700;
  font-size: 13px;
  margin: 0 0 3px;
}

.banner {
  background: #000;
  color: #fff;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 18px;
  padding: 5px 8px;
}

.title-box {
  border: 2px solid #000;
  margin: 8px 0 10px;
  padding: 8px 12px 9px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
}

.title-box.caps .title-line { text-transform: uppercase; }

.title-line { margin: 0; }

.title-line + .title-line { margin-top: 1px; }

.title-placeholder { color: #9a9a9a; font-weight: 600; }

.is-hl, mark {
  background: #ffe14a;
  color: inherit;
  padding: 0 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.is-center { text-align: center; }

.is-ul { text-decoration: underline; }

#out-intro p { font-weight: 700; }

#out-dirs {
  margin: 6px 0 8px 1.15em;
  padding: 0;
}

#out-dirs:empty, #out-dirs[hidden] { display: none; }

#out-dirs li { margin: 0 0 7px; }

.dir-label { font-weight: 700; }

.thanks {
  text-align: center;
  font-weight: 700;
  margin: 8px 0;
}

.thanks.blue {
  color: #1d4e9e;
  font-style: italic;
}

.signoff {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.35;
}

.signoff p { margin: 0; }

.visual-frame {
  position: relative;
  margin: 10px 0 8px;
  border: 1px solid #9a9a9a;
  min-height: 105mm;
  background: #e5e0d6;
}

#map-canvas { height: 105mm; width: 100%; background: #e5e0d6; }

#map-canvas.is-locked .leaflet-control-zoom a {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

.visual-frame.is-photo {
  border: 0;
  min-height: 0;
  background: transparent;
  display: flex;
  justify-content: center;
}

.visual-frame.is-photo #map-canvas { display: none; }

#photo-view { display: none; max-width: 92%; height: auto; }

.visual-frame.is-photo #photo-view:not([hidden]) { display: block; }

.photo-empty {
  display: none;
  width: 100%;
  text-align: center;
  color: #777;
  border: 1px dashed #bbb;
  padding: 28px 12px;
  background: #fff;
}

.visual-frame.is-photo.is-empty .photo-empty { display: block; }

.north-rose {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 500;
  width: 34px;
  height: 42px;
  display: grid;
  justify-items: center;
  align-content: end;
  pointer-events: none;
}

.north-rose b {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #222;
  display: grid;
  place-items: center;
  font: 700 12px Calibri, Candara, sans-serif;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.north-rose::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #111;
  margin-bottom: -6px;
}

.map-hint {
  position: absolute;
  z-index: 500;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: 88%;
  margin: 0;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #222;
  padding: 6px 10px;
  font: 600 12px/1.35 "Segoe UI", sans-serif;
  text-align: center;
}

.plain-icon.leaflet-div-icon {
  background: transparent;
  border: 0;
  overflow: visible;
}

.arrow-rot {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}

.arrow-head {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 12px solid var(--c, #f15a00);
  filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
}

.vertex {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--c, #d50000);
  box-shadow: 0 0 0 1px #fff;
}

.note-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #222;
  background: #1f4e79;
}

.note-dot.closed {
  background: #d50000;
  box-shadow: 0 0 0 1px #d50000;
}

.note-dot.temp { background: #2e7d32; }

.note-dot.work {
  background: #ffe14a;
  box-shadow: 0 0 0 1px #111;
}

.note-dot, .work-flag, .callout { cursor: grab; }

.work-flag {
  width: 132px;
  background: #ffe14a;
  border: 2px solid #111;
  color: #111;
  font: 700 11px/1.25 Calibri, Candara, sans-serif;
  text-align: center;
  padding: 4px 6px 6px;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
}

.callout {
  width: max-content;
  max-width: 180px;
  background: #fff;
  color: #111;
  border: 1px solid #222;
  border-radius: 2px;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
  font: 700 11px/1.3 Calibri, Candara, sans-serif;
  padding: 3px 6px;
}

.leaflet-tooltip.note-tip {
  background: #fff;
  color: #111;
  border: 1px solid #222;
  border-radius: 2px;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
  font: 700 11px/1.3 Calibri, Candara, sans-serif;
  padding: 3px 6px;
  max-width: 180px;
}

.leaflet-tooltip.note-tip::before { border-top-color: #222; }

.sheet .leaflet-container {
  font-family: Calibri, Candara, sans-serif;
  font-synthesis: none;
}

.map-tiles-print .leaflet-tile {
  opacity: 1 !important;
}

.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(255, 255, 255, 0.8) !important;
}

@media (max-width: 1100px) {
  html, body, .app { height: auto; }
  .layout { display: block; }
  .editor, .preview-column { overflow: visible; }
  .editor { border-right: 0; border-bottom: 1px solid #d5cfc3; }
  .app-header { align-items: flex-start; flex-direction: column; }
}

@media print {
  @page { size: A4; margin: 10mm; }

  html, body, .app, .layout, .preview-column {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
    background: #fff !important;
  }

  .no-print, .app-header, .editor, .preview-label { display: none !important; }

  .preview-column { padding: 0; }

  .sheet {
    width: auto;
    max-width: none;
    padding: 0;
    box-shadow: none;
  }

  .leaflet-control-zoom, .vertex-icon, .map-hint { display: none !important; }

  .leaflet-container.is-print-sharp .map-tiles-screen { display: none !important; }

  .visual-frame, #map-canvas { break-inside: avoid; }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
