:root {
  --bg: #FAF6EE;
  --surface: #F3ECDE;
  --ink: #26231F;
  --muted: #6B655B;
  --border: #E2D9C8;
  --accent: #4A7C2A;
  --accent-hover: #6B9A3D;
  --accent-soft: #EAF3E2;
  --link: #0066CC;
  --error-ink: #9E2A2B;
  --error-bg: #FBEAEA;
  --error-border: #E8C5C5;
  --shadow: 0 1px 4px rgba(38, 35, 31, 0.08);
  --radius-chip: 6px;
  --radius-card: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 500;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-icon {
  display: block;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.about-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-chip);
  cursor: pointer;
  white-space: nowrap;
}

.about-btn:hover {
  border-color: var(--accent-hover);
  color: var(--accent);
}

.about-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.lang-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  padding: 2px;
  flex-shrink: 0;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.lang-btn:hover {
  color: var(--ink);
}

.lang-btn.is-active {
  background: var(--accent);
  color: #FAF6EE;
}

/* Map stage */
.map-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.map-canvas {
  width: 100%;
  height: 100%;
  background: var(--surface);
  z-index: 1;
}

/* Status banner */
.status-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  max-width: calc(100% - 28px);
  padding: 8px 14px;
  border-radius: var(--radius-card);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  text-align: center;
}

.status-banner.is-success {
  background: var(--accent-soft);
  border-color: #C7DFB3;
  color: #2E5218;
}

.status-banner.is-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-ink);
}

/* Floating bottom controls */
.bottom-controls {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 550;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, calc(100% - 24px));
  pointer-events: none;
}

.bottom-controls > button {
  pointer-events: auto;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-card);
  background: var(--accent);
  color: #FAF6EE;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

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

.btn-drop {
  flex: 1;
  box-shadow: var(--shadow);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
}

.btn-secondary:hover:not(:disabled) {
  background: #EAE1CE;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--surface);
  color: var(--accent);
}

/* Bottom sheets */
.bottom-sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 650;
  width: min(520px, 100%);
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-top-left-radius: var(--radius-card);
  border-top-right-radius: var(--radius-card);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sheet-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  background: var(--surface);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.btn-close:hover {
  color: var(--ink);
}

.drop-hint {
  margin: 0 0 12px;
  padding: 8px 10px;
  background: var(--accent-soft);
  border: 1px solid #D3E4C5;
  border-radius: var(--radius-chip);
  color: #2E5218;
  font-size: 13px;
  font-weight: 500;
}

.drop-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.char-counter {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.size-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.size-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.size-chip:hover {
  border-color: var(--accent-hover);
}

.size-chip.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.chip-name {
  font-size: 13px;
  font-weight: 600;
}

.chip-sub {
  font-size: 11px;
  color: var(--muted);
}

.size-chip.is-selected .chip-sub {
  color: #365C1E;
}

.text-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  background: #FFFDF8;
  color: var(--ink);
  font-size: 14px;
}

.text-input::placeholder {
  color: var(--muted);
}

.text-input:focus {
  border-color: var(--accent);
}

.form-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-chip);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-ink);
  font-size: 13px;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 8px;
  margin-top: 2px;
}

/* Pin detail sheet */
.detail-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.size-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.detail-sub {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-chip);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.detail-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 14px;
  word-break: break-word;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.directions-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--link);
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px 4px;
}

.directions-link:hover {
  color: #004C99;
}

.detail-actions .btn-primary {
  flex: 1;
  max-width: 240px;
}

/* About / Mission sheet */
.about-body {
  max-height: 62dvh;
  overflow-y: auto;
  padding-right: 2px;
}

.about-text {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}

.about-text:last-child {
  margin-bottom: 0;
}

.about-subheading {
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.about-list {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}

.about-list li {
  margin-bottom: 6px;
}

.about-list li:last-child {
  margin-bottom: 0;
}

/* Custom MapLibre markers (44x44 touch hit area) */
.bd-marker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.bd-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #FAF6EE;
  color: #FAF6EE;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.bd-pin.is-selected {
  background: #2E5218;
  border-color: #FAF6EE;
  outline: 2px solid var(--accent);
}

.bd-pin-draft {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #FAF6EE;
  border: 3px solid var(--accent);
  color: var(--accent);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: grab;
}

.bd-user-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0066CC;
  border: 2px solid #FAF6EE;
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* Style MapLibre controls to match warm theme */
.maplibregl-ctrl-group {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-chip) !important;
  box-shadow: var(--shadow) !important;
}

.maplibregl-ctrl-group button {
  background: var(--bg) !important;
  color: var(--ink) !important;
  border-color: var(--border) !important;
}

.maplibregl-ctrl-group button:hover {
  background: var(--surface) !important;
}

.maplibregl-ctrl-attrib {
  background: rgba(250, 246, 238, 0.88) !important;
  color: var(--muted) !important;
  font-size: 11px !important;
}

.maplibregl-ctrl-attrib a {
  color: var(--link) !important;
}

@media (max-width: 420px) {
  .top-header {
    padding: 8px 10px;
  }

  .brand-title {
    font-size: 15px;
  }

  .bottom-sheet {
    border-left: 0;
    border-right: 0;
  }
}
