/* Canonical nav chrome — the CSS half of the one-navigation-bar rule. nav.js owns what
 * the bar CONTAINS; this owns how it looks. Loaded last on every page, so it wins over
 * per-page inline <style> at equal specificity.
 *
 * What it is fixing, measured at 1440px before this file existed:
 *   billing.html  brand 118px wide vs 78px everywhere else — it had `.brand { flex: 0 0 auto }`
 *                 and NO font rule and NO `.brand img` rule, so the wordmark fell back to the
 *                 body face and the mark rendered at its intrinsic size. Links started at
 *                 x=152 instead of x=112: a 40px jump every time you opened Billing.
 *   audio.html    `.nav { padding: 0 12px }` against 10px elsewhere — every link 2px right.
 *
 * 🔴 Geometry the phone pass owns is deliberately NOT touched at mobile widths. index.html
 * varies nav padding under 721px and raises the nav opacity to .97 on phones on purpose;
 * a later stylesheet setting those unconditionally would silently undo that work at equal
 * specificity. Hence the min-width guard on everything positional.
 */

/* Brand: same face, same mark, same gap, everywhere. Safe at all widths — it sets no
   box geometry that the phone layout depends on. */
nav.nav .brand,
nav.topnav .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  font: 600 20px/1 Fraunces, var(--serif, Georgia, serif);
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--ink, #F2F4F7);
}
nav.nav .brand img,
nav.topnav .brand img {
  height: 24px;
  width: auto;
  display: block;
}

/* Links: one row, one gap. `.links` is prompts.html's container name, `.nav-links`
   everyone else's — both are canonical inputs to nav.js, so both are styled here. */
nav.nav .nav-links, nav.nav .links,
nav.topnav .nav-links, nav.topnav .links {
  display: flex;
  align-items: center;
  gap: 2px;
}

@media (min-width: 721px) {
  nav.nav,
  nav.topnav {
    height: 54px !important;
    min-height: 54px !important;
    gap: 10px !important;
    padding: 0 12px !important;
    border-bottom-color: rgba(255, 255, 255, .065);
    background:
      linear-gradient(105deg, rgba(255, 255, 255, .04), transparent 22%),
      rgba(8, 10, 12, .78) !important;
    box-shadow: 0 12px 38px rgba(0, 0, 0, .22);
    -webkit-backdrop-filter: blur(22px) saturate(1.2);
    backdrop-filter: blur(22px) saturate(1.2);
  }

  nav.nav .brand,
  nav.topnav .brand {
    min-width: 0 !important;
    min-height: 24px !important;
    gap: 0 !important;
    font: 600 20px/1 Fraunces, Georgia, serif !important;
  }

  nav.nav .brand img,
  nav.topnav .brand img {
    width: auto !important;
    height: 24px !important;
  }

  nav.nav .nav-links,
  nav.nav .links,
  nav.topnav .nav-links,
  nav.topnav .links {
    flex: 0 1 auto;
    min-width: 0;
    min-height: 38px !important;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 3px !important;
    border: 1px solid rgba(255, 255, 255, .075);
    border-radius: 999px !important;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, .055), transparent 37%),
      rgba(255, 255, 255, .025) !important;
    box-shadow: inset 0 1px rgba(255, 255, 255, .035);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  nav.nav .nav-links::-webkit-scrollbar,
  nav.nav .links::-webkit-scrollbar,
  nav.topnav .nav-links::-webkit-scrollbar,
  nav.topnav .links::-webkit-scrollbar {
    display: none;
  }

  nav.nav .nav-right,
  nav.topnav .nav-right {
    flex: 0 0 auto;
  }

  nav.nav .nav-links a,
  nav.nav .links a,
  nav.topnav .nav-links a,
  nav.topnav .links a {
    min-height: 30px !important;
    padding: 6px 11px !important;
    border-radius: 999px !important;
    color: var(--dim, #9FA3AD) !important;
    font: 500 13.5px/1 "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    text-decoration: none !important;
    transition:
      color 110ms cubic-bezier(.2, .8, .2, 1),
      background-color 110ms cubic-bezier(.2, .8, .2, 1),
      box-shadow 110ms cubic-bezier(.2, .8, .2, 1),
      transform 110ms cubic-bezier(.2, .8, .2, 1);
  }

  nav.nav .nav-links a:hover,
  nav.nav .links a:hover,
  nav.topnav .nav-links a:hover,
  nav.topnav .links a:hover {
    background: rgba(255, 255, 255, .065) !important;
    color: var(--ink, #F2F4F7) !important;
    transform: translateY(-1px);
  }

  nav.nav .nav-links a.active,
  nav.nav .links a.active,
  nav.topnav .nav-links a.active,
  nav.topnav .links a.active {
    background: #F1F0EC !important;
    color: #171819 !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, .2), inset 0 1px #fff !important;
  }
}

.saga-create {
  position: relative;
  z-index: 130;
  margin-left: auto;
}

.saga-create + .nav-right {
  margin-left: 0 !important;
}

.saga-account-balance {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .1), transparent 44%),
    rgba(255, 255, 255, .045);
  color: var(--ink, #F2F4F7);
  box-shadow: inset 0 1px rgba(255, 255, 255, .05);
  font: 600 11px/1 var(--mono, ui-monospace, monospace);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 110ms ease, background-color 110ms ease, transform 110ms ease;
}

