/* ===== Phone shell · every css/mobile/ file is phone-only by its media <link>, and this one owns the tokens the rest read ===== */

:root {
  --tabbar-h: 3.75rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* the smallest thing a thumb is asked to hit */
  --touch: 2.75rem;
  /* everything fixed to the bottom stacks above this line */
  --phone-floor: calc(var(--tabbar-h) + var(--safe-bottom));
}

/* room under the page for the bar, so the last row never sits behind it */
body { padding-bottom: var(--phone-floor); }

/* iOS zooms the page into any field under 16px, so every field starts at 16px */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea { font-size: 16px; }


/* ─── Tab bar ─────────────────────────────────────────────── */
.tabbar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--phone-floor);
  padding: 0.25rem 0.25rem var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px var(--shadow-sm);
  /* above the drawer's scrim, so the bar stays tappable while More is open */
  z-index: var(--z-panel);
}
.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 0;
  min-height: var(--touch);
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tabbar-icon { display: flex; }
.tabbar-icon svg { width: 22px; height: 22px; }
.tabbar-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar-item.is-active { color: var(--primary); }
.tabbar-item:active { background: var(--row-hover); }


/* ─── Navbar · More replaces the hamburger, so the bar keeps the brand, the bell and you ─── */
.btn-hamburger { display: none; }
.navbar { gap: 0.5rem; padding: 0 0.5rem 0 0.75rem; }
.nav-auth { margin-left: auto; gap: 0.25rem; }
.btn-notif-bell,
.btn-theme-toggle { min-width: var(--touch); min-height: var(--touch); }
.btn-nav-login { min-height: var(--touch); }
/* Log Out shrinks to a door icon · its text stays in the DOM (font-size 0), so it's still the button's name */
.btn-nav-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  border: 0;
  font-size: 0;
}
.btn-nav-logout::before {
  content: "";
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 4H5v16h5M15 8l4 4-4 4M19 12H9'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 4H5v16h5M15 8l4 4-4 4M19 12H9'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* the bell's list fills the width rather than hanging off a 320px corner */
.notif-dropdown { position: fixed; top: var(--navbar-h); left: 0.5rem; right: 0.5rem; width: auto; max-width: none; max-height: calc(100dvh - var(--navbar-h) - var(--phone-floor) - 1rem); }


/* ─── Drawer · a sheet rising from the tab bar, its groups laid out as tile grids ─── */
.navbar-links {
  top: auto;
  bottom: var(--phone-floor);
  left: 0;
  right: 0;
  width: auto;
  max-height: calc(100dvh - var(--navbar-h) - var(--phone-floor) - 1rem);
  padding: 0.75rem 0.75rem 1rem;
  border: 0;
  border-top: 1px solid var(--navbar-overlay-strong);
  border-radius: 16px 16px 0 0;
  /* the spread shadow is the scrim, so the sheet needs no second element to dim the page */
  box-shadow: 0 0 0 100vmax var(--overlay);
}
.navbar-links.nav-mobile-open {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  align-content: start;
}
.navbar-links .nav-group {
  grid-column: 1 / -1;
  margin: 0.4rem 0.15rem 0;
  padding: 0;
}
.navbar-links .nav-group:first-child { margin-top: 0; }
.navbar-links .nav-link {
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  min-height: 4.25rem;
  padding: 0.5rem 0.25rem;
  border-radius: 12px;
  background: var(--navbar-overlay-soft);
  font-size: 0.78rem;
  text-align: center;
}
.navbar-links .nav-link .icon-slot svg { width: 22px; height: 22px; }
.navbar-links .nav-link.active { background: var(--navbar-overlay-strong); color: var(--navbar-text); }
/* the pin editor's way in, heading the sheet · press-and-hold on any tab is the other */
.nav-edit-tabbar {
  display: inline-flex;
  grid-column: 1 / -1;
  justify-self: end;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0 1rem;
  border: 1px solid var(--navbar-overlay-strong);
  border-radius: 1.25rem;
  background: none;
  color: var(--navbar-text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
}
/* holding a tab opens its pin menu, so the hold never selects its label or raises the phone's own menu */
.navbar-links .nav-link { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }


/* ─── Tab bar editor · the pins, locked Home first, then everything else to add (shared/tabbar_editor.js) ─── */
.tbe-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin: 0.25rem 0 0.4rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-sub); }
.tbe-hint { font-size: 0.75rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-muted); }
.tbe-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 0.9rem; }
.tbe-row { display: flex; align-items: center; gap: 0.6rem; min-height: 3.25rem; padding: 0 0.25rem 0 0.75rem; border-top: 1px solid var(--border-light); }
.tbe-row:first-child { border-top: 0; }
.tbe-row.is-locked { background: var(--table-surface); color: var(--text-sub); }
.tbe-num { width: 1rem; font-size: 0.8rem; font-weight: 700; color: var(--text-faint); }
.tbe-icon { display: flex; color: var(--primary); }
.tbe-icon svg { width: 20px; height: 20px; }
.tbe-name { flex: 1; min-width: 0; font-weight: 600; }
.tbe-lock { padding: 0 0.75rem; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }
.tbe-btn { width: 2.5rem; height: var(--touch); border: 0; border-radius: 8px; background: none; color: var(--text-muted); font-size: 1rem; }
.tbe-btn:disabled { color: var(--border); }
.tbe-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin-bottom: 0.9rem; }
.tbe-add { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; min-height: 3.75rem; border: 1px solid var(--border-light); border-radius: 10px; background: var(--table-surface); color: var(--text-sub); font: inherit; font-size: 0.75rem; font-weight: 600; }
.tbe-add .tbe-icon { color: var(--text-sub); }
.tbe-plus { position: absolute; top: 0.3rem; right: 0.35rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-size: 0.85rem; line-height: 1.1rem; text-align: center; font-weight: 700; }
.tbe-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.tbe-foot .btn-secondary { min-height: 2.5rem; }
.tbe-note { margin: 0 0 0.6rem; font-size: 0.82rem; color: var(--text-sub); line-height: 1.4; }
.tbe-foot .tbe-note { margin: 0; }
/* the swap sheet and the hold menu · one full-width row per choice */
.tbe-swap { display: flex; align-items: center; gap: 0.75rem; min-height: 3.25rem; padding: 0 0.9rem; border: 0; border-top: 1px solid var(--border-light); background: var(--surface); color: var(--text); font: inherit; font-size: 0.95rem; font-weight: 600; text-align: left; }
.tbe-swap:first-child { border-top: 0; }
.tbe-swap.is-primary { color: var(--primary); background: var(--row-selected); }


/* ─── Modals · a sheet from the bottom, full width, above the tab bar ─── */
.modal-overlay { align-items: flex-end; }
.modal,
.modal-sm,
.modal-lg,
.modal-xl {
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - var(--navbar-h));
  display: flex;
  flex-direction: column;
  border-radius: 16px 16px 0 0;
  padding-bottom: var(--safe-bottom);
}
.modal-body { flex: 1; min-height: 0; max-height: none; overflow-y: auto; }
.modal-close { min-width: var(--touch); min-height: var(--touch); }
/* A labelled form row's select keeps a 240px floor on desktop · on a phone it takes the room the row has, like its inputs */
.form-row select { min-width: 0; }


/* ─── Toasts · above the tab bar, not under it ─── */
.app-toast { bottom: calc(var(--phone-floor) + 0.75rem); max-width: calc(100vw - 2rem); text-align: center; }

#app-version-label { display: none; }


/* ─── Dense editors are view-only on a phone · the macro's chip shows, every data-phone-hide entry point goes ─── */
.phone-view-only-note { display: inline-flex; }
[data-phone-hide] { display: none !important; }
