/* mobile-shell: phone (≤760px) and tablet (761–1100px) layout — see the matching builder's notes */
/* The app shell. Phones get an app's chrome: a slim top bar with the page title, a bottom tab bar
   with round New task / Say tasks buttons docked at its end, and a More sheet. Tablets keep the desktop bar but every page
   tab shows (a second row). Desktop (over 1100px) is untouched: the phone parts never show there. */

.appbar-title, .tabbar, .fab-stack, .menu .menu-theme { display: none; }

/* ---- More sheet (opened from the phone tab bar): a bottom sheet of the other pages ---- */
.more-sheet {
  top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-width: none; max-height: calc(100dvh - 48px);
  margin: 0; padding: 0 max(0px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(0px, env(safe-area-inset-left, 0px));
  overflow-y: auto; border: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  background: var(--surface, #16181d); color: var(--text); box-shadow: 0 -16px 48px rgba(0, 0, 0, .45);
}
.more-sheet[open] { animation: more-sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
.more-sheet::backdrop { background: rgba(0, 0, 0, .5); }
@keyframes more-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.more-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 10px 4px 22px; }
.more-head::before { content: ''; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line); } /* grab handle */
.more-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.more-close { width: 40px; height: 40px; }
.more-list { display: flex; flex-direction: column; padding: 4px 10px 14px; }
.more-list :is(a, button) { display: flex; width: 100%; border: 0; background: none; font-family: inherit; cursor: pointer; text-align: left; align-items: center; gap: 14px; height: 52px; padding: 0 14px; border-radius: 14px; color: var(--text); font-size: 16px; font-weight: 500; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.more-list :is(a, button) svg { width: 22px; height: 22px; flex: none; color: var(--muted); }
.more-list :is(a, button):active { background: rgba(255, 255, 255, .06); }
.more-list a.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
.more-list a.active svg { color: var(--accent); }
.more-list :is(a, button):focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.more-list .more-talk { display: none; } /* only on very narrow phones, where the mic leaves the tab bar */
.more-sep { height: 1px; margin: 6px 14px; background: var(--line); }
:where(html[data-theme="light"]) .more-sheet { box-shadow: 0 -12px 40px -8px rgba(15, 23, 42, .25); }
:where(html[data-theme="light"]) .more-sheet::backdrop { background: rgba(15, 23, 42, .35); }
:where(html[data-theme="light"]) .more-list :is(a, button):active { background: rgba(15, 23, 42, .05); }
@media (prefers-reduced-motion: reduce) { .more-sheet[open] { animation: none; } }

/* ================================================================ phone */
@media (max-width: 760px) {
  :root {
    --appbar-h: calc(56px + env(safe-area-inset-top, 0px));
    --tabbar-h: calc(64px + env(safe-area-inset-bottom, 0px));
    --dock-clear: calc(var(--tabbar-h) + 24px); /* every page clears the tab bar (the round buttons are in it) */
  }
  html { scroll-padding-top: calc(var(--appbar-h) + 16px); scroll-padding-bottom: calc(var(--tabbar-h) + 16px); }
  #app-screen .layout { padding-bottom: 0; min-height: calc(100dvh - var(--appbar-h)); }
  #app-screen .sidebar { margin-bottom: 0; }

  /* top app bar: mark, page title; Business/Personal, search and you on the right */
  .topbar {
    flex-wrap: nowrap; gap: 10px; row-gap: 0; height: var(--appbar-h); overflow: visible; background: transparent;
    padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  }
  /* the same frosted surface as the tab bar. It sits on a layer behind the bar's contents rather than on
     the bar itself, so the bar never becomes the containing block of anything fixed inside it. */
  .topbar::before {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    -webkit-backdrop-filter: saturate(1.5) blur(20px); backdrop-filter: saturate(1.5) blur(20px);
  }
  /* the mark: a 40px target, drawn where it was (22px, flush with the gutter) */
  .topbar .brand { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 0; width: 40px; height: 40px; margin: 0 -9px; font-size: 0; letter-spacing: 0; }
  .topbar .brand svg { width: 22px; height: 22px; }
  .topbar:has(#space-switch:not([hidden])) .brand { display: none; } /* Projects pages: the title needs the room */
  .topbar .brand .os-ver { display: none; }
  .appbar-title { display: block; flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--text); font-size: 17px; font-weight: 600; line-height: 24px; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .tabs { display: none; } /* the tab bar at the bottom takes over; #nav-add / #nav-talk live on as the round buttons */
  .topbar .who { flex: none; gap: 4px; margin-left: auto; }
  #theme-btn, #width-btn { display: none; } /* Light / Dark is a row in the account menu */
  .topbar #search-btn, .topbar #user-btn { width: 40px; height: 40px; }
  .topbar #search-btn svg { width: 19px; height: 19px; }
  .topbar #user-btn { font-size: 15px; }
  /* Business / Personal: two 40px-tall segments; the outline is drawn inside so it adds no height */
  .topbar .space-switch { gap: 0; margin-right: 0; padding: 0; border: 0; box-shadow: inset 0 0 0 1px var(--line); }
  .topbar .space-switch button { height: 40px; padding: 0 10px; font-size: 12px; }
  .topbar .space-switch button svg { display: none; }
  .menu .menu-theme { display: flex; }
  .menu a, .menu button { height: 44px; }
  .menu { max-height: calc(100dvh - var(--appbar-h) - 16px); overflow-y: auto; }

  /* bottom tab bar: the pages, then the round buttons docked at its end */
  .tabbar {
    position: fixed; right: 0; bottom: 0; left: 0; z-index: 8; display: flex; align-items: flex-start; height: var(--tabbar-h);
    padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
    border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 84%, transparent);
    -webkit-backdrop-filter: saturate(1.5) blur(20px); backdrop-filter: saturate(1.5) blur(20px);
  }
  .tabbar-set { display: flex; flex: 1 1 auto; min-width: 0; height: 64px; }
  .tabbar-set[hidden] { display: none; }
  /* equal widths while there is room; a label never gets cut (the item keeps its text's width) */
  .tb-item {
    position: relative; display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: min-content;
    padding: 0 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; line-height: 14px; letter-spacing: .01em;
    text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color .15s;
  }
  .tb-item svg { position: relative; z-index: 1; width: 24px; height: 24px; }
  .tb-item span { white-space: nowrap; }
  .tb-item::before { content: ''; position: absolute; top: 8px; right: 0; left: 0; width: min(56px, calc(100% - 4px)); height: 30px; margin: 0 auto; border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, transparent); opacity: 0; transform: scaleX(.6); transition: opacity .18s, transform .18s; }
  .tb-item.active { color: var(--accent); }
  .tb-item.active::before { opacity: 1; transform: none; }
  .tb-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 14px; }
  @media (hover: hover) { .tb-item:hover { color: var(--text); } .tb-item.active:hover { color: var(--accent); } }

  /* round buttons: the mic, then + (New task / Add password), sitting in the bar at its end. They are
     part of the bar, not floating over the page, so they never cover a control or a line of text. */
  .fab-stack { display: flex; flex: none; align-items: center; gap: 8px; height: 64px; padding: 0 6px 0 8px; }
  .fab-stack[hidden] { display: none; }
  .fab-stack > button { display: grid; place-items: center; padding: 0; border-radius: 50%; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .12s, background .15s; }
  .fab-stack > button[hidden] { display: none; }
  .fab-add { width: 48px; height: 48px; border: 0; background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--accent) 55%, transparent), 0 2px 5px rgba(0, 0, 0, .3); }
  .fab-add svg { width: 24px; height: 24px; }
  .fab-talk {
    width: 44px; height: 44px; border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
  }
  .fab-talk svg { width: 20px; height: 20px; }
  .fab-stack > button:active { transform: scale(.93); }
  .fab-stack > button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
  :where(html[data-theme="light"]) .fab-add { box-shadow: 0 6px 14px -6px rgba(15, 23, 42, .45), 0 2px 5px rgba(15, 23, 42, .15); }
  :where(html[data-theme="light"]) .fab-talk { background: color-mix(in srgb, var(--accent) 10%, var(--surface, #fff)); }

  /* the notice sits just above the tab bar */
  body:has(#app-screen:not([hidden])) > .toast { bottom: calc(var(--tabbar-h) + 12px); }
}
@media (max-width: 400px) {
  .topbar .space-switch button { padding: 0 8px; font-size: 11.5px; }
}
@media (max-width: 350px) {
  /* very narrow: the tab bar keeps 40px+ targets by handing the mic to the More sheet */
  .fab-stack > .fab-talk { display: none; }
  .more-list .more-talk:not([hidden]) { display: flex; }
}
@media (max-width: 360px) {
  .topbar .brand { display: none; } /* very narrow: the title and controls keep their room */
  .topbar .space-switch button { padding: 0 7px; }
  .appbar-title { font-size: 16px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .fab-stack > button, .tb-item, .tb-item::before { transition: none; }
}

/* ================================================================ tablet */
/* on Projects pages (seven tabs) the top bar wraps to two rows so every tab shows: brand and
   controls, then the tabs spread across the full width. Vault pages (two tabs) fit on one row. */
@media (min-width: 761px) and (max-width: 1100px) {
  .topbar:has(.tab[data-app="projects"]:not([hidden])) { flex-wrap: wrap; height: auto; row-gap: 10px; column-gap: 16px; padding-top: 10px; padding-bottom: 10px; overflow: visible; }
  .topbar:has(.tab[data-app="projects"]:not([hidden])) .brand { margin-right: auto; }
  .topbar:has(.tab[data-app="projects"]:not([hidden])) .tabs { order: 10; flex: 1 1 100%; max-width: none; margin-right: 0; overflow: visible; }
  .topbar:has(.tab[data-app="projects"]:not([hidden])) .tab { flex: 1 1 auto; justify-content: center; padding: 0 10px; letter-spacing: .1em; }
  .topbar:has(.tab[data-app="projects"]:not([hidden])) .tabs :is(.nav-add, .nav-talk) { position: static; }
  html:has(.tab[data-app="projects"]:not([hidden])) { scroll-padding-top: 136px; }
}
