:root {
  --void: #000000;
  --surface: #0a0a0a;
  --elevated: #121212;
  --border: #2e2e2e;
  --fg: #ecece6;
  --muted: #9a9a90;
  --subtle: #5a5a55;
  --primary: #c6ff00;
  --primary-fg: #0a0a0a;
  --danger: #ff5c5c;
  --ok: #6dffb0;
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  background: var(--void);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }
.glyph-sheet {
  background-image:
    linear-gradient(rgba(46,46,46,0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46,46,46,0.35) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}
.skip {
  position: absolute; left: -9999px;
}
.skip:focus {
  left: 1rem; top: 1rem; z-index: 100;
  background: var(--primary); color: var(--primary-fg); padding: 0.5rem 0.75rem;
}

.top-nav {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(8px);
}
.nav-inner {
  max-width: 72rem; margin: 0 auto;
  padding: 0 1.5rem; height: 4rem;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
}
.mark {
  width: 1.5rem; height: 1.5rem;
  border: 2px solid var(--primary);
  box-shadow: 3px 3px 0 var(--primary);
  display: inline-block;
}
.top-nav nav { display: flex; align-items: center; gap: 0.15rem; }
.top-nav nav a {
  padding: 0.45rem 0.75rem; border-radius: 0.35rem;
  font-size: 0.9rem; color: var(--muted);
}
.top-nav nav a.active, .top-nav nav a:hover { color: var(--primary); }
.x-pill {
  margin-left: 0.5rem !important;
  border: 1px solid var(--border) !important;
  color: var(--muted) !important;
}
.x-pill:hover { border-color: var(--primary) !important; color: var(--primary) !important; }

.mobile-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 3.5rem; padding: 0 1rem;
  border-bottom: 1px solid var(--border);
}
.dock {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(6, 1fr);
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.95);
  padding-bottom: env(safe-area-inset-bottom);
}
.dock a {
  text-align: center; padding: 0.65rem 0.25rem;
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.dock a.active { color: var(--primary); }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.foot {
  height: auto; padding: 1.25rem 1.5rem;
  font-size: 0.75rem; color: var(--subtle);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap;
}
.foot a { margin-left: 1rem; color: var(--subtle); }
.foot a:hover { color: var(--primary); }

main#content {
  flex: 1 0 auto;
  width: 100%;
  padding-bottom: 5.5rem;
}
@media (min-width: 768px) {
  main#content { padding-bottom: 2rem; }
  .mobile-only { display: none !important; }
}
@media (max-width: 767px) {
  .desktop-only { display: none !important; }
}

.wrap { max-width: 72rem; margin: 0 auto; padding: 2rem 1rem; }
@media (min-width: 768px) { .wrap { padding: 2.5rem 1.5rem; } }

.mono { font-family: var(--font-mono); }
.display { font-family: var(--font-display); }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.primary { color: var(--primary); }
.uppercase { text-transform: uppercase; letter-spacing: 0.12em; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }

h1.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 10vw, 5.5rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
  margin: 0.75rem 0 0;
}

.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--border);
  background: transparent; color: var(--fg);
  padding: 0.55rem 1rem; font-size: 0.9rem;
  font-family: var(--font-body); cursor: pointer;
  border-radius: 0.25rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--primary); color: var(--primary-fg);
  border-color: var(--primary); font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); color: var(--primary-fg); }
.btn-offset {
  background: var(--primary); color: var(--primary-fg);
  border: 2px solid var(--primary);
  box-shadow: 6px 6px 0 #5a7a00;
  font-weight: 600;
}
.btn-offset:hover { translate: 1px 1px; box-shadow: 5px 5px 0 #5a7a00; color: var(--primary-fg); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-ghost { border-color: transparent; color: var(--muted); }

.badge {
  display: inline-block;
  font-family: var(--font-mono); font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem; border: 1px solid var(--border);
  color: var(--muted);
}
.badge-live { border-color: var(--primary); color: var(--primary); }
.badge-ok { border-color: var(--ok); color: var(--ok); }
.badge-wait { border-color: #e6c200; color: #e6c200; }
.badge-no { border-color: var(--danger); color: var(--danger); }

.card {
  border: 1px solid var(--border);
  background: var(--void);
  padding: 1rem;
}
.card-offset {
  border: 2px solid var(--primary);
  box-shadow: 6px 6px 0 var(--primary);
  padding: 0.5rem;
}

input, textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.55rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  border-radius: 0.25rem;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--primary);
}
label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.field { margin-bottom: 1rem; }

