:root {
  --surface: rgba(252, 248, 242, 0.82);
  --surface-strong: #fff8ef;
  --border: rgba(49, 36, 27, 0.12);
  --text: #1f1a17;
  --muted: #6b625c;
  --accent: #cf4c31;
  --accent-deep: #8f2f1d;
  --mint: #207868;
  --warning-bg: rgba(207, 76, 49, 0.12);
  --success-bg: rgba(32, 120, 104, 0.12);
  --shadow: 0 24px 80px rgba(55, 37, 13, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(207, 76, 49, 0.24), transparent 28%),
    radial-gradient(circle at right 20%, rgba(32, 120, 104, 0.18), transparent 22%),
    linear-gradient(180deg, #f6f1e8 0%, #ede4d5 100%);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  display: block;
  margin-bottom: 24px;
}

.hero-copy,
.card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-copy,
.card {
  padding: 28px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

h1,
h2,
h3 {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.04em;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 1;
}

.hero-text,
.section-note,
.resolved-meta,
.resolved-outcome,
.prediction-state,
.muted-text {
  color: var(--muted);
}

.hero-text {
  margin: 16px 0 10px;
  font-size: 1rem;
  line-height: 1.55;
}

.hero-subtle,
.badge,
.result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
}

.hero-subtle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.78fr);
  gap: 24px;
}

.layout > * {
  min-width: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head > div {
  min-width: 0;
}

.section-note {
  flex: 0 0 9ch;
  max-width: 9ch;
  margin: 0;
  text-align: right;
  font-size: 0.92rem;
}

.section-note-inline {
  max-width: none;
  margin-top: 8px;
  text-align: left;
  flex: initial;
}

.callout {
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(49, 36, 27, 0.08);
  line-height: 1.5;
}

.callout.warning {
  background: var(--warning-bg);
}

.callout.success {
  background: var(--success-bg);
}

.search-form label,
.toolbar-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.input-row {
  display: flex;
  gap: 12px;
}

.secondary-row {
  margin-top: 12px;
}

.stacked-row {
  display: block;
}

.field-group {
  width: 100%;
}

.type-filter-group {
  margin: 0;
  padding: 0;
  border: 0;
}

.type-filter-group legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 600;
}

.type-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.type-filter-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(49, 36, 27, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  font-weight: 600;
}

.type-filter-option input {
  width: 16px;
  min-height: auto;
  margin: 0;
  padding: 0;
}

.date-parts {
  display: grid;
  grid-template-columns: 72px 12px 72px 12px 92px 42px;
  align-items: center;
  gap: 8px;
}

.time-parts {
  display: grid;
  grid-template-columns: 72px 12px 72px 64px 42px;
  align-items: center;
  gap: 8px;
}

.date-parts input,
.time-parts input {
  width: 100%;
  text-align: center;
}

.time-separator {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.date-separator {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.picker-btn {
  min-height: 42px;
  min-width: 42px;
  padding: 0;
  border-radius: 999px;
  background: rgba(31, 26, 23, 0.08);
  color: var(--text);
}

.icon-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  grid-column: auto;
  align-self: center;
}

.picker-now-btn {
  min-height: 42px;
  min-width: 64px;
  padding: 0 10px;
  background: rgba(31, 26, 23, 0.08);
  color: var(--text);
  font-size: 0.82rem;
}

.picker-slot {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 42px;
  overflow: hidden;
  flex: 0 0 42px;
}

.picker-slot .picker-btn {
  width: 42px;
  height: 42px;
}

.native-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: transparent;
  opacity: 0;
  cursor: pointer;
}

.compact-list {
  margin-top: 10px;
}

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

