/* App shell organised like a big social network (spec §9.5):
   sticky top bar · left shortcuts · centre page · right family panel. Phones: bottom nav. */

:root { --topbar-h: 60px; --left-w: 300px; --right-w: 340px; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s3);
  padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .15);
}
.topbar__start, .topbar__end { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.topbar__end { justify-content: flex-end; }
.topbar__brand { display: flex; align-items: center; flex: none; }
.topbar__brand img { width: 40px; height: 40px; }

.topsearch { position: relative; display: none; align-items: center; flex: 1; max-width: 280px; }
.topsearch svg { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.topsearch input {
  width: 100%; height: 40px; padding: 0 14px 0 38px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--fs-sm);
}
.topsearch input:focus { outline: 2px solid var(--leaf); outline-offset: 1px; }

.toptabs { display: none; height: 100%; }
.toptabs a {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: clamp(72px, 9vw, 112px); height: 100%; color: var(--muted); text-decoration: none;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
.toptabs a:hover { background: var(--surface-2); }
.toptabs a svg { width: 26px; height: 26px; }
.toptabs a[aria-current="page"] { color: var(--leaf); border-bottom-color: var(--leaf); }
.toptabs a[aria-current="page"] svg { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--leaf) 55%, transparent)); }
.toptabs .nav-badge { top: 8px; right: calc(50% - 24px); }

/* account menu (no JS: <details>) */
.menu { position: relative; }
.menu__trigger { list-style: none; cursor: pointer; display: flex; border-radius: 50%; }
.menu__trigger::-webkit-details-marker { display: none; }
.menu__trigger:focus-visible { outline: 2px solid var(--leaf); outline-offset: 3px; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 300px; padding: var(--s2);
  display: flex; flex-direction: column; gap: 2px; z-index: 40; box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.menu__panel a, .menu__panel button {
  display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 10px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; text-align: left;
}
.menu__panel a:hover, .menu__panel button:hover { background: var(--surface-2); }
.menu__panel svg { width: 20px; height: 20px; color: var(--muted); }
.menu__me { border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0 !important; margin-bottom: 4px; padding-bottom: 12px !important; }
.menu__me > span:last-child { display: flex; flex-direction: column; }
.menu__me .muted { font-size: var(--fs-xs); font-weight: 400; }

/* ---------------------------------------------------------------- frame */
.frame {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5);
  width: 100%; min-height: calc(100vh - var(--topbar-h));
  padding: var(--s4) max(12px, env(safe-area-inset-right, 0px)) calc(84px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}
.frame__left, .frame__right { display: none; }
.frame__main { min-width: 0; width: 100%; max-width: 680px; margin: 0 auto; }
.app--wide .frame__main { max-width: none; }

.frame__left, .frame__right {
  position: sticky; top: calc(var(--topbar-h) + var(--s4)); align-self: start;
  max-height: calc(100vh - var(--topbar-h) - var(--s5)); overflow-y: auto; scrollbar-width: thin;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: 6px 10px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.side-nav a:hover { background: var(--surface-2); }
.side-nav a[aria-current="page"] { background: var(--surface-2); color: var(--leaf); }
.side-nav__icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--leaf); }
.side-nav a:nth-child(3n+2) .side-nav__icon { color: var(--gold); }
.side-nav a:nth-child(3n) .side-nav__icon { color: var(--blue); }
.side-nav__icon svg { width: 20px; height: 20px; }
.side-nav__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav .nav-badge { position: static; margin-left: auto; }
.side-nav--compact a { min-height: 44px; }
.side-title { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: var(--s4) 10px var(--s2); padding-top: var(--s3); border-top: 1px solid var(--border); }
.side-foot { margin: var(--s4) 10px; font-size: var(--fs-xs); color: var(--muted); }
.side-foot a { color: var(--muted); }
.comm-dot { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; font-family: var(--font-display); font-weight: 700; color: var(--on-accent); background: linear-gradient(135deg, var(--gold), var(--bark)); }

/* ---------------------------------------------------------------- family panel (right) */
.panel__block { padding: 0 0 var(--s3); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s2); }
.panel__block:last-child { border-bottom: 0; }
.panel__title { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--muted); font-weight: 600; letter-spacing: .02em; margin: 0; }
.panel__title svg { width: 18px; height: 18px; color: var(--gold); }
.panel__hint { font-size: var(--fs-xs); margin: 0; }
.panel__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.panel__list li { display: flex; align-items: center; gap: var(--s2); }
.panel__list li > a:first-child { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s3); padding: 6px 8px; border-radius: 10px; color: var(--text); text-decoration: none; }
.panel__list li > a:first-child:hover { background: var(--surface-2); }
.panel__list li > a:first-child > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.panel__list strong { font-weight: 600; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel__list .muted { font-size: var(--fs-xs); }
.panel__alert { display: flex; gap: var(--s2); align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--border)); color: var(--text); text-decoration: none; font-size: var(--fs-sm); background: color-mix(in srgb, var(--gold) 8%, transparent); }
.panel__alert svg { width: 20px; height: 20px; color: var(--gold); flex: none; }

/* ---------------------------------------------------------------- bottom nav (phones) */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 56px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500;
}
.bottomnav svg { width: 22px; height: 22px; }
.bottomnav a[aria-current="page"] { color: var(--leaf); }
.bottomnav a[aria-current="page"] svg { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--leaf) 60%, transparent)); }

.nav-badge { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--root); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1; }

/* ---------------------------------------------------------------- breakpoints */
@media (min-width: 700px) {
  .topsearch { display: flex; }
  .topbar__search-btn { display: none; }
}
@media (min-width: 900px) {
  .toptabs { display: flex; }
  .bottomnav { display: none; }
  .frame { padding-bottom: var(--s6); grid-template-columns: minmax(0, 1fr) var(--right-w); }
  .frame__right { display: block; }
  .app--wide .frame { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 1200px) {
  .frame { grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w); gap: var(--s6); }
  .frame__left { display: block; }
  .app--wide .frame { grid-template-columns: var(--left-w) minmax(0, 1fr); }
}
@media (max-width: 699px) {
  .topbar { grid-template-columns: auto 1fr; }
  .toptabs { display: none; }
}
.side-foot { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); }
.menu__panel .langs a { width: auto; display: inline-flex; padding: 6px 11px; gap: 6px; font-size: var(--fs-xs); }
.menu__panel .langs a[aria-current="true"]:hover { background: var(--leaf); }
