/* mobile — < 720px overrides */
@media (max-width: 720px) {
  /* Hide desktop sidebar */
  .tf-side { display: none; }

  /* Main takes full width */
  .app-main { margin-left: 0; padding-bottom: 68px; }

  /* Mobile top bar */
  .topbar {
    padding: var(--s-3) var(--s-4);
    gap: var(--s-3);
  }
  .topbar__day { font-size: var(--t-xl); }
  .topbar__title { font-size: var(--t-xl); }
  .progress-rail { min-width: 100px; }
  .progress-rail__num { font-size: var(--t-lg); }

  /* Ledger rows — 2-line reflow */
  .ledger__row {
    grid-template-columns: 8px 1fr auto;
    grid-template-rows: auto auto;
    gap: var(--s-1) var(--s-2);
    padding: var(--s-2) var(--s-3) var(--s-2) var(--s-2);
  }
  .ledger__edge {
    grid-row: 1 / 3;
    height: auto;
    align-self: stretch;
  }
  .ledger__id    { display: none; }
  .ledger__title { grid-column: 2; grid-row: 1; font-size: var(--t-sm); }
  .ledger__meta  { grid-column: 2; grid-row: 2; }
  .ledger__due   { display: none; }
  .ledger__assignee { display: none; }
  .ledger__row-actions {
    grid-column: 3;
    grid-row: 1 / 3;
    position: static;
    background: none;
    padding: 0;
    padding-left: var(--s-2);
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    align-self: center;
  }
  .ledger__row-actions .ledger__snooze { display: none; }
  .ledger__row-actions .ledger__view   { display: none; }

  /* Board: horizontal scroll, narrower columns */
  .board-grid { grid-template-columns: repeat(4, 260px); }
  .board-shell { padding: var(--s-3); }

  /* Team: simplified */
  .team-summary { grid-template-columns: 1fr 1fr; }
  .team-member-row { grid-template-columns: 32px 1fr 60px; }
  .member-stat:not(:first-of-type):not(:nth-of-type(2)), .member-activity, .member-actions { display: none; }
  .team-members-sort { display: none; }

  /* Detail panel: full screen */
  .detail-panel {
    width: 100%;
    left: 0;
  }

  /* Modals: full-screen sheets */
  .modal {
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }
  .modal-overlay { align-items: flex-end; }
  .modal { height: 90%; border-radius: var(--r-3) var(--r-3) 0 0; }

  /* Bottom mobile tab bar */
  .mobile-tabs {
    display: flex !important;
  }

  /* FAB */
  .fab { display: flex !important; }

  /* Daily quote bar: compact */
  .daily-quote { padding: var(--s-1) var(--s-4); min-height: 28px; }
  .daily-quote .caps { display: none; }
}

/* Mobile bottom tab bar — hidden on desktop */
.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 68px;
  background: var(--surface);
  border-top: 1px solid var(--hair);
  z-index: 200;
  align-items: stretch;
}
.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-mute);
  font-family: var(--f-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  transition: color .12s;
  position: relative;
}
.mobile-tab svg { width: 20px; height: 20px; }
.mobile-tab.is-active { color: var(--accent); }
.mobile-tab.is-active::before {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

/* Floating action button */
.fab {
  display: none;
  position: fixed;
  right: var(--s-5);
  bottom: calc(68px + var(--s-4));
  width: 52px; height: 52px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  z-index: 201;
  transition: transform .15s var(--ease), background .15s;
}
.fab:hover { background: var(--ink-2); transform: scale(1.06); }
.fab svg { width: 22px; height: 22px; }

/* ─────────────────────────────────────────────────────────────
   Phone refinements (≤ 720px). Loaded after the rules above, so
   these win. Desktop (> 720px) is completely unaffected.
   ───────────────────────────────────────────────────────────── */
@media (max-width: 720px) {

  /* 1. Kill accidental sideways scroll / the "zoomed-out" look that
        happens when one wide element escapes the viewport. */
  html, body { overflow-x: hidden; }
  .app-main { width: 100%; max-width: 100vw; overflow-x: hidden; }

  /* 2. iOS Safari zooms the page in whenever a focused form control
        has a font smaller than 16px. Force 16px on phones to stop it. */
  input, select, textarea,
  .input,
  .notes-drawer__textarea,
  .comment-composer textarea { font-size: 16px; }

  /* 3. Topbars: tighter, wrap cleanly, headline not oversized. */
  .topbar { gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-4); }
  .topbar__day,
  .topbar__title { font-size: var(--t-2xl); }
  .topbar__head { flex: 1 1 100%; }
  .topbar__actions { margin-left: 0; flex: 1 1 100%; flex-wrap: wrap; gap: var(--s-3); }

  /* Daily view ships a FAB, so the inline "New Task" button is redundant.
     (Board keeps #boardCreateTaskBtn — it has no FAB.) */
  #createTaskBtn { display: none; }

  /* Progress rail reads as a compact single row on phones. */
  .progress-rail { flex-direction: row; align-items: center; gap: var(--s-2); min-width: 0; }
  .progress-rail__bar-wrap { width: 80px; }
  .progress-rail__label { display: none; }

  /* Board filter dropdown: let it size to the row instead of a fixed 160px. */
  #priorityFilterCsel { width: auto !important; flex: 1 1 140px; }

  /* 4. Board: don't force a tall min-height that pushes rows under the
        bottom tab bar; let columns size to content. */
  .board-grid { min-height: 0; height: auto; }
  .board-col { min-height: 240px; }

  /* 5. Full-height surfaces use dynamic viewport height so the mobile
        URL bar doesn't clip their bottoms. */
  .detail-panel,
  .notes-drawer { height: 100dvh; }
  .modal { height: auto; max-height: 88dvh; }

  /* 6. Safe-area insets for fixed chrome (notch / home indicator). */
  .mobile-tabs {
    height: auto;
    min-height: 60px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app-main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .fab { bottom: calc(64px + env(safe-area-inset-bottom) + var(--s-4)); }
  .modal-foot { padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom)); }
  .dp-toolbar { padding-top: calc(var(--s-3) + env(safe-area-inset-top)); }

  /* 7. Detail-panel time-log form: 3 cramped columns → 2 roomy ones. */
  .time-log-form { grid-template-columns: 1fr 1fr; }
}
