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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a1a;
  color: #e8e8e8;
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 320px;
  min-width: 280px;
  padding: 1.25rem 1rem;
  background: #252525;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.tagline {
  margin: 0;
  font-size: 0.875rem;
  color: #999;
}

.area-picker {
  padding: 0.75rem 0;
  border-bottom: 1px solid #333;
  margin-bottom: 0.25rem;
}

.area-label,
.step-label {
  font-size: 0.8125rem;
  color: #999;
  margin: 0 0 0.35rem 0;
  display: block;
}

.step-label {
  margin-top: 0.5rem;
}

.area-display {
  margin: 0.5rem 0 0 0;
  font-size: 0.8125rem;
  color: #8ab88a;
  min-height: 1.25rem;
}

.area-input-wrap {
  position: relative;
}

.place-input-wrap {
  position: relative;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.place-autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 2px 0 0 0;
  padding: 0;
  list-style: none;
  background: #252525;
  border: 1px solid #444;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
}

.place-autocomplete-list li {
  margin: 0;
  padding: 0;
}

.place-autocomplete-list [role="option"] {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  text-align: left;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #e8e8e8;
  cursor: pointer;
}

.place-autocomplete-list [role="option"]:hover,
.place-autocomplete-list [role="option"].autocomplete-active {
  background: #333;
}

.place-autocomplete-list [role="option"]:first-child {
  border-radius: 6px 6px 0 0;
}

.place-autocomplete-list [role="option"]:last-child {
  border-radius: 0 0 6px 6px;
}

#place-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid #444;
  border-radius: 8px;
  background: #1a1a1a;
  color: #e8e8e8;
}

#place-input::placeholder {
  color: #666;
}

#place-input:focus {
  outline: none;
  border-color: #6b9bd1;
  box-shadow: 0 0 0 2px rgba(107, 155, 209, 0.25);
}

#add-btn {
  padding: 0.6rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #4a7ab8;
  color: #fff;
  cursor: pointer;
}

#add-btn:hover {
  background: #5a8ac8;
}

#add-btn:active {
  transform: scale(0.98);
}

.multi-add {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.multi-add-label {
  font-size: 0.8125rem;
  color: #999;
  margin: 0;
}

#place-batch {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid #444;
  border-radius: 8px;
  background: #1a1a1a;
  color: #e8e8e8;
  resize: vertical;
  min-height: 4.5rem;
}

#place-batch::placeholder {
  color: #666;
}

#place-batch:focus {
  outline: none;
  border-color: #6b9bd1;
  box-shadow: 0 0 0 2px rgba(107, 155, 209, 0.25);
}

#add-all-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #3d6a4a;
  color: #fff;
  cursor: pointer;
}

#add-all-btn:hover:not(:disabled) {
  background: #4d7a5a;
}

#add-all-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.start-end-options {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0 0.5rem 0;
}

.start-end-label {
  font-size: 0.8125rem;
  color: #999;
  margin: 0;
}

.start-end-select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1a1a1a;
  color: #e8e8e8;
  cursor: pointer;
}

.start-end-select:focus {
  outline: none;
  border-color: #6b9bd1;
}

.place-suggestions {
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: #1e2a1e;
  border: 1px solid #2d3d2d;
  border-radius: 8px;
}

.place-suggestions-title {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  color: #e8e8e8;
}

.place-suggestions-list {
  list-style: none;
  margin: 0 0 0.5rem 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}

.place-suggestions-list li {
  margin-bottom: 0.25rem;
}

.place-suggestions-list button {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.875rem;
  text-align: left;
  border: 1px solid #444;
  border-radius: 6px;
  background: #252525;
  color: #e8e8e8;
  cursor: pointer;
}

.place-suggestions-list button:hover {
  background: #333;
  border-color: #2d7a4a;
}

.place-suggestions-skip {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #888;
  cursor: pointer;
}

.place-suggestions-skip:hover {
  color: #e8e8e8;
}

.place-list-caption {
  margin: 0 0 0.35rem 0;
  font-size: 0.8125rem;
  color: #999;
}

.place-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  min-height: 80px;
}

.place-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.25rem;
  background: #1e1e1e;
  border-radius: 6px;
  font-size: 0.9rem;
}

.place-list li .order {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #333;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.place-list li .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-list li .remove {
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid #444;
  border-radius: 4px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
}

.place-list li .remove:hover {
  color: #e66;
  border-color: #e66;
  background: rgba(230, 102, 102, 0.15);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#optimize-btn {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #2d7a4a;
  color: #fff;
  cursor: pointer;
}

#optimize-btn:hover:not(:disabled) {
  background: #3d8a5a;
}

#optimize-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border: 1px solid #444;
  border-radius: 8px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
}

.secondary:hover {
  background: #333;
  color: #e8e8e8;
}

.route-info {
  padding: 0.75rem;
  background: #1e2a1e;
  border-radius: 8px;
  border: 1px solid #2d3d2d;
}

.route-info p {
  margin: 0 0 0.25rem 0;
  font-size: 0.875rem;
}

.route-info p:last-child {
  margin-bottom: 0;
}

.route-stats {
  color: #8ab88a;
  font-size: 0.8125rem;
}

.status {
  margin: 0;
  font-size: 0.8125rem;
  color: #888;
  min-height: 1.25rem;
}

.status.error {
  color: #e66;
}

.status.loading {
  color: #8ab88a;
}

.app-footer {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 0.8125rem;
  color: #888;
}

.app-footer a {
  color: #8ab88a;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.map-container {
  flex: 1;
  min-width: 0;
  min-height: 300px;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.numbered-marker {
  background: none;
  border: none;
}

.numbered-marker-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: #2d7a4a;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  font-family: system-ui, -apple-system, sans-serif;
}

.leaflet-popup-content-wrapper {
  background: #252525;
  color: #e8e8e8;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.leaflet-popup-tip {
  background: #252525;
}

.leaflet-popup-content {
  margin: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid #333;
  }

  #map {
    min-height: 55vh;
  }
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.25rem;
  background: #252525;
  border-top: 1px solid #444;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  z-index: 9999;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3);
}

.cookie-banner-text {
  margin: 0;
  font-size: 0.875rem;
  color: #e8e8e8;
  flex: 1;
  min-width: 200px;
}

.cookie-banner-text a {
  color: #8ab88a;
  text-decoration: none;
}

.cookie-banner-text a:hover {
  text-decoration: underline;
}

.cookie-banner-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #2d7a4a;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.cookie-banner-btn:hover {
  background: #3d8a5a;
}

/* Static pages (About, Privacy) */
.static-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.static-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: #252525;
  border-bottom: 1px solid #333;
}

.static-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #e8e8e8;
  text-decoration: none;
}

.static-logo:hover {
  color: #fff;
}

.static-nav {
  display: flex;
  gap: 1.25rem;
}

.static-nav a {
  color: #aaa;
  text-decoration: none;
  font-size: 0.9375rem;
}

.static-nav a:hover {
  color: #e8e8e8;
}

.static-main {
  flex: 1;
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  width: 100%;
}

.static-main h1 {
  margin: 0 0 1rem 0;
  font-size: 1.75rem;
}

.static-main h2 {
  margin: 1.5rem 0 0.5rem 0;
  font-size: 1.125rem;
  color: #ccc;
}

.static-main p,
.static-main ul {
  margin: 0 0 0.75rem 0;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #ccc;
}

.static-main ul {
  padding-left: 1.5rem;
}

.static-main a {
  color: #8ab88a;
  text-decoration: none;
}

.static-main a:hover {
  text-decoration: underline;
}

.static-back {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: 0.875rem;
}
