/* Phones look like the iOS app (Native theme), sizes in pt taken from the Swift views:
   NativeFastTab header (title 34 bold on the sky, 38 pt glass buttons), NativeWeekStrip, NativeTabBar.
   Desktop and tablets keep the wide layout; everything here is inside the phone breakpoint. */
@media (min-width: 768px) { .phone-only, .title-phone { display: none !important; } }
@property --orb-turn { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes orb-turn { to { --orb-turn: 360deg; } }

@media (max-width: 767px) {
  :root { --phone-top: calc(68px + env(safe-area-inset-top)); }

  /* Header: the tab name in the sky, round glass buttons on the right, avatar as the last button. */
  .app-shell { position: relative; }
  .app-shell main { padding-top: var(--phone-top); }
  .app-header { position: absolute; top: var(--phone-top); inset-inline-end: 20px; margin: 0; padding: 0; height: 38px; min-height: 0; align-items: center; }
  .header-actions { padding: 0; gap: 8px; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  :root[data-sky="dark"] .header-actions { background: none; box-shadow: none; }
  .app-header .sync-status[data-state="ok"] { display: none; }
  .app-header .sync-status { padding: 0 12px; height: 34px; border-radius: 999px; background: var(--glass-tint); box-shadow: var(--glass-edge), var(--glass-lift); font-size: var(--text-meta); }
  .app-header .avatar { width: 38px; height: 38px; font-size: 1.125rem; box-shadow: var(--glass-edge), var(--glass-lift); }

  .app-shell .page-heading { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 58px; padding-inline-end: 46px; min-height: 38px; }
  .page-heading > div:first-child { flex: 1; min-width: 0; }
  .page-heading .date-caption, .page-heading .lead, .page-heading .title-full { display: none; }
  .page-heading h1 { font: 700 2.125rem/1.1 var(--font-display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .page-heading .day-picker { flex-wrap: nowrap; gap: 8px; justify-content: flex-end; }
  .page-heading [data-action="previous-day"], .page-heading [data-action="next-day"] { display: none; }
  .page-heading .icon-button, .page-heading .date-field { width: 38px; height: 38px; min-height: 38px; padding: 0; justify-content: center; color: var(--ink); flex: none; }
  .page-heading .icon-button .icon, .page-heading .date-field .icon { width: 19px; height: 19px; }
  .page-heading .date-field > .icon:not(.phone-only) { display: none; }
  .page-heading .date-field input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
  .page-heading .sky-accent, :root[data-sky="dark"] .page-heading .sky-accent { background: var(--accent); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .35), 0 6px 16px rgb(22 176 90 / .35); }
  .page-heading .sky-accent .icon { width: 20px; height: 20px; }
  .sky-today { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px; border-radius: 999px; background: var(--accent); color: #fff; font: 600 var(--text-secondary)/1 var(--font); box-shadow: inset 0 1px 0 rgb(255 255 255 / .35); }
  .sky-today .icon { width: 15px; height: 15px; }
  /* Not today: the «Today» pill takes the place of Report, as in the app. */
  /* Past day: «Today» takes the place of Report and Calendar (the week strip picks days), the title gets a bit smaller. */
  .page-heading .sky-today ~ a[href="#report"], .page-heading .day-picker:has(.sky-today) .date-field { display: none; }
  .page-heading:has(.sky-today) h1 { font-size: 1.75rem; }

  /* Calorie rows: Activity and Eaten carry the accent, as the app's tinted SF Symbols. */
  .calorie-line .icon[data-icon="tile-run"], .calorie-line .icon[data-icon="tile-fork"] { color: var(--accent); }

  /* Week strip, NativeWeekStrip: 60 pt cells, 11 pt weekday, 17 pt date, 5 pt dot, swipe by week. */
  .week-strip { display: flex; position: relative; margin: -10px -4px 12px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
  .week-strip::-webkit-scrollbar { display: none; }
  .week { flex: 0 0 100%; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 0 2px; scroll-snap-align: start; scroll-snap-stop: always; }
  .week-day { height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 16px; border: 1px solid transparent; color: var(--ink); }
  .week-day:disabled { opacity: .35; }
  .week-day > span { font: 600 .6875rem/1.2 var(--font); color: var(--muted); }
  .week-day > b { font: 500 1.0625rem/1.15 var(--font); font-variant-numeric: tabular-nums; }
  .week-day > i { width: 5px; height: 5px; border-radius: 50%; }
  .week-day.marked > i { background: rgb(108 108 114 / .45); }
  .week-day.today > span, .week-day.today > b { color: var(--accent-ink); }
  .week-day.today > i { background: var(--accent); }
  .week-day.today > b, .week-day.selected > b { font-weight: 700; }
  .week-day.selected { background: rgb(22 176 90 / .12); border-color: rgb(22 176 90 / .25); }
  .week-day.selected > span { color: var(--accent-ink); }

  /* Tab bar, NativeTabBar: 62 pt capsule, 11 pt labels in ink, the current tab green on a raised capsule. */
  .mobile-nav { inset-inline: 16px; bottom: max(8px, env(safe-area-inset-bottom)); padding: 4px; height: 62px; border-radius: 999px; }
  .mobile-nav .nav-item { min-height: 54px; height: 54px; gap: 2px; justify-content: center; border-radius: 999px; color: var(--ink); font: 600 .6875rem/1.15 var(--font); }
  .mobile-nav .nav-item .icon { width: 24px; height: 24px; }
  .mobile-nav .nav-item.active { background: rgb(255 255 255 / .9); color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgb(20 30 60 / .08); }
  .mobile-nav .nav-item.active .icon { transform: scale(1.06); }
  .mobile-nav .nav-item[href="#chat"]::before { content: none; }
  .mobile-nav .nav-item[href="#chat"], .mobile-nav .nav-item[href="#chat"].active { background: none; box-shadow: none; }

  /* AI: a dark glossy disc in a chromatic ring (AITabOrb / AIMetalDisc). */
  .ai-orb { position: relative; display: grid; place-content: center; justify-items: center; width: 52px; height: 52px; border-radius: 50%; color: #fff; isolation: isolate;
    background: radial-gradient(circle at 50% 4%, rgb(255 255 255 / .2), transparent 55%), #121317;
    box-shadow: 0 2px 3px rgb(0 0 0 / .08); }
  .ai-orb::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 50%; padding: 2.5px;
    background: conic-gradient(from var(--orb-turn), #ff6b6b, #ffd166, #6ee7b7, #60a5fa, #c084fc, #ff6b6b);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
    animation: orb-turn 9s linear infinite; }
  .nav-item.active .ai-orb { transform: scale(1.04); box-shadow: 0 2px 5px rgb(0 0 0 / .14); }
  .nav-item.active .ai-orb::before { animation-duration: 4s; }
  .ai-orb .icon { width: 20px; height: 20px; color: #fff; }
  .ai-orb b { font: 800 .625rem/1 var(--font); letter-spacing: .02em; }
}
@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .ai-orb::before { animation: none; }
}
