/* One header row: brand · pages · two clocks · account. Phones move the pages to a bottom tab bar.
   Structural rules use :root[data-theme] so they hold over each theme's older header layout;
   colours, borders and type stay with the themes. */
:root[data-theme] .site-header {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  height: auto;
  min-height: 0;
}
:root[data-theme] .site-header .brand {
  flex: none;
}
:root[data-theme] .site-header .feature-navigation {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  min-width: 0;
  margin: 0;
}
:root[data-theme] .site-header .feature-navigation[hidden] {
  display: none;
}
:root[data-theme] .site-header .timezones {
  order: 0;
  width: auto;
  margin-left: auto;
  flex-wrap: nowrap;
}
:root[data-theme] .site-header:has(#account-menu:not([hidden])) .about-button {
  display: none;
}
.nav-icon {
  display: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.account-menu {
  position: relative;
  flex: none;
}
.account-menu[hidden],
.account-menu-panel[hidden],
.account-avatar-dot[hidden] {
  display: none;
}
.account-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--text-on-accent);
  font: 400 16px/1 var(--font-heading, serif);
  cursor: pointer;
}
.account-avatar-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface-page);
  border-radius: 50%;
  background: var(--danger);
  font-size: 0;
}
.account-menu-panel {
  position: absolute;
  z-index: 45;
  top: calc(100% + 10px);
  right: 0;
  width: min(272px, calc(100vw - 32px));
  padding: 6px 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 10px);
  background: var(--surface-card);
  color: var(--text-primary);
  box-shadow: 0 12px 32px rgb(0 0 0 / 14%);
}
.account-menu-head {
  margin: 0;
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.account-menu-head strong {
  display: block;
  font: 400 16px/1.5 var(--font-heading, serif);
}
.account-menu-head small,
.account-menu-panel > button small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}
.account-menu-head small {
  display: block;
}
.account-menu-panel > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: 14px/1.5 var(--font-body, inherit);
  text-align: left;
  cursor: pointer;
}
.account-menu-panel > button:last-child {
  border-top: 1px solid var(--border-subtle);
}
.account-menu-panel > button:is(:hover, :focus-visible),
.account-menu-panel > button[aria-current='page'] {
  background: var(--surface-inset, rgb(0 0 0 / 5%));
}
.account-menu-panel > button:focus-visible,
.account-avatar:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
@media (max-width: 1099px) {
  :root[data-theme] .site-header :is(.brand small, #time-gap) {
    display: none;
  }
}
@media (max-width: 720px) {
  :root[data-theme] .site-header {
    gap: 10px;
    padding-block: 10px;
  }
  :root[data-theme] .site-header .brand {
    gap: 8px;
    font-size: 22px;
    letter-spacing: 2px;
    line-height: 1;
  }
  :root[data-theme] .site-header .brand-mark {
    transform: scale(0.7);
    margin-inline: -4px;
  }
  :root[data-theme] .site-header :is(.sun-icon, .time-divider) {
    display: none !important;
  }
  /* Both clocks fold into one pill so the brand and the account still share the row. */
  :root[data-theme] .site-header .timezones {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 5px 11px;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: var(--surface-card);
    font-size: 11px;
  }
  :root[data-theme] .site-header .timezones > span {
    flex-direction: row;
    gap: 4px;
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    color: var(--text-secondary);
  }
  :root[data-theme] .site-header .timezones b {
    font: 500 13px/1 var(--font-body, inherit);
    letter-spacing: 0;
    color: var(--text-primary);
  }
  :root[data-theme] .site-header .account-avatar {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }
  :root[data-theme] .site-header .feature-navigation {
    position: fixed;
    z-index: 35;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--border-subtle);
    border-radius: 0;
    background: var(--surface-page);
    box-shadow: 0 -6px 18px rgb(0 0 0 / 6%);
    overflow: visible;
  }
  :root[data-theme] .site-header .feature-navigation button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    margin: 0;
    padding: 4px 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    color: var(--text-secondary);
    font: 11px/1.3 var(--font-body, inherit);
    letter-spacing: 0;
  }
  :root[data-theme] .site-header .feature-navigation button::before {
    content: none;
  }
  :root[data-theme]
    .site-header
    .feature-navigation
    button:is([aria-pressed='true'], [aria-current='page'])::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 32%;
    right: 32%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
  }
  :root[data-theme]
    .site-header
    .feature-navigation
    button:is([aria-pressed='true'], [aria-current='page']) {
    color: var(--accent-primary);
    background: none;
  }
  :root[data-theme] .site-header .nav-icon {
    display: block;
  }
  :root[data-theme] .site-header .feature-navigation .feature-unread-dot {
    position: absolute;
    top: 6px;
    left: calc(50% + 7px);
    margin: 0;
  }
  :root.is-typing[data-theme] .site-header .feature-navigation {
    display: none;
  }
  #library-view:has(#feature-navigation:not([hidden])) {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }
  body:has(#library-view:not([hidden]) #feature-navigation:not([hidden]))
    :is(.voice-capsule, .toast) {
    bottom: calc(72px + env(safe-area-inset-bottom));
  }
}
