@font-face {
  font-family: "Rotachrome 3270";
  src: url("/fonts/3270/3270NerdFont-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bar-h: 50px;
  --drawer-w: 420px;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  background: var(--bg);
}

/* ---- toolbar ---- */
.toolbar {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 5;
  font-size: 13px;
}
.brand {
  font-weight: 700;
  letter-spacing: 0;
  font-size: 15px;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--muted); margin: 0 1px; }
.controls { display: flex; gap: 5px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
.size-controls {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.size-controls button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
}
.size-controls button:last-child { border-right: 0; }
.toolbar-menu {
  position: relative;
  display: inline-flex;
}
.toolbar-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.toolbar-menu-panel {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  z-index: 30;
  display: none;
  width: 210px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(20, 25, 34, 0.14);
}
.toolbar-menu.open .toolbar-menu-panel,
.toolbar-menu:focus-within .toolbar-menu-panel { display: grid; gap: 2px; }
.toolbar-menu-panel button {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  border-radius: 5px;
  padding: 0 8px;
  text-align: left;
}
.pro-locked {
  border-color: #111827;
  color: #111827;
  background: #f7f7f8;
  font-weight: 700;
}
.pro-locked:hover {
  background: #eceef2;
}
.toolbar-menu-panel button:hover { background: #f7f7f8; }
.badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.badge:empty { display: none; }
.hint { color: var(--muted); font-size: 12px; }
/* When the badge is present it takes the auto-margin; keep the hint snug. */
.badge + .hint { margin-left: 12px; }
/* Drop the verbose hint on narrower widths so the toolbar stays on one line. */
@media (max-width: 1280px) {
  .hint { display: none; }
}

button, select, input, textarea {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 5px;
  padding: 7px 11px;
  cursor: pointer;
}
/* toolbar controls are tighter than form fields in the drawers */
.controls button, .controls select { padding: 5px 8px; border-radius: 4px; }
button:hover { background: #f7f7f8; }
button:active { transform: translateY(1px); }
select { cursor: pointer; }
textarea, input { cursor: text; width: 100%; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#generate { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
#generate:hover { opacity: 0.9; background: var(--ink); }
button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
button.active:hover { background: var(--ink); opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: default; }

/* ---- shared (read-only) view ---- */
.shared-title { display: flex; align-items: center; gap: 12px; margin-left: auto; min-width: 0; }
.shared-title.hidden { display: none; }
.shared-title .shared-name { font-weight: 700; }
.shared-title a { color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; }
.shared-title a:hover { color: var(--ink); }
/* name + the fun LLM description stacked; description is muted and clipped */
.shared-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.shared-blurb {
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
  max-width: 56ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shared-blurb.hidden { display: none; }
/* In shared mode, hide the editor controls — only the title + strip remain. */
body.shared .controls,
body.shared .badge,
body.shared .hint,
body.shared #userChip { display: none; }
/* let the header grow to fit the stacked name + description */
body.shared .toolbar { height: auto; min-height: var(--bar-h); padding-top: 6px; padding-bottom: 6px; }
body.shared .swatch.readonly { cursor: default; }

/* ---- swatch strip ---- */
.strip {
  height: calc(100vh - var(--bar-h));
  display: flex;
  min-width: 0;
  width: 100%;
  transition: width 0.18s ease;
}
.account-banner:not(.hidden) + .strip {
  height: calc(100vh - var(--bar-h) - 42px);
}
body.drawer-open .strip {
  width: calc(100% - var(--drawer-w));
}

/* On narrow screens a single row turns the swatches into unusable slivers.
   Switch to a gapless 2-column grid that scrolls instead. */
@media (max-width: 640px) {
  :root { --drawer-w: 100vw; }
  .toolbar {
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
  }
  .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  .controls {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(112px, 1fr) 90px 76px;
    gap: 8px;
    width: 100%;
    white-space: normal;
  }
  .controls select,
  .controls > button,
  .controls > .toolbar-menu,
  .toolbar-menu-trigger {
    width: 100%;
    min-width: 0;
  }
  .size-controls {
    width: 76px;
  }
  .size-controls button {
    width: 38px;
    min-width: 0;
  }
  .toolbar-menu-panel {
    position: absolute;
    left: 0;
    right: auto;
    bottom: auto;
    top: calc(100% + 6px);
    width: min(300px, calc(100vw - 24px));
    max-width: none;
    padding: 6px;
    border-radius: 10px;
    box-shadow: 0 16px 36px rgba(20, 25, 34, 0.16);
  }
  .toolbar-menu-panel button {
    min-height: 44px;
    font-size: 14px;
  }
  .controls > .toolbar-menu:last-of-type {
    grid-column: 1 / -1;
  }
  .controls > .toolbar-menu:last-of-type .toolbar-menu-panel {
    width: 100%;
  }
  #togglePalettes {
    grid-column: 1 / -1;
  }
  #userChip {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    max-width: min(240px, calc(100vw - 170px));
    overflow: hidden;
    gap: 6px;
  }
  #userChip img {
    width: 24px;
    height: 24px;
  }
  #userChip .palette-status-icon {
    width: 28px;
    height: 22px;
  }
  #userChip .name {
    max-width: 56px;
  }
  #userChip .plan-pill { display: none; }
  #userChip button {
    padding: 5px 8px;
  }
  /* (mobile drawer = full-screen sheet; rules live after the .drawer base
     below so they win the cascade — see the dedicated media query there) */

  .strip {
    height: auto;
    min-height: calc(100vh - var(--bar-h));
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    width: 100vw;
    transition: none;
  }
  .account-banner:not(.hidden) + .strip {
    height: auto;
    min-height: calc(100vh - var(--bar-h) - 42px);
  }
  .strip .swatch {
    min-height: 32vh;
    padding: 0 8px 14px;
    justify-content: center;
    cursor: default;
    /* allow vertical flicks to scroll the grid; the touch editor engages only
       after a press-and-hold, then preventDefault()s to take over the drag */
    touch-action: pan-y;
  }
  /* a lone trailing swatch spans the full width instead of leaving a gap */
  .strip .swatch:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* resting state stays clean: just the icons + hex + name. No hover, so the
     action icons are always shown; the dense readout and HSB panel are hidden. */
  .strip .swatch .actions { opacity: 1; }
  .strip .swatch .icon.move { display: inline-block; }
  .strip .swatch .formats { display: none; }
  .strip .swatch .adjust { display: none; }
  /* engaged feedback: an inner ring in the swatch's adaptive ink */
  .strip .swatch.adjusting { box-shadow: inset 0 0 0 3px currentColor; }
  /* brightness strip appears only while a swatch is being edited */
  .strip .swatch.editing .bright {
    display: block;
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 8px;
    width: auto;
    height: 16px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit; /* so accent-color follows the swatch's adaptive ink */
    accent-color: currentColor;
    opacity: 0.95;
  }
}
.swatch {
  flex: 1 1 0;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 7vh;
  transition: transform 0.16s ease;
  user-select: none;
  cursor: grab;
  touch-action: none; /* allow pointer-drag on touch devices */
}
.swatch .actions {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-top: 12px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.swatch:hover .actions { opacity: 1; }
.swatch .icon {
  background: transparent;
  border: none;
  color: inherit; /* follow the swatch's adaptive ink instead of the global --ink */
  line-height: 0;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
}
.swatch .icon svg { width: 17px; height: 17px; display: block; }
.swatch .icon:hover { background: rgba(0,0,0,0.08); }
.swatch.locked .lock { opacity: 1; }
.swatch .lock { opacity: 0.55; }

.swatch .hexval {
  font-weight: 700;
  font-size: clamp(15px, 1.6vw, 22px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  color: inherit; /* follow the swatch's adaptive ink instead of the global --ink */
  text-align: center;
  width: 8ch;
  cursor: text;
  padding: 2px 0;
}
.swatch .cname {
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.85;
  margin-top: 4px;
  min-height: 1em;
  text-align: center;
  max-width: 90%;
  white-space: normal;
  overflow-wrap: anywhere;
}
/* Instant nearest-color guess, before/without the LLM idiom. */
.swatch .cname-local { opacity: 0.55; font-style: italic; }
.swatch .formats {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.12s ease;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.swatch:hover .formats { opacity: 0.8; }
.swatch.dragging {
  transition: none; /* follow the cursor with no lag */
  z-index: 30;
  cursor: grabbing;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

/* The bottom brightness strip and the reorder handle are mobile-only controls
   (shown in the media query below); the desktop swatch uses the hover HSB panel
   and whole-swatch drag instead. */
.swatch .bright { display: none; }
.swatch .move { display: none; }
.swatch.reordering { opacity: 0.5; }
.swatch.drop-target { box-shadow: inset 0 0 0 4px currentColor; }

/* long-hover HSB adjust panel — sits in the swatch's empty middle */
.swatch .adjust {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: min(82%, 200px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.swatch .adjust.show {
  opacity: 0.92;
  pointer-events: auto;
}
.swatch .adjust label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
}
.swatch .adjust input[type="range"] {
  flex: 1;
  margin: 0;
  cursor: pointer;
  accent-color: currentColor; /* thumb follows the swatch's adaptive ink */
}

/* ---- drawers ---- */
.drawer {
  position: fixed;
  top: var(--bar-h);
  right: 0;
  width: var(--drawer-w);
  height: calc(100vh - var(--bar-h));
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(0,0,0,0.06);
  z-index: 10;
  display: flex;
  flex-direction: column;
}
.drawer.hidden { display: none; }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 15px; }
.close { border: none; font-size: 20px; padding: 2px 8px; }
.drawer-body { padding: 16px; overflow-y: auto; }

/* On phones the drawer becomes a full-screen sheet that slides up — an opaque,
   self-contained surface instead of a desktop side panel peeking over the app.
   Placed after the .drawer base so these win the cascade on mobile. */
@media (max-width: 640px) {
  .drawer {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh; /* dvh tracks the iOS dynamic toolbar; vh fallback below */
    border-left: none;
    box-shadow: none;
    z-index: 40; /* above toolbar (5) + toast (20), below login overlay (50) */
  }
  .drawer-head { padding: 16px; }
  .drawer-head h2 { font-size: 18px; }
  /* a comfortable 44px tap target for dismiss */
  .close { font-size: 26px; line-height: 1; padding: 10px 12px; margin: -8px -6px -8px 0; }
  .drawer-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  /* lock the page behind the sheet so it can't scroll through */
  body.drawer-open { overflow: hidden; }
  body.drawer-open .strip { width: 100vw !important; }
}

.search-row { display: flex; gap: 8px; margin-bottom: 14px; }
.search-row input { flex: 1; }

.palettes-list { display: flex; flex-direction: column; gap: 12px; }
.pcard { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pcard .swatches { display: flex; height: 44px; }
.pcard .swatches div { flex: 1; }
.pcard .meta { padding: 8px 10px; display: flex; align-items: center; gap: 8px; }
.pcard .meta .title { font-size: 13px; font-weight: 600; }
.pcard .meta .sub { font-size: 11px; color: var(--muted); }
.pcard .meta .spacer { margin-left: auto; }
.pcard .meta button { padding: 4px 8px; font-size: 12px; }

.ai-block { margin-bottom: 18px; }
.ai-block label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.ai-block textarea { margin-bottom: 8px; }
.ai-output { font-size: 13px; color: var(--ink); }
.ai-output .row { display: flex; height: 40px; border-radius: 8px; overflow: hidden; margin: 8px 0; }
.ai-output .row div { flex: 1; }
.ai-output .reason { color: var(--muted); margin-top: 6px; }
.ai-output .err { color: #b91c1c; }
.ai-output .applybar { display: flex; gap: 8px; margin-top: 8px; }
.spinner { color: var(--muted); font-size: 13px; }

/* ---- palette audit ---- */
.audit-report {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.audit-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.audit-summary h3,
.audit-section h3,
.audit-issues h3,
.audit-pro h3 {
  margin: 0;
  font-size: 13px;
}
.audit-summary strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.audit-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.audit-rating-strong { border-color: #86efac; background: #f0fdf4; }
.audit-rating-usable { border-color: #bfdbfe; background: #eff6ff; }
.audit-rating-limited { border-color: #fde68a; background: #fffbeb; }
.audit-rating-decorative { border-color: #fecaca; background: #fef2f2; }
.audit-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.audit-stats div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.audit-stats strong {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.audit-stats span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}
.audit-section,
.audit-issues {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.audit-issues ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.audit-issues p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.audit-roles {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.audit-role {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.audit-role > span:first-child {
  color: var(--muted);
  font-weight: 700;
}
.audit-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.audit-empty {
  color: var(--muted);
  font-size: 12px;
}
.audit-pairs {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.audit-pair {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
}
.audit-pair-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-weight: 900;
}
.audit-pair strong,
.audit-pair span {
  display: block;
  font-size: 12px;
}
.audit-pair span {
  margin-top: 2px;
  color: var(--muted);
}
.audit-matrix {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 11px;
}
.audit-matrix th,
.audit-matrix td {
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.audit-matrix th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.audit-matrix .audit-chip {
  min-width: 72px;
  min-height: 24px;
  font-size: 10px;
}
.audit-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.audit-label-aaa,
.audit-label-aa { color: #166534; background: #dcfce7; }
.audit-label-aa-large { color: #92400e; background: #fef3c7; }
.audit-label-fail { color: #991b1b; background: #fee2e2; }
.audit-pro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed #c8ccd3;
  border-radius: 8px;
  background: #fafafa;
}
.audit-pro p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.audit-pro a,
.audit-pro button,
.audit-autofix-preview button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 5px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--ink);
  cursor: pointer;
}
.audit-pro a:focus-visible,
.audit-pro button:focus-visible,
.audit-autofix-preview button:focus-visible {
  outline: 3px solid #60a5fa;
  outline-offset: 2px;
}
.audit-pro-pill {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 10px;
  font-weight: 800;
  vertical-align: 1px;
}
.audit-pro-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.audit-secondary-action {
  background: #fff !important;
  color: var(--ink) !important;
}
.audit-autofix-preview {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.audit-autofix-preview h3,
.audit-autofix-preview p {
  margin: 0;
}
.audit-autofix-preview p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.audit-autofix-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.audit-autofix-head button {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.audit-fix-list {
  display: grid;
  gap: 8px;
}
.audit-fix-row {
  display: grid;
  grid-template-columns: 24px minmax(82px, auto) 18px minmax(82px, auto) minmax(84px, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}
.audit-fix-index,
.audit-fix-arrow,
.audit-fix-ratio {
  color: var(--muted);
  font-weight: 700;
}
.audit-fix-ratio {
  justify-self: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.audit-autofix-ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
@media (max-width: 640px) {
  .audit-pro,
  .audit-autofix-head {
    align-items: stretch;
    flex-direction: column;
  }
  .audit-pro-actions,
  .audit-pro a,
  .audit-pro button,
  .audit-autofix-head button {
    width: 100%;
  }
  .audit-fix-row {
    grid-template-columns: 22px minmax(0, 1fr) 18px minmax(0, 1fr);
  }
  .audit-fix-ratio {
    grid-column: 2 / -1;
    justify-self: start;
  }
}

/* ---- user chip ---- */
.userchip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
}
.userchip.hidden { display: none; }
.userchip img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
}
.userchip .name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userchip button { padding: 5px 9px; font-size: 12px; white-space: nowrap; border-radius: 4px; }
.userchip .name { white-space: nowrap; }
.palette-status-icon {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  width: 30px;
  height: 22px;
  overflow: hidden;
  border: 1px solid #14191c;
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  flex: 0 0 auto;
}
.palette-status-icon span {
  background: var(--status-color-a);
  animation: palette-status-cycle 14s ease-in-out infinite;
}
.palette-status-icon span:nth-child(1) {
  --status-color-a: #173b43;
  --status-color-b: #e84a5f;
  --status-color-c: #f6b73c;
}
.palette-status-icon span:nth-child(2) {
  --status-color-a: #e84a5f;
  --status-color-b: #f6b73c;
  --status-color-c: #173b43;
}
.palette-status-icon span:nth-child(3) {
  --status-color-a: #f6b73c;
  --status-color-b: #173b43;
  --status-color-c: #e84a5f;
}
.palette-status-icon strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}
@keyframes palette-status-cycle {
  0%, 24% { background: var(--status-color-a); }
  34%, 58% { background: var(--status-color-b); }
  68%, 100% { background: var(--status-color-c); }
}
@media (prefers-reduced-motion: reduce) {
  .palette-status-icon span { animation: none; }
}
.plan-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f7f8;
  color: #30343b;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.account-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 42px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff7ed;
  color: #43240c;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.account-banner.hidden { display: none; }
.account-banner-demo { background: #ecfdf5; color: #063f2c; }
.account-banner-free { background: #fff7ed; color: #43240c; }
.account-banner a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

/* ---- login overlay ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 28, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  width: min(360px, 90vw);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.login-brand { font-weight: 700; font-size: 22px; letter-spacing: 0; }
.login-brand span { color: var(--muted); }
.login-sub { color: var(--muted); font-size: 14px; margin: 8px 0 20px; }
.login-buttons { display: flex; flex-direction: column; gap: 10px; }
.login-buttons a {
  display: block;
  text-decoration: none;
  text-align: center;
  font-weight: 600;
  padding: 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
}
.login-buttons a:hover { background: #f7f7f8; }
.login-buttons a.github { background: var(--ink); color: #fff; border-color: var(--ink); }
.login-status {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ---- image color picker ---- */
.image-card {
  background: #fff;
  border-radius: 16px;
  width: min(520px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}
.image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.image-head h2 { margin: 0; font-size: 15px; }
.image-body { padding: 18px; }
.image-dropzone {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px;
  border: 1px dashed #c8ccd3;
  border-radius: 10px;
  background: #fafafa;
  text-align: center;
  cursor: pointer;
}
.image-dropzone:hover,
.image-dropzone.dragover {
  border-color: var(--ink);
  background: #f4f4f5;
}
.image-drop-main {
  font-weight: 700;
  font-size: 14px;
}
.image-drop-sub {
  color: var(--muted);
  font-size: 12px;
}
.image-drop-mobile,
.image-mobile-actions { display: none; }
.image-source-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.image-source-button:hover { background: #f7f7f8; }
.image-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.image-tools label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.image-tools input {
  width: 76px;
  padding: 6px 8px;
  font-variant-numeric: tabular-nums;
}
.image-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  min-height: 160px;
  max-height: 42vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f3f4f6;
  overflow: hidden;
}
.image-preview.hidden { display: none; }
.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 42vh;
  object-fit: contain;
}
.image-palette-row {
  display: flex;
  height: 58px;
  margin-top: 14px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.image-palette-row:empty { display: none; }
.image-palette-row div {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 7px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.image-status {
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}
.image-status.err { color: #b91c1c; }
.image-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.image-actions button {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 600;
}
.image-actions button:hover { background: var(--ink); opacity: 0.9; }

@media (max-width: 640px) {
  .image-card {
    width: min(100vw - 16px, 420px);
    max-height: calc(100dvh - 24px);
    border-radius: 12px;
  }
  .image-head { padding: 14px 16px; }
  .image-head h2 { font-size: 16px; }
  .image-body { padding: 16px; }
  .image-dropzone {
    min-height: 92px;
    padding: 14px;
  }
  .image-drop-main,
  .image-drop-sub { display: none; }
  .image-drop-mobile {
    display: block;
    font-size: 14px;
    font-weight: 700;
  }
  .image-mobile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
  }
  .image-tools {
    justify-content: space-between;
    margin-top: 12px;
  }
  .image-tools input {
    width: 84px;
    min-height: 40px;
  }
  .image-preview {
    min-height: 132px;
    max-height: 32dvh;
    margin-top: 12px;
  }
  .image-preview img { max-height: 32dvh; }
  .image-palette-row {
    height: 50px;
    margin-top: 12px;
  }
  .image-palette-row div {
    padding: 6px 2px;
    font-size: 9px;
  }
  .image-actions { margin-top: 12px; }
  .image-actions button {
    min-height: 44px;
    min-width: 132px;
  }
}

/* ---- palette applications ---- */
.application-card {
  background: #fff;
  border-radius: 16px;
  width: min(920px, 94vw);
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}
.application-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}
.application-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.application-swatches div {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 8px 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.application-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.application-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.application-grid select {
  width: 100%;
  color: var(--ink);
}
.application-reference {
  display: grid;
  gap: 12px;
}
.application-dropzone {
  display: grid;
  place-items: center;
  min-height: 104px;
  padding: 18px;
  border: 1px dashed #c8ccd3;
  border-radius: 10px;
  background: #fafafa;
  text-align: center;
  cursor: pointer;
}
.application-dropzone:hover,
.application-dropzone.dragover,
.application-reference-required .application-dropzone {
  border-color: var(--ink);
  background: #f4f4f5;
}
.application-dropzone span {
  font-size: 14px;
  font-weight: 800;
}
.application-dropzone small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.application-reference-preview,
.application-render {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f3f4f6;
  overflow: hidden;
}
.application-reference-preview.hidden { display: none; }
.application-reference-preview {
  min-height: 180px;
  max-height: 42vh;
}
.application-reference-preview img,
.application-render img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.application-reference-preview img {
  max-height: 42vh;
}
.application-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}
.application-status.err { color: #b91c1c; }
.application-progress {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fafb;
}
.application-progress.hidden { display: none; }
.application-progress strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 13px;
}
.application-progress small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.application-progress-mark {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: conic-gradient(from var(--application-progress-turn, 0deg), var(--application-progress-palette, #141820 0% 25%, #f2f2f2 25% 50%, #8b8f98 50% 75%, #d6d8dc 75% 100%));
  box-shadow:
    inset 0 0 0 1px rgba(20, 24, 32, 0.16),
    inset 0 0 0 9px rgba(255, 255, 255, 0.3),
    0 8px 18px rgba(20, 24, 32, 0.12);
  animation: application-palette-orbit 5.5s linear infinite, application-palette-breathe 2.4s ease-in-out infinite;
}
.application-progress-mark::before {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(20, 24, 32, 0.12);
}
.application-progress-mark::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(20, 24, 32, 0.16);
  opacity: 0.65;
}
@keyframes application-palette-orbit {
  to { transform: rotate(360deg); }
}
@keyframes application-palette-breathe {
  0%, 100% { filter: saturate(0.9) brightness(1); }
  50% { filter: saturate(1.18) brightness(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .application-progress-mark {
    animation: none;
  }
}
.application-card.is-rendering .application-dropzone,
.application-card.is-rendering select {
  opacity: 0.58;
}
.application-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.application-actions .motion,
.application-actions button:last-child {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 700;
}
.application-result {
  display: grid;
  gap: 12px;
}
.application-result.hidden { display: none; }
.application-render {
  min-height: 280px;
  max-height: 58vh;
}
.application-render img {
  max-height: 58vh;
}
.application-result details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}
.application-result summary {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.application-result pre {
  max-height: 220px;
  margin: 0;
  padding: 0 12px 12px;
  overflow: auto;
  color: #343841;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .application-card {
    width: min(100vw - 16px, 440px);
    max-height: calc(100dvh - 24px);
    border-radius: 12px;
  }
  .application-body {
    padding: 16px;
    gap: 14px;
  }
  .application-grid {
    grid-template-columns: 1fr;
  }
  .application-dropzone {
    min-height: 88px;
  }
  .application-reference-preview {
    min-height: 132px;
    max-height: 32dvh;
  }
  .application-reference-preview img { max-height: 32dvh; }
  .application-render {
    min-height: 190px;
    max-height: 40dvh;
  }
  .application-render img { max-height: 40dvh; }
  .application-progress {
    grid-template-columns: 1fr;
  }
  .application-progress-mark {
    width: 38px;
    height: 38px;
  }
  .application-progress-mark::before {
    inset: 9px;
  }
  .application-actions button {
    min-height: 42px;
  }
}

/* ---- export / share modal ---- */
.export-card {
  background: #fff;
  border-radius: 16px;
  width: min(420px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}
.export-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.export-head h2 { margin: 0; font-size: 15px; }
.export-preview {
  padding: 18px;
  display: flex;
  justify-content: center;
  background: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 50% / 22px 22px;
  border-bottom: 1px solid var(--line);
}
#exportCanvas {
  max-width: 100%;
  max-height: 46vh;
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.export-controls { padding: 16px 18px 18px; }
.seg {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}
.seg button {
  flex: 1;
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  font-weight: 600;
  padding: 8px;
}
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--ink); color: #fff; }
.seg button.active:hover { background: var(--ink); opacity: 0.9; }
.export-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.export-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  width: 52px;
  flex: none;
}
.export-row button { padding: 7px 12px; font-size: 13px; flex: 1; }
.export-row button.motion { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.export-row button.motion:hover { opacity: 0.9; background: var(--ink); }
.export-progress {
  font-size: 12px;
  color: var(--muted);
  width: 116px;
  text-align: right;
  flex: 0 0 116px;
  font-variant-numeric: tabular-nums;
}

/* ---- production theme export modal ---- */
.production-asset-card {
  background: #fff;
  border-radius: 16px;
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.production-asset-body {
  min-height: 0;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
}
.production-asset-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
}
.production-asset-title {
  font-size: 17px;
  font-weight: 700;
}
.production-asset-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.production-asset-swatches {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.production-asset-swatches span {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.14);
}
.production-asset-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(420px, 1.15fr);
  gap: 16px;
}
.production-asset-section h3 {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
}
.production-asset-mapping,
.production-asset-preview {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.production-asset-mapping {
  padding: 14px;
}
.production-asset-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #edf3ea;
}
.production-asset-preview-head {
  display: grid;
  grid-template-columns: auto minmax(320px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #f6f8f3;
}
.production-asset-role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.production-asset-role-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.production-asset-role-head {
  min-width: 0;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}
.production-asset-role-label {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.production-asset-role-label strong {
  font-size: 13px;
  line-height: 1.2;
  color: var(--ink);
}
.production-asset-role-label small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.production-asset-role-swatch {
  flex: 0 0 auto;
  width: 38px;
  height: 30px;
  border: 1px solid rgba(20, 25, 34, 0.15);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}
.production-asset-role-row select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
}
.production-asset-format-seg {
  margin-bottom: 0;
}
.production-asset-format-seg button {
  padding: 8px 10px;
  font-size: 13px;
}
.production-asset-code {
  margin: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: 20px 22px;
  border: 10px solid #edf3ea;
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background:
    radial-gradient(circle at top left, rgba(173, 207, 159, 0.18), transparent 42%),
    #243029;
  color: #e4ecdc;
  font-size: 15px;
  line-height: 1.48;
  text-shadow: 0 0 4px rgba(197, 225, 187, 0.12);
}
.production-asset-code code {
  font-family: "Rotachrome 3270", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}
.production-asset-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 2px;
}
.production-asset-actions button {
  min-width: 128px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
}
.production-asset-actions .motion {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 600;
}

@media (max-width: 640px) {
  .production-asset-card {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }
  .production-asset-body {
    padding: 12px;
    gap: 12px;
  }
  .production-asset-summary {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }
  .production-asset-workspace {
    display: block;
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .production-asset-mapping { padding: 12px; }
  .production-asset-role-grid {
    grid-template-columns: 1fr;
  }
  .production-asset-role-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 9px;
  }
  .production-asset-role-swatch {
    width: 34px;
    height: 28px;
  }
  .production-asset-preview {
    display: block;
    min-height: 0;
    overflow: visible;
    margin-top: 12px;
  }
  .production-asset-preview-head {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }
  .production-asset-code {
    height: auto;
    font-size: 12px;
    overflow: visible;
    border-width: 8px;
    padding: 14px;
  }
  .production-asset-code code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .production-asset-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .production-asset-actions button {
    min-width: 0;
  }
}

/* ---- toast ---- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 20;
}
.toast.hidden { display: none; }

/* ---- home page ---- */
.home-page {
  --home-ink: #151515;
  --home-muted: #666b73;
  --home-line: #d9dde3;
  --home-soft: #f6f7f9;
  --home-surface: #ffffff;
  --home-accent: #f2673a;
  --home-blue: #6f4938;
  --home-primary: #6f4938;
  min-height: 100%;
  color: var(--home-ink);
  background:
    linear-gradient(180deg, rgba(246, 247, 249, 0.9) 0%, rgba(255, 255, 255, 0) 42%),
    #ffffff;
}

.home-page a { color: inherit; }

.home-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 28px;
  min-height: 64px;
  padding: 0 clamp(18px, 4vw, 52px);
  border-bottom: 1px solid rgba(21, 21, 21, 0.08);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
}

.home-brand,
.home-footer > span {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.home-brand span,
.home-footer span span { color: var(--home-muted); }

.home-nav nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 30px);
}

.home-nav nav a,
.home-nav-cta,
.home-footer a {
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.home-nav nav a { color: var(--home-muted); }
.home-nav nav a:hover,
.home-footer a:hover { color: var(--home-ink); }

.home-nav-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-nav-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--home-ink);
  border-radius: 6px;
  color: #fff;
  background: var(--home-ink);
}

.home-nav-cta-secondary {
  color: var(--home-ink);
  background: #fff;
}

.home-plan-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid rgba(21, 21, 21, 0.12);
  border-radius: 999px;
  background: #fff;
  color: var(--home-ink);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.home-plan-status.hidden { display: none; }

.hero-section,
.ksp-section,
.comparison-section,
.pricing-section {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(520px, 1.1fr);
  gap: clamp(34px, 5vw, 76px);
  align-items: center;
  min-height: clamp(680px, calc(100svh - 140px), 780px);
  padding: clamp(42px, 6vw, 74px) 0 clamp(36px, 5vw, 58px);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}

.hero-copy h1 {
  margin: 0;
  max-width: 10.5ch;
  font-size: clamp(54px, 8vw, 102px);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy h1 span { color: var(--home-primary); }

.hero-copy p {
  margin: 0;
  max-width: 58ch;
  color: var(--home-muted);
  font-size: clamp(17px, 1.8vw, 21px);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid var(--home-line);
}

.home-page .button-primary {
  background: var(--home-primary);
  border-color: var(--home-primary);
  color: #fff;
}

.home-page .button-primary:hover { background: #064ec1; border-color: #064ec1; }

.home-page .home-nav-cta:not(.home-nav-cta-secondary) { color: #fff; }

.home-nav-cta:hover { background: #2a2a2a; }
.home-nav-cta-secondary:hover { background: var(--home-soft); }

.button-secondary {
  background: #fff;
  color: var(--home-ink);
}

.button-secondary:hover { background: var(--home-soft); }

.studio-preview {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(21, 21, 21, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 22px 60px rgba(21, 21, 21, 0.12);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.preview-toolbar span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--home-line);
  border-radius: 6px;
  background: #fff;
  color: var(--home-muted);
  font-size: 12px;
  font-weight: 800;
}

.preview-swatches {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 360px;
  overflow: hidden;
  border-radius: 7px;
}

.preview-swatches div {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  padding: 18px 12px;
  color: var(--ink);
  background: var(--swatch);
}

.preview-swatches strong,
.preview-swatches span {
  display: block;
  color: var(--ink);
  overflow-wrap: normal;
}

.preview-swatches strong {
  font-size: 14px;
  line-height: 1.15;
}

.preview-swatches span {
  font-size: 12px;
  font-weight: 800;
  opacity: 0.82;
}

.preview-panels {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 12px;
}

.image-picker-panel,
.production-asset-panel {
  min-height: 116px;
  border: 1px solid var(--home-line);
  border-radius: 8px;
  background: #fff;
}

.image-picker-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--home-muted);
  font-size: 12px;
  font-weight: 800;
}

.image-chip-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.image-chip-grid span {
  display: block;
  aspect-ratio: 1;
  border-radius: 6px;
}

.production-asset-panel {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px;
}

.production-asset-panel code {
  display: block;
  padding: 9px 10px;
  border-radius: 6px;
  background: var(--home-soft);
  color: #2b3037;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
}

.home-theme-export {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--home-line);
  border-radius: 8px;
  background: #fbfcf8;
}

.home-theme-export-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--home-muted);
  font-size: 12px;
  font-weight: 900;
}

.home-theme-export-head strong {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--home-ink);
  color: #fff;
  font-size: 11px;
}

.home-theme-export-body {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 12px;
}

.home-theme-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.home-theme-map span {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 34px;
  padding: 7px;
  border: 1px solid var(--home-line);
  border-radius: 7px;
  background: #fff;
  color: var(--home-ink);
  font-size: 11px;
  font-weight: 800;
}

.home-theme-map i {
  display: block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(21, 21, 21, 0.14);
  border-radius: 5px;
}

.home-theme-export pre {
  min-width: 0;
  margin: 0;
  padding: 13px 14px;
  overflow: hidden;
  border: 1px solid rgba(36, 48, 41, 0.22);
  border-radius: 8px;
  background:
    radial-gradient(circle at top left, rgba(173, 207, 159, 0.17), transparent 45%),
    #243029;
  color: #e4ecdc;
  font-family: "Rotachrome 3270", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.38;
}

.home-theme-export code {
  font-family: inherit;
  white-space: pre-wrap;
}

.ksp-section,
.comparison-section,
.pricing-section {
  padding: clamp(54px, 7vw, 88px) 0;
  border-top: 1px solid rgba(21, 21, 21, 0.08);
}

.compare-page .comparison-section {
  padding-top: clamp(42px, 6vw, 76px);
  border-top: 0;
}

.section-intro {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(300px, 0.65fr);
  gap: clamp(20px, 5vw, 72px);
  align-items: end;
  margin-bottom: 30px;
}

.section-intro h2 {
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
  letter-spacing: 0;
}

.section-intro p {
  margin: 0;
  color: var(--home-muted);
  font-size: 16px;
  line-height: 1.6;
}

.ksp-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ksp-grid article {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 226px;
  padding: 20px;
  border: 1px solid var(--home-line);
  border-radius: 8px;
  background: #fff;
}

.ksp-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  background: var(--home-soft);
  color: var(--home-ink);
  font-size: 12px;
  font-weight: 900;
}

.ksp-grid article:nth-child(2) .ksp-marker { background: #f3ece7; color: var(--home-blue); }
.ksp-grid article:nth-child(3) .ksp-marker { background: #e9f7f1; color: #27725c; }
.ksp-grid article:nth-child(4) .ksp-marker { background: #fff0e9; color: var(--home-accent); }

.ksp-grid h3,
.pricing-card h3,
.newsletter-panel h3 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
}

.ksp-grid p,
.pricing-card li,
.newsletter-panel p {
  margin: 0;
  color: var(--home-muted);
  font-size: 14px;
  line-height: 1.55;
}

.compare-plans-section {
  scroll-margin-top: 88px;
}

.compare-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--home-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(21, 21, 21, 0.06);
}

.compare-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
  text-align: left;
}

.compare-feature-col { width: 44%; }
.compare-plan-col { width: 28%; }

.compare-table th,
.compare-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--home-line);
  vertical-align: middle;
  font-size: 14px;
  line-height: 1.45;
}

.compare-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  color: var(--home-muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.compare-table thead th:nth-child(2),
.compare-table thead th:nth-child(3),
.compare-table td:nth-child(2),
.compare-table td:nth-child(3) {
  text-align: center;
}

.compare-table td:nth-child(3) {
  background: #fff;
}

.compare-pro-heading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pro-mark {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(5, 1fr);
  width: 37px;
  height: 22px;
  overflow: hidden;
  border: 1px solid #14191c;
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  flex: 0 0 auto;
}

.pro-mark span:nth-child(1) { background: #132a2e; }
.pro-mark span:nth-child(2) { background: #f2673a; }
.pro-mark span:nth-child(3) { background: #f6d35f; }
.pro-mark span:nth-child(4) { background: #88c9b8; }
.pro-mark span:nth-child(5) { background: #efe7d2; }

.feature-name {
  display: block;
  color: var(--home-ink);
  font-size: 15px;
  font-weight: 800;
}

.feature-note {
  display: block;
  margin-top: 3px;
  color: var(--home-muted);
  font-size: 12px;
  font-weight: 560;
}

.compare-group-row th {
  padding: 20px 18px 10px;
  border-bottom: none;
  background: var(--home-soft);
  color: var(--home-ink);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.compare-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 950;
  line-height: 1;
}

.compare-badge.yes {
  color: #1f8a5b;
  background: #eaf7f0;
}

.compare-badge.no {
  color: #d73535;
  background: #fff0f0;
}

.compare-limited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--home-soft);
  color: var(--home-muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.compare-card-list {
  display: none;
}

.compare-cta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--home-line);
  border-radius: 8px;
  background: #fff;
}

.compare-cta p {
  margin: 0;
  color: var(--home-ink);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 760;
}

.pricing-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr) minmax(320px, 0.9fr);
  gap: 14px;
  align-items: stretch;
}

.pricing-card,
.newsletter-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  border: 1px solid var(--home-line);
  border-radius: 8px;
  background: #fff;
}

.pricing-card-pro {
  border-color: rgba(21, 21, 21, 0.42);
  box-shadow: inset 0 0 0 1px rgba(21, 21, 21, 0.18);
}

.price {
  margin: 8px 0 0;
  font-size: 44px;
  line-height: 1;
  font-weight: 900;
}

.price span {
  color: var(--home-muted);
  font-size: 16px;
  font-weight: 800;
}

.pricing-card ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pricing-card li {
  position: relative;
  padding-left: 18px;
}

.pricing-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.66em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--home-accent);
}

.pricing-card .button { margin-top: auto; width: 100%; }

.newsletter-panel {
  background:
    linear-gradient(135deg, rgba(242, 103, 58, 0.12), rgba(83, 103, 255, 0.12)),
    #fff;
}

.newsletter-form {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.newsletter-form label {
  font-size: 12px;
  font-weight: 900;
  color: var(--home-muted);
}

.newsletter-form > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.newsletter-form input {
  min-height: 44px;
  border-radius: 6px;
  background: #fff;
}

.newsletter-form button {
  min-height: 44px;
  border-color: var(--home-ink);
  border-radius: 6px;
  background: var(--home-ink);
  color: #fff;
  font-weight: 800;
}

.form-status {
  min-height: 20px;
  margin: 0;
  color: var(--home-muted);
  font-size: 13px;
}

.form-status.error { color: #a23b25; }
.form-status.success { color: #1d6b55; }

.home-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 46px;
  border-top: 1px solid rgba(21, 21, 21, 0.08);
  color: var(--home-muted);
}

.home-footer > span { margin-right: auto; color: var(--home-ink); }

.legal-shell {
  width: min(840px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(58px, 8vw, 96px) 0 clamp(64px, 8vw, 104px);
}

.legal-hero {
  display: grid;
  gap: 18px;
  padding-bottom: 34px;
  border-bottom: 1px solid rgba(21, 21, 21, 0.08);
}

.legal-hero p {
  margin: 0;
  color: var(--home-muted);
  font-size: 13px;
  font-weight: 800;
}

.legal-hero h1 {
  margin: 0;
  font-size: clamp(44px, 7vw, 78px);
  line-height: 0.98;
  letter-spacing: 0;
}

.legal-intro {
  max-width: 68ch;
  color: var(--home-muted);
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.6;
}

.legal-content {
  display: grid;
  gap: 32px;
  padding-top: 38px;
}

.legal-content section {
  display: grid;
  gap: 12px;
}

.legal-content h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.legal-content p {
  margin: 0;
  color: #3f444c;
  font-size: 15px;
  line-height: 1.72;
}

@media (max-width: 980px) {
  .home-nav {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 12px 18px;
  }

  .home-nav nav {
    grid-column: 1 / -1;
    order: 3;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .hero-section {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 50px;
  }

  .hero-copy h1 { max-width: 11.5ch; }
  .studio-preview { max-width: 760px; }
  .section-intro,
  .pricing-grid { grid-template-columns: 1fr; }
  .ksp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .home-nav-cta { min-height: 36px; padding: 0 12px; }
  .hero-section,
  .ksp-section,
  .comparison-section,
  .pricing-section,
  .legal-shell,
  .home-footer { width: min(100% - 28px, 1180px); }
  .hero-copy h1 {
    max-width: 12ch;
    font-size: 50px;
  }
  .preview-swatches {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 520px;
  }
  .preview-panels,
  .home-theme-export-body,
  .ksp-grid,
  .newsletter-form > div { grid-template-columns: 1fr; }

  .compare-table-wrap {
    display: none;
  }

  .compare-card-list {
    display: grid;
    gap: 14px;
  }

  .compare-card-group {
    display: grid;
    gap: 8px;
  }

  .compare-group-title {
    margin: 18px 0 2px;
    color: var(--home-ink);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .compare-feature-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--home-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(21, 21, 21, 0.04);
  }

  .compare-feature-card h4 {
    margin: 0;
    color: var(--home-ink);
    font-size: 16px;
    font-weight: 850;
    line-height: 1.2;
  }

  .compare-feature-card p {
    margin: 4px 0 0;
    color: var(--home-muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
  }

  .compare-plan-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .compare-plan-cell {
    position: relative;
    display: grid;
    gap: 8px;
    align-content: center;
    justify-items: center;
    min-height: 74px;
    padding: 10px;
    border: 1px solid var(--home-line);
    border-radius: 7px;
    background: #fff;
  }

  .compare-plan-cell > span:first-child:not(.pro-mark) {
    color: var(--home-muted);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .compare-plan-cell.pro {
    border-color: var(--home-line);
    background: #fff;
    box-shadow: none;
  }

  .compare-plan-cell.pro .pro-mark {
    position: absolute;
    top: 8px;
    right: 8px;
  }

  .compare-plan-cell.pro > span:nth-child(2) {
    color: var(--home-muted);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .compare-cta {
    grid-template-columns: 1fr;
  }

  .compare-cta .button {
    width: 100%;
  }

  .compare-badge {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }
}
