:root {
  --bg: #eef3f7;
  --card: #ffffff;
  --ink: #172033;
  --muted: #6d7888;
  --line: #d7e0ea;
  --blue: #1f6feb;
  --blue-soft: #e8f1ff;
  --blue-deep: #154ea8;
  --shadow: 0 16px 40px rgba(28, 52, 84, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

button, input {
  touch-action: manipulation;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background:
    radial-gradient(1200px 480px at 50% -180px, #d9e8ff 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.page {
  width: min(440px, calc(100% - 32px));
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 0 max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.search {
  display: flex;
  gap: 8px;
  flex: none;
  padding: 6px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.search-label {
  display: flex;
  align-items: center;
  padding-left: 12px;
  color: var(--ink);
  font-size: 16px;
  flex: none;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border: 0;
  outline: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.2;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}

.search input::placeholder { color: #9aa6b4; }

.search button {
  border: 0;
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.search button:disabled,
.login button:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-view {
  flex: 1;
  display: flex;
  align-items: center;
}

.app-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.login-view[hidden],
.app-view[hidden] {
  display: none !important;
}

.login-panel {
  width: 100%;
  margin-top: -8vh;
}

.login-head {
  margin: 0 4px 18px;
}

.login-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 680;
  letter-spacing: 0.02em;
}

.login-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login {
  width: 100%;
  padding: 22px 20px 16px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.field input {
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: #f7fafc;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 400;
}

.field input::placeholder {
  color: #9aa6b4;
}

.field input:focus {
  outline: 2px solid rgba(31, 111, 235, 0.22);
  border-color: var(--blue);
  background: #fff;
}

.login .message {
  margin: -4px 2px 14px;
}

.login button[type="submit"] {
  width: 100%;
  height: 48px;
  margin-top: 2px;
  border: 0;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.auto-login {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #eef2f6;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.auto-login input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.message {
  margin: 14px 4px 0;
  color: #b42318;
  font-size: 14px;
}

.result {
  flex: 1;
  min-height: 0;
  margin-top: 16px;
  padding: 18px 10px 14px 16px;
  overflow: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 32, 51, 0.28) transparent;
}

.result::-webkit-scrollbar {
  width: 6px;
}

.result::-webkit-scrollbar-track {
  background: transparent;
  margin-top: 5px;
  margin-bottom: 5px;
}

.result::-webkit-scrollbar-thumb {
  background: rgba(23, 32, 51, 0.28);
  border-radius: 6px;
}

.route-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 12px;
}

.route-name {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.dirs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dir {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.dir.active {
  border-color: transparent;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-weight: 650;
}

.hours {
  display: flex;
  gap: 18px;
  margin: 14px 2px 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef2f6;
  color: var(--muted);
  font-size: 13px;
}

.hours strong {
  margin-left: 6px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 650;
}

.hours .count {
  margin-left: auto;
  align-self: center;
  color: var(--blue-deep);
  font-weight: 600;
}

.stops {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.stop {
  display: grid;
  grid-template-columns: 22px 1fr;
  column-gap: 8px;
}

.rail {
  position: relative;
  display: flex;
  justify-content: center;
}

.rail::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: -2px;
  width: 2px;
  background: #d5e2f2;
}

.stop:last-child .rail::before { display: none; }

.dot {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  background: #fff;
}

.stop.is-end .dot,
.stop.is-start .dot {
  background: var(--blue);
}

.body {
  min-width: 0;
  padding-bottom: 4px;
}

.name {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
}

.buses, .between {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.buses { margin: 6px 0 8px; }
.buses:empty { display: none; }

.between {
  margin: 2px 0 10px;
  min-height: 8px;
}

.between:empty { min-height: 14px; }

.bus {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-size: 12px;
  line-height: 18px;
}

.bus svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.updated {
  margin: 4px 0 0;
  color: #98a2b0;
  font-size: 12px;
  flex: none;
  white-space: nowrap;
}
