/* OPC Studio — a light table for comparing finished websites.
   The previews are the content, so the chrome stays neutral: a cool grey
   canvas, white working panels, ink-black actions and one cobalt selection
   ring. One system family, readable sizes, no decorative numbering. */

:root {
  color-scheme: light;
  --bg: #eceef1;
  --bg-2: #ffffff;
  --bg-3: #f5f6f8;
  --ink: #15171c;
  --ink-2: #353a44;
  --muted: #5f6673;
  --faint: #8d939e;
  --line: #d8dce2;
  --line-strong: #c2c7cf;
  --select: #2f4bff;
  --select-soft: #e6eaff;
  --danger: #b4261a;
  --ok: #1f7a4a;
  /* Earlier names kept for scripts and inline styles that reference them. */
  --acid: var(--select);
  --acid-ink: #ffffff;
  --acid-glow: rgba(47, 75, 255, 0.16);

  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --topbar: 60px;
  --radius: 10px;
  --radius-s: 7px;
  --ease: 140ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar) + 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font-sans);
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--select-soft);
  color: var(--ink);
}

img,
svg {
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input,
select,
summary,
textarea {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--select);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only,
.skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip:focus {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 120;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar);
  padding: 0 20px;
  background: rgba(236, 238, 241, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.wordmark svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.wordmark span {
  font-weight: 450;
  color: var(--muted);
}

.header-note {
  padding-left: 16px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.source-link {
  margin-left: auto;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
}

.source-link:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.version {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------- three-column shell ---------- */

.studio-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 348px;
  align-items: start;
  max-width: 1920px;
  margin: 0 auto;
}

/* ---------- purpose sidebar ---------- */

.sidebar {
  position: sticky;
  top: var(--topbar);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 12px 16px;
  scrollbar-width: thin;
}

.side-label {
  margin: 0 8px 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.sidebar nav {
  display: grid;
  gap: 2px;
}

.sidebar nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.3;
  text-align: left;
  transition: background-color var(--ease), color var(--ease);
}

.sidebar nav button > span {
  flex: none;
  margin-left: auto;
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sidebar nav button:hover {
  background: rgba(21, 23, 28, 0.05);
  color: var(--ink);
}

.sidebar nav button.active {
  background: var(--bg-2);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--line);
}

.sidebar nav button.active > span {
  color: var(--ink-2);
}

.catalog-facets {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px 8px 0;
  border-top: 1px solid var(--line);
}

.catalog-facets label,
.catalog-facets summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.catalog-facets summary {
  cursor: pointer;
  padding: 2px 0;
}

.catalog-facets select,
.side-bottom select {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: 6px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--bg-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%235f6673' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 10px center / 10px 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  appearance: none;
  -webkit-appearance: none;
}

.catalog-facets select:hover,
.side-bottom select:hover {
  border-color: var(--line-strong);
}

.catalog-facets .text-button {
  justify-self: start;
}

.side-bottom {
  margin-top: auto;
  padding: 16px 8px 0;
}

.side-bottom > p:first-child {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.side-bottom > p:last-child {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- catalogue ---------- */

main {
  min-width: 0;
  padding: 28px 28px 80px;
}

.intro {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.intro-tag {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.intro h1 {
  max-width: 24ch;
  margin: 0;
  color: var(--ink);
  font-size: clamp(30px, 2.6vw, 40px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.028em;
  text-wrap: balance;
}

.intro > p {
  max-width: 62ch;
  margin: 10px 0 16px;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.55;
  text-wrap: pretty;
}

.progress-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 0 6px 0 0;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--ease);
}

.progress-link:hover {
  border-color: var(--ink);
}

.catalog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.catalog-meta span {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(21, 23, 28, 0.06);
  color: var(--ink-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.catalog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 24px 0 4px;
}

.catalog-toolbar h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.018em;
}

.catalog-search {
  flex: 0 1 320px;
  min-width: 0;
}

.catalog-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235f6673' stroke-width='1.6'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat 14px center / 16px 16px;
  color: var(--ink);
  font-size: 14.5px;
}

.catalog-search input::placeholder {
  color: var(--faint);
}

.catalog-search input:hover {
  border-color: var(--line-strong);
}

.catalog-search input:focus {
  outline: none;
  border-color: var(--select);
  box-shadow: 0 0 0 3px var(--acid-glow);
}

.result-count {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#no-templates {
  margin: 0;
  padding: 48px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 36px 28px;
}

.template-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.preview-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-2);
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(21, 23, 28, 0.06);
  overflow: hidden;
  text-align: left;
  transition: box-shadow var(--ease), transform var(--ease);
}

.preview-button:hover {
  box-shadow: 0 0 0 1px var(--line-strong), 0 12px 28px -14px rgba(21, 23, 28, 0.35);
}

.template-card.is-selected .preview-button {
  box-shadow: 0 0 0 2px var(--select), 0 12px 28px -14px rgba(47, 75, 255, 0.45);
}

.mini-browser {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
}

.mini-browser span {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--line-strong);
}

.mini-browser small {
  margin: 0 auto;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-frame {
  position: relative;
  height: 230px;
  overflow: hidden;
  background: #fff;
}

.preview-frame iframe {
  display: block;
  width: 1280px;
  height: 900px;
  border: 0;
  background: #fff;
  transform-origin: top left;
  pointer-events: none;
}

.preview-label {
  position: absolute;
  left: 50%;
  bottom: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity var(--ease), transform var(--ease);
  pointer-events: none;
}

.preview-button:hover .preview-label,
.preview-button:focus-visible .preview-label {
  opacity: 1;
  transform: translate(-50%, 0);
}

.card-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 14px 2px 0;
}

.card-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.card-title h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.012em;
}

.card-title span {
  color: var(--muted);
  font-size: 13px;
}

.card-content > p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.card-features span {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(21, 23, 28, 0.06);
  color: var(--ink-2);
  font-size: 12.5px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
  transition: color var(--ease), text-decoration-color var(--ease);
}

.text-button:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.choose-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-left: auto;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}

