:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --ink: #1b2830;
  --muted: #65737b;
  --line: #d9e1e5;
  --panel: #ffffff;
  --panel-strong: #eef4f1;
  --accent: #b21f2d;
  --accent-dark: #871722;
  --green: #0f7a50;
  --amber: #a15f00;
  --red: #bd2732;
  --shadow: 0 20px 60px rgba(30, 45, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(178, 31, 45, 0.08), transparent 34%),
    linear-gradient(240deg, rgba(15, 122, 80, 0.09), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family:
    "Noto Sans TC",
    "Microsoft JhengHei",
    system-ui,
    sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.search-panel,
.results-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 225, 229, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel {
  align-self: start;
  padding: 24px;
  position: sticky;
  top: 24px;
}

.results-panel {
  min-height: calc(100vh - 64px);
  padding: 24px;
}

.brand-row,
.summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-row {
  justify-content: flex-start;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 42px;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.search-form {
  display: grid;
  gap: 16px;
}

.credential-box {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.credential-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(178, 31, 45, 0.12);
}

.preference-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  background: var(--panel-strong);
}

.toggle-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.secondary-action:hover {
  background: var(--panel-strong);
}

.route-pill {
  max-width: 48%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  background: white;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}

.status-message {
  margin: 22px 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fbfcfc;
}

.results-list {
  display: grid;
  gap: 12px;
}

.train-card {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 190px);
  gap: 18px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
}

.train-main {
  display: grid;
  gap: 14px;
}

.train-topline,
.seat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.train-number {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.time-block {
  display: grid;
  grid-template-columns: auto minmax(64px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.time-station strong {
  display: block;
  font-size: 25px;
  line-height: 1.1;
}

.time-station span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.track-line {
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #d8a33d, var(--green));
}

.seat-box {
  display: grid;
  align-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 16px;
  background: #f7faf9;
  text-align: center;
}

.seat-count {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.seat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.badge {
  border-radius: 999px;
  padding: 6px 10px;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.badge.good {
  background: var(--green);
}

.badge.low {
  background: var(--amber);
}

.badge.full {
  background: var(--red);
}

.meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 16px 0;
  }

  .search-panel {
    position: static;
  }

  .results-panel {
    min-height: auto;
  }

  .summary-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .route-pill {
    max-width: 100%;
  }

  .train-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .preference-row,
  .time-block {
    grid-template-columns: 1fr;
  }

  .track-line {
    width: 2px;
    height: 28px;
    margin-left: 10px;
  }
}
