/* PitchPlay 2.0.2 — native-app mobile / PWA chrome + overflow layout.
   Desktop sidebar (>=901px) is unchanged except SVG nav icons.
   Mobile breakpoint is 900px to replace the existing top-wrapped sidebar, not leave a gap at 821–900. */

/* —— Icons in the desktop sidebar (and as a base for mobile clones) —— */
#nav a i.nav-ic,
.pp-mn-tab i,
.pp-mn-sheet i.nav-ic{
  font-style:normal;width:20px;height:20px;flex:none;display:inline-flex;align-items:center;justify-content:center;
  color:var(--muted);background:none;border:0;padding:0
}
#nav a i.nav-ic svg,
.pp-mn-tab i svg,
.pp-mn-sheet i.nav-ic svg{width:20px;height:20px;display:block;stroke:currentColor;fill:none}
#nav a.active i.nav-ic{color:var(--cyan)}

/* Bars are injected as siblings of #app; hidden until the signed-in app is shown on a phone. */
.pp-mn-topbar,.pp-mn-tabbar,.pp-mn-backdrop,.pp-mn-sheet{display:none}

@media (max-width:900px){
  :root{
    --pp-mn-top:52px;
    --pp-mn-tab:64px;
    --pp-safe-top:constant(safe-area-inset-top,0px);
    --pp-safe-top:env(safe-area-inset-top,0px);
    --pp-safe-bottom:constant(safe-area-inset-bottom,0px);
    --pp-safe-bottom:env(safe-area-inset-bottom,0px);
    --pp-app-height:100dvh
  }

  /* Fill the visible viewport. Do not use position:fixed for the tab bar:
     on iOS standalone the ICB used by position:fixed can be short by the
     top safe-area (~47–62px). Shifting a fixed bar into that gap (1.9.2)
     gets clipped on a real iPhone, which hides the labels and leaves a
     body-colored dead band. The chrome is in-flow in a flex column sized
     to 100dvh / --pp-app-height instead, so it can paint in that region
     the same way the body background already does. */
  html,body{
    height:var(--pp-app-height,100dvh)!important;
    max-height:var(--pp-app-height,100dvh)!important;
    min-height:0!important;
    background:var(--bg)
  }
  /* Any leftover sliver below the shell uses the tab-bar color, not --bg. */
  html{background:#06182e}

  /* Safety net only — root causes are fixed below. */
  html,body{overflow-x:hidden;max-width:100%}
  #app,.shell,.main,#view,.card,.page-head,.toolbar,.bulkbar,.form{max-width:100%;min-width:0;box-sizing:border-box}
  img,svg,video,canvas{max-width:100%;height:auto}
  .lv-frame iframe{max-width:none} /* keep 1920×1080 source; scaled inside overflow:hidden frame */

  /* Hide the sidebar; #nav stays in the DOM for app.js. */
  #app .side{display:none!important}

  #app:not([hidden]) ~ .pp-mn-topbar,
  #app:not([hidden]) ~ .pp-mn-tabbar{display:flex}

  html:has(#app:not([hidden])),
  html:has(#app:not([hidden])) body{
    display:flex;flex-direction:column;overflow:hidden;width:100%
  }
  html:has(#app:not([hidden])) body{flex:1 1 auto;min-height:0}
  html:has(#app:not([hidden])) #app.shell{
    order:2;flex:1 1 0;min-height:0;min-width:0;height:auto;flex-direction:column
  }

  .pp-mn-topbar{
    position:relative;top:auto;left:auto;right:auto;z-index:40;align-items:center;gap:10px;
    order:1;flex:none;width:100%;
    height:calc(var(--pp-mn-top) + var(--pp-safe-top));
    padding:var(--pp-safe-top) 14px 0;
    background:#06182e;border-bottom:1px solid var(--line);box-sizing:border-box
  }
  .pp-mn-topbar .pp-mn-mark{width:28px;height:28px;border-radius:7px;flex:none}
  .pp-mn-title{
    flex:1;min-width:0;font-weight:700;font-size:1.05rem;letter-spacing:-.02em;color:var(--white);
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis
  }

  .pp-mn-tabbar{
    position:relative;left:auto;right:auto;bottom:auto;z-index:40;align-items:stretch;justify-content:space-around;
    order:3;flex:none;width:100%;
    height:calc(var(--pp-mn-tab) + var(--pp-safe-bottom));
    min-height:calc(var(--pp-mn-tab) + var(--pp-safe-bottom));
    padding:0 2px var(--pp-safe-bottom);
    background:#06182e;border-top:1px solid var(--line);box-sizing:border-box
  }
  .pp-mn-tab{
    flex:1 1 0;min-width:0;min-height:44px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
    padding:6px 2px 4px;border:0;background:transparent;-webkit-appearance:none;appearance:none;border-radius:10px;color:#9fb2c7;font:600 11px/1.15 Inter,ui-sans-serif,system-ui,-apple-system,sans-serif;
    text-decoration:none;-webkit-tap-highlight-color:transparent;cursor:pointer
  }
  .pp-mn-tab i{width:24px;height:24px;color:inherit;flex:none}
  .pp-mn-tab i svg{width:24px;height:24px}
  .pp-mn-tab span,.pp-mn-tab-label{
    display:block;flex:none;font:600 11px/1.2 Inter,ui-sans-serif,system-ui,-apple-system,sans-serif;
    color:inherit;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;letter-spacing:-.01em
  }
  .pp-mn-tab.on,a.pp-mn-tab[aria-current="page"]{color:var(--cyan)}
  .pp-mn-tab:focus{outline:none}.pp-mn-tab:focus-visible{background:rgba(30,205,247,.08);border-radius:10px}

  html.pp-mn-open .pp-mn-backdrop{
    display:block;position:fixed;inset:0;z-index:44;background:rgba(2,8,16,.55);border:0;padding:0;cursor:pointer
  }
  html.pp-mn-open .pp-mn-sheet{
    display:block;position:fixed;left:0;right:0;bottom:0;z-index:45;max-height:min(86dvh,100%);
    overflow:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
    background:#071525;background:linear-gradient(180deg,#0b223f 0%,#071525 48px,#071525 100%);
    border-top:1px solid var(--line);
    border-radius:18px 18px 0 0;padding:8px 12px calc(16px + var(--pp-safe-bottom));
    box-shadow:0 -16px 40px rgba(0,0,0,.45);box-sizing:border-box
  }
  .pp-mn-sheet-handle{width:36px;height:4px;border-radius:4px;background:rgba(255,255,255,.22);margin:6px auto 12px}
  .pp-mn-sheet h2{font-size:1.1rem;margin:0 12px 10px}
  .pp-mn-sheet nav{display:flex;flex-direction:column;gap:2px}
  .pp-mn-sheet nav a{
    display:flex;align-items:center;gap:12px;min-height:44px;padding:10px 12px;border-radius:12px;
    color:#c3d4e4;font-weight:600
  }
  .pp-mn-sheet nav a i.nav-ic{width:22px;height:22px}
  .pp-mn-sheet nav a i.nav-ic svg{width:22px;height:22px}
  .pp-mn-sheet nav a:hover{background:rgba(255,255,255,.04);color:#fff}
  .pp-mn-sheet nav a.on{background:linear-gradient(90deg,rgba(30,205,247,.18),rgba(30,205,247,.04));color:#fff}
  .pp-mn-sheet nav a.on i.nav-ic{color:var(--cyan)}
  .pp-mn-account{border-top:1px solid var(--line);margin-top:10px;padding:14px 12px 4px;display:flex;flex-direction:column;gap:10px}
  .pp-mn-account b{display:block}
  .pp-mn-account small{color:var(--muted);font-size:.78rem}
  .pp-mn-account .btn{min-height:44px}
  html.pp-mn-open,html.pp-mn-open body{overflow:hidden}

  /* Chrome is in-flow, so content only needs inner spacing — not a fixed-bar offset. */
  #app .main{
    padding:12px 16px 28px;
    overflow:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
    min-height:0;flex:1 1 0
  }

  /* Page title lives in the top bar; keep actions reachable and wrapping. */
  .page-head{gap:8px;margin-bottom:14px;align-items:stretch}
  .page-head h1:not(:has(.title-input)){
    position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0
  }
  .page-head h1:has(.title-input){
    position:static;width:100%;height:auto;margin:0;clip:auto;overflow:visible;white-space:normal;
    display:flex;flex-wrap:wrap;align-items:center;gap:6px;font-size:0
  }
  .page-head h1:has(.title-input) .crumb{display:none}
  .page-head h1:has(.title-input) .title-input{font-size:1.2rem}
  .page-head .actions{width:100%;display:flex;flex-wrap:wrap;gap:8px}
  .page-head .actions .btn{min-height:44px}
  .page-head:has(.actions:empty){display:none;margin:0}

  /* Toolbars: stack, full-width fields. */
  .toolbar{display:flex;flex-direction:column;align-items:stretch;gap:8px;max-width:100%}
  .toolbar .search,.toolbar select,.toolbar input{width:100%;max-width:none}
  .toolbar .muted{align-self:flex-start}

  /* Bulk actions: identity on the first row, actions as a horizontally scrollable chip row. */
  .bulkbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;max-width:100%}
  .bulkbar .sp{display:none}
  .pp-mn-chiprow{
    display:flex;flex-wrap:nowrap;gap:8px;overflow-x:auto;-webkit-overflow-scrolling:touch;
    width:100%;padding:2px 0 4px;scrollbar-width:thin;overscroll-behavior-x:contain
  }
  .pp-mn-chiprow .btn{flex:none;min-height:44px}

  /* Data tables → stacked cards (JS adds .pp-mn-cards + data-label). */
  .card:has(> table.tbl.pp-mn-cards),
  .card:has(> h3 + table.tbl.pp-mn-cards),
  .card:has(> .pad0 + table.tbl.pp-mn-cards){
    background:none;border:0;box-shadow:none;padding:0
  }
  .card:has(> table.tbl.pp-mn-cards) > h3,
  .card:has(> h3 + table.tbl.pp-mn-cards) > h3,
  .card:has(> .pad0 + table.tbl.pp-mn-cards) > h3{padding:4px 4px 12px}
  table.tbl.pp-mn-cards,table.tbl.pp-mn-cards tbody{display:block;width:100%;border:0}
  table.tbl.pp-mn-cards thead{display:none}
  table.tbl.pp-mn-cards tr{
    display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:0 8px;
    background:linear-gradient(180deg,#0b223f,#081a31);border:1px solid var(--line);border-radius:16px;
    padding:12px 14px;margin:0 0 12px;box-shadow:0 18px 40px rgba(0,0,0,.25)
  }
  table.tbl.pp-mn-cards td{
    display:flex;justify-content:space-between;align-items:flex-start;gap:10px;
    grid-column:1/-1;padding:8px 0;border:0;border-bottom:1px solid var(--line);
    white-space:normal;overflow-wrap:break-word;word-break:normal;min-width:0
  }
  table.tbl.pp-mn-cards td[data-label]{flex-direction:column;align-items:flex-start;gap:4px}
  table.tbl.pp-mn-cards td.r{white-space:normal;text-align:left}
  table.tbl.pp-mn-cards .tag,.tbl.pp-mn-cards .badge{white-space:nowrap;word-break:normal;overflow-wrap:normal}
  table.tbl.pp-mn-cards td::before{
    content:attr(data-label);color:var(--muted);font-weight:600;font-size:.72rem;line-height:1.3;
    text-transform:uppercase;letter-spacing:.06em;flex:none;max-width:none;padding-top:0
  }
  table.tbl.pp-mn-cards td:not([data-label])::before{content:none;display:none}
  table.tbl.pp-mn-cards td.pp-mn-check{
    grid-column:1;grid-row:1;border:0;padding:4px 0;align-items:center;justify-content:flex-start
  }
  table.tbl.pp-mn-cards td.pp-mn-primary{
    grid-column:2;grid-row:1;border:0;padding:4px 0;display:block;font-weight:700;min-width:0
  }
  table.tbl.pp-mn-cards tr:not(.pp-mn-has-check) td.pp-mn-primary{grid-column:1/3}
  table.tbl.pp-mn-cards tr:not(.pp-mn-has-status) td.pp-mn-primary{grid-column:2/-1}
  table.tbl.pp-mn-cards tr:not(.pp-mn-has-check):not(.pp-mn-has-status) td.pp-mn-primary{grid-column:1/-1}
  table.tbl.pp-mn-cards td.pp-mn-primary::before{display:none}
  table.tbl.pp-mn-cards td.pp-mn-status{
    grid-column:3;grid-row:1;border:0;padding:4px 0;justify-content:flex-end;text-align:right
  }
  table.tbl.pp-mn-cards td.pp-mn-status::before{display:none}
  table.tbl.pp-mn-cards td.pp-mn-row-actions{
    border:0;padding:10px 0 2px;justify-content:flex-start;flex-wrap:wrap;gap:8px
  }
  table.tbl.pp-mn-cards td.pp-mn-row-actions .btn{min-height:44px}
  table.tbl.pp-mn-cards td.pp-mn-empty{display:none}
  table.tbl.pp-mn-cards td:has(input:not([type=checkbox]):not([type=hidden]),select,textarea){
    flex-direction:column;align-items:stretch
  }
  table.tbl.pp-mn-cards td:has(input:not([type=checkbox]):not([type=hidden]),select,textarea)::before{
    max-width:none;flex:none
  }
  table.tbl.pp-mn-cards input:not([type=checkbox]),
  table.tbl.pp-mn-cards select,
  table.tbl.pp-mn-cards textarea,
  table.tbl.pp-mn-cards .sm-in{width:100%;max-width:none}
  .pp-mn-actmenu{position:relative;width:100%}
  .pp-mn-actmenu > summary{
    list-style:none;display:inline-flex;align-items:center;justify-content:center;min-height:44px;min-width:44px;cursor:pointer
  }
  .pp-mn-actmenu > summary::-webkit-details-marker{display:none}
  .pp-mn-actmenu-list{display:flex;flex-direction:column;gap:6px;margin-top:8px}
  .pp-mn-actmenu-list .btn{width:100%}

  /* Root-cause overflow: fixed mins, 2-col grids, nowrap rows. */
  .title-input{min-width:0;width:100%;font-size:1.2rem}
  .two,.theme-row{grid-template-columns:1fr}
  @media (min-width:420px){ .theme-row{grid-template-columns:1fr 1fr} }
  .up-row{grid-template-columns:1fr}
  .stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .cards,.media-grid{grid-template-columns:minmax(0,1fr)}
  .row{flex-wrap:wrap}
  .ov-row label,.ov-row label.wide{min-width:0;width:100%}
  .ov-add{flex-wrap:wrap;max-width:100%;align-items:stretch}
  .ov-add select,.ov-add .btn{width:100%;max-width:100%;min-width:0;flex:1 1 100%}
  .row-head{flex-wrap:wrap;gap:8px;max-width:100%}
  .row-head h3{min-width:0;flex:1 1 auto}
  select,input,textarea{max-width:100%;min-width:0}

  .kv b{max-width:100%;white-space:normal}
  pre,code,.now,.short,.copy{overflow-wrap:anywhere;word-break:break-word}
  .modal-card,.modal-card.wide{max-width:100%}
  .code-input{letter-spacing:.18em;font-size:1.5rem}
  .dl-hero,.dl-meta{max-width:100%}
  .tabs{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;flex-wrap:nowrap}
  .tab{flex:none}


  .cal-seg,.cal-bar,.cal-tools{flex-wrap:wrap;max-width:100%}
  .cal-seg{width:100%}
  .cal-seg .btn{flex:1 1 auto;min-height:44px}
  .pl-items li{flex-wrap:wrap}
  .dur{flex-wrap:wrap}

  /* Calendar week grid may be 640px — scroll inside the calendar, never the page. */
  .cal-wrap,.v-week,.cg-scroll,.cal-bar,.cal-tools{max-width:100%;min-width:0}
  .v-week,.cg-scroll{overflow-x:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}

  /* Fixed UI cleared above the tab bar. */
  .toast{
    bottom:calc(var(--pp-mn-tab) + var(--pp-safe-bottom) + 12px);
    max-width:calc(100% - 24px)
  }
  .iq-fab{right:16px;bottom:calc(var(--pp-mn-tab) + var(--pp-safe-bottom) + 12px)}
  .iq-drawer{
    top:calc(var(--pp-mn-top) + var(--pp-safe-top));
    bottom:calc(var(--pp-mn-tab) + var(--pp-safe-bottom));
    width:100%;max-width:100%;z-index:35
  }
  .savebar{padding-bottom:12px}
  html,#view,.main,#scForm,form:has(.savebar){scroll-padding-bottom:128px}
  input,select,textarea{scroll-margin-bottom:128px}
  /* font-size of inputs stays 16px (1.2.9 iOS zoom rule) — do not override. */

  /* Screen detail: tidy 2-column action grid. Remove is full-width and set apart. */
  .page-head .sc-actions{
    display:grid;grid-template-columns:1fr 1fr;gap:8px;width:100%;justify-content:stretch
  }
  .page-head .sc-actions .btn{
    width:100%;min-height:44px;margin:0;padding:10px 12px;border-radius:10px;
    justify-content:center;gap:8px;font-size:.88rem;white-space:nowrap;box-sizing:border-box
  }
  .page-head .sc-actions .btn.danger{
    grid-column:1/-1;margin-top:4px;background:rgba(255,93,108,.10);border-color:rgba(255,93,108,.35)
  }

  .auth-body{padding:24px 16px;padding-top:max(24px,var(--pp-safe-top));padding-bottom:max(24px,var(--pp-safe-bottom))}
  .auth-card{padding:24px 18px}
}

@media (max-width:900px) and (prefers-reduced-motion:no-preference){
  html.pp-mn-open .pp-mn-sheet{animation:pp-mn-up .22s ease-out}
  @keyframes pp-mn-up{from{transform:translateY(18px)}to{transform:none}}
}
