.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 18px);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 80;
  height: calc(var(--header-height) + env(safe-area-inset-top));
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,.11);
  background: linear-gradient(180deg, rgba(10,13,18,.97), rgba(10,13,18,.88));
  backdrop-filter: blur(20px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand__wordmark { color: #fff; font-size: 1rem; font-weight: 600; letter-spacing: .012em; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; color: var(--gold); background: rgba(255,255,255,.04); cursor: pointer; }
.local-status { min-height: 34px; padding: 6px 10px; display: flex; align-items: center; gap: 7px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; color: #eef2f6; background: rgba(255,255,255,.055); font-size: .69rem; font-weight: 500; }
.local-status__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 4px rgba(98,217,154,.1); }
.local-status[data-status="offline"] { color: #c3c9d1; border-color: var(--line); background: rgba(255,255,255,.035); }
.local-status[data-status="offline"] .local-status__dot { background: #8c96a3; box-shadow: 0 0 0 4px rgba(140,150,163,.1); }
.local-status[data-status="warning"] { color: #ffd38b; border-color: rgba(239,202,109,.28); background: rgba(239,202,109,.07); }
.local-status[data-status="warning"] .local-status__dot { background: var(--gold); box-shadow: 0 0 0 4px rgba(239,202,109,.11); }
.local-status[data-status="synced"] { color: #aaf5f7; border-color: rgba(82,216,223,.26); background: rgba(82,216,223,.065); }
.local-status[data-status="synced"] .local-status__dot { background: var(--cyan); box-shadow: 0 0 0 4px rgba(82,216,223,.11); }

.app-view { width: min(100%, var(--content-max)); min-height: calc(100dvh - var(--header-height) - var(--nav-height)); margin: 0 auto; padding: 24px 16px 34px; outline: 0; }

.bottom-nav {
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
  height: var(--nav-height);
  max-width: 620px;
  margin: 0 auto;
  padding: 7px 7px 5px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(31,37,48,.94), rgba(10,13,18,.98));
  box-shadow: 0 18px 52px rgba(0,0,0,.48), inset 0 1px rgba(255,255,255,.055);
  backdrop-filter: blur(20px);
}

.desktop-nav__label,
.desktop-nav__footer { display: none; }

.bottom-nav__item {
  position: relative;
  min-width: 0;
  height: 61px;
  padding: 6px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 16px;
  color: #cbd1da;
  text-decoration: none;
  font-size: .67rem;
  font-weight: 500;
  transition: color .2s ease, background .2s ease, transform .2s var(--ease);
}

.bottom-nav__item:hover { color: var(--text); }
.bottom-nav__item[aria-current="page"] { color: #fff; background: rgba(255,255,255,.085); }
.nav-icon { width: 23px; height: 23px; display: grid; place-items: center; }
.nav-icon svg { width: 100%; height: 100%; stroke: currentColor; }

.bottom-nav__item--orb { transform: translateY(-10px); gap: 0; color: var(--text-soft); }
.bottom-nav__item--orb:hover { transform: translateY(-12px); }
.bottom-nav__item--orb[aria-current="page"] { color: var(--gold-bright); background: transparent; }

.nova-mark {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(239,202,109,.55);
  border-radius: 50%;
  color: var(--gold-bright);
  background:
    radial-gradient(circle at 67% 30%, rgba(157,98,255,.72), transparent 23%),
    radial-gradient(circle at 35% 70%, rgba(239,202,109,.16), transparent 44%),
    linear-gradient(145deg, #171126, #090d15 65%);
  box-shadow: 0 0 0 5px rgba(157,98,255,.12), 0 12px 28px rgba(0,0,0,.42), 0 0 28px rgba(157,98,255,.25);
}

.nova-mark__letter { position: relative; z-index: 2; transform: translate(-2px, 1px); font-family: Georgia, "Times New Roman", serif; font-size: 2rem; line-height: 1; text-shadow: 0 0 15px rgba(239,202,109,.28); }
.nova-mark__star { position: absolute; z-index: 3; top: 8px; right: 10px; color: #f7eaff; font-size: .88rem; text-shadow: 0 0 9px var(--violet), 0 0 16px var(--violet); }
.nova-mark__orbit { position: absolute; z-index: 1; width: 46px; height: 22px; border: 1.5px solid rgba(239,202,109,.78); border-radius: 50%; transform: rotate(-18deg); }
.nova-mark__orbit::after { content: ""; position: absolute; top: -3px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px rgba(239,202,109,.8); }
.nova-mark--small { width: 40px; height: 40px; box-shadow: 0 0 0 3px rgba(157,98,255,.08), 0 8px 18px rgba(0,0,0,.3); }
.nova-mark--small .nova-mark__letter { font-size: 1.35rem; }
.nova-mark--small .nova-mark__star { top: 5px; right: 7px; font-size: .65rem; }
.nova-mark--small .nova-mark__orbit { width: 31px; height: 15px; }

@media (min-width: 760px) {
  .app-view { padding: 34px 28px 52px; }
  .app-header { padding-left: max(28px, calc((100vw - var(--content-max)) / 2)); padding-right: max(28px, calc((100vw - var(--content-max)) / 2)); }
  .bottom-nav { bottom: 18px; }
}

@media (min-width: 1200px) {
  .app-shell {
    min-height: 100dvh;
    padding-bottom: 0;
    display: grid;
    grid-template-columns: var(--desktop-sidebar) minmax(0, 1fr);
    grid-template-rows: var(--header-height) minmax(calc(100dvh - var(--header-height)), auto);
  }

  .app-header {
    grid-column: 1 / -1;
    grid-row: 1;
    height: var(--header-height);
    padding: 10px 24px;
  }

  .brand__wordmark { font-size: 1.06rem; }
  .header-actions { gap: 11px; }
  .local-status { min-height: 36px; padding-inline: 12px; font-size: .72rem; }

  .app-view {
    grid-column: 2;
    grid-row: 2;
    width: min(100%, var(--desktop-content-max));
    min-height: calc(100dvh - var(--header-height));
    margin: 0 auto;
    padding: 40px clamp(30px, 4vw, 58px) 72px;
  }

  .bottom-nav {
    position: sticky;
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    top: calc(var(--header-height) + 20px);
    left: auto;
    right: auto;
    bottom: auto;
    width: calc(var(--desktop-sidebar) - 28px);
    height: calc(100dvh - var(--header-height) - 40px);
    max-width: none;
    margin: 20px 0 20px 14px;
    padding: 18px 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    border-radius: 25px;
    background:
      radial-gradient(circle at 50% 0%, rgba(157,98,255,.1), transparent 190px),
      linear-gradient(160deg, rgba(30,36,47,.9), rgba(9,12,17,.97));
  }

  .desktop-nav__label {
    display: block;
    padding: 2px 10px 10px;
    color: var(--text-muted);
    font-size: .61rem;
    font-weight: 650;
    letter-spacing: .14em;
    text-transform: uppercase;
  }

  .bottom-nav__item {
    width: 100%;
    min-height: 52px;
    height: auto;
    padding: 9px 12px;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: 14px;
    font-size: .78rem;
    font-weight: 570;
  }

  .bottom-nav__item:hover {
    color: #fff;
    background: rgba(255,255,255,.045);
    transform: translateX(2px);
  }

  .bottom-nav__item[aria-current="page"] {
    border-color: rgba(255,255,255,.1);
    color: #fff;
    background: linear-gradient(100deg, rgba(255,255,255,.105), rgba(255,255,255,.035));
    box-shadow: inset 3px 0 var(--cyan), 0 8px 18px rgba(0,0,0,.14);
  }

  .nav-icon { width: 21px; height: 21px; flex: 0 0 auto; }

  .bottom-nav__item--orb,
  .bottom-nav__item--orb:hover {
    min-height: 62px;
    gap: 10px;
    transform: none;
  }

  .bottom-nav__item--orb:hover { transform: translateX(2px); }
  .bottom-nav__item--orb[aria-current="page"] { color: var(--gold-bright); background: rgba(239,202,109,.055); box-shadow: inset 3px 0 var(--gold), 0 8px 18px rgba(0,0,0,.14); }
  .bottom-nav__item--orb .nova-mark { width: 42px; height: 42px; box-shadow: 0 0 0 3px rgba(157,98,255,.08), 0 8px 20px rgba(0,0,0,.28), 0 0 20px rgba(157,98,255,.18); }
  .bottom-nav__item--orb .nova-mark__letter { font-size: 1.45rem; }
  .bottom-nav__item--orb .nova-mark__star { top: 6px; right: 8px; font-size: .68rem; }
  .bottom-nav__item--orb .nova-mark__orbit { width: 33px; height: 16px; }

  .desktop-nav__footer {
    margin-top: auto;
    padding: 14px 11px 4px;
    display: grid;
    gap: 5px;
    border-top: 1px solid rgba(255,255,255,.075);
    color: var(--text-muted);
  }

  .desktop-nav__footer span { display: flex; align-items: center; gap: 7px; color: #c8f1d7; font-size: .68rem; font-weight: 600; }
  .desktop-nav__footer i { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 4px rgba(98,217,154,.09); }
  .desktop-nav__footer small { font-size: .61rem; line-height: 1.45; }

  .toast-region {
    left: calc(var(--desktop-sidebar) + (100vw - var(--desktop-sidebar)) / 2);
    bottom: 24px;
  }

  .app-dialog { width: min(calc(100vw - 80px), 680px); }
  .app-dialog__surface { padding: 30px; }
}

@media (max-width: 390px) {
  .local-status { min-height: 32px; padding: 5px 8px; font-size: .65rem; }
  .app-view { padding-left: 12px; padding-right: 12px; }
  .bottom-nav { left: 5px; right: 5px; bottom: max(5px, env(safe-area-inset-bottom)); }
  .bottom-nav__item { font-size: .65rem; }
  .nova-mark { width: 53px; height: 53px; }
}

@media (max-width: 330px) {
  .app-header { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .header-actions { gap: 6px; }
  .local-status { width: 32px; padding: 0; justify-content: center; }
  .local-status__label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
}
