/* ── Code: a side panel on desktop, a bottom sheet on mobile ─────────────────
   Lifted to <body>, fixed, above the header — so it has room and never fights
   the stage for space. */
/* The code output reuses the shared ContextMenu behaviour (open/close, anchored
   positioning, outside-click + Escape) but keeps its own dark-card styling.
   `.context-menu` already supplies position:absolute + the fade/slide on `.active`. */
.gs-code-menu.context-menu {
  width: min(36rem, calc(100vw - 1.5rem)); /* the foot's five actions on one row */
  max-height: calc(100svh - var(--gs-header-clear, 4rem) - 1.5rem);
  overflow-y: auto;
  padding: 1.1rem;
  border-radius: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 14, 22, 0.92);
  -webkit-backdrop-filter: blur(36px) saturate(1.5);
  backdrop-filter: blur(36px) saturate(1.5);
  box-shadow: 0 1.5rem 4rem -1rem rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 1100;
}
/* The module sets inline display:block on the root, so the flex column lives on an
   inner wrapper. */
.gs-code-menu__inner {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
/* Re-scope the panel's controls so the component's generic `.context-menu button`
   reset (width:100%, background:none, list padding, …) can't flatten them. These
   are more specific than that rule, so our styling wins. */
.gs-code-menu button { width: auto; }
.gs-code-menu .gs-btn {
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}
/* The window's one primary action: the page's ink, as the dock's Code button
   (the window lives on <body>, outside the gradient's own custom properties) */
.gs-code-menu .gs-btn--gradient {
  border: none;
  color: #0a0e16;
  background: var(--color-text-primary);
}
.gs-code-menu .gs-btn--ghost {
  background: none;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.gs-code-menu .gs-codetab {
  padding: 0.3rem 0.55rem;
  background: none;
  color: rgba(255, 255, 255, 0.55);
}
.gs-code-menu .gs-codetab.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.gs-code-menu .gs-code-window__close {
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.gs-code-window__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.gs-code-window__close {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.gs-code-window__close:hover { background: rgba(255, 255, 255, 0.16); }
.gs-code-window__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.gs-code-window__code {
  width: 100%;
  flex: 1;
  min-height: 8rem;
  resize: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.7rem;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(232, 240, 255, 0.95);
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 0.7rem 0.85rem;
}
.gs-code-window__code:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 0; }

.gs-code-window__foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  /* A short screen scrolls the window: the actions stay on its bottom edge */
  position: sticky;
  bottom: -1.1rem;
  z-index: 1;
  margin-inline: -1.1rem;
  padding: 0.75rem 1.1rem 1.1rem;
  background: rgba(10, 14, 22, 0.96);
}
.gs-code-window__note {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.55);
}
.gs-code-window__note[hidden] { display: none; }

/* Mesh image-format view: the rendered gradient + a direct download. */
.gs-code-preview {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: stretch;
}
.gs-code-preview[hidden] { display: none; }
.gs-code-preview__img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
}
.gs-code-preview__download { align-self: flex-start; }
/* ── Always-visible code line (the job-to-be-done) ────────── */

.gs-codeline__tabs {
  display: inline-flex;
  gap: 2px;
  flex-shrink: 0;
}

.gs-codetab {
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  box-shadow: none;
  transition: background 140ms ease, color 140ms ease;
}

.gs-codetab:hover { color: #fff; }
.gs-codetab.active { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* ── Output drawer ────────────────────────────────────────── */

.gs-output { display: grid; gap: var(--space-xs); overflow: hidden; }
.gs-output[hidden] { display: none; }

.gs-output__block {
  background: var(--shade-500, #080b11);
  color: var(--shade-000, #f9f9f9);
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

.gs-output__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.8rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gs-output__copy {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease;
}

.gs-output__copy:hover { background: rgba(255, 255, 255, 0.22); }

.gs-code {
  margin: 0;
  padding: 0.8rem;
  font-family: var(--mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Phone: the shared ContextMenu opens the window as a bottom sheet with its own
   grip and title, so our close button steps aside. The sheet is the site's
   surface; the window's controls are light-on-dark, so it takes the window's
   dark card. */
.gs-code-menu.context-menu--sheet .gs-code-window__close { display: none; }
html .gs-code-menu.context-menu.context-menu--sheet {
  --color-text-primary: #eef2f8;
  --color-text-secondary: rgba(226, 232, 240, 0.64);
  --color-border: rgba(255, 255, 255, 0.12);
  --color-bg-elevated: #11161f;
  --sheet-bg: #0b0f17;
  color: var(--color-text-primary);
}
/* The scroll edge that fades the sheet's foot (floatingDock.css) fades into the card. */
html:has(.gs-code-menu.context-menu--sheet.active) .page-scroll-edge { background-color: #0b0f17; }
/* The modal's form styles would paint the code box light; keep it the window's. */
#gs-code-menu .gs-code-window__code {
  background: rgba(0, 0, 0, 0.35);
  color: rgba(232, 240, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
#gs-code-menu .gs-code-window__code:focus {
  box-shadow: none; /* the site's cyan field ring; the box shows focus by its edge */
  border-color: rgba(255, 255, 255, 0.45);
}
