/* Android phone layout: Material 3 surfaces, app bars, fields and navigation. */
@media (max-width: 760px) {
  :root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #edf2f8;
    --ink: #17263b;
    --muted: #5d6d82;
    --line: #dce4ee;
    --primary: #2864c8;
    --primary-hover: #1b4f9f;
    --mint: #e4edfb;
    --amber: #5c6572;
    --amber-bg: #edf2f8;
    --shadow: 0 1px 2px rgb(20 42 74 / 8%);
    color-scheme: light;
  }

  [data-theme="dark"] {
    --bg: #0f1726;
    --surface: #182438;
    --surface-2: #202f46;
    --ink: #edf3fc;
    --muted: #a9b8cc;
    --line: #34455d;
    --primary: #91baff;
    --primary-hover: #b1ceff;
    --mint: #293b58;
    --amber: #c2cfe3;
    --amber-bg: #202f46;
    --shadow: 0 1px 2px rgb(0 0 0 / 20%);
    color-scheme: dark;
  }

  html { scroll-padding-top: calc(68px + env(safe-area-inset-top)); }
  body {
    overflow-x: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: Roboto, "Google Sans", "Noto Sans", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: contain;
  }

  h1, h2, h3 { letter-spacing: -.02em; }
  h1 { color: var(--ink); font-size: 28px; line-height: 1.18; font-weight: 650; }
  h2 { font-size: 20px; line-height: 1.3; font-weight: 600; }
  h3 { font-size: 17px; line-height: 1.35; font-weight: 600; }
  p { line-height: 1.5; }

  .app-shell { min-height: 100dvh; padding-top: env(safe-area-inset-top); background: var(--bg); }
  .topbar {
    position: sticky;
    top: env(safe-area-inset-top);
    z-index: 40;
    display: flex;
    height: 64px;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 68%, transparent);
    background: var(--surface);
    box-shadow: none;
    backdrop-filter: none;
  }
  .topbar .brand { min-width: 0; gap: 8px; }
  .brand-mark, .brand-mark svg { display: block; width: 30px; height: 31px; }
  .brand-word { color: var(--ink); font-size: 19px; line-height: 1; font-weight: 700; letter-spacing: -.7px; }
  .brand-word > span { margin: 4px 0 0 2px; color: var(--muted); font-size: 8px; line-height: 1; letter-spacing: 2.3px; }
  .topbar .primary-nav { display: none; }
  .top-actions { display: flex; align-items: center; gap: 4px; }
  .top-actions .local-clock, .settings-action { display: none; }
  .top-actions .icon-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
  }
  .notification-dot i { top: 10px; right: 11px; }

  .demo-banner {
    width: auto;
    min-height: 40px;
    margin: 8px 16px 0;
    padding: 0 8px 0 12px;
    gap: 9px;
    border: 0;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
  }
  .demo-banner > .icon { width: 18px; height: 18px; flex: none; color: var(--primary); }
  .demo-message { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .demo-message strong { color: var(--ink); font-weight: 600; }
  .demo-message .banner-separator { padding: 0 3px; }
  .demo-banner button {
    display: grid;
    width: 40px;
    height: 40px;
    min-width: 40px;
    place-items: center;
    margin-left: auto;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
  }
  .demo-banner button .icon:first-child { width: 20px; height: 20px; }
  .demo-banner button .icon:last-child, .demo-desktop-label { display: none; }

  .page-main, main.page-main {
    width: 100%;
    max-width: none;
    min-height: calc(100dvh - 64px);
    margin: 0;
    padding: 8px 16px calc(108px + env(safe-area-inset-bottom));
  }
  .page-heading { display: block; margin: 8px 0 16px; }
  .page-heading .eyebrow { display: none; }
  .page-heading h1 { max-width: none; margin: 0 0 6px; font-size: 28px; line-height: 1.18; font-weight: 650; }
  .page-heading p { max-width: none; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
  .page-heading > .btn { width: 100%; margin-top: 14px; }

  .card, .journey-card, .tool-card, .query-summary, .popular-route, .directory-card,
  .live-workspace, .live-reference, .settings-card, .screen-group {
    border-color: var(--line);
    border-radius: 20px;
    box-shadow: none;
  }
  .card { padding: 18px; }
  .btn { min-height: 48px; border-radius: 14px; font-size: 14px; font-weight: 600; }
  .btn:hover, .tool-card:hover, .directory-card:hover { transform: none; }
  .icon-btn { width: 48px; height: 48px; min-width: 48px; min-height: 48px; }
  input, select { min-height: 48px; font-size: 16px; }
  .field { min-height: 60px; padding: 10px 12px; border-color: var(--line); border-radius: 14px; font-size: 12px; letter-spacing: 0; }
  .field input, .field select { min-height: 36px; font-size: 16px; line-height: 1.35; font-weight: 500; }
  .field-content > .icon { width: 20px; height: 20px; }

  .home-layout { display: block; }
  .screen-home .home-desktop-title, .screen-home .home-desktop-copy { display: none; }
  .screen-home .home-mobile-title, .screen-home .home-mobile-copy { display: inline; }
  .screen-home .page-heading { margin: 8px 0 16px; }
  .screen-home .page-heading h1 { font-size: 29px; }
  .screen-home .page-heading p { font-size: 15px; }
  .screen-home .source-bar { display: none; }
  .screen-home .search-modes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin: 0 0 12px;
    padding: 4px;
    border: 0;
    border-radius: 16px;
    background: var(--surface-2);
  }
  .screen-home .search-modes .chip {
    min-width: 0;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 550;
    white-space: nowrap;
  }
  .screen-home .search-modes .chip.selected {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 2px rgb(20 42 74 / 12%);
  }
  .screen-home .search-modes .chip .icon { width: 19px; height: 19px; }
  .screen-home .search-panel { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .screen-home .search-panel-title { display: none; }
  .screen-home .station-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px;
    grid-template-rows: auto auto;
    gap: 0;
    margin: 0 0 8px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: none;
  }
  .screen-home .station-fields .combo:first-child { grid-column: 1; grid-row: 1; border-bottom: 1px solid var(--line); }
  .screen-home .station-fields .combo:last-child { grid-column: 1; grid-row: 2; }
  .screen-home .station-fields .combo { min-width: 0; padding: 5px 5px; border: 0; border-radius: 0; background: transparent; }
  .screen-home .station-fields .combo label { color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }
  .screen-home .station-fields .field-content { gap: 10px; margin-top: 2px; }
  .screen-home .station-fields .field-content > .icon { width: 20px; height: 20px; color: var(--primary); }
  .screen-home .station-fields .field input { min-height: 38px; padding: 3px 0; font-size: 16px; font-weight: 550; }
  .screen-home .station-fields .swap-btn {
    position: static;
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    justify-self: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    box-shadow: none;
    color: var(--primary);
    transform: none;
  }
  .screen-home .station-fields .swap-btn > .icon { width: 20px; height: 20px; transform: none; }

  .screen-home .form-three {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 6px;
  }
  .screen-home .form-three .field {
    min-width: 0;
    min-height: 70px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
  }
  .screen-home .form-three input[type="date"] { width: 100%; min-height: 40px; padding: 3px 0; border: 0; background: transparent; color: var(--ink); font-size: 16px; font-weight: 550; }
  .screen-home .form-three select { width: 100%; min-height: 40px; padding: 3px 16px 3px 0; border: 0; background-color: transparent; color: var(--ink); font-size: 15px; font-weight: 550; }
  .screen-home .form-three .passenger-field {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    min-height: 60px;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px 4px 14px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--surface);
  }
  .screen-home .passenger-field > span:first-child { color: var(--ink); font-size: 15px; font-weight: 500; letter-spacing: 0; text-transform: none; }
  .passenger-stepper { display: inline-flex; min-height: 48px; align-items: center; justify-content: flex-end; gap: 8px; margin: 0; }
  .passenger-stepper button { display: grid; width: 44px; height: 44px; min-width: 44px; min-height: 44px; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--primary); }
  .passenger-stepper button .icon { width: 18px; height: 18px; }
  .passenger-stepper input { width: 32px; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: center; font-size: 16px; font-weight: 600; appearance: textfield; }
  .passenger-stepper input::-webkit-inner-spin-button, .passenger-stepper input::-webkit-outer-spin-button { appearance: none; margin: 0; }

  .screen-home .date-shortcuts {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 2px 0 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
  }
  .screen-home .date-shortcuts::-webkit-scrollbar { display: none; }
  .screen-home .date-shortcuts .mini {
    min-height: 40px;
    flex: 0 0 auto;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 500;
    scroll-snap-align: start;
  }
  .screen-home .search-advanced { margin: 4px 0 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .screen-home .search-advanced summary { min-height: 56px; display: flex; align-items: center; gap: 12px; list-style: none; cursor: pointer; }
  .screen-home .search-advanced summary::-webkit-details-marker { display: none; }
  .screen-home .search-advanced summary > span:first-child { display: grid; min-width: 0; gap: 3px; }
  .screen-home .search-advanced summary strong { color: var(--ink); font-size: 15px; font-weight: 550; }
  .screen-home .search-advanced summary small { color: var(--muted); font-size: 12px; }
  .screen-home .advanced-current { max-width: 42%; margin-left: auto; overflow: hidden; color: var(--muted); font-size: 12px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
  .screen-home .search-advanced summary > .icon { width: 20px; height: 20px; flex: none; color: var(--muted); transition: transform .18s; }
  .screen-home .search-advanced[open] summary > .icon { transform: rotate(180deg); }
  .screen-home .advanced-content { display: grid; gap: 10px; padding: 0 0 14px; }
  .screen-home .train-quota { grid-template-columns: 1fr; gap: 10px; margin: 0; }
  .screen-home .mode-field { margin: 6px 0 0; }
  .screen-home .mode-field legend { margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 550; letter-spacing: 0; }
  .screen-home .mode-field .segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
  .screen-home .mode-field .segmented label { min-height: 44px; justify-content: flex-start; padding: 8px 12px; border-radius: 11px; font-size: 13px; white-space: normal; }
  .screen-home .mode-field .segmented label:has(input:checked) { background: var(--surface); box-shadow: 0 1px 2px rgb(20 42 74 / 12%); }
  .screen-home .search-cta {
    position: static;
    z-index: auto;
    width: 100%;
    min-height: 56px;
    margin: 8px 0 0;
    border-radius: 16px;
    background: var(--primary);
    box-shadow: none;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
  }
  [data-theme="dark"] .screen-home .search-cta { color: #102039; }
  .screen-home .form-footnote { justify-content: flex-start; margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
  .screen-home .form-footnote > .icon { width: 17px; height: 17px; flex: none; }
  .screen-home #form-error:empty { display: none; }
  .screen-home .journey-inspiration { display: none; }
  .screen-home .quick-tools { display: flex; gap: 10px; margin: 0 -2px; padding: 2px 2px 6px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory; }
  .screen-home .quick-tools::-webkit-scrollbar { display: none; }
  .screen-home .tool-card { min-height: 80px; flex: 0 0 180px; grid-template-columns: 40px minmax(0, 1fr) 16px; grid-template-rows: auto auto; align-content: center; gap: 4px 10px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: none; scroll-snap-align: start; }
  .screen-home .tool-card .tile-icon { grid-row: 1 / span 2; width: 40px; height: 40px; border-radius: 13px; background: var(--surface-2); color: var(--primary); }
  .screen-home .tool-card strong { font-size: 13px; line-height: 1.3; }
  .screen-home .tool-card > span:not(.tile-icon) { font-size: 12px; }

  .bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    height: calc(80px + env(safe-area-inset-bottom));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
    background: var(--surface);
    box-shadow: none;
    backdrop-filter: none;
  }
  .bottom-tab {
    min-width: 0;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 14px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
  }
  .bottom-tab .nav-indicator { width: 64px; height: 32px; display: grid; place-items: center; border-radius: 999px; color: inherit; }
  .bottom-tab .icon { width: 22px; height: 22px; }
  .bottom-nav > .bottom-tab.active { background: transparent; color: var(--primary); font-weight: 600; }
  .bottom-nav > .bottom-tab.active .nav-indicator { background: var(--mint); }
  .main-footer { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 32px; padding: 20px 0 12px; color: var(--muted); font-size: 12px; }
  .main-footer > span:last-child { grid-column: 1 / -1; font-size: 10px; }
  #toast { bottom: calc(90px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); font-size: 14px; }

  .journey-grid, .settings-grid, .saved-grid, .trip-grid, .fare-grid { grid-template-columns: 1fr; }
  .query-summary { padding: 16px; }
  .results-toolbar, .results-meta { align-items: flex-start; flex-direction: column; }
  .filter-chips { flex-wrap: nowrap; overflow-x: auto; }
  .policy-page { margin: 16px 0; padding: 22px 18px; border-radius: 20px; box-shadow: none; }
  .sheet-header h2 { font-size: 22px; }
  dialog#sheet { width: 100%; max-width: none; max-height: 90dvh; margin: 0; padding: 24px 22px calc(28px + env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0; }
}

@media (max-width: 390px) {
  .page-main, main.page-main { padding-right: 14px; padding-left: 14px; }
  .topbar { padding-inline: 14px; }
  .demo-banner { margin-inline: 14px; }
  .screen-home .page-heading { margin: 6px 0 12px; }
  .screen-home .form-three { gap: 7px; }
  .screen-home .form-three .field { padding-inline: 10px; }
  .screen-home .form-three select { font-size: 14px; }
  .bottom-tab { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