.saga-account-balance:hover {
  border-color: rgba(139, 220, 204, .36);
  background-color: rgba(121, 220, 201, .08);
  transform: translateY(-1px);
}

.saga-account-balance-label {
  color: #767F83;
  font-size: 8px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.saga-account-balance-value {
  color: #F2F4F7;
  font: inherit;
}

.saga-account-balance[data-tone="low"] {
  border-color: rgba(244, 192, 102, .55);
}

.saga-account-balance[data-tone="empty"] {
  border-color: rgba(255, 139, 139, .58);
}

.saga-account-balance-floating {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9997;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.saga-create-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .13), transparent 43%),
    rgba(255, 255, 255, .055);
  color: var(--ink, #F2F4F7);
  box-shadow: inset 0 1px rgba(255, 255, 255, .065);
  cursor: pointer;
  font: 600 10px/1 var(--mono, ui-monospace, monospace);
  transition:
    transform 105ms cubic-bezier(.2, .8, .2, 1),
    border-color 105ms cubic-bezier(.2, .8, .2, 1),
    background-color 105ms cubic-bezier(.2, .8, .2, 1);
}

.saga-create-trigger:hover,
.saga-create.open .saga-create-trigger {
  border-color: rgba(139, 220, 204, .34);
  background-color: rgba(121, 220, 201, .09);
}

.saga-create-trigger:active {
  transform: scale(.975);
}

.saga-create-trigger svg {
  width: 14px;
  height: 14px;
}

.saga-create-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  width: min(600px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 21px;
  background:
    radial-gradient(circle at 12% -12%, rgba(255, 255, 255, .1), transparent 31%),
    linear-gradient(140deg, rgba(121, 220, 201, .04), transparent 43%),
    rgba(14, 17, 19, .94);
  color: #F4F5F3;
  box-shadow: 0 28px 86px rgba(0, 0, 0, .6), inset 0 1px rgba(255, 255, 255, .07);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  backdrop-filter: blur(24px) saturate(1.2);
  animation: saga-create-in 130ms cubic-bezier(.2, .8, .2, 1) both;
}

.saga-create-kicker {
  display: block;
  padding: 2px 3px 11px;
  color: #7E868A;
  font: 600 8px/1 var(--mono, ui-monospace, monospace);
  letter-spacing: .09em;
  text-transform: uppercase;
}

.saga-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.saga-create-grid > a {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 62px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: #A8AFB2;
  text-decoration: none;
  transition:
    transform 105ms cubic-bezier(.2, .8, .2, 1),
    color 105ms cubic-bezier(.2, .8, .2, 1),
    border-color 105ms cubic-bezier(.2, .8, .2, 1),
    background-color 105ms cubic-bezier(.2, .8, .2, 1);
}

.saga-create-grid > a:hover {
  border-color: rgba(255, 255, 255, .075);
  background: rgba(255, 255, 255, .045);
  color: #fff;
  transform: translateY(-1px);
}

.saga-create-grid > a > svg {
  width: 32px;
  height: 32px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .055);
  color: #8BDCCC;
}

/* nav.js works without a Lucide bundle. When those placeholders are not upgraded to
   SVG, keep the menu visual instead of leaving an unexplained empty icon column. */
