:root {
  font-family: Inter, system-ui, sans-serif;
  background: #f5f7fb;
  color: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 14px;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
}

.app-shell {
  width: min(100%, 660px);
}

.home-card {
  text-align: center;
}

.home-actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.home-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
}

.home-button:hover,
.secondary-button:hover {
  background: #4338ca;
}

.page-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.page-link-row .secondary-button {
  flex: 1 1 48%;
  background: #e2e8f0;
  color: #1f2937;
}

.page-link-row .secondary-button:hover {
  background: #cbd5e1;
}

.station-page-card > p {
  margin: 0 0 16px;
  padding: 0;
}

.station-page-card > .status {
  margin: 0 0 14px;
}

.station-page-card,
.card {
  overflow: hidden;
}

.card {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
  padding: 20px;
}

h1 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.8rem;
}

p {
  margin-top: 0;
  margin-bottom: 18px;
  line-height: 1.6;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

input {
  width: 100%;
  border: 1px solid #d2d6dc;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1rem;
  margin-bottom: 14px;
}

button {
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 1rem;
  width: 100%;
}

button:hover {
  background: #4338ca;
}

.status {
  margin-top: 16px;
  min-height: 24px;
  font-size: 0.98rem;
}

.train-details {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.train-detail-card {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 16px;
  padding: 16px;
}

.train-detail-card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: #1e293b;
}

.train-detail-card-header {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: 12px;
  margin-bottom: 14px;
}

.train-number {
  color: #475569;
  font-size: 0.95rem;
}

.train-route-pill-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.route-arrow {
  font-size: 1.1rem;
  color: #475569;
  font-weight: 700;
}

.route-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 0.9rem;
  font-weight: 600;
}

.train-detail-status {
  display: grid;
  gap: 10px;
  color: #334155;
  font-size: 0.95rem;
  line-height: 1.5;
}

.map {
  margin-top: 18px;
  width: 100%;
  min-height: 280px;
  border-radius: 18px;
  border: 1px solid #e5e7eb;
}
.train-map-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #1d4ed8;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.24);
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.current-status {
  margin-top: 20px;
  padding: 18px 20px 16px 20px;
  border-radius: 18px;
  background: #f2f6ff;
  border: 1px solid #dbeafe;
  color: #1e293b;
}

.train-status-arrived {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.train-status-arriving {
  background: #e0f2fe;
  color: #0c4a6e;
  border-color: #7dd3fc;
}

.train-status-passed {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.train-schedule,
.train-halts {
  margin-top: 16px;
}

.train-schedule-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.train-schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 100%;
  background: #ffffff;
}

.train-schedule-table th,
.train-schedule-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.station-panel {
  margin-top: 18px;
  padding: 16px;
}

.train-schedule-table th {
  background: #eef2ff;
  color: #1e293b;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.train-schedule-table tbody tr {
  transition: background-color 0.15s ease-in-out;
}

.train-schedule-table tbody tr.current-stop {
  background: #f8fafc;
}

.train-schedule-table td {
  color: #334155;
}

.train-schedule-table td:last-child {
  width: 1px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .train-schedule-table-wrap {
    margin-top: 10px;
  }

  .train-schedule-table,
  .train-schedule-table thead,
  .train-schedule-table tbody,
  .train-schedule-table tr,
  .train-schedule-table th,
  .train-schedule-table td {
    display: block;
    width: 100%;
  }

  .train-schedule-table thead {
    display: none;
  }

  .train-schedule-table tr {
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #ffffff;
  }

  .train-schedule-table td {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid #f1f5f9;
  }

  .train-schedule-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #64748b;
    margin-right: 12px;
    flex: 0 0 36%;
  }

  .train-schedule-table td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .train-schedule-table tbody tr.current-stop {
    border-color: #bfdbfe;
  }
}

.station-panel {
  margin-top: 20px;
  padding: 18px 18px 16px 18px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.station-panel h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.1rem;
  color: #1f2937;
}

.small-text {
  margin: 0 0 14px;
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.5;
}

#stationSearch {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-right: none;
  border-radius: 14px 0 0 14px;
  padding: 12px 14px;
  font-size: 1rem;
  line-height: 1.5;
  height: 44px;
  box-sizing: border-box;
}

#stationSearch.station-search-selected {
  background: #f8fafc;
  border-color: #94a3b8;
}

.station-select-hidden {
  display: none;
}

#stationSelect {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1rem;
  margin-bottom: 14px;
  min-height: 130px;
}

.search-with-button {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  align-items: stretch;
}

.search-with-button input {
  flex: 1 1 auto;
  border-radius: 14px 0 0 14px;
  border-right: none;
  min-height: 48px;
  height: 48px;
}

.search-with-button button {
  width: auto;
  min-width: 80px;
  height: 48px;
  padding: 0 14px;
  border-radius: 0 14px 14px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-left: none;
  line-height: 1;
}

.search-with-button button.secondary-button {
  background: #eff2ff;
  color: #1e3a8a;
}

.search-with-button .location-button {
  width: 50px;
  height: 48px;
  border: 1px solid #cbd5e1;
  border-left: none;
  border-right: none;
  background: #ffffff;
  color: #334155;
  border-radius: 0;
  font-size: 1.25rem;
}

.search-with-button input.station-search-selected + .location-button {
  background: #f8fafc;
  border-color: #94a3b8;
}