.choose-button:hover {
  border-color: var(--ink);
}

.choose-button[aria-pressed="true"] {
  border-color: var(--select);
  background: var(--select);
  color: #fff;
}

.card-reference {
  color: var(--faint);
  font-size: 12.5px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-reference:hover {
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.catalog-footer {
  max-width: 72ch;
  margin: 56px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------- build panel ---------- */

.configuration {
  position: sticky;
  top: var(--topbar);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--topbar));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 22px 24px;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  scrollbar-width: thin;
}

.config-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 0 14px;
}

.selection-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--select);
}

.config-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

#selected-type {
  margin-left: auto;
  max-width: 55%;
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-summary {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-3);
  border: 1px solid var(--line);
}

.selection-summary h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.selection-summary p {
  margin: 0 0 6px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.5;
}

#project-form {
  display: grid;
  gap: 16px;
  padding: 20px 0 0;
}

#project-form label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}

#project-form label input,
#project-form label select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background-color: var(--bg-2);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 400;
  transition: border-color var(--ease), box-shadow var(--ease);
}

#project-form label select {
  padding-right: 30px;
  background: var(--bg-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%235f6673' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 12px center / 10px 7px;
  appearance: none;
  -webkit-appearance: none;
}

#project-form label input:hover,
#project-form label select:hover {
  border-color: var(--line-strong);
}

#project-form label input:focus,
#project-form label select:focus {
  outline: none;
  border-color: var(--select);
  box-shadow: 0 0 0 3px var(--acid-glow);
}

#project-form label input:disabled,
#project-form label select:disabled {
  background-color: var(--bg-3);
  color: var(--faint);
  cursor: not-allowed;
}

#project-form input[type="color"] {
  padding: 4px;
  cursor: pointer;
}

#project-form input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

#project-form input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

.field-note {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.field-note:empty {
  display: none;
}

summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform var(--ease);
}

