/* ═══════════════════════════════════════
   mobile.css — styles for #mobile-root engine
   ═══════════════════════════════════════ */

#mobile-root {
  position: fixed; inset: 0; z-index: 5000; display: flex; flex-direction: column;
  background: var(--bg); font-family: 'OpenDyslexic', sans-serif; overflow: hidden;
  -webkit-text-size-adjust: 100%; color: var(--text);
}
#mobile-root *, #mobile-root *::before, #mobile-root *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
#mobile-root input { -webkit-user-select: text; user-select: text; }
#mobile-root button, #mobile-root input { font-family: 'OpenDyslexic', sans-serif; }

/* ── Header ── */
#m-hdr {
  display: flex; align-items: stretch; height: 44px; background: var(--bg);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#m-tabs {
  display: flex; align-items: flex-end; flex: 1; overflow-x: auto; padding-left: 8px;
  gap: 2px; scrollbar-width: none;
}
#m-tabs::-webkit-scrollbar { display: none; }
.m-tab {
  background: transparent; border: 1px solid var(--border); border-bottom: none;
  font-size: 9px; font-weight: bold; color: var(--text3); padding: 4px 12px 3px;
  border-radius: 5px 5px 0 0; white-space: nowrap; position: relative; top: 1px;
  text-decoration: underline; text-underline-offset: 2px; text-transform: uppercase; cursor: pointer;
}
.m-tab.on { color: var(--text); background: var(--bg); z-index: 1; }
#m-hdr-right {
  display: flex; align-items: center; padding: 0 10px;
  border-left: 1px solid var(--border); flex-shrink: 0;
}
#m-settings-btn {
  background: none; border: none; color: var(--text3); padding: 10px;
  display: flex; align-items: center; cursor: pointer;
}
#m-tab-add-btn {
  background: none; border: none; color: var(--text3);
  font-size: 18px; padding: 8px 10px; cursor: pointer; line-height: 1;
  font-family: 'OpenDyslexic', sans-serif;
}
#m-not-now-btn {
  background: none; border: none; color: var(--text3); padding: 8px 6px;
  font-family: var(--od); font-size: 16px; cursor: pointer; display: flex; align-items: center;
  letter-spacing: 0.05em;
}
#m-not-now-btn:active { color: var(--text2); }
#m-search-btn {
  background: none; border: none; color: var(--text3); padding: 8px 6px;
  font-size: 16px; cursor: pointer; display: flex; align-items: center; line-height: 1;
}
#m-search-btn:active { color: var(--text2); }

/* ── Main area ── */
#m-main { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ── Column nav ── */
#m-col-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 4px; flex-shrink: 0;
}
#m-col-title {
  font-size: 13px; font-weight: bold; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.08em;
}
#m-col-ctrl { display: flex; align-items: center; gap: 10px; }
.m-arr { font-size: 22px; color: var(--text); padding: 12px 16px; cursor: pointer; user-select: none; }
.m-arr.off { color: var(--border-mid); pointer-events: none; }
#m-col-pos { font-size: 9px; color: var(--text3); }

/* ── Dots ── */
#m-dots { display: flex; gap: 5px; padding: 0 16px 8px; flex-shrink: 0; }
.m-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border-mid); }
.m-dot.on { background: var(--text); }

/* ── Card ── */
#m-card {
  margin: 0 10px 8px; background: var(--card); border-radius: 2px; flex: 1;
  min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