#clearStationSearchButton {
  border-radius: 0 14px 14px 0;
  border: 1px solid #cbd5e1;
  border-left: none;
}

.track-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.location-button:hover {
  background: #eef2ff;
}

.station-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.station-suggestion {
  padding: 8px 14px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #1e40af;
  cursor: pointer;
  font-size: 0.95rem;
}

.station-suggestion.selected {
  background: #c7d2fe;
  color: #1e3a8a;
  box-shadow: inset 0 0 0 1px #818cf8;
}

.trains-between {
  margin-top: 14px;
}

.station-summary {
  margin-bottom: 14px;
  padding: 14px 16px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 16px;
}

.station-summary h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  color: #1e293b;
}

.station-summary p {
  margin: 0;
  color: #475569;
  font-size: 0.95rem;
}

.refresh-trains-button {
  width: auto;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #4f46e5;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 700;
}

.refresh-trains-button:hover:not(:disabled) {
  background: #4338ca;
}

.refresh-trains-button:disabled {
  cursor: progress;
  opacity: 0.82;
}

.station-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e7ef;
  border-radius: 14px;
}

.station-pagination span {
  flex: 1;
  text-align: center;
  color: #475569;
  font-size: 0.95rem;
}

.trains-between .train-item {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border-radius: 14px;
  border: 1px solid #e2e7ef;
}

.train-location-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
  appearance: none;
  border: 1px solid #c7d2fe;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.train-location-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #818cf8;
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.12);
}

.train-location-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.trains-between .train-item h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #1e293b;
}

.trains-between .train-item p {
  margin: 0;
  color: #475569;
  font-size: 0.95rem;
}

.arrival-destination {
  margin-bottom: 8px;
  color: #1e293b;
  font-weight: 600;
}

.arrival-card {
  background: #ffffff;
}

.arrival-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.arrival-card-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #1e293b;
}

.arrival-pill {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.selected-train-location {
  margin-top: 14px;
}

.current-train-status {
  margin-top: 12px;
}

.current-status h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #1e293b;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
}

.status-line {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  flex: 1 1 auto;
  min-width: 0;
}

.status-subline {
  margin: 0;
  margin-left: auto;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 6px 14px;
  display: inline-block;
  border: 1px solid rgba(15, 23, 42, 0.12);
  letter-spacing: 0.01em;
  border-radius: 999px;
  flex: 0 1 auto;
  max-width: 100%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

@media (max-width: 520px) {
  .status-subline {
    flex: 1 1 100%;
    margin-left: 0;
  }
}

.train-status-moving {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

@media (min-width: 640px) {
  .card {
    padding: 32px;
  }

  .current-status {
    padding: 20px 24px 18px 24px;
  }

  .status-row {
    justify-content: space-between;
  }
}

.train-status-halted {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.train-status-unknown {
  background: #eef2ff;
  color: #334155;
  border-color: #c7d2fe;
}

@media (max-width: 640px) {
  body {
    padding: 10px;
    place-items: start center;
  }

  .app-shell {
    width: 100%;
  }

  .card {
    padding: 16px;
    border-radius: 18px;
  }

  h1 {
    font-size: 1.45rem;
    margin-bottom: 10px;
  }

  p {
    margin-bottom: 16px;
    line-height: 1.55;
  }

  input,
  button {
    min-height: 48px;
  }

  .page-link-row,
  .track-action-row,
  .station-pagination,
  .station-suggestions {
    gap: 8px;
  }

  .page-link-row {
    flex-direction: column;
  }

  .page-link-row .secondary-button,
  .track-action-row button,
  .station-pagination .secondary-button,
  .refresh-trains-button {
    width: 100%;
  }

  .track-action-row {
    flex-direction: column;
  }

  .search-with-button {
    flex-wrap: nowrap;
    min-width: 0;
  }

  .search-with-button input,
  .search-with-button button {
    min-height: 48px;
  }

  .search-with-button button,
  #clearStationSearchButton,
  .location-button {
    min-width: 0;
    border: 1px solid #cbd5e1;
  }

  .location-button {
    height: 48px;
  }

  .station-page-card > p,
  .station-summary p,
  .trains-between .train-item p,
  .small-text {
    line-height: 1.55;
  }

  .train-detail-card-header,
  .train-route-pill-group {
    flex-wrap: wrap;
  }

  .train-detail-card-header {
    justify-content: center;
    text-align: center;
  }

  .train-detail-title {
    margin-bottom: 12px;
    text-align: center;
  }

  .route-arrow {
    order: 0;
    width: auto;
    text-align: center;
    margin: 0;
    flex: 0 0 auto;
  }

  .route-pill {
    width: auto;
  }

  .train-detail-status,
  .station-panel,
  .station-summary,
  .current-status {
    border-radius: 14px;
  }

  .map {
    min-height: 220px;
    border-radius: 14px;
    margin-top: 14px;
  }

  .schedule-header,
  .schedule-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .schedule-header {
    padding: 10px 12px;
  }

  .schedule-row {
    padding: 10px 12px;
  }

  .station-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .station-pagination span {
    order: -1;
  }

  .status-row {
    gap: 10px;
    justify-content: center;
  }

  .status-line,
  .status-subline {
    width: 100%;
  }

  .status-line {
    text-align: center;
  }

  .status-subline {
    margin-left: 0;
    text-align: center;
  }
}
