:root {
  --blue: #2563eb;
  --gray: #9ca3af;
  --ink: #1f2937;
  --sub: #6b7280;
  --bg: #ffffff;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
}

#map {
  position: absolute;
  inset: 0;
}

/* disclaimer modal */

#disclaimer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#disclaimer-backdrop.hidden {
  display: none;
}

#disclaimer-modal {
  background: var(--bg);
  border-radius: 16px;
  padding: 22px 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

#disclaimer-modal p {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
}

#disclaimer-credit {
  font-size: 12px !important;
  color: var(--sub) !important;
}

#disclaimer-credit a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

#disclaimer-close {
  display: block;
  width: 100%;
  border: none;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
}

#disclaimer-close:active {
  opacity: 0.8;
}

/* header */

#app-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.92), rgba(255,255,255,0.75) 70%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

#app-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

#status-line {
  margin-top: 2px;
  font-size: 12px;
  color: var(--sub);
}

#updated-line {
  margin-top: 1px;
  font-size: 11px;
  color: var(--sub);
  opacity: 0.8;
}

/* search */

#search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 10px;
  background: rgba(255,255,255,0.95);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  pointer-events: auto;
}

#search-icon {
  padding: 0 4px 0 12px;
  font-size: 13px;
  opacity: 0.6;
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  padding: 11px 8px;
  color: var(--ink);
  min-width: 0;
}

#search-input::placeholder {
  color: var(--sub);
}

#search-clear {
  display: none;
  border: none;
  background: none;
  color: var(--sub);
  font-size: 18px;
  line-height: 1;
  padding: 0 12px;
  cursor: pointer;
}

#search-box.has-value #search-clear {
  display: block;
}

#search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  background: rgba(255,255,255,0.97);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.16);
  max-height: 45vh;
  overflow-y: auto;
  pointer-events: auto;
  display: none;
}

#search-results.visible {
  display: block;
}

#search-results li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 9px;
  cursor: pointer;
}

#search-results li:active {
  background: #f3f4f6;
}

#search-results li.empty {
  color: var(--sub);
  font-size: 13px;
  justify-content: center;
  cursor: default;
}

#search-results li.empty:active {
  background: transparent;
}

.result-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.result-dot.open { background: var(--blue); }
.result-dot.closed { background: var(--gray); }

.result-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-city {
  font-size: 12px;
  color: var(--sub);
  flex-shrink: 0;
}

/* legend */

#legend {
  position: absolute;
  left: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 10;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  font-size: 12px;
  line-height: 1.9;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}

.dot-open { background: var(--blue); }
.dot-closed { background: var(--gray); }

.cross-mark {
  color: #dc2626;
  font-weight: 700;
  font-size: 12px;
  width: 9px;
  display: inline-flex;
  justify-content: center;
}

/* bottom sheet */

#sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#sheet-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

#sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  padding: 10px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 45vh;
  overflow-y: auto;
}

#sheet.visible {
  transform: translateY(0);
}

#sheet-handle {
  width: 36px;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin: 2px auto 12px;
}

#sheet-close {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: none;
  background: #f3f4f6;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: var(--sub);
  cursor: pointer;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  margin-bottom: 8px;
}

.badge-open { background: var(--blue); }
.badge-closed { background: var(--gray); }

#sheet-name {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}

#sheet-municipality {
  margin: 0 0 2px;
  font-size: 13px;
  color: var(--sub);
}

#sheet-address {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink);
}

#sheet-official {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

#sheet-directions {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  border-radius: 12px;
}

#sheet-directions:active {
  opacity: 0.8;
}

/* maplibre control tweaks */

.maplibregl-ctrl-top-right {
  top: calc(env(safe-area-inset-top, 0px) + 64px);
}

.maplibregl-ctrl-bottom-right {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
}

/* traffic closure popup */

.maplibregl-popup-content {
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
}

.closure-status {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  margin-bottom: 8px;
}

.closure-status.active { background: #dc2626; }
.closure-status.cleared { background: var(--gray); }

.closure-route {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.closure-range {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.5;
}

.closure-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--sub);
}
