:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1d2433;
  --muted: #5d6676;
  --border: #dde1e7;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e8efff;
  --danger: #c62828;
  --success-bg: #ecf8ef;
  --success-border: #9fd5ab;
  --error-bg: #fdecec;
  --error-border: #f2a7a7;
  --focus: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c;
    --surface: #181d26;
    --surface-2: #212734;
    --text: #e6e9ef;
    --muted: #9aa3b2;
    --border: #2d3442;
    --accent: #5b8cff;
    --accent-text: #0b1020;
    --accent-soft: #1d2a4a;
    --danger: #ff6b6b;
    --success-bg: #12291a;
    --success-border: #2f6b40;
    --error-bg: #2e1517;
    --error-border: #7a3238;
    --focus: #8ab0ff;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #11151c;
  --surface: #181d26;
  --surface-2: #212734;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --border: #2d3442;
  --accent: #5b8cff;
  --accent-text: #0b1020;
  --accent-soft: #1d2a4a;
  --danger: #ff6b6b;
  --success-bg: #12291a;
  --success-border: #2f6b40;
  --error-bg: #2e1517;
  --error-border: #7a3238;
  --focus: #8ab0ff;
  --shadow: none;
  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; padding-bottom: 48px; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 12px; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.92em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.prose { white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- header / footer ---------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 12px; }