#m-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ── Items ── */
.m-item {
  display: flex; align-items: flex-start; padding: 14px 12px; gap: 8px; cursor: pointer; min-height: 48px;
  border-bottom: 1px solid var(--border);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.m-item:last-child { border-bottom: none; }
.m-item.sel { background: var(--inverted-bg); }

/* ── Press-and-hold drag reorder ── */
.m-item.m-drag-src { opacity: 0.3; background: var(--surface2); }
.m-drag-ghost {
  position: fixed; z-index: 9999; pointer-events: none;
  background: var(--card); border-radius: 4px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.3), 0 0 0 1px var(--border-mid);
  transform: scale(1.02); opacity: 0.97;
}
.m-item-row { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; }
.m-item-text { font-size: 12px; line-height: 1.5; color: var(--text); word-break: break-word; }
.m-item.sel .m-item-row,
.m-item.sel .m-item-row *:not(.m-pill) { color: #fff !important; }
.m-pill {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: bold;
  padding: 2px 8px; border-radius: 8px; white-space: nowrap; color: var(--text);
  box-shadow: 0 0 0 1px var(--border-mid);
}
.m-item.sel .m-pill { opacity: 0.85; }

/* ── Action bar ── */
#m-action-bar {
  background: var(--inverted-bg); display: flex; align-items: stretch; flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.m-act {
  flex: 1; padding: 16px 2px; font-size: 10px; font-weight: bold;
  color: rgba(255,255,255,0.55); text-align: center; text-transform: uppercase;
  letter-spacing: 0.05em; background: none; border: none;
  border-right: 1px solid rgba(255,255,255,0.08); cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  font-family: 'OpenDyslexic', sans-serif;
  -webkit-appearance: none; appearance: none;
  touch-action: manipulation;
}
.m-act:last-child { border-right: none; }
.m-act.done { color: #00E5FF; }
.m-act.del  { color: #FF4D4D; }

/* ── Capture ── */
#m-cap {
  display: flex; align-items: center; padding: 8px 12px;
  border-top: 1px solid var(--border); flex-shrink: 0; background: var(--card);
}
#m-cap-inp, #m-dump-inp {
  flex: 1; font-size: 13px; background: none; border: none; outline: none;
  color: var(--text); -webkit-user-select: text; user-select: text;
  font-family: 'OpenDyslexic', sans-serif;
}
#m-cap-inp::placeholder, #m-dump-inp::placeholder { color: var(--text3); }
#m-cap-ret {
  background: none; border: none; font-size: 16px; color: var(--text3);
  padding: 12px 12px; cursor: pointer; font-family: 'OpenDyslexic', sans-serif;
}

/* ── Spine — horizontal pill tray, always visible, above nav ── */
#m-spine {
  display: flex; gap: 6px; padding: 6px 10px 7px; overflow-x: auto; flex-shrink: 0;
  align-items: center; scrollbar-width: none; background: var(--bg);
  border-top: 1px solid var(--border);
}
#m-spine::-webkit-scrollbar { display: none; }
.m-spine-pill {
  border-radius: 10px; padding: 5px 13px; font-size: 9px; font-weight: bold;
  color: var(--text); white-space: nowrap; flex-shrink: 0; cursor: pointer;
  font-family: 'OpenDyslexic', sans-serif;
}
#m-spine-add {
  background: none; border: 1px solid var(--border-mid); border-radius: 10px;
  padding: 4px 10px; font-size: 10px; color: var(--text3); flex-shrink: 0; cursor: pointer;
  font-family: 'OpenDyslexic', sans-serif;
}

/* ── Bottom nav ── */
#m-nav {
  display: flex; align-items: stretch; background: var(--bg);
  border-top: 1px solid var(--border); flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.m-nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; padding: 10px 0; background: none; border: none;
  cursor: pointer; font-family: 'OpenDyslexic', sans-serif;
  -webkit-appearance: none; appearance: none; touch-action: manipulation;
}
.m-nav-ico { font-size: 18px; color: var(--text3); line-height: 1; }
.m-nav-lbl {
  font-size: 8px; color: var(--text3); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: bold;
}
.m-nav-btn.on .m-nav-ico, .m-nav-btn.on .m-nav-lbl { color: var(--text); }