details[open] > summary::before {
  transform: rotate(45deg);
}

details p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.brand-details,
.data-module {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.brand-details[open] {
  display: grid;
  gap: 14px;
}

.business-composition {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-3);
}

.business-composition legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 650;
}

.module-options {
  display: grid;
  gap: 6px;
}

#project-form .module-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--bg-2);
  font-weight: 400;
  cursor: pointer;
  transition: border-color var(--ease), background-color var(--ease);
}

#project-form .module-option:hover {
  border-color: var(--line-strong);
}

#project-form .module-option input {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  accent-color: var(--select);
}

.module-option span {
  display: grid;
  gap: 2px;
}

.module-option strong {
  font-size: 14px;
  font-weight: 600;
}

.module-option small {
  color: var(--muted);
  font-size: 12px;
}

.module-option:has(input:disabled) {
  cursor: default;
  opacity: 0.7;
}

.module-option:has(input:checked) {
  border-color: var(--select);
  background: var(--select-soft);
}

.module-summary,
.module-requirements {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.module-summary:empty,
.module-requirements:empty {
  display: none;
}

#module-fixes {
  padding: 12px;
  border-radius: var(--radius-s);
  background: #fff4f2;
  border: 1px solid #f1d0cb;
  font-size: 13px;
  line-height: 1.55;
}

#module-fixes p {
  margin: 0 0 8px;
}

#compatible-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

#use-business-stack {
  margin-top: 8px;
  min-height: 44px;
  white-space: normal;
}

#product-settings {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-3);
}

.module-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 500;
}

.module-status::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.module-status:empty {
  display: none;
}

.module-status[data-compatible="false"] {
  color: var(--danger);
}

.primary-button,
.secondary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-s);
  font-size: 14.5px;
  font-weight: 600;
  text-align: center;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}

.primary-button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.primary-button:hover {
  background: #2c303a;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--ink);
}

#project-form button:disabled,
#copy-prompt:disabled,
#preview-selection:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#copy-status {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--ok);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.command-details,
.reference-module {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.command-details pre,
.command-details #agent-prompt {
  max-height: 240px;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: var(--radius-s);
  background: #16181d;
  color: #e7e9ee;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow: auto;
  overflow-wrap: anywhere;
}

.command-details .text-button {
  margin-top: 6px;
}

#references {
  display: grid;
  gap: 2px;
  margin-top: 8px;
}

.reference-module a {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-underline-offset: 3px;
}

.reference-module p {
  margin: 2px 0 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.local-only {
  margin: 20px 0 0;
  color: var(--faint);
  font-size: 12.5px;
  line-height: 1.5;
}

.mobile-config {
  display: none;
}

/* ---------- preview dialog ---------- */

.preview-dialog {
  display: flex;
  flex-direction: column;
  width: calc(100vw - 40px);
  height: calc(100vh - 40px);
  max-width: 1600px;
  max-height: 1000px;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--bg-2);
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(10, 12, 20, 0.5);
}

.preview-dialog:not([open]) {
  display: none;
}

.preview-dialog::backdrop {
  background: rgba(16, 18, 24, 0.55);
  backdrop-filter: blur(3px);
}

.preview-dialog > header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
  min-height: 60px;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--line);
}

.preview-dialog header > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}

.preview-dialog header strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.preview-dialog header span {
  color: var(--muted);
  font-size: 13px;
}

.preview-dialog header .preview-note {
  color: var(--select);
  white-space: nowrap;
}

.preview-dialog header > a {
  flex: none;
  color: var(--ink-2);
  font-size: 14px;
  text-underline-offset: 4px;
}

.device-switch {
  display: inline-flex;
  flex: none;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg);
}

.device-switch button {
  min-height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.device-switch button[aria-pressed="true"] {
  background: var(--bg-2);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(21, 23, 28, 0.12);
}

#close-preview {
  flex: none;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink);
  font-size: 13.5px;
}

#close-preview:hover {
  border-color: var(--ink);
}

