:root {
  --bg: #141414;
  --surface: #1e1e1e;
  --surface-hover: #282828;
  --accent: #e67e22;
  --accent-hover: #d35400;
  --text: #f0f0f0;
  --text-muted: #9ca3af;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto auto 1fr;
  gap: 0;
  min-height: 100vh;
}

.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.75rem;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.controls {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.75rem;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#radius {
  width: 120px;
  accent-color: var(--accent);
}

#radius-value {
  min-width: 3.5rem;
  font-weight: 600;
  color: var(--accent);
}

.filter-today-group {
  flex-wrap: wrap;
  align-items: flex-start;
}

.filter-today-group .checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
}

.filter-today-group .hint {
  width: 100%;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-weight: normal;
}

.plz-group {
  flex: 1;
  min-width: 200px;
}

.plz-group label {
  display: block;
  margin-bottom: 0.25rem;
}

#plz {
  width: 140px;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-right: 0.5rem;
}

#plz:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(230, 126, 34, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 12px rgba(230, 126, 34, 0.4);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
}

.btn-secondary:hover {
  background: #333;
  border-color: rgba(255,255,255,0.12);
}

#map {
  grid-column: 1;
  min-height: 400px;
  background: #0d0d0d;
}

.leaflet-container {
  background: #0d0d0d;
  font-family: inherit;
}

.sidebar {
  grid-column: 2;
  background: var(--surface);
  border-left: 1px solid rgba(255,255,255,0.06);
  overflow-y: auto;
  padding: 1.25rem;
}

.sidebar h2 {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.results-list .placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0;
}

.result-card {
  padding: 1rem 1.1rem;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 4px solid var(--accent);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.result-card:hover {
  background: var(--surface-hover);
  transform: translateX(2px);
}

.result-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}

.result-card .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.result-card .meta.tag {
  color: var(--accent);
  font-weight: 500;
}

.result-card-image {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin: -1rem -1.1rem 0.5rem -1.1rem;
  display: block;
}

.leaflet-popup-content .popup-image {
  display: block;
  max-width: 240px;
  max-height: 160px;
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  object-fit: cover;
}

.leaflet-popup-content .popup-route {
  display: inline-block;
  margin: 0.5rem 0.25rem 0.25rem 0;
  padding: 0.4rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.leaflet-popup-content .popup-route:hover {
  background: var(--accent-hover);
  color: #fff;
}

.result-card-actions {
  margin-top: 0.5rem;
}

.btn-route {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.btn-route:hover {
  background: var(--accent-hover);
  color: #fff;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 2000;
  max-width: 90vw;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.modal-content h2 {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-content label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.modal-content textarea {
  resize: vertical;
  min-height: 60px;
}

.modal-section-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.25rem 0 0.5rem 0;
}

.modal-location-options {
  margin: 0.5rem 0 0;
}

.btn-location {
  width: 100%;
  padding: 0.85rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(230, 126, 34, 0.15);
  color: var(--accent);
  border: 1px solid rgba(230, 126, 34, 0.4);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-location:hover {
  background: rgba(230, 126, 34, 0.25);
  border-color: var(--accent);
}

.btn-location:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-location-icon {
  font-size: 1.2rem;
}

.modal-location-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  min-height: 1.25em;
}

.modal-location-status.success {
  color: #2ecc71;
}

.btn-link-different {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.btn-link-different:hover {
  color: var(--accent-hover);
}

.modal-divider {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin: 1rem 0 0.5rem;
}

.modal-content input[type="file"] {
  padding: 0.5rem 0;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-content input[type="file"]::file-selector-button {
  padding: 0.5rem 1rem;
  margin-right: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}

.image-preview {
  margin-top: 0.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 120px;
  background: var(--bg);
}

.image-preview img {
  display: block;
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 45vh 1fr;
  }

  .header {
    padding: 1rem 1.25rem;
  }

  .header h1 {
    font-size: 1.35rem;
  }

  .controls {
    padding: 0.9rem 1.25rem;
    gap: 1rem;
  }

  .plz-group {
    width: 100%;
  }

  #plz {
    flex: 1;
    min-width: 0;
  }

  .sidebar {
    grid-column: 1;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.06);
    max-height: 45vh;
    padding: 1rem 1.25rem;
  }

  #map {
    min-height: 45vh;
  }

  .modal {
    padding: 0.75rem;
    align-items: flex-start;
    overflow-y: auto;
  }

  .modal-content {
    margin: auto 0;
    padding: 1.25rem;
  }

  .btn-location {
    padding: 1rem 1rem;
    font-size: 1rem;
    min-height: 48px;
  }
}
