/* Scrollbars */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
  background-clip: padding-box;
}

body {
  font-size: 13px;
}

/* Page layout */

.container {
  display: flex;
  height: 100vh;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

/* Mobile drawer controls are enabled in the responsive block. */
.sidebar-close,
.sidebar-scrim,
.mobile-controls-btn {
  display: none;
}

/* Sidebar controls */

.brand {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 53px;
  font-weight: 600;
  font-size: 14.5px;
  line-height: 22.5px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--ease);
}

.brand:hover {
  opacity: 0.75;
}

.theme-toggle {
  width: 100%;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  transition: color var(--ease), border-color var(--ease), background var(--ease), box-shadow var(--ease);
}

.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.theme-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.theme-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

[data-theme="dark"] .theme-icon--moon,
[data-theme="light"] .theme-icon--sun {
  display: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  flex: 0 0 auto;
}

.brand-name {
  font-size: 14.5px;
  line-height: 22.5px;
  white-space: nowrap;
}

.brand-name span,
.brand-separator,
.brand-product {
  color: var(--text-secondary);
}

.brand-name span {
  opacity: 0.4;
}

.brand-product {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-group {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-title,
.field span {
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric span {
  color: var(--text-secondary);
}

.metric strong,
.badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.info-text {
  padding: 10px 14px;
  background: var(--accent-muted);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.info-text p {
  margin: 0;
}

.info-text p + p {
  margin-top: 8px;
}

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

input,
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  transition: border-color var(--ease), box-shadow var(--ease);
}

select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%238e8e8e' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  padding: 7px 14px;
  line-height: 1.2;
  background: var(--surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.btn:hover {
  background: var(--surface-hover-raised);
  border-color: var(--border-hover);
}

.btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.btn--accent {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

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

.toggle-btn {
  justify-content: center;
  width: 100%;
}

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

.legend div {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot--train {
  background: #5b9cf5;
}

.dot--bus {
  background: #5ccf71;
}

.dot--ferry {
  background: #e8aa40;
}

.footer {
  color: var(--text-muted);
  font-size: 11px;
  padding: 16px;
  margin-top: auto;
}

/* Main panel */

.content {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.tool-panel {
  background: var(--surface-island);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  animation: panel-in 0.18s ease;
  box-shadow: var(--shadow-panel);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px 16px;
}

.mobile-controls-btn {
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
}

.mobile-controls-btn svg {
  width: 15px;
  height: 15px;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-header p {
  color: var(--text-secondary);
  margin: 6px 0 0;
}

.estimate-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.badge {
  display: inline-block;
  padding: 4px 9px;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.time-state {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex: 0 0 auto;
}

.time-mode {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.2;
  white-space: nowrap;
}

.time-mode.is-offset {
  color: var(--accent);
}

.map-wrap {
  flex: 1;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-inset);
}

#map {
  height: 100%;
  min-height: 360px;
  background: var(--surface-inset);
}

/* Map markers and Leaflet overrides */

.vehicle-marker-shell {
  display: grid;
  place-items: center;
  overflow: visible;
  opacity: 1;
  visibility: visible;
}

.vehicle-marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-sizing: border-box;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
  margin: 0 auto;
  overflow: hidden;
}

.vehicle-marker::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
}

.vehicle-marker--labelled {
  width: 100%;
  height: 28px;
  border-radius: var(--radius-pill);
  padding: 3px 6px;
}

.vehicle-marker--labelled::after {
  display: none;
}

.vehicle-marker__label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.vehicle-marker__label--route {
  grid-area: 1 / 1;
  opacity: 0;
}

.vehicle-marker__label--cat {
  position: absolute;
  inset: 0;
  color: #111;
  font-size: 9px;
  opacity: 1;
}

.vehicle-marker--labelled .vehicle-marker__label--route {
  opacity: 1;
}

.vehicle-marker--labelled .vehicle-marker__label--cat {
  opacity: 0;
}

.stop-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .35);
}

.stop-marker--selected {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--accent-muted), 0 2px 8px rgba(0, 0, 0, .42);
}

.leaflet-control-attribution,
.leaflet-control-zoom a,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.leaflet-container {
  color: var(--text-primary);
}

.leaflet-popup-content {
  font-family: var(--font-ui);
  font-size: 12.5px;
  margin: 12px 14px;
}

.popup-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.popup-meta {
  color: var(--text-secondary);
}

.popup-meta--dwell {
  color: var(--accent);
  font-weight: 600;
}

.popup-meta--countdown {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 600;
}

.popup-actions {
  margin-top: 10px;
}

.popup-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-hover);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.popup-btn:hover,
.popup-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent);
}

.popup-btn svg {
  width: 13px;
  height: 13px;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .container {
    height: 100vh;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 8000;
    width: min(320px, calc(100vw - 44px));
    min-width: unset;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-panel);
    transform: translateX(-100%);
    transition: transform var(--ease);
    -webkit-overflow-scrolling: touch;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 7990;
    display: block;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ease);
  }

  body.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    color: var(--text-secondary);
  }

  .sidebar-close svg {
    width: 16px;
    height: 16px;
  }

  .sidebar-close:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--surface-hover);
  }

  .brand {
    padding-right: 54px;
  }

  .content {
    padding: 14px;
    min-height: 0;
    overflow: hidden;
  }

  .tool-panel {
    padding: 14px;
    border-radius: var(--radius-lg);
  }

  .mobile-controls-btn {
    display: inline-flex;
  }

  .panel-header {
    gap: 12px;
  }

  .panel-header p {
    font-size: 12px;
  }

  .map-wrap,
  #map {
    min-height: 0;
  }
}