.brand { display: inline-flex; align-items: center; min-width: 0; text-decoration: none; }
.brand img { display: block; height: 34px; width: auto; }
.header-inner .btn { white-space: nowrap; flex: none; }
@media (max-width: 480px) {
  .hide-sm { display: none; }
}
@media (max-width: 420px) {
  .brand img { height: 28px; }
}
.site-footer { border-top: 1px solid var(--border); padding: 20px 0; font-size: 0.85rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.site-footer a { color: inherit; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; margin-left: auto; }
.btn-danger:hover { background: var(--error-bg); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

/* ---------- home ---------- */

.hero { padding: 24px 0 8px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 640px; }
.type-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 24px 0 40px; }
.type-card {
  display: grid; gap: 4px; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; transition: border-color 0.15s, transform 0.15s;
}
.type-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.type-card-icon { font-size: 2rem; }
.type-card-label { font-weight: 700; font-size: 1.1rem; }
.type-card-text { color: var(--muted); font-size: 0.95rem; }
.how, .mine { margin-bottom: 40px; }
.steps { padding-left: 20px; display: grid; gap: 8px; }
.mine-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.mine-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.mine-list .mine-icon { font-size: 1.4rem; }
.mine-list .mine-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.mine-list .mine-links { display: flex; gap: 12px; font-size: 0.9rem; }

/* ---------- form ---------- */

.page-head { margin-bottom: 16px; }
.entry-form { display: grid; gap: 16px; }
.card {
  margin: 0; padding: 20px; border-radius: var(--radius); min-width: 0;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.card-title { font-weight: 700; font-size: 1.05rem; padding: 0; margin-bottom: 12px; float: left; width: 100%; }
.card-title + * { clear: both; }
.field { display: grid; gap: 6px; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > legend { font-weight: 600; font-size: 0.95rem; padding: 0; }
.req { font-weight: 400; font-size: 0.8rem; color: var(--muted); margin-left: 4px; }
input[type="text"], input[type="url"], input[type="tel"], input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.9rem; margin: 0; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0; }
.grid-2 { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.details-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.details-grid .field:last-child { margin-bottom: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px;
  border: 1px solid var(--border); border-radius: 10px; font-weight: 600; cursor: pointer; text-align: center;
}
.segment input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.segment input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.class-field { margin: 16px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip > span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px; font-weight: 600; font-size: 0.93rem; cursor: pointer;
  background: var(--surface);
}
.chip > span:hover { background: var(--surface-2); }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Show only the sections that apply to the chosen type (works without JavaScript). */
.only-event, .only-place, .only-device, .only-ev { display: none; }
.entry-form:has(#type-event:checked) .only-event,
.entry-form:has(#type-place:checked) .only-place,
.entry-form:has(#type-device:checked) .only-device { display: block; }
.entry-form:has(option[value="EV charger"]:checked) .only-ev { display: grid; }

.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }
.geo-results {
  list-style: none; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); max-height: 240px; overflow: auto;
}
.geo-results button {
  display: block; width: 100%; text-align: left; padding: 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 0.93rem; cursor: pointer;
}
.geo-results button:hover, .geo-results button:focus-visible { background: var(--surface-2); }
.geo-results .geo-empty { padding: 10px; color: var(--muted); font-size: 0.93rem; }

.map { width: 100%; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); z-index: 0; }
.map-form { height: 320px; margin: 4px 0 14px; cursor: crosshair; }
.map-entry { height: 300px; margin: 20px 0; }
.coords .field { margin-bottom: 10px; }

.pin-row { display: flex; gap: 20px; align-items: flex-start; }
.pin-controls { flex: 1; min-width: 0; }
.pin-preview { flex: none; width: 64px; height: 64px; position: relative; margin-top: 4px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.icon-btn {
  height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  font-size: 1.25rem; cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.is-on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.icon-input { max-width: 120px; text-align: center; font-size: 1.2rem !important; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch:has(input:checked) { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
.swatch:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 4px; }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- map pins ---------- */

.otm-pin { background: none; border: 0; }
.pin-preview, .otm-pin-body {
  --size: 44px;
}
.otm-pin-body, .pin-preview > span {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: var(--size); height: var(--size);
}
.otm-pin-body::before, .pin-preview > span::before {
  content: ""; position: absolute; inset: 0;
  background: var(--pin, #2563eb); border: 2px solid #fff;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgb(0 0 0 / 35%);
}
.otm-pin-emoji, .pin-preview > span {
  display: flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1;
}
.otm-pin-emoji { position: absolute; inset: 0; padding-bottom: 4px; }
.pin-preview > span { padding-bottom: 4px; }
.pin-preview > span::before { z-index: -1; }
.pin-preview { isolation: isolate; }

/* ---------- entry page ---------- */

.alert { padding: 16px; border-radius: var(--radius); border: 1px solid; margin-bottom: 16px; }
.alert-error { background: var(--error-bg); border-color: var(--error-border); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); }
.alert h2 { font-size: 1.15rem; }
.copy-row { display: flex; gap: 8px; margin-bottom: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }

.entry {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.entry > section { margin-top: 24px; }
.entry-head { display: flex; gap: 16px; align-items: flex-start; }
.entry-badge {
  flex: none; width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center;
  font-size: 2rem; background: color-mix(in srgb, var(--pin) 16%, var(--surface)); border: 2px solid var(--pin);
}
.entry-kind { color: var(--muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.entry-head h1 { overflow-wrap: anywhere; }
.entry-when { font-weight: 600; margin-bottom: 4px; }
.entry-where { color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.status-pill { display: inline-block; margin-top: 8px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 0.85rem; font-weight: 600; }
.section-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.open-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.details { margin: 0; display: grid; gap: 0; }
.details > div { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.details > div:first-child { border-top: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.entry-foot { margin-top: 28px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

.message { padding: 48px 0; text-align: center; }
.owner-links { display: inline-flex; gap: 16px; }

/* ---------- submit to maps ---------- */

.crumb { margin: 0 0 12px; font-size: 0.93rem; }
.crumb a { text-decoration: none; }
.copy-card { margin-bottom: 16px; }
.copy-list { margin: 0; display: grid; }
.copy-list > div { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); align-items: start; }
.copy-list > div:first-child { border-top: 0; }
.copy-list dt { color: var(--muted); padding-top: 6px; }
.copy-list dd { margin: 0; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; min-width: 0; }
.copy-value { padding-top: 6px; min-width: 0; }
.copy-list .btn { flex: none; }
.service-list { display: grid; gap: 16px; }
.service-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.service-head h2 { margin: 0; font-size: 1.15rem; }
.service-steps { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; background: var(--surface-2); white-space: nowrap; }
.badge-live { background: var(--success-bg); border: 1px solid var(--success-border); }
.badge-under_review, .badge-submitted { background: var(--accent-soft); color: var(--accent); }
.badge-error { background: var(--error-bg); border: 1px solid var(--error-border); }
.track { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-weight: 600; font-size: 0.93rem; }
.track select { width: auto; min-height: 38px; padding: 6px 10px; }
.nearby { margin: 0 0 10px; padding-left: 20px; display: grid; gap: 4px; }
.plain { margin: 0; padding-left: 18px; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.88rem; line-height: 1.5; }
.confirm { align-items: flex-start; margin-top: 12px; font-size: 0.95rem; }
.confirm input { margin-top: 4px; }
a.btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
@media (max-width: 560px) {
  .copy-list > div { grid-template-columns: 1fr; gap: 2px; }
  .copy-list dt { padding-top: 0; }
}

@media (max-width: 560px) {
  .card, .entry { padding: 16px; }
  .pin-row { flex-direction: column; gap: 12px; }
  .details > div { grid-template-columns: 1fr; gap: 2px; }
  .segment span { flex-direction: column; gap: 0; font-size: 0.92rem; }
  .btn-danger { margin-left: 0; }
}
