/* Shared responsive layout. Load after feature CSS. The rail participates in
   the same grid as the header and every screen; no independent fixed offsets. */
:root {
  --bet-shell-max:1920px;
  --bet-rail-width:180px;
  --bet-shell-gap:24px;
  --bet-shell-pad:clamp(16px,2vw,32px);
}
#app-view, #app-view > .tab-panel, #app-view > .appbar,
#app-view .card, #app-view .row > *, #app-view .section-head > *,
#app-view .inbox-item-main > *, #app-view .inbox-item-text-row > *,
#app-view .link-preview-copy, #app-view .media-item > * {
  min-width:0;
}
#app-view > .tab-panel { width:100%; max-width:100%; }
#app-view .card, #app-view .section-head, #app-view .row,
#app-view .inbox-item-main, #app-view .inbox-item-text-row,
#app-view .inbox-item-text, #app-view .rich-text { max-width:100%; }
#app-view .inbox-item-main > div { flex:1 1 0; width:100%; }
#app-view .inbox-item-text-row .rich-text { min-width:0; max-width:100%; }
#app-view .rich-text .link-preview { width:min(560px,100%); max-width:100%; }
#app-view .link-preview-copy { flex:1 1 0; }
#app-view .inbox-capture-row { flex-wrap:wrap; }
#app-view .inbox-capture-row #inbox-input { min-width:0; flex:1 1 220px; }
#app-view .section-head, #app-view .calendar-head { flex-wrap:wrap; }
#app-view .row { grid-template-columns:repeat(auto-fit,minmax(min(150px,100%),1fr)); }
#app-view .stats-grid { grid-template-columns:repeat(auto-fit,minmax(min(170px,100%),1fr)); }
#app-view .project-group-projects:not(.hidden) { grid-template-columns:repeat(auto-fit,minmax(min(280px,100%),1fr)); }
#app-view .card img:not(.icon), #app-view canvas { max-width:100%; }
#app-view .week-calendar, #app-view .work-kanban, #app-view .wb-chart-scroll {
  min-width:0; max-width:100%; overflow-x:auto; overscroll-behavior-x:contain;
}
#app-view .week-calendar { margin-inline:0; }
#app-view .week-head.days-2,#app-view .week-body.days-2,
#app-view .week-head.days-3,#app-view .week-body.days-3 { min-width:100%; }
#app-view .section-head h2, #app-view .bet-title, #app-view .meta,
#app-view .inbox-item-text { overflow-wrap:anywhere; }
#modal-box { min-width:0; max-width:100%; overflow-x:auto; }
@media(min-width:1024px) {
  #bet-shell:has(> #app-view:not(.hidden)) {
    width:100%; max-width:var(--bet-shell-max);
    margin-inline:auto; padding:18px var(--bet-shell-pad) 150px;
  }
  #app-view:not(.hidden) {
    display:grid; grid-template-columns:var(--bet-rail-width) minmax(0,1fr);
    grid-template-rows:auto 1fr; column-gap:var(--bet-shell-gap);
    align-items:start; width:100%; max-width:100%; padding:0!important; min-height:calc(100dvh - 36px);
  }
  #app-view > .appbar { grid-column:2; grid-row:1; width:100%; margin-inline:0; }
  #app-view > .tab-panel { grid-column:2; grid-row:2; width:100%; max-width:100%!important; margin-inline:0; }
  #app-view > #bottomnav {
    grid-column:1; grid-row:2; align-self:start;
    position:sticky; top:80px; left:auto; right:auto; bottom:auto;
    width:100%; max-width:100%; height:auto; max-height:calc(100dvh - 96px);
    transform:none; margin:0; padding:4px 10px 8px 0;
    display:flex; flex-direction:column; align-items:stretch; justify-content:flex-start;
    overflow:auto; border:0; border-right:1px solid var(--border);
    border-radius:0; background:var(--bg); box-shadow:none;
  }
  #app-view > #bottomnav .navbtn { flex:0 0 auto; width:100%; min-width:0; margin:0; gap:10px; }
  #app-view > #bottomnav .navbtn > span:last-child { display:inline; white-space:normal; text-align:left; }
  #fab-menu,#konto-menu,#organize-menu,
  body:has(#tab-todos.todo-board-view:not(.hidden)) :is(#fab-menu,#konto-menu,#organize-menu) {
    left:calc(max(0px,(100vw - var(--bet-shell-max))/2) + var(--bet-shell-pad) + var(--bet-rail-width) + 8px);
  }
  #timerbar {
    left:calc(50% + (var(--bet-rail-width) + var(--bet-shell-gap))/2);
    right:auto; bottom:18px;
    width:min(1120px,calc(100vw - var(--bet-rail-width) - var(--bet-shell-gap) - 2 * var(--bet-shell-pad)));
    max-width:calc(100vw - var(--bet-rail-width) - var(--bet-shell-gap) - 2 * var(--bet-shell-pad))!important;
  }
  #app-view .tiles { grid-template-columns:repeat(auto-fit,minmax(min(170px,100%),1fr)); }
}
@media(min-width:1024px) and (max-width:1199px) {
  :root { --bet-rail-width:64px; --bet-shell-gap:18px; }
  #app-view > #bottomnav { padding-right:8px; }
  #app-view > #bottomnav .navbtn { justify-content:center; padding:10px 3px; gap:0; min-height:46px; }
  #app-view > #bottomnav .navbtn > span:last-child { display:none; }
}
@media(min-width:1200px) and (max-width:1439px) {
  :root { --bet-rail-width:156px; --bet-shell-gap:22px; }
  #app-view > #bottomnav .navbtn { justify-content:flex-start; padding:9px; }
}
@media(max-width:1023px) {
  #app-view > #bottomnav { position:fixed; top:auto; bottom:0; }
  #app-view .inbox-capture-row #inbox-input { flex:1 1 100%; }
}
@media(max-width:620px) {
  #app-view .section-head { gap:8px; }
  #app-view .inbox-item-text-row { align-items:flex-start; }
  #app-view .inbox-actions button { min-width:0; white-space:normal; }
  #app-view .inbox-actions button span { min-width:0; overflow-wrap:anywhere; }
}