input,
button {
  font: inherit;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(49, 36, 27, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
}

button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.predict-btn,
.station-result {
  background: rgba(31, 26, 23, 0.08);
  color: var(--text);
}

.predict-btn {
  position: relative;
}

.predict-btn.active {
  background: var(--accent);
  color: white;
}

.predict-btn-flash-on-time {
  animation: predictFlashOnTime 2000ms ease;
}

.predict-btn-flash-delayed {
  animation: predictFlashDelayed 2000ms ease;
}

.predict-btn-train {
  position: absolute;
  width: 58px;
  height: auto;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 5px 10px rgba(31, 26, 23, 0.22));
}

.predict-btn-train-on-time {
  filter: drop-shadow(0 5px 10px rgba(32, 120, 104, 0.28));
}

.predict-btn-train-delayed {
  filter: drop-shadow(0 5px 10px rgba(207, 76, 49, 0.28));
}

@keyframes predictFlashOnTime {
  0% {
    background: rgba(31, 26, 23, 0.08);
    color: var(--text);
  }
  12% {
    background: var(--mint);
    color: white;
  }
  88% {
    background: var(--mint);
    color: white;
  }
  100% {
    background: rgba(31, 26, 23, 0.08);
    color: var(--text);
  }
}

@keyframes predictFlashDelayed {
  0% {
    background: rgba(31, 26, 23, 0.08);
    color: var(--text);
  }
  12% {
    background: var(--accent-deep);
    color: white;
  }
  88% {
    background: var(--accent-deep);
    color: white;
  }
  100% {
    background: rgba(31, 26, 23, 0.08);
    color: var(--text);
  }
}

.selected-station,
.board-hint,
#board-status {
  margin-bottom: 12px;
}

.board-grid,
.stack-list {
  display: grid;
  gap: 14px;
}

.tip-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.tip-count {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid rgba(49, 36, 27, 0.08);
  font-weight: 600;
}

.tip-count-on-time {
  color: var(--mint);
}

.tip-count-delayed {
  color: var(--accent-deep);
}

.tip-arrow {
  font-size: 1rem;
}

.station-result,
.train-card,
.resolved-card {
  width: 100%;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(49, 36, 27, 0.08);
  text-align: left;
  background: rgba(255, 251, 246, 0.88);
}

.station-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.station-name {
  font-weight: 700;
}

.station-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.train-topline,
.resolved-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.train-code {
  margin: 0 0 6px;
  font-size: 0.84rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.badge.upcoming,
.badge.resolved,
.result-pill.correct {
  background: rgba(32, 120, 104, 0.14);
  color: var(--mint);
}

.result-pill.neutral {
  background: rgba(31, 26, 23, 0.08);
  color: var(--text);
}

.result-pill.incorrect {
  background: rgba(207, 76, 49, 0.14);
  color: var(--accent-deep);
}

.train-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 16px 0;
}

.train-meta div {
  margin: 0;
}