.saga-create-grid > a > span[data-lucide] {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, .055);
  color: #8BDCCC;
  font: 600 14px/1 var(--sans, system-ui, sans-serif);
}
.saga-create-grid > a > span[data-lucide]::before { content: '✦'; }
.saga-create-grid > a > span[data-lucide="layout-template"]::before { content: '▦'; }
.saga-create-grid > a > span[data-lucide="image"]::before { content: '▧'; }
.saga-create-grid > a > span[data-lucide="video"]::before { content: '▶'; font-size: 10px; }
.saga-create-grid > a > span[data-lucide="library"]::before { content: '▤'; }
.saga-create-grid > a > span[data-lucide="wand-sparkles"]::before { content: '⌁'; }
.saga-create-grid > a > span[data-lucide="audio-lines"]::before { content: '♫'; }

.saga-create-grid > a > span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.saga-create-grid strong {
  color: inherit;
  font: 600 10px/1.1 var(--sans, system-ui, sans-serif);
}

.saga-create-grid small {
  overflow: hidden;
  color: #737B80;
  font: 500 7.5px/1.25 var(--mono, ui-monospace, monospace);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saga-create-grid b {
  position: absolute;
  top: 7px;
  right: 8px;
  padding: 3px 5px;
  border-radius: 999px;
  background: rgba(121, 220, 201, .12);
  color: #8BDCCC;
  font: 700 6.5px/1 var(--mono, ui-monospace, monospace);
}

.saga-create-panel footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 11px 3px 1px;
  border-top: 1px solid rgba(255, 255, 255, .065);
}

.saga-create-panel footer a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #A8AFB2;
  font: 600 8px/1 var(--mono, ui-monospace, monospace);
  text-decoration: none;
}

.saga-create-panel footer a:hover {
  color: #fff;
}

.saga-create-panel footer a svg {
  width: 12px;
  height: 12px;
}

.saga-create-panel footer > span {
  color: #62696D;
  font: 500 7px/1 var(--mono, ui-monospace, monospace);
}

@keyframes saga-create-in {
  from { opacity: 0; transform: translateY(-5px) scale(.988); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1080px) and (min-width: 721px) {
  .saga-create-trigger {
    width: 36px;
    padding: 0;
  }

  .saga-create-trigger span:last-child {
    display: none;
  }
}

@media (max-width: 1360px) and (min-width: 721px) {
  nav.nav .sizer,
  nav.topnav .sizer {
    display: none;
  }

  nav.nav .profile,
  nav.topnav .profile {
    gap: 0;
    padding-inline: 8px;
  }

  nav.nav .profile .pname,
  nav.topnav .profile .pname {
    display: none;
  }
}

@media (max-width: 720px) {
  .saga-account-balance {
    gap: 0;
    min-height: 36px;
    padding-inline: 10px;
  }

  .saga-account-balance-label {
    display: none;
  }

  .saga-create {
    position: static;
    margin-left: auto;
  }

  .saga-create-trigger {
    width: 36px;
    padding: 0;
  }

  .saga-create-trigger span:last-child {
    display: none;
  }

  .saga-create-panel {
    position: fixed;
    inset: auto 8px 8px;
    width: auto;
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
    border-radius: 20px;
  }

  .saga-create-grid {
    grid-template-columns: 1fr;
  }

  .saga-create-grid strong { font-size: 12px; }
  .saga-create-grid small { font-size: 9px; }

  body:has(#composer) .saga-create-panel {
    inset: auto 8px calc(72px + env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - var(--nav-h, 54px) - 82px);
  }
}

/* index.html puts Profile in the phone's top-right corner and .nav-right on row two.
   Create otherwise lands beyond the clipped link row and is "visible" to the DOM but
   absent from the screen. Pin the compact launcher directly beside Profile; Edit stays
   available in this same outcome menu. */
@media (max-width: 640px) {
  nav.nav .saga-create,
  nav.topnav .saga-create {
    position: absolute;
    z-index: 2;
    top: 8px;
    right: 56px;
    margin: 0;
  }
  nav.nav .nav-links,
  nav.nav .links,
  nav.topnav .nav-links,
  nav.topnav .links {
    max-width: calc(100vw - 248px);
    overflow: hidden;
    flex-wrap: nowrap;
  }
}

@media (max-width: 420px) {
  nav.nav .nav-links,
  nav.nav .links,
  nav.topnav .nav-links,
  nav.topnav .links { max-width: 122px; }
}

@media (prefers-reduced-motion: reduce) {
  .saga-create-panel,
  .saga-create-trigger,
  .saga-create-grid > a {
    animation: none;
    transition: none;
  }
}
