/* One bounded app viewport: content scrolls without moving the capture header.
   Safe-area variables use env() in production and can be overridden by layout QA. */
:root {
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-safe-left: env(safe-area-inset-left, 0px);
  --app-safe-right: env(safe-area-inset-right, 0px);
}
.phone-title { display:none; }
.app { position:fixed; inset:0; height:100dvh; }
.app main { min-height:0; }
.bar, #status { flex-shrink:0; }
.view { min-height:0; overscroll-behavior-y:contain; }

@media (max-width:820px), (max-width:980px) and (max-height:500px) {
  body { background:var(--forest-deep); }
  .app { --r:12px; }
  .app>aside { display:none; }
  .workgrid { grid-template-columns:minmax(0,1fr); }
  .bar {
    flex:none; flex-wrap:wrap; gap:12px; border:0; box-shadow:none;
    padding:calc(12px + var(--app-safe-top)) calc(16px + var(--app-safe-right)) 14px calc(16px + var(--app-safe-left));
    background:var(--forest-deep); color:var(--forest-fg);
  }
  .desktop-title { display:none; }
  .bar .phone-title { display:block; font:600 25px/1 "EB Garamond",Georgia,serif; }
  .phone-title small { display:block; margin-top:6px; color:var(--gold-pale); font:600 9px/1.3 "Libre Franklin",sans-serif; letter-spacing:.16em; }
  .bar .quick-add-trigger { min-height:44px; border-radius:24px; background:var(--gold-pale); border-color:var(--gold-pale); color:var(--forest-deep); font-size:13px; padding:10px 16px; }
  .bar .search { display:block; flex:0 0 100%; order:3; width:100%; min-width:0; height:44px; border-radius:10px; background:rgba(255,255,255,.08); color:var(--forest-fg); border-color:rgba(255,255,255,.18); font-size:16px; }
  .bar .search::placeholder { color:#CAD4C6; font-size:13px; }
  .view { background:var(--stone-50); padding:22px calc(16px + var(--app-safe-right)) calc(94px + var(--app-safe-bottom)) calc(16px + var(--app-safe-left)); scroll-padding-block:16px; }
  .page-head { flex-wrap:nowrap; align-items:flex-start; gap:12px; margin-bottom:20px; }
  .page-head>div { min-width:0; flex:1; }
  .h2 { font-size:34px; }
  .page-head .sub { font-size:12px; line-height:1.5; }
  .page-head>.field { width:108px; flex:none; font-size:11px; color:var(--ink-2); }
  .page-head .in { width:100%; min-height:44px; padding:8px; font-size:14px; border-radius:10px; }
  .card { border-color:#DEE1D6; border-radius:14px; box-shadow:0 2px 8px rgba(27,48,32,.035); }
  .stats { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-bottom:20px; }
  .stat { padding:16px; }
  .stat .n { font-size:34px; color:var(--forest); }
  .stat .l { font-size:10px; letter-spacing:.07em; }
  .panel-head { padding:18px 16px; gap:10px; flex-wrap:wrap; }
  .panel-head h3 { font:600 22px/1.15 "EB Garamond",Georgia,serif; letter-spacing:0; text-transform:none; color:var(--forest-deep); }
  .taskline { display:grid; grid-template-columns:24px minmax(0,1fr); gap:8px 12px; padding:16px; }
  .taskline .task-open strong { font-size:13px; line-height:1.5; }
  .taskline .task-open small { font-size:11px; line-height:1.5; }
  .taskline .task-meta { grid-column:2; flex-direction:row; align-items:center; justify-content:space-between; }
  .task-meta .due { font-size:11px; }
  .row { padding:16px; gap:12px; }
  .row .grow { overflow-wrap:anywhere; }
  .row .t,.row strong { font-size:13px; }
  .row .m { font-size:12px; }
  .pbtn { min-height:44px; border-radius:10px; font-size:12px; }
  .pbtn.sm,.claim { min-height:44px; }
  .ptabs { background:var(--stone-100); padding:4px; border-radius:12px; gap:3px; }
  .ptabs button { border:0; border-radius:9px; min-height:44px; font-size:12px; }
  .ptabs button:not(.on) { background:transparent; }
  .board { scroll-snap-type:x proximity; gap:12px; }
  .board .col { flex:0 0 min(82vw,320px); min-width:0; border:1px solid var(--stone-200); border-radius:14px; scroll-snap-align:start; }
  .board .colh { display:block; padding:12px 10px; }
  .colh .nm { font-size:13px; }
  .colh .tot,.board .colhint { font-size:11px; }
  .jc { border-radius:10px; }
  .jc .nm { font-size:14px; }
  .jc .ac,.card-next { font-size:12px; }
  .advance-job { border-radius:9px; }
  .bottom-nav { position:fixed; display:flex; bottom:0; left:0; right:0; z-index:10; border-top:1px solid var(--stone-200); padding:8px calc(6px + var(--app-safe-right)) calc(8px + var(--app-safe-bottom)) calc(6px + var(--app-safe-left)); background:var(--paper); box-shadow:0 -3px 14px rgba(27,48,32,.05); gap:3px; }
  .bottom-nav button { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; min-width:0; min-height:54px; padding:7px 1px; flex:1; border:0; background:none; border-radius:10px; color:var(--ink-2); font-size:10px; }
  .bottom-nav svg { width:22px; height:22px; flex:none; }
  .bottom-nav button.on { background:#E8EDE3; color:var(--forest-deep); }
  dialog { border:0; border-radius:18px; width:calc(100% - 24px); max-height:calc(100dvh - var(--app-safe-top) - var(--app-safe-bottom) - 24px); margin:auto; inset:var(--app-safe-top) var(--app-safe-right) var(--app-safe-bottom) var(--app-safe-left); overscroll-behavior:contain; }
  dialog .mh { padding:20px 18px 14px; }
  dialog .mh h2 { font-size:28px; }
  dialog .mb { padding:0 18px 18px; gap:16px; }
  dialog .mb label { font-size:11px; letter-spacing:.04em; }
  dialog .in { min-height:46px; font-size:16px; border-radius:10px; }
  dialog .mf { padding:14px 18px 18px; border-top:1px solid var(--stone-100); background:var(--paper); position:sticky; bottom:0; }
  dialog .mf .pbtn { flex:1; font-size:14px; }
  .quick-add-dialog { inset:0; margin:auto 12px calc(12px + var(--app-safe-bottom)); width:calc(100% - 24px); }
  .quick-add-options .pbtn { min-height:58px; padding:16px; border-radius:12px; font-size:15px; }
  .toast { bottom:calc(86px + var(--app-safe-bottom)); }
  .signin { margin:calc(24px + var(--app-safe-top)) 16px 24px; padding:24px; }
}
@media (max-width:360px) {
  .bar .phone-title { font-size:22px; }
  .bar .quick-add-trigger { min-width:106px; padding:10px 12px; }
  .page-head { flex-wrap:wrap; }
}