.train-meta dt {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.train-meta dd {
  margin: 0;
  font-weight: 600;
}

.prediction-actions {
  position: relative;
  overflow: visible;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.prediction-state,
.resolved-meta,
.resolved-outcome {
  margin: 12px 0 0;
  line-height: 1.5;
}

.prediction-plain-list {
  display: grid;
  gap: 10px;
}

.history-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(31, 26, 23, 0.08);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  margin-top: 14px;
}

.prediction-plain-item {
  padding: 12px 0;
  border-bottom: 1px solid rgba(49, 36, 27, 0.08);
}

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

.prediction-plain-title,
.prediction-plain-meta,
.prediction-plain-outcome {
  margin: 0;
}

.prediction-count {
  font-weight: 600;
}

.prediction-counts {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.prediction-count-on-time {
  color: var(--mint);
}

.prediction-count-delayed {
  color: var(--accent-deep);
}

.prediction-plain-title {
  font-weight: 700;
  color: var(--text);
}

.prediction-plain-meta,
.prediction-plain-outcome {
  margin-top: 4px;
  color: var(--muted);
}

.prediction-outcome-on-time {
  color: var(--mint);
}

.prediction-outcome-delayed {
  color: var(--accent-deep);
}

.history-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.history-actions {
  display: flex;
  gap: 10px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-status {
  margin: 0 0 18px;
}

.admin-card {
  display: grid;
  gap: 18px;
}

.admin-auth,
.admin-list {
  display: grid;
  gap: 14px;
}

.admin-login {
  display: flex;
  gap: 12px;
  align-items: end;
}

.admin-toolbar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: end;
}

.admin-filter {
  display: flex;
  gap: 12px;
  align-items: end;
}

.admin-logout-btn,
.admin-delete-btn {
  background: rgba(138, 51, 27, 0.12);
  color: var(--accent-deep);
}

.admin-delete-btn:hover,
.admin-logout-btn:hover {
  background: rgba(138, 51, 27, 0.18);
}

.admin-train-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(49, 36, 27, 0.08);
  border-radius: 22px;
  background: rgba(255, 251, 246, 0.88);
}

.admin-train-header {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.admin-train-title {
  margin: 0 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
}

.admin-train-meta,
.admin-train-route {
  margin: 0;
  color: var(--muted);
}

.admin-train-status {
  margin: 0;
  font-weight: 700;
}

.admin-train-status-on-time {
  color: var(--mint);
}

.admin-train-status-delayed {
  color: var(--accent-deep);
}

.admin-train-status-open,
.admin-train-status-partial {
  color: var(--text);
}

.history-stats {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.history-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.history-stat-grid-open {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-stat-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(49, 36, 27, 0.08);
  background: rgba(255, 251, 246, 0.88);
}

.history-stat-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-stat-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1;
  color: var(--text);
}

.open-stat-tip-split {
  display: grid;
  gap: 4px;
  margin-top: 4px;
}

.history-stat-on-time .history-stat-value {
  color: var(--mint);
}

.history-stat-delayed .history-stat-value {
  color: var(--accent-deep);
}

.history-stat-total-delay {
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  align-items: center;
}

.history-stat-total-delay .history-stat-label {
  margin: 0;
}

.history-stat-total-delay-values {
  display: grid;
  grid-template-columns: auto auto auto auto auto;
  column-gap: 28px;
  align-items: start;
}

.history-delay-segment {
  display: grid;
  gap: 2px;
  grid-template-rows: auto auto;
  justify-items: center;
}

.history-delay-time-segment {
  min-width: 0;
}

.history-delay-number {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
  color: var(--text);
}

.history-delay-unit {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-delay-separator,
.history-delay-colon {
  display: flex;
  align-items: center;
  align-self: start;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  font-weight: 700;
  line-height: 1;
  color: rgba(49, 36, 27, 0.35);
  transform: translateY(0.12em);
}

.history-item {
  padding: 14px 0;
  border-bottom: 1px solid rgba(49, 36, 27, 0.08);
}

.history-group {
  display: grid;
  gap: 2px;
  margin-bottom: 20px;
  border: 1px solid rgba(49, 36, 27, 0.08);
  border-radius: 22px;
  background: rgba(255, 251, 246, 0.82);
  overflow: hidden;
}

.history-group:last-child {
  margin-bottom: 0;
}

.history-group-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.history-group-summary::-webkit-details-marker {
  display: none;
}

.history-group-title-wrap {
  display: grid;
  gap: 6px;
}

.history-group-title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
}

.history-group-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.history-group-route {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.history-group-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, auto));
  gap: 10px;
  align-items: center;
}

.history-group-metric {
  display: grid;
  gap: 4px;
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(49, 36, 27, 0.06);
}

.history-group-metric-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-group-metric-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  color: var(--text);
}

.history-group-tip-value {
  display: inline-block;
}

.history-group-tip-on-time {
  color: var(--mint);
}

.history-group-tip-delayed {
  color: var(--accent-deep);
}

.history-group-tip-separator {
  margin: 0 6px;
  color: var(--muted);
}

