/* Global chrome: topbar, account menu, and mobile navigation. */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--topbar);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line-soft);
}

.topbar__inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 var(--pad);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  color: var(--txt);
  font-family: var(--f-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.035em;
}

.wordmark__dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--tally);
  box-shadow: 0 0 0 0 var(--tally-soft);
  animation: shell-tally 3.4s ease-out infinite;
}

@keyframes shell-tally {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tally) 55%, transparent); }
  60% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.wordmark__suffix {
  color: var(--txt-faint);
  font-weight: 800;
}

.desktop-nav {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.desktop-nav::-webkit-scrollbar {
  display: none;
}

.desktop-nav__link {
  padding: 7px 12px;
  border-radius: var(--r-sm);
  color: var(--txt-dim);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: color .13s, background .13s;
}

.desktop-nav__link:hover {
  color: var(--txt);
  background: var(--bg-3);
}

.desktop-nav__link.is-active {
  color: var(--txt);
  background: var(--bg-3);
  box-shadow: inset 0 -2px 0 var(--tally);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.topbar__search {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 10px 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--txt-faint);
  font-size: 13.5px;
  transition: border-color .13s, color .13s;
}

.topbar__search:hover {
  border-color: var(--txt-faint);
  color: var(--txt-dim);
}

.topbar__search svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.topbar__search kbd {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--txt-faint);
  font-family: var(--f-mono);
  font-size: 10.5px;
}

.account {
  position: relative;
}

.account__toggle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--txt-dim);
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 600;
  transition: border-color .13s, color .13s;
}

.account__toggle:hover,
.account__toggle[aria-expanded="true"] {
  border-color: var(--txt-faint);
  color: var(--txt);
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  min-width: 246px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-2);
  box-shadow: var(--shadow);
  animation: shell-menu-in .13s ease-out;
}

@keyframes shell-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
}

.account-menu[hidden] {
  display: none;
}

.account-menu__identity {
  margin-bottom: 6px;
  padding: 9px 10px 11px;
  border-bottom: 1px solid var(--line-soft);
}

.account-menu__status,
.account-menu__copy {
  margin: 0;
}

.account-menu__status {
  color: var(--txt);
  font-size: 13.5px;
  font-weight: 600;
}

.account-menu__copy {
  color: var(--txt-faint);
  font-size: 12px;
}

.account-menu__actions {
  display: grid;
  gap: 1px;
}

.account-menu__actions button,
.account-menu__actions a {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--txt-dim);
  font-size: 13.5px;
  text-align: left;
}

.account-menu__actions button:hover:not(:disabled),
.account-menu__actions a:hover {
  background: var(--bg-hover);
  color: var(--txt);
}

.account-menu__actions button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.account-menu__actions svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.account-menu__separator {
  height: 1px;
  margin: 6px 2px;
  background: var(--line-soft);
}

.theme-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
}

.theme-controls > span {
  color: var(--txt-dim);
  font-size: 13.5px;
}

.theme-controls__choices {
  display: flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-2);
}

.theme-controls__choices button {
  padding: 4px 10px;
  border-radius: 4px;
  color: var(--txt-dim);
  font-size: 12px;
}

.theme-controls__choices button:hover,
.theme-controls__choices button[aria-pressed="true"] {
  background: var(--bg-hover);
  color: var(--txt);
}

.mobile-tabbar {
  display: none;
}

@media (max-width: 860px) {
  :root {
    --topbar: 54px;
  }

  .desktop-nav {
    display: none;
  }

  .wordmark {
    flex: 1;
  }

  .mobile-tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 75;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: var(--tabbar-h);
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(14px) saturate(1.4);
    border-top: 1px solid var(--line-soft);
  }

  .mobile-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--txt-faint);
    font-family: var(--f-mono);
    font-size: 9.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
  }

  .mobile-tab__icon {
    display: grid;
    place-items: center;
  }

  .mobile-tab__icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
  }

  .mobile-tab.is-active {
    color: var(--txt);
  }

  .mobile-tab.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 26px;
    height: 2px;
    background: var(--tally);
    transform: translateX(-50%);
  }

  .topbar__search span,
  .topbar__search kbd {
    display: none;
  }

  .topbar__search {
    width: 34px;
    justify-content: center;
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark__dot,
  .account-menu,
  .desktop-nav__link,
  .topbar__search,
  .account__toggle {
    animation: none;
    transition: none;
  }
}
