/* SkyMind chrome — header, bottom tab bar, slideout menu.
 * Loads after skymind.css and overrides only these three surfaces.
 * Everything derives from the existing token set; no new palette.
 */

/* ================================================================ header */

.topbar {
  height: var(--top);
  padding: 0 14px 0 20px;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

.top-left { gap: 12px; min-width: 0; }
.top-right { gap: 8px; }

/* Brand appears in the bar only on mobile, where the sidebar is hidden. */
.top-brand { display: none; }

.top-context { display: flex; align-items: center; gap: 8px; }
.top-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar .kbd {
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--panel);
  color: var(--muted);
}

.network-pill {
  gap: 8px;
  padding: 6px 12px 6px 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 11.5px;
  font-weight: 560;
  color: var(--text);
}
.network-dot {
  width: 7px; height: 7px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 16%, transparent);
}

.topbar .icon-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s var(--ease), background .15s var(--ease), transform .12s var(--ease);
}
.topbar .icon-btn:hover { color: var(--text); background: var(--panel2); }
.topbar .icon-btn:active { transform: scale(.94); }
.topbar #themeToggle { display: grid; }
@media (min-width: 761px) { .mobile-menu-btn { display: none; } }

/* ======================================================== bottom tab bar */

@media (max-width: 760px) {

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: stretch;
    height: calc(62px + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: blur(22px) saturate(1.5);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    border-top: 1px solid var(--line);
  }

  .mobile-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s var(--ease);
  }
  .mobile-tab:active .tab-icon { transform: scale(.9); }

  .tab-icon {
    width: 40px; height: 28px;
    display: grid; place-items: center;
    border-radius: 10px;
    transition: transform .14s var(--ease), background .18s var(--ease);
  }
  .tab-label { font-size: 10px; font-weight: 580; letter-spacing: .01em; }

  /* Active state: soft pill behind the icon rather than a bare color swap. */
  .mobile-tab.active { color: var(--brand); }
  .mobile-tab.active .tab-icon { background: var(--brandSoft); }

  /* Center action: the SkyMind mark itself, lifted out of the bar. */
  .mobile-tab-center { color: var(--text); }
  .mobile-tab-center .center-orb {
    width: 50px; height: 50px;
    margin-top: -24px;
    border-radius: 17px;
    background: var(--panel);
    border: 1px solid var(--line);
    display: grid; place-items: center;
    box-shadow: 0 10px 26px rgba(105, 88, 232, .28), 0 2px 6px rgba(31, 35, 48, .1);
    overflow: hidden;
    transition: transform .16s var(--ease), box-shadow .16s var(--ease);
  }
  .mobile-tab-center:active .center-orb {
    transform: scale(.92);
    box-shadow: 0 5px 14px rgba(105, 88, 232, .24);
  }
  .orb-logo { width: 100%; height: 100%; object-fit: cover; }

  /* Partner link: full-bleed logo, no tint — the mark is the identity. */
  .tab-logo { width: 24px; height: 24px; border-radius: 8px; object-fit: cover; }

  /* Logo fallbacks render only if the image file is absent (see js handler). */
  .logo-slot { position: relative; }
  .logo-slot .logo-fallback { display: none; }
  .logo-slot.logo-missing img { display: none; }
  .logo-slot.logo-missing .logo-fallback {
    display: grid; place-items: center;
    width: 24px; height: 24px;
    border-radius: 8px;
    background: var(--brandSoft);
    color: var(--brand);
    font-weight: 750; font-size: 12px;
  }
  .center-orb.logo-missing .logo-fallback {
    width: 100%; height: 100%;
    border-radius: 0;
    background: var(--brand);
    color: #fff;
    font-size: 22px;
  }

  /* Header on mobile: brand mark replaces the hidden sidebar's identity. */
  .topbar { height: 58px; padding: 0 10px; }
  .top-brand {
    display: flex; align-items: center; gap: 8px;
    color: var(--text);
    font-size: 15px; font-weight: 720; letter-spacing: -.03em;
    text-decoration: none;
    min-width: 0;
  }
  .top-brand-logo { width: 27px; height: 27px; border-radius: 9px; object-fit: cover; }
  .top-context { display: none; }
  .followup { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

@media (min-width: 761px) {
  .mobile-tabs, .sidebar-scrim, .sidebar-close { display: none; }
}

/* ============================================================== slideout */

@media (max-width: 760px) {

  .sidebar-scrim {
    position: fixed; inset: 0;
    z-index: 95;
    background: color-mix(in srgb, var(--text) 34%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .26s var(--ease);
  }
  .app.mobile-sidebar .sidebar-scrim { opacity: 1; pointer-events: auto; }

  .sidebar {
    width: min(86vw, 332px);
    border-right: 0;
    border-radius: 0 22px 22px 0;
    box-shadow: 0 24px 80px rgba(15, 17, 26, .35);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateX(-105%);
    transition: transform .3s var(--ease);
    z-index: 100;
  }
  .app.mobile-sidebar .sidebar { transform: none; }

  .sidebar .brand { height: 62px; padding-right: 54px; }

  .sidebar-close {
    position: absolute;
    top: calc(11px + env(safe-area-inset-top));
    right: 11px;
    width: 38px; height: 38px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--panel);
    display: grid; place-items: center;
    color: var(--muted);
    cursor: pointer;
    z-index: 2;
  }

  /* Touch targets: every nav row reaches 48px. */
  .new-search { margin: 14px 16px 10px; padding: 13px 15px; border-radius: 14px; }
  .side-nav { padding: 4px 16px; gap: 3px; }
  .side-btn { padding: 13px 12px; border-radius: 12px; }
  .nav-label { font-size: 14px; }
  .history-wrap { padding: 6px 16px 10px; }
  .history-item { padding: 11px 32px 11px 11px; font-size: 13px; }
  .side-account { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
}

@media (min-width: 761px) {
  .sidebar-close { display: none; }
}

/* Network link above the account row — rendered at every width. */
.side-network {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 14px 4px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel2);
  color: var(--text);
  text-decoration: none;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.side-network:hover { border-color: color-mix(in srgb, var(--brand) 42%, var(--line)); background: var(--panel); }
.side-network .icon { color: var(--muted); margin-left: auto; flex: 0 0 auto; }
.side-network-logo { width: 30px; height: 30px; border-radius: 10px; object-fit: cover; display: block; }
.side-network .logo-fallback { width: 30px; height: 30px; border-radius: 10px; font-size: 14px; }
.side-network-copy { display: flex; flex-direction: column; min-width: 0; }
.side-network-copy strong { font-size: 13px; font-weight: 660; letter-spacing: -.01em; }
.side-network-copy small { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.side-network .logo-slot { position: relative; }
.side-network .logo-slot .logo-fallback { display: none; }
.side-network .logo-slot.logo-missing img { display: none; }
.side-network .logo-slot.logo-missing .logo-fallback {
  display: grid; place-items: center;
  background: var(--brandSoft); color: var(--brand); font-weight: 750;
}
.sidebar-collapsed .side-network { justify-content: center; padding: 10px; }
.sidebar-collapsed .side-network-copy,
.sidebar-collapsed .side-network > .icon { display: none; }

@media (max-width: 760px) {
  .side-network { margin: 0 16px 6px; padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-scrim, .tab-icon, .center-orb { transition: none; }
}

/* ==================================================== verification notes */
/* Collapsed by default; a one-line summary until the reader asks for more. */

.verify-notes {
  margin-top: 12px;
  max-width: var(--measure);
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  overflow: hidden;
}
.verify-notes summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 580;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.verify-notes summary::-webkit-details-marker { display: none; }
.verify-notes summary::after {
  content: '';
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  transition: transform .18s var(--ease);
}
.verify-notes[open] summary::after { transform: rotate(-135deg); }
.verify-notes summary:hover { color: var(--text); background: var(--panel2); }
.verify-notes .icon { color: var(--amber); flex: 0 0 auto; }
.verify-count {
  min-width: 17px; height: 17px;
  padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.verify-notes ul {
  margin: 0;
  padding: 4px 14px 12px 32px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
.verify-notes li + li { margin-top: 5px; }

/* Two-letter monograms fit the fallback tile. */
.logo-slot.logo-missing .logo-fallback { font-size: 10.5px; letter-spacing: .02em; }

/* ===================================================== themed tab logos */
/* Each partner slot carries a light and a dark image; the app's own
   data-theme attribute picks one, so the manual theme toggle is honored
   (prefers-color-scheme media queries would ignore it). */

[data-theme='light'] .logo-dark { display: none; }
[data-theme='dark'] .logo-light { display: none; }

/* Dark variant of the Nerddi glasses mark, derived at render time from the
   hosted light file: luminance flips, hue survives. Replace with the real
   nerddi_glasses_logo_dark.png (tools/make-dark-logo.html generates it) by
   swapping the src and removing this class. */
.logo-derived-dark { filter: invert(1) hue-rotate(180deg); }

/* ====================================================== bigger tab tiles */
/* contain, not cover: wide marks like the glasses logo must never crop. */

@media (max-width: 760px) {
  .mobile-tabs { height: calc(66px + env(safe-area-inset-bottom)); }
  .tab-icon { width: 46px; height: 34px; border-radius: 11px; }
  .tab-logo { width: 32px; height: 32px; border-radius: 9px; object-fit: contain; }
  .mobile-tab-center .center-orb { width: 56px; height: 56px; margin-top: -26px; border-radius: 19px; }
  .logo-slot.logo-missing .logo-fallback { width: 32px; height: 32px; }
  .followup { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
}

/* ================================================= conversation history */

.history-head { padding: 10px 8px 8px; }

.history-bucket {
  padding: 12px 10px 5px;
  font-size: 10px;
  font-weight: 720;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.history-bucket:first-child { padding-top: 4px; }

.history-list { gap: 3px; padding-right: 2px; }

.history-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 34px 9px 11px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  white-space: normal;
  overflow: visible;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.history-item:hover { background: var(--panel2); color: inherit; }
.history-item.active {
  background: var(--panel2);
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
}
.history-item.active::before {
  content: '';
  position: absolute;
  left: -1px; top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand);
}

.history-q {
  font-size: 12.5px;
  font-weight: 540;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-item:not(:hover):not(.active) .history-q { color: var(--muted); }

.history-meta {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: .01em;
}

.history-delete {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--muted);
  opacity: 0;
  transition: opacity .14s var(--ease), background .14s var(--ease), color .14s var(--ease);
}
.history-item:hover .history-delete,
.history-item:focus-within .history-delete { opacity: 1; }
.history-delete:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }

/* Touch devices have no hover: keep delete faintly present. */
@media (hover: none) {
  .history-delete { opacity: .45; }
}

.history-empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  border: 1px dashed var(--line);
  border-radius: 13px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.history-empty strong { color: var(--text); font-size: 12.5px; }

@media (max-width: 760px) {
  .history-item { padding: 11px 38px 11px 12px; }
  .history-q { font-size: 13.5px; }
  .history-meta { font-size: 11px; }
  .history-delete { width: 32px; height: 32px; }
}
