.qit-shell {
  position: sticky;
  top: 0;
  z-index: 200;
  width: 100%;
  height: var(--shell-h);
  flex-shrink: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background .25s, border-color .25s;
}

body.qit-has-context { --shell-h: 104px; }

.qit-shell-inner {
  max-width: 1180px;
  margin: 0 auto;
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.qit-shell-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  color: var(--text);
}

.qit-shell-logo img { width: 36px; height: 36px; object-fit: contain; display: block; }
.qit-shell-logo img.logo-dark { display: none; }
[data-theme="dark"] .qit-shell-logo img.logo-light { display: none; }
[data-theme="dark"] .qit-shell-logo img.logo-dark { display: block; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .qit-shell-logo img.logo-light { display: none; }
  html:not([data-theme="light"]) .qit-shell-logo img.logo-dark { display: block; }
}

.qit-shell-word { display: grid; gap: 2px; line-height: 1; }
.qit-shell-word b { font-size: 16px; font-weight: 800; letter-spacing: .04em; }
.qit-shell-word small { color: var(--muted); font-size: 10px; font-weight: 600; }
.qit-shell-right { display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; }
.qit-shell-nav { display: flex; align-items: center; gap: 3px; }

.qit-shell-nav > a,
.qit-tool-menu > summary {
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  transition: background .15s, color .15s;
}

.qit-tool-menu > summary::-webkit-details-marker { display: none; }
.qit-tool-menu > summary::after { content: "⌄"; margin-left: 6px; color: var(--muted); }
.qit-shell-nav > a:hover, .qit-tool-menu > summary:hover, .qit-tool-menu[open] > summary { background: var(--surface-2); color: var(--text); }
.qit-shell-nav > a.active { background: var(--accent-soft); color: var(--accent); }
.qit-tool-menu { position: relative; }

.qit-tool-menu-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(420px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.qit-tool-menu-panel > a { padding: 10px; border-radius: 10px; color: var(--text); display: grid; gap: 3px; }
.qit-tool-menu-panel > a:hover, .qit-tool-menu-panel > a.active { background: var(--accent-soft); color: var(--accent); }
.qit-tool-menu-panel strong { font-size: 13px; }
.qit-tool-menu-panel span { color: var(--muted); font-size: 10px; line-height: 1.35; }
.qit-tool-account { display: flex; gap: 12px; grid-column: 1 / -1; padding: 9px 10px 2px; border-top: 1px solid var(--border); }
.qit-tool-account a { color: var(--text-2); font-size: 11px; font-weight: 700; }

.qit-shell-actions, .qit-auth-slot { display: flex; align-items: center; gap: 6px; min-width: 0; }
.qit-auth-link, .qit-auth-user, .qit-auth-login {
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.qit-auth-login { padding: 0 4px; }
.qit-auth-link { background: var(--accent); color: #fff; }
.qit-auth-link:hover { color: #fff; filter: brightness(.95); }
.qit-auth-link.muted { background: var(--surface-2); color: var(--muted); pointer-events: none; }
.qit-auth-user { border: 1px solid var(--border); background: var(--surface); }
.qit-auth-user:hover, .qit-auth-login:hover { color: var(--accent); }
.qit-auth-avatar { width: 22px; height: 22px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 800; }
.qit-auth-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.qit-auth-logout, .qit-theme-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.qit-auth-logout { font-size: 18px; }
.qit-theme-btn { font-size: 18px; }
.qit-auth-logout:hover { border-color: var(--danger, #dc2626); color: var(--danger, #dc2626); }
.qit-theme-btn:hover { border-color: var(--accent); color: var(--accent); }

.qit-context-bar { height: 40px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 82%, transparent); }
.qit-context-inner { max-width: 1180px; height: 100%; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 18px; }
.qit-breadcrumb { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 11px; }
.qit-breadcrumb a { color: var(--muted); }
.qit-breadcrumb span { color: var(--border-strong); }
.qit-breadcrumb strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qit-context-result { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.qit-context-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success, #16a34a); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success, #16a34a) 15%, transparent); }
.qit-context-return { color: var(--accent); font-size: 11px; font-weight: 750; white-space: nowrap; }

@media (max-width: 900px) {
  .qit-nav-secondary { display: none; }
  .qit-shell-word small { display: none; }
  .qit-auth-name { display: none; }
}

@media (max-width: 640px) {
  body.qit-has-context { --shell-h: 116px; }
  .qit-shell-inner { padding: 0 14px; gap: 8px; }
  .qit-shell-logo img { width: 32px; height: 32px; }
  .qit-shell-word { display: none; }
  .qit-shell-nav > a { padding: 8px 7px; font-size: 12px; }
  .qit-tool-menu > summary { max-width: 104px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  .qit-auth-login, .qit-auth-link { display: none; }
  .qit-theme-btn { width: 32px; height: 32px; }
  .qit-tool-menu-panel { position: fixed; top: 60px; left: 14px; right: 14px; width: auto; }
  .qit-context-bar { height: 52px; }
  .qit-context-inner { padding: 0 14px; gap: 10px; }
  .qit-context-result { display: none; }
  .qit-context-return { margin-left: auto; }
}
