:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #657488;
  --line: #dce3ec;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #eab308;
  --danger: #b91c1c;
  --shadow: 0 18px 40px rgba(23, 32, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(234, 179, 8, 0.15), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 128px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.04;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary-dark);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.icon-button:hover {
  border-color: var(--primary);
}

.notice,
.favorites-panel,
.search-panel,
.arrival-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.notice {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding: 16px;
  color: var(--danger);
}

.hidden {
  display: none;
}

.search-panel {
  padding: 18px;
}

.favorites-panel {
  margin-bottom: 18px;
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

#favoriteCount {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.favorite-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.favorite-item {
  display: grid;
  grid-template-columns: 1fr 40px;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfdff;
}

.favorite-open {
  display: grid;
  gap: 4px;
  border: 0;
  padding: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.favorite-open:hover {
  background: #ecfdf5;
}

.favorite-name {
  font-weight: 800;
}

.favorite-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.favorite-delete {
  display: grid;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
}

.favorite-delete:hover {
  background: #fff1f2;
}

.search-form {
  display: grid;
  gap: 8px;
}

.direct-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input {
  min-width: 0;
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
}

input:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--primary);
}

button[type="submit"] {
  height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.station-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.station-item {
  display: grid;
  gap: 4px;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.station-item:hover,
.station-item.selected {
  border-color: var(--primary);
  background: #ecfdf5;
}

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

.station-meta,
.status-line,
.label,
small {
  color: var(--muted);
}

.status-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 2px 12px;
  font-size: 0.95rem;
}

.arrival-list {
  display: grid;
  gap: 12px;
}

.arrival-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 16px;
  align-items: stretch;
  padding: 16px;
}

.route-badge {
  display: grid;
  place-items: center;
  min-width: 0;
  border-radius: 8px;
  background: var(--primary-dark);
  color: #fff;
  font-weight: 900;
  word-break: break-word;
  text-align: center;
}

.arrival-main {
  display: grid;
  gap: 14px;
}

.arrival-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

h2 {
  margin: 0;
  font-size: 1.4rem;
}

.direction {
  color: var(--primary-dark);
  font-weight: 700;
}

.arrival-times {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.arrival-times > div {
  display: grid;
  gap: 4px;
  min-height: 74px;
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}

.label {
  font-size: 0.82rem;
  font-weight: 800;
}

.first-message,
.second-message {
  font-size: 1.1rem;
}

.arrival-side {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 6px;
  min-width: 112px;
  color: var(--muted);
  font-size: 0.92rem;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1040px);
    padding-top: 20px;
  }

  .hero {
    align-items: flex-start;
  }

  .search-row,
  .arrival-card,
  .arrival-times {
    grid-template-columns: 1fr;
  }

  .arrival-card {
    gap: 12px;
  }

  .route-badge {
    min-height: 46px;
  }

  .arrival-side {
    justify-items: start;
    min-width: 0;
  }
}
