/* Phone-first layout: safe areas, readable type, thumb-sized controls and a native-feeling tab bar. */
@media (max-width: 760px) {
  html, body { min-height: 100%; overscroll-behavior-y: contain; -webkit-tap-highlight-color: transparent; }
  body { min-height: 100dvh; overflow-x: hidden; }
  .app-shell, .main-area { display: block; min-height: 100dvh; }
  .sidebar { display: none; }

  .topbar {
    height: calc(54px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
  }
  .crumb { height: 100%; gap: 0; letter-spacing: 0; }
  .crumb span, .crumb > b { display: none; }
  .crumb strong { color: var(--text); font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
  .top-actions { gap: 8px; }
  .icon-button, .top-avatar { width: 44px; height: 44px; border-radius: 50%; font-size: 18px; }
  .top-avatar { display: grid; background: var(--panel); border: 1px solid var(--line); color: var(--text); }

  .view { width: 100%; margin: 0; padding: 24px 18px calc(112px + env(safe-area-inset-bottom)); }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 16px; margin-bottom: 24px; }
  .page-heading h1 { margin: 7px 0 8px; font-size: 32px; line-height: 1.08; letter-spacing: -1px; }
  .page-heading p { max-width: 34ch; font-size: 14px; line-height: 1.5; }
  .eyebrow { font-size: 10px; letter-spacing: 1px; }
  .heading-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; width: 100%; }
  .button { min-height: 48px; padding: 11px 13px; border-radius: 14px; font-size: 14px; line-height: 1.25; white-space: normal; }
  .button.small { min-height: 44px; padding: 9px 11px; font-size: 13px; }
  .text-button { min-height: 44px; padding: 8px; font-size: 13px; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 30px; }
  .stat-card { min-width: 0; min-height: 112px; align-items: flex-start; gap: 8px; padding: 14px 13px; border-radius: 18px; box-shadow: 0 3px 12px #00000008; }
  .stat-icon { width: 34px; height: 34px; border-radius: 11px; font-size: 12px; }
  .stat-card span { font-size: 9px; letter-spacing: .65px; line-height: 1.3; white-space: normal; }
  .stat-card b { margin: 3px 0 1px; font-size: 22px; }
  .stat-card b small { font-size: 11px; }
  .stat-card em { font-size: 10px; line-height: 1.35; white-space: normal; }
  .section-title-row, .panel-heading { align-items: center; gap: 10px; }
  .section-title-row { margin: 0 0 15px; }
  .section-title-row h2 { font-size: 21px; letter-spacing: -.5px; }
  .bike-grid, .lower-grid { grid-template-columns: 1fr; gap: 13px; }

  .bike-card, .panel, .component-card, .schedule-row { border-radius: 20px; }
  .bike-card { padding: 18px 16px 14px; box-shadow: 0 4px 18px #0000000a; }
  .bike-card-top { gap: 12px; padding-bottom: 15px; }
  .bike-visual { width: 58px; height: 58px; border-radius: 17px; font-size: 24px; }
  .bike-title h2, .garage-bike h2 { font-size: 20px; }
  .bike-title p, .garage-bike-head p { font-size: 12px; line-height: 1.4; }
  .year-chip { padding: 4px 7px; border-radius: 7px; font-size: 10px; }
  .bike-actions-inline { gap: 8px; margin-top: 9px; flex-wrap: wrap; }
  .bike-actions-inline button, .record-actions button { min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-size: 12px; }
  .bike-actions-inline button { flex: 1; }
  .odo-row { padding: 15px 0 13px; }
  .odo-row span, .garage-odo > span { font-size: 10px; letter-spacing: .6px; }
  .odo-row strong { font-size: 20px; }
  .odo-row strong small { font-size: 12px; }
  .next-row { gap: 10px; padding: 16px 0; }
  .next-row b { max-width: none; font-size: 14px; line-height: 1.35; white-space: normal; }
  .next-row small { font-size: 11px; line-height: 1.4; }
  .progress-ring { width: 48px; height: 48px; }
  .progress-ring b { font-size: 15px; }
  .progress-ring small { font-size: 8px; }
  .prediction-row { gap: 8px; flex-wrap: wrap; padding-top: 12px; font-size: 11px; }
  .prediction-row button { min-height: 42px; padding: 8px 10px; border-radius: 11px; background: color-mix(in srgb, var(--lime) 10%, transparent); font-size: 12px; }
  .bike-spend-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 1px; padding-top: 12px; }
  .bike-spend-row span { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; font-size: 8px; letter-spacing: .4px; }
  .bike-spend-row b { font-size: 12px; }

  .panel { padding: 17px 15px; }
  .panel-heading { margin-bottom: 14px; }
  .panel-heading h3, .panel h3 { font-size: 16px; line-height: 1.3; }
  .panel p, .insight-panel p { font-size: 13px; line-height: 1.55; }
  .action-row { min-height: 62px; gap: 10px; padding: 10px 0; }
  .icon-tile { width: 38px; height: 38px; border-radius: 12px; font-size: 16px; }
  .action-copy b { font-size: 13px; line-height: 1.3; white-space: normal; }
  .action-copy small { font-size: 11px; line-height: 1.35; }
  .status-pill { min-height: 26px; height: auto; padding: 4px 8px; border-radius: 9px; font-size: 10px; }
  .row-arrow { min-width: 40px; min-height: 40px; }
  .demo-banner { align-items: flex-start; gap: 10px; padding: 13px; border-radius: 15px; }
  .demo-banner small { font-size: 11px; line-height: 1.45; }
  .demo-banner button { min-height: 40px; font-size: 12px; }

  .mobile-nav {
    position: fixed;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    gap: 3px;
    left: 0; right: 0; bottom: 0;
    height: calc(72px + env(safe-area-inset-bottom));
    padding: 7px 9px calc(7px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--sidebar) 86%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--line-strong) 65%, transparent);
    backdrop-filter: saturate(180%) blur(22px);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    z-index: 8;
  }
  .mobile-nav button { min-width: 0; min-height: 52px; padding: 5px 2px; border: 0; border-radius: 14px; justify-content: center; gap: 4px; background: transparent; }
  .mobile-nav button span { font-size: 20px; line-height: 1; transition: transform .16s ease; }
  .mobile-nav button small { font-size: 10px; line-height: 1.2; white-space: nowrap; }
  .mobile-nav button.active { color: var(--lime); background: color-mix(in srgb, var(--lime) 11%, transparent); }

  .filter-row { gap: 10px; margin-bottom: 14px; }
  .bike-select { min-height: 46px; padding: 10px 34px 10px 12px; border-radius: 13px; font-size: 14px; }
  .filter-count, .schedule-counts { font-size: 12px; }
  .schedule-row { gap: 11px; padding: 15px; }
  .schedule-icon { width: 40px; height: 40px; border-radius: 13px; }
  .schedule-main { width: calc(100% - 52px); flex: 1; }
  .schedule-title { gap: 7px; flex-wrap: wrap; }
  .schedule-title h3 { font-size: 15px; line-height: 1.35; }
  .schedule-row p, .schedule-meta { font-size: 12px; line-height: 1.5; }
  .schedule-actions { width: 100%; margin: 0 0 0 51px; display: flex; gap: 8px; flex-wrap: wrap; }
  .schedule-actions .button { flex: 1; }
  .timeline { margin-left: 0; padding-left: 18px; }
  .timeline:before { left: 5px; }
  .service-date { position: static; width: auto; margin: 0 0 8px; display: flex; align-items: center; gap: 9px; }
  .service-date b { font-size: 12px; }
  .service-date small { font-size: 11px; }
  .service-entry { margin-bottom: 14px; }
  .service-card { padding: 15px; border-radius: 18px; }
  .service-card h3 { font-size: 15px; line-height: 1.35; }
  .service-detail-row, .service-notes { font-size: 12px; line-height: 1.5; }
  .record-actions { gap: 8px; flex-wrap: wrap; }
  .component-grid { grid-template-columns: 1fr; gap: 12px; }
  .component-card { padding: 16px; }
  .component-card h3 { font-size: 16px; }
  .component-card p, .component-data b, .component-foot { font-size: 12px; line-height: 1.45; }
  .component-data { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .component-data span { font-size: 9px; }
  .calendar-layout, .settings-grid { grid-template-columns: 1fr; }
  .calendar-aside, .settings-aside { display: none; }
  .calendar-month { padding: 12px; border-radius: 18px; overflow: auto; }
  .calendar-cell { min-height: 52px; }
  .calendar-day { font-size: 11px; }
  .calendar-event { gap: 5px; font-size: 10px; }
  .legend { gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
  .legend span { font-size: 10px; }
  .calendar-controls { gap: 8px; }
  .calendar-step { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
  .calendar-controls > b { font-size: 14px; }
  .calendar-view-switch { margin: 0; padding: 3px; border-radius: 11px; }
  .calendar-view-button { min-height: 36px; padding: 7px 9px; border-radius: 8px; font-size: 11px; }
  .book-cover { gap: 13px; padding: 17px; border-radius: 20px; }
  .book-mark { width: 48px; height: 55px; border-radius: 12px; font-size: 25px; }
  .book-cover h2 { font-size: 17px; }
  .book-cover p { font-size: 11px; line-height: 1.45; }
  .book-stats { display: flex; flex-direction: column; gap: 8px; }
  .book-stats b { font-size: 13px; }
  .book-stats small { display: block; margin: 2px 0 0; font-size: 10px; }
  .book-record { grid-template-columns: 74px 9px minmax(0, 1fr); gap: 9px; }
  .book-record-date { font-size: 11px; }
  .book-record-date small, .book-record-body small { font-size: 11px; line-height: 1.45; }

  .more-grid { grid-template-columns: 1fr; gap: 9px; }
  .more-tile { display: grid; grid-template-columns: 46px minmax(0, 1fr) 18px; grid-template-rows: auto auto; align-items: center; gap: 3px 12px; min-height: 82px; padding: 13px 14px; border-radius: 18px; }
  .more-tile > span { grid-column: 1; grid-row: 1 / 3; width: 42px; height: 42px; border-radius: 13px; font-size: 18px; }
  .more-tile > b { grid-column: 2; grid-row: 1; font-size: 14px; }
  .more-tile > small { grid-column: 2; grid-row: 2; max-width: none; font-size: 11px; line-height: 1.4; }
  .more-tile > i { position: static; grid-column: 3; grid-row: 1 / 3; font-size: 16px; }
  .settings-card { padding: 16px; }
  .settings-heading { gap: 11px; }
  .settings-heading h3 { font-size: 16px; }
  .settings-heading p { font-size: 12px; line-height: 1.45; }
  .setting-row { align-items: flex-start; gap: 12px; padding: 14px 0; }
  .setting-row > div:first-child { min-width: 0; }
  .setting-row b { font-size: 13px; }
  .setting-row small { font-size: 11px; line-height: 1.45; }
  .inline-input { max-width: 58%; flex-wrap: wrap; }
  .inline-input input { min-width: 75px; min-height: 44px; font-size: 16px; }
  .cloud-form { gap: 13px; }
  .field { gap: 7px; }
  .field > span { font-size: 12px; }
  .field input, .field textarea, .field select, .bike-select { min-height: 48px; padding: 12px; border-radius: 13px; font-size: 16px; }
  .field input[type=file] { font-size: 13px; }
  .field small, .small-help { font-size: 11px; line-height: 1.5; }
  .form-grid { gap: 13px; }
  .modal { position: fixed; inset: auto 0 0; margin: 0; width: 100%; max-width: none; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); border-radius: 26px 26px 0 0; border-bottom: 0; }
  .modal-head { padding: 18px 18px 14px; }
  .modal-head h2 { font-size: 19px; }
  .modal-form { padding: 16px 18px 20px; }
  .modal-intro { font-size: 12px; line-height: 1.5; }
  .modal-actions { position: sticky; bottom: 0; padding: 12px 0 0; background: var(--panel); }
  .modal-actions .button { flex: 1; }
  .empty-state { padding: 36px 18px; border-radius: 20px; }
  .empty-state h2 { font-size: 21px; }
  .empty-state p { font-size: 14px; line-height: 1.5; }
  .empty-inline { padding: 18px 0; }
  .empty-inline b { font-size: 14px; }
  .empty-inline small { font-size: 12px; line-height: 1.5; }
  .note-panel, .warning-note { padding: 14px; border-radius: 16px; }
  .note-panel p { font-size: 12px; line-height: 1.55; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 680px; }
}

@media(max-width:350px) {
  .view { padding-left: 15px; padding-right: 15px; }
  .heading-actions { grid-template-columns: 1fr; }
  .stat-card { min-height: 104px; padding: 12px; }
  .stat-card span { font-size: 8px; }
  .bike-card { padding-left: 14px; padding-right: 14px; }
  .bike-actions-inline button { padding-right: 7px; padding-left: 7px; font-size: 11px; }
  .mobile-nav { padding-right: 5px; padding-left: 5px; }
  .mobile-nav button small { font-size: 9px; }
  .book-stats { display: none; }
}

@media(hover:none) {
  .button:hover, .more-tile:hover { transform: none; }
}