.grid-2 { display: grid; gap: 2rem; }
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1fr 1fr; align-items: center; }
}
.stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats > div {
  background: var(--void); text-align: center;
  padding: 2rem 1rem;
}
.stats .val {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.75rem;
}

.strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* mobile: 2 per row */
  gap: 0.75rem;
}
@media (min-width: 640px) { .strip { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .strip { grid-template-columns: repeat(6, 1fr); } }
.strip .tile {
  border: 1px solid var(--border); padding: 0.35rem;
  background: var(--void);
}
.strip .tile canvas, .glyph-canvas { width: 100%; height: auto; display: block; }

.marquee {
  overflow: hidden; border-block: 1px solid var(--border);
  background: var(--surface); padding: 0.7rem 0;
}
.marquee-track {
  display: flex; gap: 2rem; width: max-content;
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  animation: marquee 40s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.faq details {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
}
.faq summary {
  cursor: pointer; font-weight: 600;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq p { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0 0; }

.flash {
  max-width: 72rem; margin: 1rem auto 0; padding: 0.75rem 1rem;
  border: 1px solid var(--border); font-size: 0.9rem;
}
.flash.ok { border-color: var(--ok); color: var(--ok); }
.flash.err { border-color: var(--danger); color: var(--danger); }

.admin-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1.5rem 0; }
.admin-tabs a, .admin-tabs button {
  font-size: 0.8rem;
}
.table-card {
  border: 1px solid var(--border); padding: 1rem; margin-bottom: 0.75rem;
}
.swatches { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.swatch {
  width: 1.75rem; height: 1.75rem; border: 1px solid var(--border);
  cursor: pointer; padding: 0;
}
.swatch.active { outline: 2px solid var(--primary); outline-offset: 2px; }


.studio-layout {
  display: grid;
  gap: 1.5rem;
}
@media (min-width: 900px) {
  .studio-layout {
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 2rem;
    align-items: start;
  }
}

.editor-frame {
  border: 2px solid var(--primary);
  box-shadow: 6px 6px 0 var(--primary);
  padding: 0.5rem;
  width: 100%;
  max-width: 28rem;
  min-height: 12rem;
  box-sizing: border-box;
}

#editor-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  touch-action: none;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

.glyph-canvas,
.tile canvas,
.card-offset canvas,
#preview-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.card-offset {
  width: 100%;
  max-width: 22rem;
  box-sizing: border-box;
}

/* Studio tools */
.tool-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}
.tool-btn.is-active {
  background: var(--primary) !important;
  color: #000 !important;
  border-color: var(--primary) !important;
}

/* ——— Global mobile pass ——— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}
/* Prevent horizontal scroll from offset shadows / wide rows */
body {
  overflow-x: hidden;
}

@media (max-width: 767px) {
  body { font-size: 14px; }

  .wrap {
    padding: 1.25rem 0.85rem 2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  h1.hero-title {
    font-size: clamp(2.4rem, 14vw, 3.5rem);
  }

  .nav-inner {
    padding: 0 0.85rem;
    height: 3.5rem;
  }

  .foot {
    padding: 1rem 0.85rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .foot a { margin-left: 0; margin-right: 0.85rem; }

  main#content {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .dock {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .dock a {
    font-size: 0.62rem;
    padding: 0.45rem 0.15rem;
    letter-spacing: 0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Buttons & forms */
  .btn {
    max-width: 100%;
  }
  .btn-offset {
    box-shadow: 4px 4px 0 #5a7a00;
  }
  .btn-offset:hover {
    box-shadow: 3px 3px 0 #5a7a00;
  }

  input, textarea, select {
    font-size: 16px; /* avoids iOS zoom on focus */
  }

  .stats > div { padding: 1.25rem 0.5rem; }
  .stats .val { font-size: 1.35rem; }

  .strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
  .strip .tile {
    min-width: 0;
  }

  .card-offset {
    max-width: 100%;
    margin-inline: auto;
    box-shadow: 4px 4px 0 var(--primary);
  }

  .grid-2 { gap: 1.25rem; }

  /* Studio mobile: canvas only in flow; tools in FAB sheet */
  .studio-title { font-size: 1.75rem; margin: 0.35rem 0 0; }
  .studio-lead { margin: 0.5rem 0 0; max-width: none; }
  .studio-layout {
    display: block;
    margin-top: 1.25rem;
    width: 100%;
    min-width: 0;
  }
  .studio-main { width: 100%; min-width: 0; }
  .studio-meta-row,
  .studio-frame-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin: 0.5rem 0;
  }
  .studio-meta-row { margin-bottom: 0.65rem; }
  .editor-frame {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
    box-shadow: 4px 4px 0 var(--primary);
    min-height: 0;
  }
  #editor-canvas {
    width: 100% !important;
    max-width: 100%;
    min-height: min(100vw - 1.75rem, 24rem);
    aspect-ratio: 1 / 1;
    height: auto;
  }
  #preview-canvas {
    max-width: 10rem;
    margin-inline: auto;
  }
  .tool-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }
  .tool-bar .btn {
    justify-content: center;
    width: 100%;
  }

  /* Aside becomes bottom sheet — not in document flow */
  .studio-aside {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    width: 100%;
    max-height: min(78vh, 36rem);
    overflow: auto;
    margin: 0;
    padding: 0.75rem 1rem calc(5.5rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface, #0a0a0a);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.55);
    transform: translateY(110%);
    transition: transform 0.28s ease;
    -webkit-overflow-scrolling: touch;
  }
  body.studio-tray-open .studio-aside {
    transform: translateY(0);
  }
  .studio-tray-handle {
    width: 2.5rem;
    height: 0.28rem;
    border-radius: 99px;
    background: var(--border);
    margin: 0.15rem auto 0.65rem;
  }
  .studio-tray-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
  }
  .studio-export-row,
  .studio-import-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .studio-gallery { margin-top: 2rem; }


  /* Whitelist steps */
  .wl-step {
    padding: 0.85rem !important;
  }

  .admin-tabs {
    gap: 0.35rem;
    margin: 1rem 0;
  }
  .admin-tabs .btn,
  .admin-tabs a {
    font-size: 0.75rem;
    padding: 0.35rem 0.55rem;
  }
  .table-card {
    padding: 0.75rem;
    overflow-x: auto;
  }

  .flash {
    margin: 0.75rem 0.85rem 0;
    padding: 0.65rem 0.75rem;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .dock a { font-size: 0.55rem; }
  h1.hero-title { font-size: 2.15rem; }
  .strip { gap: 0.4rem; }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
  * { scroll-behavior: auto; }
}


