:root {
  color-scheme: dark;
  --bg: #020817;
  --bg-deep: #01050d;
  --surface: #061022;
  --surface-2: #0a1426;
  --surface-3: #111b2d;
  --line: #26334a;
  --line-soft: #182238;
  --text: #f4f7ff;
  --muted: #8e98aa;
  --blue: #0b49ce;
  --blue-bright: #1d63ed;
  --green: #6ce08a;
  --green-bg: rgba(14, 83, 35, 0.28);
  --amber: #f2bd59;
  --amber-bg: rgba(112, 67, 10, 0.22);
  --red: #ff7777;
  --red-bg: rgba(108, 20, 29, 0.25);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg-deep); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(18, 74, 182, 0.22), transparent 38rem),
    linear-gradient(180deg, #061126 0%, var(--bg) 40%, var(--bg-deep) 100%);
}
body.modal-open { overflow: hidden; }
button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: #8fb4ff; }

.shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom));
}
.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 20px;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--blue-bright), #1143a7);
  font-size: 28px;
  font-weight: 800;
}
.brand-copy { min-width: 0; }
.eyebrow { color: #8aa8ff; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
h1 { margin: 0; font-size: clamp(21px, 5vw, 28px); line-height: 1.05; }
h2 { margin: 0; font-size: 22px; line-height: 1.15; }
.phase-pill, .status-pill, .tag, .ready-pill, .mini-pill, .line-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.phase-pill { padding: 6px 10px; color: var(--muted); font-size: 13px; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(4, 13, 31, .96), rgba(2, 9, 22, .96));
  box-shadow: 0 20px 70px rgba(0, 0, 0, .28);
}
.input-panel { padding: 18px; }
.panel-title-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.input-panel p { margin: 8px 0 14px; color: var(--muted); line-height: 1.45; }
.icon-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #10192b;
  color: var(--text);
  cursor: pointer;
}
textarea {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 132px;
  padding: 16px;
  border: 1px solid #3a465a;
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: rgba(8, 17, 34, .98);
  font-size: 18px;
  line-height: 1.45;
}
textarea:focus { border-color: #477be5; box-shadow: 0 0 0 3px rgba(42, 104, 234, .16); }
.action-row { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin-top: 12px; }
.button {
  min-height: 54px;
  border: 0;
  border-radius: 12px;
  color: white;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.button:disabled { opacity: .55; cursor: wait; }
.button.secondary { background: #252e3f; border: 1px solid #3b4659; }
.button.secondary.listening { background: #703424; }
.button.primary { background: linear-gradient(135deg, var(--blue), #0b45c3); }
.service-message { min-height: 44px; margin-bottom: 0 !important; font-size: 14px; }
.service-message.error { color: var(--red); }
.service-message.success { color: #8ec5ff; }

.result-section { margin-top: 20px; display: grid; gap: 12px; }
.section-kicker { color: #86a7ff; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.result-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 3px 0 0; }
.result-title-row h2 { font-size: 21px; }
.ready-pill { padding: 6px 12px; color: var(--green); border-color: rgba(69, 174, 96, .3); background: var(--green-bg); font-size: 13px; }
.result-card { padding: 18px; }
.compact-route-card { padding-block: 15px; }
.route { margin: 0 0 7px; font-size: clamp(20px, 5vw, 26px); font-weight: 850; }
.time-line { margin: 0; font-size: 16px; line-height: 1.4; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.tag { padding: 5px 9px; color: #c1ccdd; background: #0d1423; font-size: 12px; font-weight: 750; }
.tag.live { color: var(--green); background: var(--green-bg); border-color: rgba(48, 151, 74, .35); }
.tag.schedule { color: var(--amber); background: var(--amber-bg); border-color: rgba(158, 109, 34, .45); }
.data-note { margin: 13px 0 0; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); line-height: 1.45; font-size: 14px; }

.clarification-card { padding: 18px; border-color: #594322; }
.clarification-title { display: flex; gap: 12px; align-items: flex-start; }
.question-mark { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border: 1px solid #9e6d22; border-radius: 50%; color: var(--amber); }
.clarification-card h3 { margin: 0; font-size: 20px; }
.clarification-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.error-card { padding: 18px; border-color: #662a34; }
.error-card h3 { margin: 0 0 8px; color: #ffd3d7; }
.error-card p { color: var(--muted); }

.journey-list { display: grid; gap: 10px; }
.journey-card.compact { padding: 0; overflow: hidden; border-radius: 18px; }
.journey-open-button {
  display: block;
  width: 100%;
  padding: 15px;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}
.journey-open-button:focus-visible { outline: 3px solid rgba(84, 139, 255, .65); outline-offset: -3px; }
.journey-open-button:active { background: rgba(29, 99, 237, .08); }
.journey-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.compact-head { align-items: flex-start; }
.journey-times { font-size: 23px; font-weight: 900; letter-spacing: -.02em; }
.journey-meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.mini-pill { padding: 4px 8px; color: #dbe4f4; background: #111a2b; font-size: 12px; font-weight: 760; }
.mini-pill.direct { color: var(--green); border-color: rgba(48,151,74,.35); background: var(--green-bg); }
.mini-pill.transfer { color: #ffe3ad; border-color: rgba(190,132,45,.45); background: rgba(95,55,8,.28); }
.delay-pill { color: var(--amber); border-color: rgba(190,132,45,.45); background: var(--amber-bg); }
.journey-lines { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.line-badge { padding: 5px 8px; color: #e5ebf6; background: #10192a; font-size: 12px; font-weight: 800; }
.transfer-preview {
  margin-top: 11px;
  padding: 9px 11px;
  border-left: 3px solid #d79837;
  border-radius: 6px 10px 10px 6px;
  color: #f4ddb3;
  background: rgba(83, 50, 10, .24);
  font-size: 13px;
  line-height: 1.35;
}
.transfer-preview.direct-preview { border-left-color: #43b867; color: #baf2c8; background: rgba(14, 83, 35, .22); }
.journey-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}
.journey-card-footer strong { color: #a9c7ff; }
.delay { color: var(--red); font-size: 12px; font-weight: 750; }

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 4, 12, .82);
  backdrop-filter: blur(7px);
}
.modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 620px);
  max-height: min(88vh, 840px);
  overflow: hidden;
  border: 1px solid #3b4d69;
  border-radius: 20px;
  background: linear-gradient(180deg, #071326, #020813 78%);
  box-shadow: 0 35px 110px rgba(0,0,0,.7);
}
.modal-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 15px 15px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 20, 40, .96);
}
.modal-heading { min-width: 0; }
.modal-heading h2 { font-size: 22px; }
.modal-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.modal-close, .modal-back {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #3a4659;
  border-radius: 10px;
  color: var(--text);
  background: #202a3a;
  cursor: pointer;
}
.modal-back[hidden] { visibility: hidden; display: grid; }
.modal-body { overflow: auto; padding: 15px; overscroll-behavior: contain; }
.modal-chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 13px; }
.journey-detail-list { display: grid; gap: 8px; }
.ride-block {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(5, 13, 28, .92);
}
.ride-block-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.ride-block-head > div { min-width: 0; }
.ride-block-head strong { font-size: 16px; }
.ride-block-head small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.segment-number { color: #8fb4ff; font-weight: 850; }
.ride-route-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  gap: 8px;
  margin-top: 10px;
  color: #d2dbea;
  font-size: 13px;
}
.ride-route-row span:last-child { text-align: right; }
.route-arrow { color: #6687bf; }
.ride-track-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 7px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.detail-button {
  width: 100%;
  min-height: 40px;
  margin-top: 11px;
  border: 1px solid #355482;
  border-radius: 9px;
  color: #e7efff;
  background: #173154;
  font-weight: 780;
  cursor: pointer;
}
.transfer-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  border: 1px solid #66450e;
  border-radius: 10px;
  color: #ffe4b3;
  background: rgba(83, 50, 10, .28);
  font-size: 13px;
}
.transfer-strip.walk { border-color: #28567a; color: #c6e9ff; background: rgba(14, 63, 91, .25); }
.transfer-strip small { flex-basis: 100%; color: var(--muted); }
.modal-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.detail-direction { margin: 0 0 15px; color: #cfd9ea; }
.stop-timeline { position: relative; display: grid; gap: 0; }
.stop-point {
  position: relative;
  display: grid;
  grid-template-columns: 72px 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 74px;
}
.timeline-dot {
  grid-column: 2;
  width: 10px;
  height: 10px;
  border: 2px solid #d6e2f4;
  border-radius: 50%;
  background: #071326;
  z-index: 2;
}
.stop-time-box { grid-column: 1; grid-row: 1; display: grid; gap: 2px; }
.stop-time-box small { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: 9px; }
.stop-time-box strong { font-size: 17px; }
.stop-time-box span { color: var(--amber); font-size: 10px; }
.stop-copy { grid-column: 3; grid-row: 1; min-width: 0; }
.stop-copy strong { display: block; font-size: 16px; }
.stop-copy span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.timeline-line {
  display: grid;
  grid-template-columns: 72px 18px 1fr;
  min-height: 52px;
  color: var(--muted);
  font-size: 11px;
}
.timeline-line::before {
  content: "";
  grid-column: 2;
  justify-self: center;
  width: 2px;
  height: 100%;
  background: #5d6d83;
}
.timeline-line span { grid-column: 3; align-self: center; }
.technical-details { margin: 16px 0 0; border-top: 1px solid var(--line); padding-top: 10px; }
.technical-details div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; padding: 5px 0; }
.technical-details dt { color: var(--muted); font-size: 11px; }
.technical-details dd { margin: 0; color: #cfd9ea; font-size: 11px; overflow-wrap: anywhere; }

.attribution { margin-top: 18px; padding: 17px; }
.attribution h2 { font-size: 17px; }
.attribution p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; font-size: 13px; }
.app-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  margin-top: 22px;
  padding: 18px 2px 0;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 13px;
}
.build-copy strong { color: #aab4c4; }
.status-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.status-pill { padding: 6px 9px; }
.status-pill.good { color: var(--green); background: var(--green-bg); border-color: rgba(48,151,74,.35); }
.status-pill.bad { color: var(--red); background: var(--red-bg); border-color: rgba(197,65,78,.36); }
.status-pill.neutral { color: var(--muted); }
.report-button {
  grid-column: 1 / -1;
  min-height: 45px;
  border: 1px solid #3d485d;
  border-radius: 12px;
  background: #151d2b;
  color: #e7ecf5;
  font-weight: 750;
  cursor: pointer;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 520px) {
  .shell { padding-inline: 14px; }
  .app-header { grid-template-columns: auto 1fr; }
  .phase-pill { display: none; }
  .app-footer { grid-template-columns: 1fr; }
  .status-pills { justify-content: flex-start; }
  .journey-head { display: grid; }
  .journey-head > .tag { justify-self: start; }
  .journey-times { font-size: 22px; }
  .transfer-preview.direct-preview { border-left-color: #43b867; color: #baf2c8; background: rgba(14, 83, 35, .22); }
.journey-card-footer { align-items: flex-end; }
  .modal { padding-inline: 8px; }
  .modal-panel { max-height: 94vh; border-radius: 16px; }
  .modal-header { padding: 12px; }
  .modal-body { padding: 12px; }
  .ride-block-head { display: grid; }
  .ride-route-row { grid-template-columns: 1fr; }
  .ride-route-row span:last-child { text-align: left; }
  .route-arrow { display: none; }
  .technical-details div { grid-template-columns: 1fr; gap: 2px; }
}