/* ── Projects / Tags view ── */
#m-proj-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 10px; }
.m-proj-card { background: var(--card); border-radius: 2px; margin-bottom: 8px; overflow: hidden; }
.m-proj-hdr {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.m-proj-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.m-proj-name { font-size: 12px; font-weight: bold; color: var(--text); flex: 1; }
.m-proj-count { font-size: 9px; color: var(--text3); }
.m-proj-last { font-size: 9px; color: var(--text3); padding: 5px 12px 8px; font-style: italic; }

/* ── What Else view ── */
/* Section header — visually distinct from task rows */
.m-we-section {
  font-size: 11px; font-weight: bold; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 18px 14px 6px; font-family: 'OpenDyslexic', sans-serif;
  border-bottom: 1.5px solid var(--text);
  margin-bottom: 2px;
}
.m-we-section:first-child { padding-top: 12px; }

/* Task rows in what else get extra vertical breathing room */
.m-we-item { padding-top: 12px !important; padding-bottom: 12px !important; }

/* ── Action sheet (move-to) ── */
.m-sheet-bd {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 7000;
  display: flex; align-items: flex-end;
}
.m-sheet {
  background: var(--bg); width: 100%; border-radius: 10px 10px 0 0;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  font-family: 'OpenDyslexic', sans-serif;
  max-height: 50vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.m-sheet-title {
  padding: 10px 20px 8px; font-size: 10px; font-weight: bold; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em;
  position: sticky; top: -8px; background: var(--bg); z-index: 1;
  border-bottom: 1px solid var(--border);
}
.m-sheet-opt {
  padding: 16px 20px; font-size: 14px; color: var(--text);
  border-bottom: 1px solid var(--border); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.m-sheet-opt:active { background: var(--surface); }
.m-sheet-sep { height: 6px; background: var(--surface); border-bottom: 1px solid var(--border); }
.m-sheet-cancel {
  padding: 16px 20px; font-size: 14px; color: var(--text3);
  text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
  position: sticky; bottom: calc(-8px - env(safe-area-inset-bottom, 0px));
  background: var(--bg); border-top: 1px solid var(--border); z-index: 1;
}

/* ── Empty state ── */
.m-empty {
  font-size: 11px; color: var(--text3); text-align: center;
  padding: 24px 16px; font-style: italic;
}

/* ── Item date/location label ── */
.m-item-date {
  font-size: 9px; color: var(--text3); margin-left: auto;
  flex-shrink: 0; white-space: nowrap; padding-left: 8px;
  font-family: 'OpenDyslexic', sans-serif;
}

/* ── Mobile note bubble ── */
.m-note-bubble {
  font-size: 10px; flex-shrink: 0; width: 16px; text-align: center;
  color: var(--text); line-height: 1; padding-top: 1px; align-self: flex-start;
  margin-top: 1px; display: inline-flex; align-items: center; justify-content: center;
}
.m-note-bubble svg { display: block; }
.m-item.sel .m-note-bubble { color: rgba(255,255,255,0.7); }
.m-item.sel .m-note-bubble svg path { stroke: #fff; }

/* ── Item done strikethrough ── */
.m-item-done { text-decoration: line-through; }

/* ── Mentioned in notes label ── */
.m-proj-mentioned-lbl {
  font-size: 8px; font-weight: bold; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 6px 12px 2px; font-family: 'OpenDyslexic', sans-serif;
}

/* ── Outlined tab pill (what else, done-zo all-tabs mode) ── */
.m-tab-pill {
  display: inline-flex; align-items: center; font-size: 8px; font-weight: bold;
  padding: 1px 6px; border-radius: 8px; white-space: nowrap; color: var(--text3);
  border: 1px solid var(--border-mid); background: none; flex-shrink: 0;
  margin-left: auto; font-family: 'OpenDyslexic', sans-serif;
}
.m-item.sel .m-tab-pill { color: rgba(255,255,255,0.5); border-color: rgba(255,255,255,0.25); }

/* ── Done-zo view header (title + tab toggle) ── */
#m-dz-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 6px; flex-shrink: 0; background: var(--card);
  border-bottom: 1px solid var(--border);
}
#m-dz-title {
  font-size: 9px; font-weight: bold; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
#m-dz-toggle {
  font-size: 9px; font-weight: bold; color: var(--text3);
  background: none; border: 1px solid var(--border-mid); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-family: 'OpenDyslexic', sans-serif;
  -webkit-appearance: none; appearance: none; touch-action: manipulation;
}
#m-dz-toggle:active { background: var(--border); }

/* ── Inline expansion (drawer + optional notes below selected row) ── */
.m-inline-expansion {
  margin: 0;
  position: relative;
}
.m-inline-actions {
  display: flex; align-items: stretch;
  background: var(--inverted-bg);
}
.m-inline-act {
  flex: 1; padding: 14px 4px;
  font-family: 'OpenDyslexic', sans-serif;
  font-size: 10px; font-weight: bold; color: #fff;
  text-align: center; text-transform: uppercase; letter-spacing: 0.06em;
  background: none; border: none;
  border-right: 1px solid rgba(255,255,255,0.08);
  cursor: pointer; line-height: 1;
  -webkit-appearance: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.m-inline-act:last-child { border-right: none; }
.m-inline-act.done { color: #4dd9aa; }
.m-inline-act.danger { color: #ff8b8b; }
.m-inline-act.on { background: rgba(255,255,255,0.10); }
.m-inline-act:active { background: rgba(255,255,255,0.15); }

.m-inline-notes {
  background: var(--inverted-bg);
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.m-inline-notes-ta {
  width: 100%; font-family: 'OpenDyslexic', sans-serif;
  font-size: 12px; color: #fff;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 2px;
  padding: 8px 10px; resize: none; outline: none;
  line-height: 1.5; -webkit-appearance: none;
  -webkit-user-select: text; user-select: text;
  min-height: 80px;
}
.m-inline-notes-ta::placeholder { color: rgba(255,255,255,0.4); }

/* ── Search bar (shared across views) ── */
.m-search-bar {
  display: flex; align-items: center; padding: 6px 12px 5px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--card);
}
.m-search-inp {
  flex: 1; font-size: 12px; background: none; border: none; outline: none;
  color: var(--text); font-family: 'OpenDyslexic', sans-serif;
  -webkit-user-select: text; user-select: text;
}
.m-search-inp::placeholder { color: var(--text3); }

/* ── Tags view layout ── */
#m-tags-wrap {
  flex: 1; min-height: 0; display: flex; flex-direction: row; overflow: hidden;
}

/* ── Tag spine strip ── */
#m-tag-spine {
  width: auto; max-width: 120px; min-width: 44px;
  background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 8px 6px 6px; gap: 5px; overflow-y: auto; flex-shrink: 0;
  scrollbar-width: none;
}
#m-tag-spine::-webkit-scrollbar { display: none; }
.m-tag-spine-pill {
  font-family: 'OpenDyslexic', sans-serif; font-size: 10px; font-weight: bold;
  color: var(--text); padding: 5px 10px; border-radius: 10px;
  white-space: nowrap; max-width: 108px; overflow: hidden;
  text-overflow: ellipsis; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--border-mid);
  -webkit-tap-highlight-color: transparent;
}
.m-tag-spine-pill.open {
  box-shadow: 0 0 0 2px var(--text);
}
.m-tag-spine-empty {
  font-size: 9px; color: var(--text3); font-style: italic; padding: 4px 2px;
  font-family: 'OpenDyslexic', sans-serif;
}
#m-tag-spine-add {
  background: none; border: 1px solid var(--border-mid); border-radius: 10px;
  font-size: 14px; color: var(--text3); padding: 3px 10px; cursor: pointer;
  font-family: 'OpenDyslexic', sans-serif; margin-top: auto; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Tag pop area ── */
#m-tag-pop-area {
  flex: 1; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 0;
  padding: 0;
}

/* ── Individual tag pop ── */
.m-tag-pop {
  background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.m-tag-pop-hdr {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px 7px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.m-tag-pop-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.m-tag-pop-title {
  font-size: 11px; font-weight: bold; color: var(--text); flex: 1;
  font-family: 'OpenDyslexic', sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-tag-pop-close {
  background: none; border: none; font-size: 16px; color: var(--text3);
  cursor: pointer; padding: 8px 10px; line-height: 1;
  font-family: 'OpenDyslexic', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.m-tag-pop-body { padding: 4px 0; flex-shrink: 0; }
.m-tag-pop-sec { padding: 4px 10px 2px; }
.m-tag-pop-sec-lbl {
  font-size: 8px; font-weight: bold; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 2px 0 3px; font-family: 'OpenDyslexic', sans-serif;
}
.m-tag-pop-cap {
  display: flex; align-items: center; padding: 6px 10px;
  border-top: 1px solid var(--border); flex-shrink: 0; background: var(--card);
}
.m-tag-pop-inp {
  flex: 1; font-size: 12px; background: none; border: none; outline: none;
  color: var(--text); font-family: 'OpenDyslexic', sans-serif;
  -webkit-user-select: text; user-select: text;
}
.m-tag-pop-inp::placeholder { color: var(--text3); }
.m-tag-pop-ret {
  background: none; border: none; font-size: 14px; color: var(--text3);
  padding: 2px 6px; cursor: pointer; font-family: 'OpenDyslexic', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ── Mobile project notes ── */
.m-proj-notes {
  padding: 6px 10px 8px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.m-proj-notes-ta {
  width: 100%; font-family: 'OpenDyslexic', sans-serif;
  font-size: 11px; color: var(--text); background: transparent;
  border: 1px solid var(--border); border-radius: 2px;
  padding: 6px 8px; resize: none; outline: none; line-height: 1.5;
  -webkit-appearance: none; -webkit-user-select: text; user-select: text;
  min-height: 50px;
}
.m-proj-notes-ta::placeholder { color: var(--text3); font-style: italic; }
.m-proj-notes-ta:focus { border-color: var(--border-mid); }

/* ═══════════════════════════════════════
   iPad / tablet layout — 768px+
   Bottom nav becomes a left-side rail.
   Grid takes over from flex-column.
   ═══════════════════════════════════════ */
@media (min-width: 768px) {
  #mobile-root {
    display: grid;
    grid-template-areas: "hdr hdr" "nav main";
    grid-template-rows: 44px 1fr;
    grid-template-columns: 76px 1fr;
  }
  #m-hdr  { grid-area: hdr; }
  #m-main { grid-area: main; }
  #m-nav  {
    grid-area: nav;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    justify-content: flex-start;
    padding-top: 6px;
    overflow: hidden;
  }
  .m-nav-btn { flex: none; padding: 14px 0; }
  .m-nav-ico { font-size: 20px; }
  .m-nav-lbl { font-size: 7px; }

  /* Breathing room for content */
  #m-card          { margin: 0 16px 12px 12px; border-radius: 4px; }
  #m-col-nav       { padding: 16px 20px 6px; }
  #m-col-title     { font-size: 15px; }
  #m-dots          { padding: 0 20px 10px; }
  .m-arr           { font-size: 26px; padding: 14px 20px; }
  .m-item          { padding: 15px 16px; min-height: 52px; }
  .m-item-text     { font-size: 13px; }
  #m-cap           { padding: 10px 16px; }
  #m-cap-inp, #m-dump-inp { font-size: 14px; }
  #m-cap-ret       { font-size: 18px; padding: 12px 14px; }
  .m-inline-act    { padding: 16px 6px; font-size: 10px; }

  /* Tags view — wider spine, more room for pops */
  #m-tag-spine { max-width: 160px; padding: 10px 8px 8px; }
  .m-tag-spine-pill { font-size: 11px; max-width: 140px; }

  /* Not-now panel wider on tablet */
  #not-now-panel { width: 360px; }

  /* Action sheet wider on tablet */
  .m-sheet { max-width: 480px; margin: 0 auto; border-radius: 10px; }
  .m-sheet-bd { align-items: center; }
}

/* ── Shared overlays above #mobile-root (z 5000) ──
   Settings, not-now and login live outside #mobile-root, so on mobile they
   need to stack above it. Order: root 5000 < not-now < sheets 7000 < settings
   < login < search 8500 < dialogs/toast 9000. */
body:has(#mobile-root) #not-now-panel      { z-index: 6000; }
body:has(#mobile-root) .settings-backdrop  { z-index: 8000; }
body:has(#mobile-root) .settings-panel     { z-index: 8010; }
body:has(#mobile-root) #login-screen       { z-index: 8400; }
body:has(#mobile-root) .debug-panel        { z-index: 8100; }
body:has(#mobile-root) .debug-toggle       { display: none; }
