/* App shell: top bar, content area and phone bottom nav, ported from the prototype */
#shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 24px; height: 52px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 600; font-size: 15px; white-space: nowrap; color: inherit; text-decoration: none; }
/* The logo SVG sets width/height 100% inline: size its wrapper */
.brand-logo { width: 34px; height: 34px; flex: none; }
.nav { display: flex; gap: 2px; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar .spacer { flex: 1; }
.iconbtn { width: 34px; height: 34px; border-radius: 17px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--muted); }
.iconbtn:hover { color: var(--ink); border-color: var(--line-strong); }
.iconbtn svg { width: 18px; height: 18px; }
.acct { position: relative; }

/* ---------- search box and its list (prototype .topsearch / searchDrop) ---------- */
.topsearch { position: relative; width: min(420px, 34vw); }
.topsearch label { display: block; position: relative; }
.topsearch input { width: 100%; height: 34px; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r); padding: 0 64px 0 32px; }
.topsearch input::placeholder { color: var(--faint); }
.topsearch input:focus { background: var(--surface); border-color: var(--line-strong); }
.topsearch label > svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.topsearch kbd { position: absolute; right: 8px; top: 7px; pointer-events: none; }
.topsearch .sclear { right: 6px; }
.sdrop { position: absolute; right: 0; top: 42px; width: min(580px, 92vw); max-height: 72vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 70; }
.sgroup h4 { font: 600 11px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 8px 8px 4px; display: flex; gap: 6px; }
.sgroup .serr { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px; color: var(--muted); }
.sall { display: block; text-align: center; padding: 9px; border-top: 1px solid var(--line); margin-top: 6px; color: var(--work); font-weight: 500; text-decoration: none; }
.sempty { padding: 18px; color: var(--muted); text-align: center; }
/* The magnifier opens the search page on the phone */
.topbar .searchbtn { display: none; }
.bottomnav { display: none; }
.topbar, .bottomnav { flex: none; }

/* ---------- page ---------- */
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding-block: 20px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
/* Without the bars (login) the screen owns the whole page */
#shell.bare main { max-width: none; padding: 0; }

/* Legal notice (Fair Play): the same look as the login footnote, at the end of the page content */
.legal { width: 100%; max-width: 70ch; margin: 0 auto; padding: 0 16px 32px; text-align: center; font-size: 12px; color: var(--muted); }
.legal[hidden] { display: none; }

/* ---------- phone: the prototype's .phone rules ---------- */
@media (max-width: 760px) {
  .topbar { gap: 4px; height: 56px; }
  .topbar .nav { display: none; }
  .topsearch { display: none; }
  .topbar .searchbtn { display: grid; }
  /* Columns follow the number of items: the same as repeat(4, 1fr) with the prototype's four */
  .bottomnav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: sticky; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .bottomnav a { text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; display: grid; justify-items: center; gap: 2px; padding: 8px 2px; position: relative; }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a[aria-current="page"] { color: var(--ink); }
  .bottomnav a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--accent); }
  .bottomnav .count { position: absolute; top: 4px; left: calc(50% + 6px); }
  main { padding-block: 14px 24px; }
  .brand span { font-size: 13.5px; }
  .brand { margin-right: auto; }
  .topbar .iconbtn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); }
  .topbar .iconbtn:hover, .topbar .iconbtn[aria-expanded="true"] { background: var(--surface-2); }
  .topbar .iconbtn svg { width: 22px; height: 22px; }
}
