:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #090d16;
  --panel: #111827;
  --panel-2: #172033;
  --border: #2a3448;
  --text: #f4f7fb;
  --muted: #98a4b8;
  --accent: #ff8a38;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { color: inherit; }

.topbar {
  height: 70px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: rgba(17, 24, 39, .96); border-bottom: 1px solid var(--border);
}
.brand, .toolbar, .brand > div { display: flex; align-items: center; }
.brand { gap: 11px; }
.brand > div { align-items: flex-start; flex-direction: column; }
.brand span:last-child { color: var(--muted); font-size: 12px; }
.brand-mark { color: var(--accent); font-size: 30px; line-height: 1; }
.toolbar { gap: 8px; }
.toolbar button, .search-wrap input {
  height: 38px; border: 1px solid var(--border); border-radius: 9px; background: #0d1422;
}
.toolbar button { padding: 0 13px; cursor: pointer; }
.toolbar button:hover { border-color: #526079; background: #172033; }
.toolbar .icon-button { width: 38px; padding: 0; font-size: 20px; }
#zoomLabel { min-width: 48px; text-align: center; color: var(--muted); font-size: 13px; }
.search-wrap input { width: min(300px, 30vw); padding: 0 12px; color: var(--text); outline: none; }
.search-wrap input:focus { border-color: var(--accent); }

main { height: calc(100vh - 70px); display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.map-wrap { position: relative; overflow: hidden; background: radial-gradient(circle at 50% 45%, #172036 0, #0a0f1a 68%); }
#mapCanvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#mapCanvas.dragging { cursor: grabbing; }
.map-help { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); pointer-events: none; padding: 7px 11px; border: 1px solid #303b51; border-radius: 20px; background: rgba(8, 13, 23, .82); color: var(--muted); font-size: 12px; white-space: nowrap; }
.search-results { position: absolute; top: 12px; right: 12px; width: min(350px, calc(100% - 24px)); max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: #111827; box-shadow: 0 16px 50px #0008; }
.search-result { display: block; width: 100%; padding: 11px 13px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; }
.search-result:hover { background: #1a2437; }
.search-result strong, .search-result span { display: block; }
.search-result span { color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.no-results { padding: 16px; color: var(--muted); }

.editor { border-left: 1px solid var(--border); background: var(--panel); overflow-y: auto; padding: 24px; }
.empty-state { min-height: 100%; display: grid; align-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-state h1 { color: var(--text); font-size: 20px; margin: 18px 0 4px; }
.empty-state p { max-width: 260px; line-height: 1.5; font-size: 14px; }
.empty-pentagon { font-size: 64px; color: #263249; }
.editor-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.editor-heading h1 { margin: 4px 0 0; font-size: 25px; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.close-button { border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }
label, legend { display: block; color: #cbd3e0; font-size: 13px; font-weight: 650; }
input, textarea { width: 100%; margin-top: 7px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; background: #0c1320; color: var(--text); outline: none; resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #ff8a381c; }
textarea { line-height: 1.5; }
form > label { margin-bottom: 20px; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 10px 0 12px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px #fff3; }
.swatch:nth-child(1) { background: #ff7f27; }
.swatch:nth-child(2) { background: #f5c542; }
.swatch:nth-child(3) { background: #63c174; }
.swatch:nth-child(4) { background: #36b5b0; }
.swatch:nth-child(5) { background: #4d91e8; }
.swatch:nth-child(6) { background: #7668d9; }
.swatch:nth-child(7) { background: #d85d91; }
.swatch.selected { border-color: white; box-shadow: 0 0 0 2px var(--accent); }
.custom-color { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.custom-color input { width: 40px; height: 34px; margin: 0; padding: 2px; cursor: pointer; }
.primary-button, .danger-button { width: 100%; border-radius: 9px; padding: 11px 14px; cursor: pointer; }
.primary-button { border: 1px solid #ff9a55; background: var(--accent); color: #1a0c03; font-weight: 800; }
.primary-button:hover { background: #ff9b55; }
.danger-button { margin-top: 9px; border: 1px solid #463142; background: transparent; color: #d5a2ad; }
.danger-button:hover { background: #301d25; }
.save-status { min-height: 24px; color: var(--muted); font-size: 12px; }

dialog { width: min(410px, calc(100% - 32px)); border: 1px solid var(--border); border-radius: 14px; padding: 24px; background: var(--panel); color: var(--text); box-shadow: 0 24px 80px #000c; }
dialog::backdrop { background: #02050bbf; }
dialog h2 { margin-top: 0; }
dialog p { color: var(--muted); line-height: 1.45; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.dialog-actions button { width: auto; border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; background: #182135; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .topbar { height: auto; min-height: 70px; gap: 10px; flex-wrap: wrap; padding: 10px 12px; }
  .brand span:last-child, #zoomLabel, #zoomOutButton, #zoomInButton { display: none; }
  .search-wrap input { width: 180px; }
  main { height: calc(100vh - 70px); grid-template-columns: 1fr; }
  .editor { position: absolute; z-index: 5; right: 0; top: 70px; bottom: 0; width: min(360px, 100%); box-shadow: -16px 0 50px #0009; }
  .editor:has(.empty-state:not([hidden])) { display: none; }
}
