/* The app header, one component for the whole product: the portal top bar (base_app.html), the tool bar
   (shared/_tool_bar.html) and the controls they share (theme icon button, tool switcher, account menu; markup in
   shared/_header_parts.html). Only tokens, so it follows the Light/Dark/Auto choice. Linked by the portal base and
   by every hosted tool next to tool-shell.css. */
:root { --header-h: 56px; }

.app-bar { position: sticky; top: 0; z-index: 15; height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); font-size: 14px; }
.hd-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }

.hd-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; }
.hd-btn:hover { background: var(--hover); }
.hd-btn svg { width: 18px; height: 18px; }
.hd-btn:focus-visible, .hd-pop > summary:focus-visible, .hd-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Theme: one icon button, the icon shows the current choice (theme.js sets data-mode) */
.theme-switch .ti { display: none; }
.theme-switch .ti-auto { display: block; }
.theme-switch[data-mode="light"] .ti-auto, .theme-switch[data-mode="dark"] .ti-auto { display: none; }
.theme-switch[data-mode="light"] .ti-light, .theme-switch[data-mode="dark"] .ti-dark { display: block; }

/* Pop-overs (tool switcher, account): <details class="hd-pop">, closed by outside click and Esc (app.js, tool-side.js) */
.hd-pop { position: relative; }
.hd-pop > summary { list-style: none; cursor: pointer; }
.hd-pop > summary::-webkit-details-marker { display: none; }
.hd-pop[open] > summary { background: var(--hover); }
.hd-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 230px; max-width: calc(100vw - 24px); padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); display: grid; gap: 2px; }
.hd-panel form { margin: 0; }
.hd-item { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 40px; padding: .5rem .7rem; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.hd-item:hover { background: var(--hover); text-decoration: none; }
.hd-item.current { background: var(--brand-soft); color: var(--ink); font-weight: 700; }
.hd-item.danger { color: var(--bad); }
.hd-item.danger:hover { background: var(--bad-soft); }
.hd-sep { height: 1px; margin: 4px 2px; background: var(--line); }
.hd-label { padding: 8px 10px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.hd-switch > summary { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font-weight: 600; white-space: nowrap; }
.hd-switch > summary:hover { background: var(--hover); }
.hd-switch svg, .acct-sum svg { width: 16px; height: 16px; flex: none; }

.acct-sum { display: inline-flex; align-items: center; gap: 2px; height: 36px; padding: 0 6px 0 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted); }
.acct-sum:hover { background: var(--hover); }
.hd-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--ink); font-size: 13px; font-weight: 700; display: grid; place-items: center; flex: none; }
.acct-who { padding: 8px 10px 6px; display: grid; gap: 1px; min-width: 0; }
.acct-who strong, .acct-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-who strong { color: var(--ink); font-size: 14px; }
.acct-who span { color: var(--muted); font-size: 12.5px; }

@media (max-width: 860px) {
  .app-bar { padding: 0 12px; gap: 8px; }
  .hd-btn, .hd-switch > summary, .acct-sum { height: 40px; }
  .hd-btn { width: 40px; }
}
/* Phones: the pop-overs span the bar's width instead of hanging from their button (a 230px panel anchored to the
   tool switcher ran off the left edge on 320-350px screens); the bar's controls sit closer so the title keeps room. */
@media (max-width: 640px) {
  .app-bar { gap: 6px; }
  .hd-right { gap: 4px; }
  .hd-pop { position: static; }
  .hd-panel { left: 12px; right: 12px; min-width: 0; max-width: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .hd-btn, .hd-item, .hd-switch > summary, .acct-sum { transition: background var(--ease); }
}
