:root {
  color-scheme: light;
  --site-forest: #173f2d;
  --site-forest-dark: #0e2d20;
  --site-cream: #f4f0df;
  --site-paper: #fffef9;
  --site-ink: #17241c;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: #f7f6ef;
  color: var(--site-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

.site-header {
  align-items: center;
  background: var(--site-paper);
  border-bottom: 1px solid #d9ddd7;
  display: flex;
  justify-content: space-between;
  padding: 14px max(24px, calc((100vw - 1500px) / 2));
}
.site-brand {
  align-items: center;
  color: var(--site-forest);
  display: flex;
  gap: 10px;
  text-decoration: none;
}
.site-brand strong { display: block; font-size: 22px; line-height: 1; }
.site-brand small { color: #5d695f; display: block; font-size: 11px; margin-top: 4px; }
.site-mark { color: #6c7d52; font-size: 30px; }
.site-header nav { display: flex; gap: 22px; }
.site-header nav a { color: #314438; font-size: 14px; font-weight: 650; text-decoration: none; }
.site-header nav a:hover { color: #0b6b43; }

main { margin: 0 auto; max-width: 1560px; padding: 0 24px 54px; }
.intro { margin: 46px auto 26px; max-width: 900px; text-align: center; }
.intro .eyebrow {
  color: #6d7547;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.intro h1 { color: var(--site-forest); font-size: clamp(30px, 4vw, 52px); line-height: 1.05; margin: 0; }
.intro p:last-child { color: #526057; font-size: 17px; margin: 16px auto 0; max-width: 760px; }

.hka-app {
  --hka-forest: #234735;
  --hka-olive: #66724a;
  --hka-earth: #8a6747;
  --hka-cream: #f2edd6;
  --hka-line: #d4d8d1;
  --hka-paper-width: 297mm;
  --hka-paper-height: 210mm;
  color: #1f2923;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
  margin: 24px auto;
  max-width: 1500px;
}

.hka-toolbar {
  align-items: end;
  background: #fff;
  border: 1px solid var(--hka-line);
  border-radius: 10px;
  box-shadow: 0 5px 18px rgba(24, 48, 35, .08);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(260px, 2fr) repeat(6, minmax(112px, 1fr)) auto;
  margin-bottom: 16px;
  padding: 16px;
  position: relative;
  z-index: 20;
}

.hka-field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
}

.hka-field input,
.hka-field select,
.hka-toolbar button {
  border: 1px solid #aeb8b1;
  border-radius: 6px;
  box-sizing: border-box;
  font: inherit;
  min-height: 42px;
  padding: 8px 10px;
  width: 100%;
}

.hka-inline {
  display: flex;
  gap: 6px;
}

.hka-inline input { flex: 1; }
.hka-inline button { flex: 0 0 72px; }

.hka-toolbar button,
.hka-zoom-controls button {
  background: #eef1ed;
  color: #1c3327;
  cursor: pointer;
  font-weight: 700;
}

.hka-toolbar button:hover,
.hka-zoom-controls button:hover { background: #e0e7df; }
.hka-toolbar button:disabled { cursor: wait; opacity: .65; }
.hka-toolbar .hka-primary { background: var(--hka-forest); color: #fff; }
.hka-toolbar .hka-primary:hover { background: #173426; }

.hka-search-field { position: relative; }
.hka-search-results {
  background: #fff;
  border: 1px solid #aeb8b1;
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .15);
  left: 0;
  max-height: 260px;
  overflow: auto;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
}

.hka-search-results button {
  background: #fff;
  border: 0;
  border-bottom: 1px solid #e5e8e5;
  border-radius: 0;
  font-weight: 500;
  min-height: 0;
  padding: 10px 12px;
  text-align: left;
}
.hka-search-results button:hover { background: #f3f6f2; }

.hka-beta-note,
.hka-map-notice {
  background: #fff7d7;
  border: 1px solid #e7d37a;
  border-radius: 6px;
  color: #51430a;
  padding: 10px 12px;
}

.hka-coordinate-readout {
  align-items: center;
  background: #edf2ec;
  border: 1px solid #cbd6cd;
  border-radius: 7px;
  display: flex;
  gap: 12px;
  margin: 10px 0;
  padding: 9px 12px;
}
.hka-coordinate-readout span { color: #5c685f; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.hka-coordinate-readout strong { color: #183d2b; font-size: 14px; }

.hka-sheet {
  background: #fff;
  border: 1px solid #c7ccc8;
  box-shadow: 0 7px 24px rgba(28, 47, 36, .12);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  max-width: 100%;
  overflow: hidden;
  padding: 14px;
  width: 100%;
}

.hka-sheet.hka-a4.hka-landscape,
.hka-sheet.hka-a3.hka-landscape { aspect-ratio: 297 / 210; }
.hka-sheet.hka-a4.hka-portrait,
.hka-sheet.hka-a3.hka-portrait { aspect-ratio: 210 / 297; max-width: 920px; }

.hka-sheet-header {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 4px 10px;
}

.hka-sheet-header h2 {
  color: var(--hka-forest);
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1.1;
  margin: 0 0 3px;
}

.hka-sheet-header p { font-size: 12px; margin: 0; }
.hka-north { font-size: 14px; font-weight: 800; height: 48px; position: relative; text-align: center; width: 42px; }
.hka-north span { display: block; }
.hka-north i {
  border-bottom: 14px solid var(--hka-forest);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  display: block;
  height: 0;
  margin: 2px auto 0;
  position: relative;
  width: 0;
}
.hka-north i::after { background: var(--hka-forest); content: ""; height: 20px; left: -1px; position: absolute; top: 12px; width: 2px; }

.hka-map {
  background: #dbe4dc;
  cursor: grab;
  flex: 1 1 auto;
  min-height: 500px;
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
}
.hka-map:active { cursor: grabbing; }
.hka-tiles { inset: 0; overflow: hidden; position: absolute; }
.hka-tile {
  image-rendering: auto;
  max-width: none !important;
  opacity: 0;
  position: absolute;
  transition: opacity .15s linear;
  user-select: none;
}
.hka-tile.hka-loaded { opacity: 1; }
.hka-overlay { height: 100%; inset: 0; pointer-events: none; position: absolute; width: 100%; }

.hka-zoom-controls {
  display: flex;
  flex-direction: column;
  left: 10px;
  position: absolute;
  top: 10px;
}
.hka-zoom-controls button {
  border: 0;
  border-bottom: 1px solid #c7cec8;
  border-radius: 0;
  font-size: 22px;
  height: 36px;
  line-height: 1;
  padding: 0;
  width: 38px;
}
.hka-zoom-controls button:first-child { border-radius: 5px 5px 0 0; }
.hka-zoom-controls button:last-child { border-bottom: 0; border-radius: 0 0 5px 5px; }

.hka-scale-bar {
  background: rgba(255, 255, 255, .86);
  border-bottom: 3px solid #111;
  border-left: 2px solid #111;
  border-right: 2px solid #111;
  bottom: 31px;
  box-sizing: border-box;
  color: #111;
  font-size: 11px;
  font-weight: 700;
  left: 12px;
  padding: 1px 3px 2px;
  text-align: center;
}
.hka-attribution {
  background: rgba(255, 255, 255, .86);
  bottom: 0;
  font-size: 9px;
  left: 0;
  padding: 3px 6px;
  position: absolute;
  right: 0;
  text-align: right;
}
.hka-map-status {
  background: rgba(255, 255, 255, .9);
  border-radius: 4px;
  color: #263a2f;
  font-size: 12px;
  left: 50%;
  padding: 6px 10px;
  pointer-events: none;
  position: absolute;
  top: 10px;
  transform: translateX(-50%);
}
.hka-map-status:empty { display: none; }
.hka-map-coordinate {
  background: rgba(20, 48, 33, .88);
  border-radius: 4px;
  bottom: 31px;
  color: #fff;
  font-size: 11px;
  left: 50%;
  padding: 4px 7px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.hka-sheet-footer {
  align-items: center;
  display: grid;
  flex: 0 0 auto;
  font-size: 10px;
  gap: 6px 14px;
  grid-template-columns: 1fr auto;
  padding: 8px 3px 0;
}
.hka-sheet-footer p { grid-column: 1 / -1; margin: 0; }
.hka-calibration { text-align: center; }
.hka-calibration span { display: block; margin-bottom: 2px; }
.hka-calibration i { border-top: 1px solid #111; display: block; height: 3px; width: 100mm; }
.hka-help { color: #536158; font-size: 13px; margin: 10px 0 0; text-align: center; }

.info-section {
  background: var(--site-paper);
  border: 1px solid #d9ddd7;
  border-radius: 10px;
  margin: 34px auto 0;
  max-width: 1100px;
  padding: 26px 30px;
}
.info-section h2 { color: var(--site-forest); margin: 0 0 12px; }
.info-section li + li { margin-top: 8px; }
.source-section p { margin-bottom: 0; }
.site-footer {
  background: var(--site-forest-dark);
  color: #edf4ef;
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  padding: 20px max(24px, calc((100vw - 1500px) / 2));
}

@media (max-width: 1150px) {
  .hka-toolbar { grid-template-columns: repeat(3, 1fr); }
  .hka-search-field { grid-column: span 2; }
  .hka-actions { align-self: end; }
}

@media (max-width: 700px) {
  .site-header { align-items: flex-start; gap: 16px; }
  .site-header nav { display: none; }
  main { padding: 0 10px 38px; }
  .intro { margin-top: 30px; }
  .hka-toolbar { grid-template-columns: 1fr 1fr; }
  .hka-search-field,
  .hka-actions { grid-column: 1 / -1; }
  .hka-sheet { padding: 7px; }
  .hka-map { min-height: 420px; }
  .hka-sheet-footer { grid-template-columns: 1fr; }
  .hka-calibration { display: none; }
}

@media print {
  html,
  body.hka-printing {
    height: 100%;
    margin: 0 !important;
    overflow: hidden;
    padding: 0 !important;
  }
  body.hka-printing .site-header,
  body.hka-printing .intro,
  body.hka-printing .hka-toolbar,
  body.hka-printing .hka-beta-note,
  body.hka-printing .hka-coordinate-readout,
  body.hka-printing .hka-help,
  body.hka-printing .info-section,
  body.hka-printing .site-footer {
    display: none !important;
  }
  body.hka-printing main,
  body.hka-printing #hka-map-app {
    margin: 0 !important;
    max-width: none !important;
    padding: 0 !important;
  }
  body.hka-printing #hka-map-app { height: 0 !important; }
  body.hka-printing #hka-sheet {
    border: 0;
    box-shadow: none;
    height: var(--hka-paper-height) !important;
    left: 0;
    margin: 0 !important;
    max-width: none !important;
    padding: 10mm;
    position: absolute;
    top: 0;
    width: var(--hka-paper-width) !important;
  }
  body.hka-printing .hka-map { min-height: 0; }
  body.hka-printing .hka-zoom-controls,
  body.hka-printing .hka-map-status { display: none !important; }
  body.hka-printing .hka-sheet-header h2 { font-size: 16pt; }
  body.hka-printing .hka-tile { transition: none; }
  body.hka-printing .hka-map-coordinate { display: none !important; }
}
