:root {
  color-scheme: light;
  --blue: #145da0;
  --blue-dark: #0d467b;
  --green: #16804a;
  --text: #17212b;
  --muted: #66717e;
  --line: #dfe5eb;
  --surface: #ffffff;
  --background: #f2f5f8;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--text);
  background: var(--background);
  -webkit-tap-highlight-color: transparent;
}

button,
input { font: inherit; }

button:focus-visible,
input:focus-visible {
  outline: 3px solid #f4b400;
  outline-offset: 2px;
}

.noscript {
  padding: 12px 16px;
  color: #7a271a;
  background: #fce8e6;
  text-align: center;
  font-weight: 700;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner,
.app-main {
  width: min(100%, 680px);
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 1.2rem; line-height: 1.3; }
h2 { font-size: 1.25rem; line-height: 1.4; }

.app-main {
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
}

.status-panel,
.schedule-panel,
.time-search-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

.current-date {
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
}

.current-time {
  margin-top: 2px;
  font-size: 1.65rem;
  line-height: 1.2;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #edf1f5;
  border-radius: 10px;
}

.segment {
  min-height: 44px;
  padding: 8px 14px;
  color: #3d4854;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
}

.direction-tabs .segment.is-active {
  color: #fff;
  background: var(--blue);
}

.day-tabs .segment.is-active {
  color: #fff;
  background: var(--green);
}

.schedule-panel { overflow: hidden; }

.time-search-panel {
  margin-top: 16px;
  overflow: hidden;
}

.time-search-heading {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.time-search-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.6;
}

.time-search-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 18px;
}

.time-search-control {
  flex: 1 1 auto;
  min-width: 0;
}

.time-search-control label {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  font-weight: 700;
}

.time-search-control input {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #aeb8c2;
  border-radius: 9px;
  font-variant-numeric: tabular-nums;
}

.time-search-button {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 9px 22px;
  color: #fff;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 9px;
  font-weight: 800;
  cursor: pointer;
}

.time-search-button:hover { background: var(--blue-dark); }

.search-error {
  margin: -6px 18px 18px;
  padding: 10px 12px;
  color: #7a271a;
  background: #fce8e6;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 700;
}

.search-results {
  border-top: 1px solid var(--line);
}

.search-results-title {
  margin: 0;
  padding: 16px 18px 10px;
  font-size: 1rem;
  line-height: 1.4;
}

.search-table-header {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(62px, .8fr) minmax(112px, 1.4fr);
  align-items: center;
  gap: 10px;
}

.search-table-header {
  padding: 10px 18px;
  color: var(--muted);
  background: #f8fafb;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: .75rem;
  font-weight: 700;
}

.search-table-header span:nth-child(2) { text-align: center; }
.search-table-header span:last-child { text-align: right; }

.search-result-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-empty-message {
  padding: 30px 18px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.schedule-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.schedule-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: .85rem;
}

.day-label {
  flex: 0 0 auto;
  padding: 5px 9px;
  color: var(--green);
  background: #eaf6ef;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
}

.table-header,
.schedule-item {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(62px, .8fr) minmax(112px, 1.4fr);
  align-items: center;
  gap: 10px;
}

.table-header {
  padding: 10px 18px;
  color: var(--muted);
  background: #f8fafb;
  border-bottom: 1px solid var(--line);
  font-size: .75rem;
  font-weight: 700;
}

.table-header span:nth-child(2) { text-align: center; }
.table-header span:last-child { text-align: right; }

.schedule-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.schedule-item {
  min-height: 66px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.schedule-item:last-child { border-bottom: 0; }

.departure-time {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.route-cell { text-align: center; }

.route-badge {
  display: inline-block;
  min-width: 42px;
  padding: 4px 8px;
  color: #4f5b66;
  background: #f1f3f5;
  border: 1px solid #d8dde2;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
}

.route-badge.route-05 { color: #11693c; background: #eaf6ef; border-color: #b9dec9; }
.route-badge.route-direct { color: #a43225; background: #fcecea; border-color: #efc2bc; }

.countdown {
  text-align: right;
  color: var(--muted);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.schedule-item:first-child .countdown { color: var(--green); }
.countdown-placeholder { color: #aeb6bf; }

.empty-message {
  padding: 38px 18px;
  color: var(--muted);
  text-align: center;
}

.notice {
  padding: 14px 4px 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.6;
}

@media (max-width: 520px) {
  .header-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .direction-tabs .segment { flex: 1; }
  .status-panel { align-items: stretch; flex-direction: column; }
  .day-tabs .segment { flex: 1; }
  .time-search-form { align-items: stretch; flex-direction: column; }
  .time-search-button { width: 100%; }
}

@media (max-width: 370px) {
  .app-main { padding-inline: 10px; }
  .header-inner { padding-inline: 10px; }
  .table-header, .schedule-item { padding-inline: 12px; }
  .table-header, .schedule-item {
    grid-template-columns: 68px 54px minmax(100px, 1fr);
    gap: 6px;
  }
  .search-table-header {
    grid-template-columns: 68px 54px minmax(100px, 1fr);
    gap: 6px;
    padding-inline: 12px;
  }
}