/* Studio FAB + scrim (mobile only — desktop sidebar unchanged) */
.studio-page .studio-layout { margin-top: 1.5rem; }
.studio-title { font-size: 2.5rem; margin: 0.4rem 0 0; }
.studio-lead { max-width: 40rem; }
.studio-meta-row,
.studio-frame-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.studio-meta-row { margin-bottom: 0.75rem; }
.studio-frame-actions { margin-top: 0.5rem; }
.studio-export-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.studio-import-block { margin-top: 0.5rem; }
.studio-gallery { margin-top: 2.5rem; }

.studio-fab {
  display: none;
}
.studio-scrim {
  display: none;
}

@media (max-width: 767px) {
  .studio-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 1rem;
    bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 56;
    width: 3.35rem;
    height: 3.35rem;
    border-radius: 999px;
    border: 2px solid var(--primary);
    background: var(--primary);
    color: #000;
    box-shadow: 4px 4px 0 #5a7a00;
    cursor: pointer;
    padding: 0;
  }
  .studio-fab:active {
    translate: 1px 1px;
    box-shadow: 3px 3px 0 #5a7a00;
  }
  .studio-fab-icon {
    font-size: 1.25rem;
    line-height: 1;
    font-weight: 700;
  }
  .studio-fab-dot {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    border: 1px solid #000;
    background: #C6FF00;
  }
  body.studio-tray-open .studio-fab {
    background: var(--void);
    color: var(--primary);
  }
  .studio-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 54;
    background: rgba(0,0,0,0.55);
    border: 0;
    padding: 0;
    cursor: pointer;
  }
  .studio-scrim[hidden] {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .studio-fab,
  .studio-scrim,
  .studio-tray-handle,
  .studio-tray-head {
    display: none !important;
  }
  .studio-aside {
    position: static !important;
    transform: none !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
  }
}
