/* ============================================================================================
   mobile.css -- the phone layer. Loaded after app.css; nothing here applies above 700px.

   Principles (Apple HIG / Material / NN-g mobile guidance, applied):
   - One column, one thumb. Navigation moves to a bottom tab bar; the header keeps only what a
     glance needs. Content gets full width with a 14px gutter and safe-area padding for notches.
   - Text never below 12px (labels) and body at 13-16px; form controls are 16px so iOS does not
     zoom the page on focus.
   - Every tap target is at least 44px (40px for dense chips), with :active feedback because
     there is no hover on a phone.
   - Drawers become bottom sheets: full width, rounded top, swipe-style handle, background locked.
   - Nothing may be wider than the screen. Wide things (code, tables) scroll inside themselves.
   ============================================================================================ */

.bnav { display: none; }

/* ---- minimum text size: nothing under 12px on a phone. Generated from app.css rules that set a smaller size
        (re-run the generator in the git history of this file if new small text is added). ---- */
@media (max-width: 700px) {
  .panel-head h2,
  .dot-label,
  .tile-label,
  .tile-unit,
  .tile-sub,
  .ctx-k,
  .ctx-since,
  .feed-when,
  .feed-sub,
  .hint,
  .ribbon-date,
  .bd-tag,
  .bd-val,
  .exc-meta,
  .chip,
  .mr-name,
  .construct-caption,
  .consensus,
  .prose code,
  .chron-date,
  .hier-lvl,
  .hier-ts,
  .hier-body,
  .fresh-age,
  .pbar-label,
  .job-meta,
  .anom,
  .graph-cap,
  .drawer-sec h3,
  .jb-section-title,
  .jb-tag,
  .jb-meta,
  .jb-raw summary,
  .jb-pre,
  .jb-tl-ruler,
  .jb-tl-name,
  .jb-filt,
  .jb-lineage,
  .nw-role,
  .nw-detail,
  .nw-svc,
  .nw-lk-pair,
  .nw-lk-type,
  .nw-lk-label,
  .nw-lk-detail,
  .nw-lk-sub,
  .ops-fine,
  .ops-fine code,
  .ops-kv code,
  .ops-l2 code,
  .ops-link,
  .ops-tag,
  .ops-a-body,
  .ops-a-note,
  .ops-cmd code,
  .ops-host-meta,
  .ops-g-n,
  .ops-g-foot,
  .ops-mini-kv i,
  .ops-sec-title,
  .ops-meta,
  .ops-l2,
  .ops-kv > span:first-child,
  .ops-pre,
  .ops-btn,
  .ops-msg,
  .repo-age,
  .vsu-k i,
  .vsu-d,
  .ct-say,
  .ct-foot i,
  .me-sub,
  .nd-card-meta,
  .nd-proj,
  .nd-divider,
  .nd-row-k,
  .nd-row-v i,
  .nd-row-note,
  .nd-legend,
  .nd-ev-meta, .nd-filter button i, .nd-ev-go,
  .nd-ev-who,
  .nd-x,
  .nd-ev-sub,
  .nd-ev-when,
  .nd-lastseen,
  .nd-sys-h,
  .nd-stage-key,
  .nd-ring-l,
  .nd-ring-bolt,
  .nd-apps-k,
  .nd-now-t i,
  .nd-app-more,
  .ops-triage-h { font-size: 12px; }
}

