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

:root {
  color-scheme: light;
  --bg: #efeae2;
  --bg-shade: #e4ddd2;
  --surface: #f7f4ef;
  --surface-2: #e7e0d6;
  --text: #241f1a;
  --muted: #6d665d;
  --button: #243126;
  --button-hover: #1a261c;
  --button-text: #f6f3ec;
  --accent: var(--button);
  --accent-soft: rgba(36, 49, 38, 0.1);
  --ring: #c4552a;
  --success: #2d6a4f;
  --warning: #9a5416;
  --danger: #9b3a32;
  --border: rgba(36, 31, 26, 0.12);
  --radius: 16px;
  --shadow: 0 16px 40px rgba(36, 31, 26, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121411;
    --bg-shade: #1c1f1a;
    --surface: #1a1d18;
    --surface-2: #242820;
    --text: #f3efe6;
    --muted: #b7b1a6;
    --button: #e7e1d6;
    --button-hover: #f6f3ec;
    --button-text: #1a1c17;
    --accent-soft: rgba(231, 225, 214, 0.12);
    --ring: #e8a07a;
    --success: #8fbf9a;
    --warning: #e0b07a;
    --danger: #e08a84;
    --border: rgba(243, 239, 230, 0.12);
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  }
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", "WenQuanYi Micro Hei", sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-shade), transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.header h1 {
  margin: 0 0 12px;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.35;
}

.intro {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 0.92rem;
  text-align: left;
}

.clock {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.route-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.route-tab {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.route-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.route-tab.active {
  background: var(--button);
  border-color: transparent;
  color: var(--button-text);
  box-shadow: var(--shadow);
}

.route-tab.active:hover {
  background: var(--button-hover);
  color: var(--button-text);
}

.route-tab:focus-visible,
.timetable-day-tab:focus-visible,
.timetable-accordion summary:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
}

.route-name {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.status-badge {
  display: inline-block;
  margin: 0 0 20px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.status-badge.ok,
.status-badge.peak {
  background: rgba(21, 128, 61, 0.1);
  color: var(--success);
}

.status-badge.ended,
.status-badge.not_today {
  background: rgba(180, 83, 9, 0.1);
  color: var(--warning);
}

.status-badge.closed {
  background: rgba(185, 28, 28, 0.1);
  color: var(--danger);
}

.next-bus .label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.next-bus .time {
  margin: 0;
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

.next-bus .time.muted {
  font-size: 2rem;
  color: var(--muted);
}

.next-bus .time.peak-message {
  font-size: clamp(1.25rem, 5.5vw, 1.6rem);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;
}

.countdown {
  margin: 12px 0 0;
  color: var(--ring);
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.detail {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.next-service {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 0.9rem;
}

.timetable-accordion {
  margin-top: 24px;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.timetable-accordion summary {
  list-style: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  user-select: none;
}

.timetable-summary-hint {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.timetable-accordion summary::-webkit-details-marker {
  display: none;
}

.timetable-accordion summary::after {
  content: "▾";
  float: right;
  transition: transform 0.15s ease;
}

.timetable-accordion[open] summary::after {
  transform: rotate(180deg);
}

.timetable-panel {
  margin-top: 16px;
}

.timetable-day-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.timetable-day-tab {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 6px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.timetable-day-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.timetable-day-tab.active,
.timetable-day-tab.active:hover {
  background: var(--button);
  border-color: transparent;
  color: var(--button-text);
}

.timetable-day-content {
  min-height: 2rem;
}

.timetable-no-service {
  margin: 8px 0 0;
  padding: 20px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.timetable-period-section + .timetable-period-section {
  margin-top: 16px;
}

.timetable-period {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.timetable-times {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timetable-times li {
  padding: 8px 6px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.timetable-peak {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
}

.timetable-peak-range {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timetable-peak-note {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
}

.route-summary,
.faq {
  margin-top: 20px;
  text-align: left;
}

.route-summary h2,
.faq h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.summary-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-card,
.faq-item {
  margin: 0 0 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.summary-card h3,
.faq-item h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.stop-line span {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
}

.summary-card p,
.faq-item p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-card p:last-child,
.faq-item p:last-child {
  margin-bottom: 0;
}

.footer {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.footer p {
  margin: 0 0 8px;
}

.footer .meta {
  margin-top: 12px;
  opacity: 0.85;
}

@media (max-width: 360px) {
  .route-tab {
    font-size: 0.75rem;
    padding: 10px 6px;
  }

  .timetable-day-tab {
    font-size: 0.68rem;
    padding: 10px 4px;
  }
}