/* Shell: header, nav, tab bar, main, container, action bar, breakpoints — spec §2.1, §3.4, §5.9, §9.2 */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.container-narrow { max-width: 760px; }
.container-reading { max-width: 720px; }

/* ---------- header (one element, two chromes) ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: var(--safe-top); }
.topbar::before { content: ""; display: block; height: 3px; background: var(--brand-600); }
.hd-desktop { display: flex; align-items: center; gap: var(--s3); height: var(--header-h); }
.hd-phone { display: none; }
.brand { display: flex; align-items: center; min-height: 44px; margin-right: var(--s3); }
.brand img { height: 32px; width: auto; max-width: 200px; object-fit: contain; }
.nav { display: flex; align-items: center; gap: 2px; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: var(--r-md); font: var(--t-body-strong); color: var(--n800); }
.nav-link:hover { background: var(--n100); }
.nav-link[aria-current="page"] { background: var(--n100); color: var(--text); box-shadow: inset 0 -2px 0 var(--brand-600); border-radius: var(--r-md) var(--r-md) 0 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

.account { position: relative; }
.avatar-chip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 4px; border-radius: var(--r-full); border: 1px solid var(--border); background: var(--surface); font: var(--t-body-strong); color: var(--text); }
.avatar-chip:hover { background: var(--n50); }
.avatar-chip .i { color: var(--text-3); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-md); padding: 6px; z-index: 30; }
.menu[hidden] { display: none; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: var(--r-md); color: var(--text); font: var(--t-body); text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: var(--n100); text-decoration: none; box-shadow: none; }
.menu-item .i { color: var(--text-3); }
.menu-item.danger { color: var(--danger-600); } .menu-item.danger .i { color: var(--danger-600); }
.menu-sep { border-top: 1px solid var(--border); margin: 6px 4px; }
.menu-head { padding: 8px 12px 4px; font: var(--t-caption); color: var(--text-3); }

/* ---------- main ---------- */
main { flex: 1; width: 100%; padding-top: var(--s6); padding-bottom: var(--s12); }
main[aria-busy="true"] .sk-only { display: block; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head h1 { flex: 1 1 auto; min-width: 0; }
.page-head .sub { font: var(--t-sm); color: var(--text-3); margin-top: 2px; }
.page-head .page-actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.section { display: flex; flex-direction: column; gap: var(--s3); }
.sections { display: flex; flex-direction: column; gap: var(--s6); }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font: var(--t-sm); color: var(--text-2); }
.back-link:hover { text-decoration: none; color: var(--text); }

/* Two-column layouts exist only at >= 1024px (spec §9.2) */
.cols-2-1, .cols-7-5 { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
.cols-2-1 > *, .cols-7-5 > * { min-width: 0; }
@media (min-width: 1024px) {
  .cols-2-1 { grid-template-columns: 2fr 1fr; align-items: start; }
  .cols-7-5 { grid-template-columns: 7fr 5fr; align-items: start; }
  .sticky-col { position: sticky; top: calc(var(--header-h) + var(--s6)); }
}

/* ---------- tab bar ---------- */
.tabbar { display: none; }

/* ---------- phone action bar (task detail) ---------- */
.actionbar { display: none; }

/* ---------- phone chrome ---------- */
@media (max-width: 719px) {
  .hd-desktop { display: none; }
  .hd-phone { display: flex; align-items: center; gap: var(--s2); height: var(--header-h-phone); }
  .ph-left, .ph-right { flex: 0 0 44px; display: flex; align-items: center; justify-content: center; min-height: 44px; }
  .ph-right { flex-basis: auto; min-width: 44px; justify-content: flex-end; }
  .ph-mark { height: 28px; width: 28px; object-fit: contain; }
  .ph-title { flex: 1; min-width: 0; font: 700 17px/22px var(--font); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hd-phone.sub .ph-title { text-align: center; }
  .hd-phone .ph-sub { display: block; font: var(--t-caption); color: var(--text-3); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding-top: var(--s4); padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s4)); }
  main.has-actionbar { padding-bottom: calc(var(--tabbar-h) + var(--actionbar-h) + var(--safe-bottom) + var(--s4)); }
  main.has-formbar { padding-bottom: calc(var(--actionbar-h) + var(--safe-bottom) + var(--s4)); }
  .page-head { margin-bottom: var(--s4); }
  .page-head .page-actions .btn-primary.hide-phone { display: none; }

  .tabbar {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 20; height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom); background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabbar-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: 700 12px/14px var(--font); color: var(--text-3); position: relative; min-width: 0; }
  .tabbar-item .i { width: 24px; height: 24px; }
  .tabbar-item[aria-current="page"] { color: var(--brand-600); }
  .tabbar-item .badge { position: absolute; top: 4px; right: calc(50% - 22px); }
  .tabbar-item.new { color: var(--text-3); }
  .tabbar-item.new .new-circle {
    position: relative; top: -14px; width: 56px; height: 56px; border-radius: 50%; background: var(--brand-600); color: #fff;
    box-shadow: var(--sh-lg); display: flex; align-items: center; justify-content: center; margin-bottom: -12px;
  }
  .tabbar-item.new .new-circle .i { width: 28px; height: 28px; }
  .tabbar-item.new.quiet .new-circle { background: var(--n800); }
  .tabbar-item.new:active .new-circle { background: var(--brand-700); }
  body.typing .tabbar, body.typing .actionbar, body.typing .formbar { display: none; }
  body.modal-route .tabbar { display: none; }
  body.modal-route main { padding-bottom: calc(var(--actionbar-h) + var(--safe-bottom) + var(--s4)); }

  .actionbar {
    position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom)); z-index: 19; min-height: var(--actionbar-h);
    background: var(--surface); border-top: 1px solid var(--border); padding: 8px 16px; display: flex; gap: 8px; align-items: center;
  }
  .actionbar .btn { height: 48px; }
  .actionbar .grow-btn { flex: 1; }
  .actionbar .btn-icon.sq { width: 48px; height: 48px; flex: 0 0 48px; }
  .actionbar .quiet-line { flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font: var(--t-sm); color: var(--text-2); }
  .formbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 19; min-height: calc(var(--actionbar-h) + var(--safe-bottom));
    padding: 8px 16px calc(8px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center;
  }
  .formbar .btn { height: 48px; } .formbar .btn-primary { flex: 1; }
  .formbar .btn-ghost { display: none; }
}
@media (min-width: 560px) and (max-width: 719px) { .formbar .btn-ghost { display: inline-flex; } }
@media (min-width: 720px) {
  .formbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
  .hide-desktop { display: none !important; }
}
@media (max-width: 719px) { .hide-phone { display: none !important; } .sr-only-phone { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } }

/* Offline / top banners */
.banner { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s4); border-radius: var(--r-md); font: var(--t-sm); border: 1px solid transparent; }
.banner .i { flex: 0 0 auto; }
.banner.info { background: var(--info-100); color: var(--info-700); }
.banner.warning { background: var(--warning-100); color: var(--warning-700); }
.banner.danger { background: var(--danger-50); color: var(--danger-text); border-left: 4px solid var(--danger-600); }
.banner.success { background: var(--success-100); color: var(--success-800); }
.banner.neutral { background: var(--n100); color: var(--text-2); }
.banner .banner-text { flex: 1; min-width: 0; }
.banner .btn { flex: 0 0 auto; }