.history-group-toggle {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.history-group[open] .history-group-toggle::after {
  content: " ▲";
}

.history-group:not([open]) .history-group-toggle::after {
  content: " ▼";
}

.history-group-content {
  display: grid;
  padding: 0 20px 4px;
  border-top: 1px solid rgba(49, 36, 27, 0.08);
}

.history-note {
  margin: 0 0 22px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(49, 36, 27, 0.08);
  background: rgba(255, 251, 246, 0.82);
}

.history-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.history-note p + p {
  margin-top: 10px;
}

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

.site-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 22px 0 6px;
  color: var(--muted);
}

.site-footer a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  color: var(--text);
}

.site-footer-history {
  padding-bottom: 0;
}

.legal-card {
  display: grid;
  gap: 24px;
}

.legal-section {
  display: grid;
  gap: 12px;
}

.legal-section h2 {
  margin: 0;
  font-size: 1.1rem;
}

.legal-section p {
  margin: 0;
  color: var(--muted);
}

.legal-section a {
  color: var(--text);
}

.history-line {
  display: flex;
  gap: 14px;
  align-items: baseline;
  white-space: nowrap;
  overflow-x: auto;
}

.history-line .prediction-plain-title {
  flex: 0 0 auto;
}

.history-line .prediction-plain-meta,
.history-line .prediction-plain-outcome {
  margin-top: 0;
  flex: 0 0 auto;
}

.open-progress {
  display: grid;
  gap: 6px;
  min-width: 180px;
  flex: 0 0 180px;
}

.open-progress-track {
  position: relative;
  display: block;
  height: 10px;
  border-radius: 999px;
  background: rgba(31, 26, 23, 0.08);
  overflow: hidden;
}

.open-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(240, 163, 59, 0.95), rgba(212, 78, 47, 0.95));
}

.open-progress-track-indeterminate .open-progress-bar-indeterminate {
  width: 42%;
  animation: openProgressIndeterminate 1600ms ease-in-out infinite;
}

.open-progress-label {
  font-size: 0.82rem;
  color: var(--muted);
}

@keyframes openProgressIndeterminate {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(260%);
  }
}


.error-text {
  color: var(--accent-deep);
  margin: 0;
}

code {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 600;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .aside-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: auto;
    margin: 0;
    padding: 20px 10px 56px;
  }

  .history-shell {
    width: auto;
    margin: 0;
    padding: 20px 10px 56px;
  }

  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .section-head,
  .toolbar,
  .input-row {
    flex-direction: column;
  }

  .section-note {
    text-align: left;
  }

  .train-meta,
  .prediction-actions,
  .segmented-control {
    grid-template-columns: 1fr;
  }

  .date-parts {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr) 12px minmax(0, 1.2fr) 42px;
  }

  .time-parts {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr) 64px 42px;
  }

  .picker-slot {
    min-width: 0;
  }

  .prediction-plain-title,
  .prediction-plain-meta,
  .prediction-plain-outcome,
  .prediction-count {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .history-header {
    flex-direction: column;
  }

  .history-actions {
    width: 100%;
  }

  .admin-login,
  .admin-filter,
  .admin-toolbar,
  .admin-train-header {
    flex-direction: column;
    align-items: stretch;
  }

  .history-stats {
    gap: 10px;
  }

  .history-stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .history-stat-total-delay {
    grid-template-columns: 1fr;
  }

  .history-stat-total-delay-values {
    gap: 16px;
  }

  .history-line {
    display: grid;
    gap: 6px;
    white-space: normal;
    overflow-x: visible;
  }

  .history-group {
    overflow: hidden;
  }

  .history-group-summary {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .history-group-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .history-group-metric {
    min-width: 0;
  }

  .history-group-content {
    padding: 0 16px 4px;
  }

  .site-footer {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px 18px;
  }

  .history-line .prediction-plain-title,
  .history-line .prediction-plain-meta,
  .history-line .prediction-plain-outcome {
    flex: initial;
  }
}
