:root {
  color-scheme: light;
  --bg: #eef4f5;
  --panel: #ffffff;
  --ink: #12222a;
  --muted: #667780;
  --line: #d7e2e5;
  --brand: #087e91;
  --brand-strong: #076b82;
  --danger: #b52635;
  --warning: #a95d00;
  --info: #1769aa;
  --ok: #147a52;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 14px calc(env(safe-area-inset-bottom) + 22px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.65rem;
  line-height: 1.12;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-size: 1.45rem;
  line-height: 1;
}

.icon-button:active {
  transform: scale(0.98);
}

.panel,
.status,
.alert-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgb(20 55 70 / 0.08);
}

.panel {
  padding: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 76px;
  min-height: 36px;
  padding: 7px 10px 7px 12px;
  border-radius: 999px;
  background: #e0f2f4;
  color: #07586a;
  font-weight: 700;
  white-space: nowrap;
}

.chip button {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgb(7 88 106 / 0.14);
  color: #07586a;
  line-height: 1;
}

.line-form,
.stop-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.line-form input,
.stop-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfeff;
}

.stop-input-wrap {
  position: relative;
  min-width: 0;
}

.stop-input-wrap input {
  width: 100%;
  padding-right: 42px;
}

.clear-input-button {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: #d7e2e8;
  color: #24424d;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

.clear-input-button:active {
  transform: translateY(-50%) scale(0.96);
}

.line-form > button,
.stop-form > button,
.detail a {
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--brand);
  color: white;
  font-weight: 700;
}

.stop-favorite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.secondary-button {
  border: 1px solid #89c3cd;
  border-radius: 8px;
  padding: 9px 11px;
  background: #f2fbfc;
  color: var(--brand-strong);
  font-weight: 800;
}

.secondary-button:disabled {
  border-color: var(--line);
  background: #f4f7f8;
  color: var(--muted);
}

.stop-favorites {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.stop-favorites[hidden] {
  display: none;
}

.favorite-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid #cfe2e6;
  border-radius: 999px;
  background: #fbfeff;
}

.favorite-select,
.favorite-remove {
  border: 0;
  background: transparent;
  color: #07586a;
  font-weight: 800;
}

.favorite-select {
  min-width: 0;
  overflow: hidden;
  padding: 7px 8px 7px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-remove {
  width: 28px;
  height: 28px;
  color: var(--muted);
}

.stop-choices {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.stop-choices[hidden] {
  display: none;
}

.stop-choice {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fbfeff;
  color: var(--ink);
  text-align: left;
}

.stop-choice strong {
  font-size: 0.95rem;
}

.stop-choice span {
  color: var(--muted);
  font-size: 0.82rem;
}

.stop-choice:focus,
.stop-choice:hover {
  border-color: #89c3cd;
  background: #f2fbfc;
}

.stop-more {
  width: 100%;
  border: 1px solid #89c3cd;
  border-radius: 8px;
  padding: 10px 11px;
  background: #e8f7f9;
  color: var(--brand-strong);
  font-weight: 800;
}

.stop-more:focus,
.stop-more:hover {
  background: #d9f0f4;
}

.status {
  margin-top: 12px;
  padding: 13px 14px;
  color: var(--muted);
}

.status.error {
  color: #8d1f2b;
  border-color: #f0bcc3;
  background: #fff6f7;
}

.departures-head,
.alerts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 10px;
}

#departureCount,
#alertCount {
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: white;
  color: var(--muted);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.departures,
.alerts {
  display: grid;
  gap: 8px;
}

.alert-card {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  text-align: left;
}

.departure-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgb(20 55 70 / 0.07);
}

.departure-row {
  display: grid;
  grid-template-columns: 52px 34px 78px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 3px 10px;
  border-top: 1px solid #edf3f5;
}

.departure-row:first-child {
  border-top: 0;
}

.departure-platform-heading {
  padding: 7px 10px 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
  background: #f6fbfc;
}

.departure-platform-heading.platform-change {
  border-top: 3px solid var(--line);
}

.departure-time {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--brand-strong);
  text-align: right;
  white-space: nowrap;
}

.departure-delay {
  min-width: 0;
  color: #b64800;
  font-size: 0.72rem;
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.departure-line {
  font-size: 0.82rem;
  font-weight: 800;
  color: #07586a;
  text-align: center;
  white-space: nowrap;
}

.departure-destination {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 750;
  white-space: nowrap;
}

.alert-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.line-badge,
.severity {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.line-badge {
  background: #e0f2f4;
  color: #07586a;
}

.severity {
  color: var(--muted);
  background: #edf2f4;
}

.severity.disruption,
.severity.cancellation {
  color: var(--danger);
  background: #fde8eb;
}

.severity.delay {
  color: var(--warning);
  background: #fff0d9;
}

.severity.info {
  color: var(--info);
  background: #e5f1fb;
}

.alert-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.28;
}

.alert-card p {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.35;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.empty {
  padding: 28px 18px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.7);
  color: var(--muted);
  text-align: center;
}

.trust-footer {
  display: grid;
  gap: 7px;
  margin: 22px 2px 0;
  padding: 14px 0 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.trust-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.trust-footer a {
  color: var(--brand-strong);
  font-weight: 750;
  text-decoration: none;
}

.trust-footer a:focus,
.trust-footer a:hover {
  text-decoration: underline;
}

dialog {
  width: min(640px, calc(100% - 24px));
  max-height: min(760px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.25);
}

dialog::backdrop {
  background: rgb(0 20 30 / 0.38);
}

.detail {
  position: relative;
  max-height: inherit;
  overflow: auto;
  padding: 18px;
}

.detail h3 {
  margin: 14px 0 12px;
  font-size: 1.25rem;
}

.detail p {
  color: var(--ink);
  line-height: 1.5;
}

.detail a {
  display: inline-block;
  margin-top: 18px;
  text-decoration: none;
}

.close-button {
  float: right;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #edf2f4;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 34px;
  }

  h1 {
    font-size: 2rem;
  }
}

@media (max-width: 390px) {
  .line-form,
  .stop-form {
    grid-template-columns: 1fr;
  }
}