@media (max-width: 700px) {
  :root { --gut: 14px; --bnav-h: 58px; --tap: 44px; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { overflow-x: clip; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  body:has(.drawer-backdrop) { overflow: hidden; } /* a sheet locks the page behind it */
  input, select, textarea { font-size: 16px; }
  pre, code { max-width: 100%; }
  pre { overflow-x: auto; }

  /* ---------------------------------------------------------------- header + nav ---- */
  .app-header {
    padding: calc(8px + env(safe-area-inset-top)) calc(var(--gut) + env(safe-area-inset-right)) 8px calc(var(--gut) + env(safe-area-inset-left));
    gap: 8px;
  }
  .app-header .tabs { display: none; }               /* replaced by the bottom bar */
  .brand { margin-right: auto; min-width: 0; }
  .brand h1 { font-size: 16px; white-space: nowrap; }
  .header-actions { gap: 6px; flex: none; }
  html, body { max-width: 100vw; overflow-x: clip; }
  .app-main, .board, .board-grid, .panel, .nd-s, .ops-stack, .nd-grid > * { min-width: 0; max-width: 100%; }
  .mk-header-link { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line-strong); border-radius: 10px; text-decoration: none; font-size: 16px; }
  .mk-text { display: none; }
  .day-pick { position: relative; width: 44px; height: 40px; padding: 0; color: transparent; background: transparent; border: 1px solid var(--line-strong); border-radius: 10px; }
  .day-pick::-webkit-datetime-edit { display: none; }
  .day-pick::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: .75; cursor: pointer; }
  .seg { display: none; }                             /* explore mode is a desktop tool */
  .vault-bar .seg { display: inline-flex; min-height: 40px; }   /* but the vault's vault / 2d-3d switches are board controls, not the header toggle */
  .seg span { display: grid; place-items: center; padding: 0 10px; font-size: 13px; }
  .icon-btn { height: 40px; min-width: 40px; border-radius: 10px; padding: 0 10px; font-size: 16px; }
  .banner { padding: 8px var(--gut); font-size: 13px; }

  .bnav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px calc(6px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(6px + env(safe-area-inset-left));
    background: color-mix(in srgb, var(--panel) 90%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
    border-top: 1px solid var(--line);
  }
  .bn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 50px; padding: 4px 0; border: 0; border-radius: 12px; background: none;
    color: var(--tx-weaker); font-size: 11px; font-weight: 560; letter-spacing: .01em;
  }
  .bn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bn-on { color: var(--accent); }
  .bn-on svg { stroke-width: 2.2; }
  .bn:active { background: var(--accent-soft); }

  /* ------------------------------------------------------------------- layout ---- */
  .app-main { padding: 12px calc(var(--gut) + env(safe-area-inset-right)) calc(var(--bnav-h) + 28px + env(safe-area-inset-bottom)) calc(var(--gut) + env(safe-area-inset-left)); }
  .board-grid, .board-grid-wide .board-grid { gap: 12px; margin-top: 12px; }
  .panel { border-radius: 14px; }
  .panel-head { padding: 12px 14px; flex-wrap: wrap; gap: 4px 12px; }
  .panel-body { padding: 14px; }
  .statusline { padding: 6px 0 12px; }
  .statusline-state { font-size: 22px; }
  .statusline-narr { font-size: 14px; }

  /* ----------------------------------------------------------- tap feedback + size ---- */
  .nd-card:active, .nd-ev-link:active, .ops-row:active, .ops-g:active, .ops-host:active, .ct:active, .ops-a:active { background: var(--panel-raised); }
  .nd-btn, .ops-btn { min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; padding-left: 16px; padding-right: 16px; font-size: 15px; }
  .ops-host { min-height: 48px; padding: 10px 12px; }
  .ops-l1 { min-height: 40px; }
  .jb-filt, .graph-cap, select { min-height: var(--tap); }
  a.ops-link, button.ops-link { display: inline-flex; align-items: center; padding: 10px 4px; margin: -10px -4px; } /* bigger hit area, no layout shift */
  .nd-proj { min-height: 32px; display: inline-flex; align-items: center; padding: 0 10px; }

  /* ---------------------------------------------------------------- bottom sheets ---- */
  .drawer-backdrop { align-items: flex-end; justify-content: stretch; }
  .drawer, .ops-drawer {
    width: 100%; height: auto; max-height: 92dvh; min-height: 50dvh;
    border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 18px 18px 0 0;
    box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, .55);
    overscroll-behavior: contain; animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
  .drawer-head { padding: 18px 16px 12px; min-height: 60px; }
  .drawer-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--line-strong); }
  .drawer-head h2 { font-size: 17px; }
  .drawer-head .icon-btn { width: var(--tap); height: var(--tap); }
  .drawer-body { padding: 14px 16px 28px; }

  /* ------------------------------------------------------------------------ Now ---- */
  /* read order on a phone: verdict, what needs me, what is happening, what happened, then context */
  .nd-grid { display: flex; flex-direction: column; }
  .nd-grid > .ops-stack { display: contents; }
  .nd-s { min-width: 0; }
  .nd-s-needs { order: 1; } .nd-s-now { order: 2; } .nd-s-happened { order: 3; }
  .nd-s-today { order: 4; } .nd-s-apps { order: 5; } .nd-s-system { order: 6; }

  .nd-hero { flex-direction: column; align-items: stretch; gap: 18px; padding: 10px 2px 4px; }
  .nd-verdict { font-size: clamp(26px, 8.4vw, 32px); }
  .nd-sub { font-size: 15px; }
  .nd-cta { flex-direction: column; margin-top: 16px; }
  .nd-btn { width: 100%; }
  .nd-hero-aside { align-items: stretch; text-align: left; gap: 12px; }
  .nd-rings { justify-content: space-between; gap: 4px; }
  .nd-ring { width: auto; flex: 1 1 0; min-width: 0; }
  .nd-ring svg { width: 52px; height: 52px; }
  .nd-presence, .nd-since { font-size: 13px; text-align: left; }

  .nd-card { flex-direction: column; gap: 10px; padding: 14px 14px 12px; }
  .nd-card-title { font-size: 16px; }
  .nd-card-why { font-size: 13px; -webkit-line-clamp: 3; }
  .nd-card-meta { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .nd-rest { flex-wrap: wrap; gap: 8px; }

  .nd-row { padding: 12px 0; }
  .nd-row-v b { font-size: 28px; }
  .nd-row-note { font-size: 12.5px; line-height: 1.45; }

  .nd-ev { grid-template-columns: 40px 1fr auto; gap: 12px; padding: 13px 2px; min-height: 60px; }
  .nd-ev-ic { width: 40px; height: 40px; border-radius: 12px; }
  .nd-ev-title { font-size: 15px; }
  .nd-ev-sub { font-size: 13px; line-height: 1.4; }
  .nd-filter { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(var(--gut) * -1); padding-inline: var(--gut); scrollbar-width: none; }
  .nd-filter button { height: 40px; flex: none; font-size: 13.5px; }

  .nd-apps { flex-wrap: wrap; overflow: visible; gap: 10px 12px; padding: 12px 14px; }
  .nd-apps-k { width: 100%; }
  .nd-now { flex: 1 1 140px; width: auto; min-width: 0; }
  .nd-apps-sep { display: none; }
  .nd-apps-list { flex: 1 1 100%; }
  .nd-apps-cols { flex: 1 1 100%; gap: 10px; }
  .nd-apps-dev { font-size: 12px; }

  /* ------------------------------------------------------------------------- Me ---- */
  .vsu-row { grid-template-columns: 92px 58px 1fr 40px; gap: 8px; }
  .ct-grid { grid-template-columns: 1fr; }
  .ct { min-height: 64px; padding: 12px 14px; }
  .tr-row { grid-template-columns: 88px 70px 1fr 44px; min-height: 48px; gap: 8px; }
  .mx-row { grid-template-columns: 1fr auto; min-height: 52px; row-gap: 4px; padding: 6px 8px; }
  .mx-name { grid-column: 1; font-size: 13.5px; } .mx-n { grid-column: 2; grid-row: 1; } .mx-cells { grid-column: 1 / -1; grid-row: 2; }
  .mx-head { display: none; } .mx-c { height: 16px; }
  .ag-row { grid-template-columns: 84px 1fr 56px; } .ag-row .ops-fine { grid-column: 1 / -1; }
  .ops-run-h { min-height: 44px; grid-template-columns: 14px 1fr 64px 60px auto; }
  .tr-d, .me-chip { font-size: 12px; }
  .hm-z { grid-template-columns: 92px 84px 1fr; min-height: 44px; }
  .hm-p { grid-template-columns: 10px 84px 1fr auto; min-height: 44px; }
  .hm-pv { font-size: 12px; }

  /* ----------------------------------------------------------------------- Vault ---- */
  .graph-controls { gap: 8px; }

  /* ------------------------------------------------------------------------ Ops ---- */
  .ops-a { grid-template-columns: 10px 1fr auto; padding: 12px; gap: 6px 10px; }
  .ops-a-title { white-space: normal; }
  .ops-a-body { grid-column: 1 / -1; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.45; }
  .ops-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ops-g { padding: 12px; }
  .ops-row { padding: 10px 12px; }
  .ops-l1 { flex-wrap: wrap; row-gap: 6px; }
  .ops-detail { margin-left: 0; }
  .ops-kv > span:first-child { min-width: 64px; }
  .ops-pre, .ops-cmd code { overflow-x: auto; }
  .ops-actions { gap: 8px; }
  .ops-actions .ops-btn { flex: 1 1 auto; }
  .ops-triage { padding: 12px; }

  /* ------------------------------------------------------------------ Tasks ---- */
  .tk { height: auto; min-height: 0; gap: 10px; }
  .tk-bar { position: sticky; top: calc(57px + env(safe-area-inset-top)); z-index: 18; margin: 0 calc(var(--gut) * -1); padding: 8px var(--gut); background: color-mix(in srgb, var(--page-bg, var(--panel)) 92%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; gap: 8px; }
  .tk-lenses { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .tk-lenses button { height: 40px; padding: 0 4px; justify-content: center; font-size: 13.5px; }
  .tk-tools { gap: 8px; }
  .tk-search { flex: 1; min-width: 0; height: 40px; }
  .tk kbd { display: none; }
  .tk-tools .tk-btn { height: 40px; }
  .tk-panes { display: block; }
  .tk-list { border: 0; background: transparent; padding: 0; overflow: visible; }
  .tk-chips.tk-filters { flex-wrap: wrap; overflow: visible; }
  .tk-filters .tk-objsel { flex: 1 0 100%; justify-content: space-between; }
  .tk-filters .tk-objsel select { flex: 1; max-width: none; }
  .tk-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(var(--gut) * -1); padding: 4px var(--gut) 10px; scrollbar-width: none; }
  .tk-chips button { height: 38px; flex: none; font-size: 13.5px; }
  .tk-group-h { top: calc(57px + env(safe-area-inset-top) + 101px); }
  .tk-row { min-height: 68px; padding: 13px 10px; }
  .tk-row:active { background: var(--accent-soft); }
  .tk-title { font-size: 15.5px; }
  .tk-meta { font-size: 13px; }
  .tk-hint { display: none; }
  /* a task opens as a full-screen sheet, actions pinned under the thumb */
  .tk-pane { display: none; }
  .tk.tk-open .tk-pane { display: flex; position: fixed; inset: 0; z-index: 45; border: 0; border-radius: 0; background: var(--page-bg, var(--panel)); animation: tk-slide .22s cubic-bezier(.2,.8,.2,1); }
  @keyframes tk-slide { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
  .tk-detail { animation: none; }
  .tk-d-head { padding: calc(6px + env(safe-area-inset-top)) 12px 6px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
  .tk-back { display: block; }
  .tk-d-body { padding: 8px 16px 24px; }
  .tk-d-title { font-size: 22px; }
  .tk-d-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .tk-decide .tk-btn { height: 48px; font-size: 15px; }
  .tk-chip { height: 44px; padding: 0 16px; font-size: 14.5px; }
  .tk-assign select { height: 44px; font-size: 16px; }
  .tk-kv { grid-template-columns: 1fr; gap: 2px; }
  .tk-bulk { position: fixed; left: 10px; right: 10px; bottom: calc(var(--bnav-h) + 10px + env(safe-area-inset-bottom)); }
  .tk-bulk-r { margin-left: 0; width: 100%; }
  .tk-toast { bottom: calc(var(--bnav-h) + 18px + env(safe-area-inset-bottom)); }
  body.tk-sheet-open .tk-toast { bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 90; }
  .tk-form-row { grid-template-columns: 1fr; }
  .tk-form .tk-in, .tk-form select { font-size: 16px; }
  .tk-form select { height: 44px; }
  .tk-pgrid { grid-template-columns: 1fr; }
  body.tk-sheet-open { overflow: hidden; }
  body.tk-sheet-open .bnav { display: none; }
}

/* touch devices at any width (tablets, landscape phones): the same tap sizes, no layout changes */
@media (pointer: coarse) {
  .tab, .seg, .icon-btn { min-height: 40px; }
  .nd-btn, .ops-btn, .tk-btn { min-height: 44px; }
}

@media (max-width: 720px) { .tk-prj-q, .tk-link { min-height: 36px; } }

/* Tasks board on a phone, 2026-11-10: bigger targets, one calm column, less chrome before the list. */
@media (max-width: 700px) {
  .tk-wish { border-radius: 12px; }
  .tk-wish-form { padding: 5px 5px 5px 14px; }
  .tk-lenses { border-radius: 10px; }
  .tk-lenses button { height: 40px; font-size: 14px; }
  .tk-row { padding: 14px 12px; gap: 12px; }
  .tk-title { font-size: 15px; line-height: 1.4; }
  .tk-meta { font-size: 13px; gap: 4px 10px; }
  .tk-bt-sum { font-size: 13px; padding: 4px 2px 8px; }
  .tk-bp-h { min-height: 52px; padding: 12px; }
  .tk-grp-h { min-height: 48px; padding: 8px 8px 8px 10px; flex-wrap: wrap; }
  .tk-grp-m { margin-left: 0; width: 100%; padding-left: 32px; font-size: 12px; }
  .tk-grp-b { padding-left: 4px; }
  .tk-bp { background: transparent; }
  .tk-bp-b { padding-left: 0; }
  .tk-ap, .tk-flight { padding: 14px; }
  .tk-d-head { padding: 12px 16px 0; }
  .tk-d-body { padding: 10px 16px 20px; }
  .tk-d-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .tk-btn, .tk-chip { min-height: 44px; }
  .tk-btn-small { min-height: 40px; }
}

/* Phone, second pass: the date picker needs its own icon (Firefox has no calendar indicator, so the field rendered blank), and the Tasks | Projects switch is a small control, not a full row. */
@media (max-width: 700px) {
  .day-pick { background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238c92a8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M8 3v4M16 3v4M3 10h18'/%3E%3C/svg%3E") no-repeat center; }
  .tk-viewseg { display: inline-grid; grid-template-columns: auto auto; align-self: flex-start; padding: 2px; border-radius: 10px; border-color: transparent; background: color-mix(in srgb, var(--text) 6%, transparent); }
  .tk-viewseg button { height: 32px; padding: 0 16px; font-size: 13px; border-radius: 8px; }
}
