/* Shared current application tokens, controls, and stationary navigation. */
:root:has(> body > .app:is(.compare-active, .search-active, .settings-active)) > body {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  height: 100dvh !important;
  overflow: hidden !important;
  display: block !important;
}

@scope (.app:is(.compare-active, .search-active, .settings-active)) {
  :scope {
    --ui-bg: #08120f;
    --ui-panel: #0e1b16;
    --ui-raised: #16261e;
    --ui-line: #26392f;
    --ui-text: #e9f0ec;
    --ui-muted: #b5c4bb;
    --ui-accent: var(--accent, #2ecb79);
    --ui-accent-text: color-mix(in srgb, var(--ui-accent) 76%, #ffffff);
    --ui-selected: color-mix(in srgb, var(--ui-accent) 14%, var(--ui-panel));
    --ui-radius: 6px;
    --ui-data: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: 56px 48px minmax(0, 1fr);
    width: 100%;
    height: 100dvh;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--ui-text);
    background: var(--ui-bg);
    box-shadow: none;
    font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
    text-transform: none;
    color-scheme: dark;
    overflow: hidden;
  }
  *, *::before, *::after { box-sizing: border-box; }
  [hidden] { display: none !important; }
  button, input, select, textarea, summary { font: inherit; color: inherit; letter-spacing: inherit; }
  button, input, select, textarea { border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-panel); }
  button, select, input:not([type="range"]) { min-height: 32px; }
  button { padding: 6px 10px; cursor: pointer; font-weight: 500; white-space: nowrap; }
  button, summary, select { transition: background 140ms ease, color 140ms ease, border-color 140ms ease; }
  button:hover, summary:hover { background: var(--ui-raised); }
  button:disabled { opacity: .45; cursor: default; }
  :is(button, input, select, textarea, summary):focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
  input, select, textarea { min-width: 0; width: 100%; padding: 6px 8px; }
  input::placeholder, textarea::placeholder { color: var(--ui-muted); opacity: .8; }
  textarea { min-height: 80px; resize: vertical; }
  label { display: grid; gap: 4px; color: var(--ui-muted); font-size: 12px; }
  strong { font-weight: 600; }
  svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
  p { margin: 0; }
  a { color: var(--ui-accent); }
  summary { display: flex; align-items: center; gap: 8px; padding: 10px 12px; list-style: none; cursor: pointer; font-weight: 600; }
  summary::-webkit-details-marker { display: none; }
  summary::after { content: ""; width: 6px; height: 6px; margin-left: auto; border: solid var(--ui-muted); border-width: 0 1px 1px 0; transform: rotate(-45deg); }
  details[open] > summary::after { transform: rotate(45deg); }

  /* Two quiet bars establish global navigation and project context. */
  .topbar { display: grid; grid-template-columns: 200px 1fr minmax(300px, 460px); align-items: center; gap: 24px; padding: 0 20px; border-bottom: 1px solid var(--ui-line); background: var(--ui-panel); z-index: 30; }
  .brand-strip { display: flex; align-items: center; gap: 10px; }
  .brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--ui-accent); color: #06140c; font-size: 12px; font-weight: 750; }
  .brand-copy strong { font-family: "Avenir Next", -apple-system, sans-serif; font-size: 19px; letter-spacing: -.6px; }
  .brand-copy > span { display: none; }
  .primary-nav { grid-column: 2; grid-row: 1; display: flex; align-self: stretch; gap: 24px; }
  .primary-nav-button { position: relative; min-width: 0; padding: 0 2px; border: 0; border-radius: 0; background: transparent; color: var(--ui-muted); }
  .primary-nav-button:hover { background: transparent; color: var(--ui-text); }
  .primary-nav-button.active { color: var(--ui-text); }
  .primary-nav-button.active::after { content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--ui-accent); }
  .search-row { grid-column: 3; grid-row: 1; display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; }
  .project-search { position: relative; flex: 1; max-width: 340px; min-width: 120px; }
  #projectSearch { height: 32px; padding-left: 32px; background: var(--ui-bg); border-color: var(--ui-line); font-size: 12px; }
  .project-search-icon { position: absolute; left: 10px; top: 8px; width: 16px; height: 16px; color: var(--ui-muted); pointer-events: none; }
  .project-search-icon svg { width: 16px; height: 16px; }
  .search-filter { display: none; }
  .settings-button { display: grid; place-items: center; flex: none; width: 32px; padding: 0; border-color: transparent; background: transparent; color: var(--ui-muted); }
  .user-avatar { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border: 1px solid var(--ui-line); border-radius: 50%; background: var(--ui-raised); color: var(--ui-accent); font-size: 11px; font-weight: 600; }
  .search-suggestions { position: absolute; top: calc(100% + 6px); right: 0; min-width: 280px; max-height: 50dvh; overflow: auto; padding: 6px; border: 1px solid var(--ui-line); border-radius: 8px; background: var(--ui-panel); box-shadow: 0 12px 32px #0006; }
  .search-suggestions:empty { display: none; }
  .search-suggestions button { width: 100%; text-align: left; }
  .account-notice { margin: 16px 0; padding: 12px 14px; max-width: 1100px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-panel); color: var(--ui-muted); font-size: 12px; line-height: 1.6; }

  @media (max-width: 1250px) {
    .topbar { grid-template-columns: 176px 1fr minmax(240px, 360px); gap: 16px; padding: 0 16px; }
  }
  @media (max-width: 700px) {
    .topbar { grid-template-columns: 1fr auto; grid-template-rows: 44px 40px; gap: 0 12px; padding: 0 12px 8px; }
    .brand-strip { gap: 8px; }
    .brand-copy strong { font-size: 17px; }
    .brand-mark { width: 28px; height: 28px; }
    .primary-nav { gap: 16px; font-size: 12px; }
    .search-row { grid-column: 1 / -1; grid-row: 2; display: flex; }
    .project-search { max-width: none; }
  }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none; } }
}
