:host {
  /* Sticky must sit on the host, not on .bar: a sticky child cannot leave
     the host's box, which is exactly the height of the bar. */
  position: sticky;
  top: 0;
  z-index: 40;
  display: block;
  font: inherit;
  color: var(--text, #e8eef8);
  --lh-bg: var(--header-bg, rgba(11, 19, 34, 0.92));
  --lh-text: var(--text, #e8eef8);
  --lh-muted: var(--muted, #93a3bb);
  --lh-border: var(--border, #22314a);
  --lh-panel: var(--panel, #111a2b);
  --lh-chip: var(--chip, #17243b);
  --lh-accent: var(--accent, #e07a3f);
  --lh-accent-strong: var(--accent-strong, #f0a274);
  --lh-radius: var(--radius, 16px);
  --lh-shadow: 0 18px 48px rgba(4, 10, 22, 0.28);
}

* { box-sizing: border-box; }

.bar {
  position: relative;
  z-index: 40;
  background: var(--lh-bg);
  border-bottom: 1px solid var(--lh-border);
  backdrop-filter: blur(12px);
}

.inner {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  width: 100%;
  max-width: 1180px;
  min-height: 54px;
  margin: 0 auto;
  padding: 7px 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--lh-text);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--lh-accent-strong), var(--lh-accent));
  color: #200f07;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.brand-mark svg { width: 17px; height: 17px; display: block; }
.brand-name { line-height: 1; }

::slotted(nav) {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
::slotted(nav)::-webkit-scrollbar { display: none; }

.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}
slot[name="tools"] { display: contents; }

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--lh-border);
  border-radius: 50%;
  background: transparent;
  color: var(--lh-text);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}
.icon-button:hover {
  background: var(--lh-chip);
  border-color: color-mix(in srgb, var(--lh-muted) 60%, transparent);
}
.icon-button:active { transform: scale(0.96); }
.icon-button:focus-visible {
  outline: 2px solid var(--lh-accent);
  outline-offset: 2px;
}

.grid-icon {
  display: grid;
  grid-template-columns: repeat(3, 3px);
  grid-template-rows: repeat(3, 3px);
  gap: 3px;
}
.grid-icon i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

.theme-icon.sun { display: none; }
:host([data-theme="light"]) .theme-icon.moon { display: none; }
:host([data-theme="light"]) .theme-icon.sun { display: inline; }
:host(:not(:defined)) { display: none; }

.bell svg { width: 18px; height: 18px; }
.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--lh-accent);
  color: #200f07;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--lh-bg);
}

.notify { position: relative; }
.notify-menu {
  position: absolute;
  top: 42px;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 24px));
  max-height: min(460px, calc(100vh - 80px));
  padding: 7px;
  border: 1px solid var(--lh-border);
  border-radius: var(--lh-radius);
  background: var(--lh-panel);
  box-shadow: var(--lh-shadow);
  z-index: 50;
}
.notify-menu[hidden] { display: none; }
.notify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 9px;
  border-bottom: 1px solid var(--lh-border);
  margin-bottom: 4px;
}
.notify-title {
  color: var(--lh-text);
  font-size: 13px;
  font-weight: 700;
}
.notify-all {
  color: var(--lh-accent-strong);
  font-size: 12px;
  text-decoration: none;
}
.notify-all:hover { text-decoration: underline; }
.notify-all[hidden] { display: none; }
.notify-body {
  display: grid;
  gap: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.notify-item {
  display: grid;
  gap: 2px;
  padding: 8px 9px;
  border-radius: 10px;
  color: var(--lh-text);
  text-decoration: none;
}
.notify-item:hover { background: var(--lh-chip); text-decoration: none; }
.notify-item.is-unread { background: color-mix(in srgb, var(--lh-accent) 9%, transparent); }
.notify-item.is-unread:hover { background: color-mix(in srgb, var(--lh-accent) 15%, transparent); }
.notify-item-title {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
}
.notify-item-body {
  overflow: hidden;
  color: var(--lh-muted);
  font-size: 11.5px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.notify-item-time {
  color: var(--lh-muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.notify-empty {
  margin: 0;
  padding: 14px 9px;
  color: var(--lh-muted);
  font-size: 12.5px;
  text-align: center;
}
.notify-footer {
  margin-top: 4px;
  padding: 9px;
  border-top: 1px solid var(--lh-border);
  color: var(--lh-accent-strong);
  font-size: 12px;
  text-align: center;
  text-decoration: none;
}
.notify-footer:hover { text-decoration: underline; }
.notify-footer[hidden] { display: none; }

.launcher {
  position: absolute;
  top: 50px;
  right: 18px;
  display: grid;
  gap: 3px;
  width: min(320px, calc(100vw - 24px));
  padding: 7px;
  border: 1px solid var(--lh-border);
  border-radius: var(--lh-radius);
  background: var(--lh-panel);
  box-shadow: var(--lh-shadow);
  z-index: 50;
}
.launcher[hidden] { display: none; }
.launcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 11px;
  color: var(--lh-text);
  text-decoration: none;
}
.launcher-item:hover { background: var(--lh-chip); }
.launcher-item.is-current { background: var(--lh-chip); }
.launcher-item.is-current .launcher-name { color: var(--lh-accent-strong); }
.launcher-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--lh-chip);
  color: var(--lh-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}
.launcher-mark[data-service="hub"] { color: #cfe0ff; background: #243a63; }
.launcher-mark[data-service="id"] { color: #d8e0ff; background: #2c3f86; }
.launcher-mark[data-service="my"] { color: #ffd9c2; background: #6a3a22; }
.launcher-mark[data-service="news"] { color: #c9f1dd; background: #1f4a3a; }
.launcher-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}
.launcher-name { font-size: 13.5px; font-weight: 650; line-height: 1.25; }
.launcher-note {
  overflow: hidden;
  color: var(--lh-muted);
  font-size: 11.5px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.launcher-arrow {
  flex: 0 0 auto;
  color: var(--lh-muted);
  font-size: 13px;
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.launcher-item:hover .launcher-arrow,
.launcher-item:focus-visible .launcher-arrow {
  opacity: 1;
  transform: translateX(0);
}

.account { position: relative; }
.account[hidden] { display: none; }
.account-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--lh-border);
  border-radius: 50%;
  background: var(--lh-chip);
  cursor: pointer;
  transition: transform 120ms ease;
}
.account-button:hover { border-color: var(--lh-accent); }
.account-button:active { transform: scale(0.96); }
.account-button:focus-visible {
  outline: 2px solid var(--lh-accent);
  outline-offset: 2px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--lh-accent-strong), var(--lh-accent));
  color: #200f07;
  font-size: 13px;
  font-weight: 800;
}
.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-image[hidden] { display: none; }
.avatar-fallback[hidden] { display: none; }

.account-menu {
  position: absolute;
  top: 42px;
  right: 0;
  display: grid;
  gap: 2px;
  width: 224px;
  padding: 7px;
  border: 1px solid var(--lh-border);
  border-radius: 14px;
  background: var(--lh-panel);
  box-shadow: var(--lh-shadow);
  z-index: 50;
}
.account-menu[hidden] { display: none; }
.account-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 9px 9px;
  border-bottom: 1px solid var(--lh-border);
  margin-bottom: 3px;
}
.account-name {
  overflow: hidden;
  color: var(--lh-text);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-caption {
  color: var(--lh-muted);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--lh-text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover { background: var(--lh-chip); }
.menu-item:focus-visible {
  outline: 2px solid var(--lh-accent);
  outline-offset: -2px;
}
.logout { color: var(--lh-muted); }
.logout:hover { color: var(--lh-accent-strong); }
.logout[hidden] { display: none; }
.logout-form { display: contents; }
.logout-form[hidden] { display: none; }

.login {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--lh-accent);
  color: #200f07;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.login:hover { background: var(--lh-accent-strong); }
.login[hidden] { display: none; }

@media (max-width: 900px) {
  .inner { flex-wrap: wrap; gap: 6px 10px; padding: 7px 14px; }
  ::slotted(nav) {
    order: 3;
    flex-basis: 100%;
    width: 100%;
    margin-left: 0;
  }
  .launcher { right: 12px; }
  .launcher-note { white-space: normal; }
}
@media (max-width: 520px) {
  .brand-name { display: none; }
  .actions { gap: 5px; }
  .account-menu { width: 210px; }
}