.live-preview {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: var(--bg);
}

.live-preview iframe {
  display: block;
  flex-shrink: 0;
  margin: 0 auto;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line);
  transform-origin: top left;
}

.preview-dialog > footer {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: none;
  min-height: 64px;
  padding: 10px 16px 10px 20px;
  border-top: 1px solid var(--line);
}

.preview-dialog footer p {
  margin: 0;
  max-width: 80ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.preview-dialog footer button {
  width: auto;
  margin: 0 0 0 auto;
  white-space: nowrap;
}

/* ---------- loading state ---------- */

.studio-startup {
  position: fixed;
  z-index: 100;
  top: 96px;
  left: 50%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--ink);
  box-shadow: 0 16px 40px -18px rgba(16, 18, 24, 0.4);
  font-size: 14px;
  transform: translateX(-50%);
}

.studio-startup[hidden] {
  display: none;
}

.studio-startup button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-s);
  background: var(--ink);
  color: #fff;
}

#studio-surface[inert] {
  opacity: 0.6;
}

#main,
#configuration-title {
  scroll-margin-top: calc(var(--topbar) + 16px);
}

/* ---------- responsive ---------- */

@media (max-width: 1360px) {
  .template-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 32px 22px;
  }
}

@media (max-width: 1180px) {
  .studio-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .header-note {
    display: none;
  }

  .configuration {
    position: static;
    grid-column: 2;
    max-height: none;
    overflow: visible;
    margin: 0 28px 48px;
    padding: 0 24px 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
  }

  #project-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #project-form > .field-note,
  #project-form > details,
  #project-form > fieldset,
  #project-form > #product-settings,
  #project-form > .module-status,
  #project-form > .primary-button,
  #project-form > .secondary-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .topbar {
    gap: 12px;
    padding: 0 16px;
  }

  .studio-shell {
    display: block;
  }

  .sidebar {
    position: static;
    display: block;
    height: auto;
    overflow: visible;
    padding: 12px 0 0;
  }

  .side-label {
    display: none;
  }

  .sidebar nav {
    display: flex;
    gap: 6px;
    padding: 0 16px 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sidebar nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar nav button {
    flex: none;
    width: auto;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--bg-2);
    box-shadow: 0 0 0 1px var(--line);
    white-space: nowrap;
  }

  .sidebar nav button > span {
    margin-left: 4px;
  }

  .sidebar nav button.active {
    background: var(--ink);
    color: #fff;
    box-shadow: none;
  }

  .sidebar nav button.active > span {
    color: rgba(255, 255, 255, 0.7);
  }

  .catalog-facets {
    grid-template-columns: 1fr 1fr;
    align-items: end;
    margin: 12px 16px 0;
    padding: 12px 0 0;
  }

  .catalog-facets > label,
  .catalog-facets > details {
    min-width: 0;
  }

  .catalog-facets > .text-button {
    grid-column: 1 / -1;
  }

  .side-bottom {
    padding: 12px 16px 0;
  }

  .side-bottom > p:first-child,
  .side-bottom > p:last-child {
    display: none;
  }

  main {
    padding: 20px 16px 96px;
  }

  .configuration {
    grid-column: auto;
    margin: 0 16px 96px;
    padding: 0 18px 20px;
  }

  .mobile-config {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 12px 30px -10px rgba(16, 18, 24, 0.5);
  }

  .preview-dialog {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }

  .preview-dialog > header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }

  .preview-dialog header > div:first-child {
    flex-basis: 100%;
  }

  .preview-dialog > footer {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
}

@media (max-width: 640px) {
  .header-note,
  .version {
    display: none;
  }

  .catalog-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .catalog-search {
    flex-basis: auto;
  }

  .template-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  #project-form {
    grid-template-columns: 1fr;
  }

  .preview-dialog header .preview-note {
    display: none;
  }

  .preview-dialog footer p {
    flex: 1 1 100%;
  }

  .preview-dialog footer .primary-button {
    width: 100%;
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
