/* 台鐵時刻表查詢 */
#tt-tool [hidden], .tt-stale[hidden], .tt-prevnote[hidden] { display: none !important; }
.tt-notice { background: #fff7e6; border-left: 4px solid var(--warn); padding: 10px 14px; border-radius: 6px; font-size: 1rem; margin: .75rem 0; }
.tt-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0 10px; align-items: end; }
.tt-pair > * { min-width: 0; }
.tt-pick select, #tt-tool select#tt-type, #tt-tool select#tt-sort {
  display: block; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 1rem; background: #fff; color: var(--fg);
}
.tt-pick .qr-field { margin-bottom: 6px; }
.tt-swap { align-self: end; margin-bottom: 0; min-height: 44px; white-space: nowrap; }
.tt-hint { min-height: 1.4em; margin: .35rem 0; font-size: .95rem; }
.tt-picked { margin: .25rem 0 .75rem; font-weight: 600; }
.tt-time label { flex-wrap: wrap; }
.tt-time input[type=time] { flex: 1 1 100%; width: calc(100% - 28px); margin: 6px 0 0 28px; min-height: 38px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 1rem; background: #fff; color: var(--fg); }
.tt-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin: 4px 0 8px; }
.tt-opt { display: block; font-weight: 600; font-size: 1rem; }
.tt-opt select { margin-top: 4px; }
.tt-summary { margin: .5rem 0; font-weight: 600; }
.tt-stale { background: #fef2f2; border-left: 4px solid var(--bad); padding: 8px 12px; border-radius: 6px; font-size: .95rem; margin: .5rem 0; }
.tt-empty { background: var(--soft); border-radius: 10px; padding: 12px 14px; font-size: 1rem; }

.tt-table { border-collapse: collapse; width: 100%; font-size: 1rem; }
.tt-table th, .tt-table td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.tt-table thead th { background: var(--soft); font-size: .92rem; white-space: nowrap; position: sticky; top: 0; }
.tt-table td strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tt-table td small { display: block; color: var(--muted); font-size: .85rem; line-height: 1.45; font-weight: 400; }
.tt-table .c-dep strong small, .tt-table .c-arr strong small { display: inline; margin-right: 3px; color: var(--warn); }
.tt-table .c-note { font-size: .92rem; min-width: 8em; }
.tt-table .c-dur { white-space: nowrap; }
.tt-table .c-no { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tt-dash { color: var(--muted); }
.tt-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .88rem; font-weight: 600; background: var(--soft); border: 1px solid var(--line); white-space: nowrap; }
.tt-badge[data-t="太魯閣"], .tt-badge[data-t="普悠瑪"], .tt-badge[data-t="自強"] { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.tt-badge[data-t="莒光"] { background: #fff7e6; border-color: #fcd34d; color: #92400e; }
.tt-badge[data-t="區間快"] { background: #eff4ff; border-color: #93b4ff; color: #1e3a8a; }
.tt-badge[data-t="區間"] { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.tt-badge[data-t="自強3000"] { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.tt-badge[data-t="復興"], .tt-badge[data-t="普快"] { background: #f3f4f6; border-color: #9ca3af; color: #374151; }
.tt-table .c-type .tt-special { display: block; margin-top: 3px; color: var(--warn); font-weight: 600; font-size: .82rem; line-height: 1.3; }
.tt-table .c-no .tt-prev { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; white-space: normal; }
.tt-table .c-via { white-space: nowrap; }
.tt-prevnote { background: var(--soft); border-left: 4px solid var(--line); padding: 8px 12px; border-radius: 6px; font-size: .92rem; margin: .5rem 0; }
.tt-fail { background: #fef2f2; border-left: 4px solid var(--bad); color: var(--bad); font-weight: 600; }
.tt-next td { background: #fff7e6; }
.tt-flag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--warn); color: #fff; font-style: normal; font-size: .8rem; font-weight: 600; }

/* 手機：結果表改成一班一張卡，不讓整頁水平捲動 */
@media (max-width: 640px) {
  .tt-pair { grid-template-columns: 1fr; gap: 6px 0; }
  .tt-swap { justify-self: stretch; margin: 2px 0; }
  .tt-table, .tt-table tbody { display: block; }
  .tt-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tt-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px 8px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: #fff; }
  .tt-row.tt-next { background: #fff7e6; border-color: var(--warn); }
  .tt-table td { border: 0; padding: 0; min-width: 0; background: transparent; }
  .tt-next td { background: transparent; }
  .tt-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .8rem; font-weight: 400; line-height: 1.4; }
  .tt-table .c-dep { order: 1; }
  .tt-table .c-arr { order: 2; }
  .tt-table .c-dur { order: 3; white-space: nowrap; }
  .tt-row { grid-template-columns: 1fr 1fr 1.3fr; }
  .tt-table .c-type { order: 4; }
  .tt-table .c-no { order: 5; white-space: normal; }
  .tt-table .c-via { order: 6; }
  .tt-table .c-note { order: 7; grid-column: 1 / -1; min-width: 0; border-top: 1px dashed var(--line); padding-top: 4px; margin-top: 2px; }
  .tt-table .c-note::before { display: none; }
  .tt-table .c-dep strong small, .tt-table .c-arr strong small { display: block; margin: 0; }
  .tt-flag { display: block; margin: 2px 0 0; width: max-content; }
  .tt-toolbar { grid-template-columns: 1fr; gap: 8px 0; }
}
