/* =====================================================================
   CommunicationLinQ Studio — shared design layer for the visual builders
   (certificate, email, survey, quiz). Loaded after app.css.
   Look: hero bar with icon tile + status pills, numbered steps, tool tiles,
   layer list, accordion groups, preset chips, radial canvas backdrop.
   Machinery styling: 8-point resize handles, magenta snap guides,
   toolbar groups with icon buttons, keyboard hints, checks panel.
   ===================================================================== */

/* ---------- Tokens (scoped so existing fallbacks resolve) ---------- */
.studio-page,
.studio,
.survey-builder,
.quiz-builder,
.studio-gallery {
  --st-accent: var(--teal, #087f75);
  --st-accent-dark: #065f58;
  --st-accent-glow: rgba(8, 127, 117, .28);
  --st-surface: #ffffff;
  --st-surface-raised: #fafcfb;
  --st-surface-muted: #eef3f1;
  --st-border: #dfe6e9;
  --st-border-strong: #c9d4d8;
  --st-text: var(--ink, #14202b);
  --st-muted: #5f7079;
  --st-warn: #b7791f;
  --st-success: #0e9f6e;
  --st-danger: #b32121;
  --st-guide: #ff2d78;
  --st-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
  --st-shadow-lg: 0 20px 44px rgba(15, 23, 42, .16);
  --st-ease-out: cubic-bezier(.23, 1, .32, 1);
  --st-dur-press: 140ms;
  --st-dur-ui: 200ms;

  /* Generic names the ported email/survey CSS already falls back on */
  --accent: var(--st-accent);
  --accent-soft: #e6f3f1;
  --accent-soft-border: #c5e3de;
  --accent-contrast: #fff;
  --surface: var(--st-surface);
  --surface-alt: var(--st-surface-raised);
  --surface-nested: #fbfcfb;
  --surface-border: var(--st-border);
  --card-border: var(--st-border);
  --card-text: #24384a;
  --input-border: var(--st-border);
  --control-bg: #fff;
  --muted-strong: #4f6270;
  --label: #3b526d;
  --shadow-sm: var(--st-shadow-sm);
  --ring: rgba(8, 127, 117, .35);
  --tap-target: 2.5rem;
  --dur-fast: 160ms;
  --dur-press: 140ms;
  --ease-out: var(--st-ease-out);
  --press-scale: .97;
  --badge-soft-fg: var(--st-accent-dark);
  --badge-soft-bg: #e6f3f1;
  --badge-warn-fg: #956013;
  --badge-warn-bg: #fff4dc;
  --brand-accent: var(--st-accent);
  --heading: var(--st-text);
  --text: var(--st-text);
}

.content:has(.studio-page) { max-width: none; }

/* ---------- Hero ---------- */
.studio-hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .85rem 1.25rem;
  padding: 1.1rem 1.25rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--st-border-strong);
  border-radius: .9rem;
  background: linear-gradient(180deg, rgba(248, 250, 252, .95) 0%, var(--st-surface) 100%);
  box-shadow: var(--st-shadow-sm);
  overflow: hidden;
}
.studio-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--st-accent) 0%, #22b5a4 55%, var(--st-success) 100%);
}
.studio-hero--sticky { position: sticky; top: .5rem; z-index: 20; }
.studio-hero-main { display: flex; align-items: flex-start; gap: .85rem; min-width: 0; flex: 1 1 22rem; }
.studio-hero-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: .85rem;
  color: #fff;
  background: linear-gradient(145deg, var(--st-accent), var(--st-accent-dark));
  box-shadow: 0 8px 18px var(--st-accent-glow);
}
.studio-hero-icon--certificate { background: linear-gradient(145deg, #7c3aed, #5b21b6); box-shadow: 0 8px 18px rgba(124, 58, 237, .3); }
.studio-hero-icon--email { background: linear-gradient(145deg, #0284c7, #0369a1); box-shadow: 0 8px 18px rgba(2, 132, 199, .3); }
.studio-hero-icon--survey { background: linear-gradient(145deg, #0e9f6e, #046c4e); box-shadow: 0 8px 18px rgba(14, 159, 110, .3); }
.studio-hero-icon--quiz { background: linear-gradient(145deg, #d97706, #b45309); box-shadow: 0 8px 18px rgba(217, 119, 6, .3); }
.studio-hero-text { min-width: 0; }
.studio-hero-eyebrow {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--st-muted);
  margin-bottom: .15rem;
}
.studio-hero-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -.015em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.studio-hero-lede { margin: .2rem 0 0; font-size: .85rem; color: var(--st-muted); line-height: 1.45; max-width: 62ch; }
.studio-hero-end { display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; flex: 0 1 auto; max-width: 100%; }
.studio-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.studio-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--st-accent-dark);
  background: color-mix(in srgb, var(--st-accent) 12%, transparent);
  white-space: nowrap;
}
.studio-pill--done { color: #046c4e; background: color-mix(in srgb, var(--st-success) 16%, transparent); }
.studio-pill--dark { color: #fff; background: var(--st-text); }
.studio-pill--warn { color: var(--st-warn); background: color-mix(in srgb, var(--st-warn) 12%, transparent); }
.studio-pill--muted { color: var(--st-muted); background: var(--st-surface-muted); }
.studio-hero-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem; }
.studio-hero-actions .primary { box-shadow: 0 8px 18px var(--st-accent-glow); }

/* ---------- Numbered step heads ---------- */
.studio-step-head { display: flex; align-items: center; gap: .6rem; margin: 0 0 .8rem; flex-wrap: wrap; }
.studio-step-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 750;
  color: #fff;
  background: var(--st-text);
}
.studio-step-title { margin: 0; font-size: .98rem; font-weight: 700; letter-spacing: -.01em; }
.studio-step-meta { margin-left: auto; font-size: .78rem; color: var(--st-muted); }

/* ---------- Toolbar ---------- */
.studio-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--st-border);
  background: color-mix(in srgb, var(--st-surface) 88%, transparent);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
}
.studio-toolbar--card {
  border: 1px solid var(--st-border);
  border-radius: .75rem;
  background: var(--st-surface-raised);
  margin-bottom: .85rem;
}
.studio-toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.studio-toolbar-group--end { margin-left: auto; }
.studio-toolbar-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: .68rem;
  margin-right: .15rem;
  color: var(--st-muted);
}
.studio-sep { width: 1px; align-self: stretch; min-height: 1.6rem; background: color-mix(in srgb, var(--st-text) 12%, transparent); margin: 0 .2rem; }
.studio-zoom-label { font-size: .78rem; min-width: 3rem; text-align: center; font-variant-numeric: tabular-nums; color: var(--st-muted); }

.studio-btn,
.studio-btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 2.1rem;
  padding: .3rem .6rem;
  border: 1px solid var(--st-border);
  border-radius: .55rem;
  background: var(--st-surface);
  color: var(--st-text);
  font-size: .8rem;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition:
    border-color var(--st-dur-ui) var(--st-ease-out),
    background-color var(--st-dur-ui) var(--st-ease-out),
    transform var(--st-dur-press) var(--st-ease-out),
    box-shadow var(--st-dur-ui) var(--st-ease-out);
}
.studio-btn--icon { width: 2.1rem; padding: 0; }
.studio-btn .studio-icon { flex: 0 0 auto; }
.studio-btn:disabled, .studio-btn--icon:disabled { opacity: .45; cursor: not-allowed; }
.studio-btn:not(:disabled):active, .studio-btn--icon:not(:disabled):active { transform: scale(.96); }
.studio-btn:focus-visible, .studio-btn--icon:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.studio-btn.is-active, .studio-btn--icon.is-active {
  border-color: var(--st-accent);
  color: var(--st-accent-dark);
  background: color-mix(in srgb, var(--st-accent) 12%, var(--st-surface));
}
.studio-btn--primary { background: var(--st-accent); border-color: var(--st-accent); color: #fff; }
.studio-btn--danger { color: var(--st-danger); }
.studio-btn--danger:not(:disabled):hover { border-color: var(--st-danger); background: color-mix(in srgb, var(--st-danger) 8%, var(--st-surface)); }
.studio-btn--ai {
  color: #5b21b6;
  border-color: #d9c8fb;
  background: linear-gradient(135deg, #f5f0ff, #eef7ff);
}
@media (hover: hover) and (pointer: fine) {
  .studio-btn:not(:disabled):hover, .studio-btn--icon:not(:disabled):hover {
    border-color: var(--st-accent);
    background: color-mix(in srgb, var(--st-accent) 6%, var(--st-surface));
  }
  .studio-btn--primary:not(:disabled):hover { background: var(--st-accent-dark); }
}
.studio-kbd {
  display: inline-block;
  padding: .05rem .35rem;
  border: 1px solid var(--st-border-strong);
  border-bottom-width: 2px;
  border-radius: .3rem;
  background: var(--st-surface);
  font: 600 .68rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--st-muted);
}
.studio-hint-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .76rem; color: var(--st-muted); }

/* ---------- Side panels ---------- */
.studio-panel {
  border: 1px solid var(--st-border);
  border-radius: .75rem;
  padding: .7rem .75rem;
  margin-bottom: .6rem;
  background: var(--st-surface);
}
.studio-panel-title {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 700;
  font-size: .82rem;
  margin: 0 0 .5rem;
}
.studio-panel-title .studio-icon { color: var(--st-accent); }
.studio-panel-title .studio-panel-meta { margin-left: auto; font-size: .7rem; font-weight: 500; color: var(--st-muted); }
.studio-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--st-muted);
  margin: 0 0 .5rem;
}
.studio-tips { background: var(--st-surface-raised); border-style: dashed; }
.studio-tips ul { margin: 0; padding-left: 1.1rem; font-size: .76rem; color: var(--st-muted); line-height: 1.5; }
.studio-tips li + li { margin-top: .2rem; }

/* Tool tiles */
.studio-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.studio-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: .55rem .35rem;
  border: 1px solid var(--st-border);
  border-radius: .7rem;
  background: var(--st-surface);
  color: var(--st-text);
  font-size: .72rem;
  font-weight: 650;
  cursor: grab;
  text-align: center;
  transition:
    border-color var(--st-dur-ui) var(--st-ease-out),
    background-color var(--st-dur-ui) var(--st-ease-out),
    transform var(--st-dur-press) var(--st-ease-out);
}
.studio-tool .studio-icon { color: var(--st-accent); width: 20px; height: 20px; }
.studio-tool.is-dragging { opacity: .5; }
.studio-tool:active { cursor: grabbing; }
.studio-tool:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
@media (hover: hover) {
  .studio-tool:hover {
    border-color: var(--st-accent);
    background: color-mix(in srgb, var(--st-accent) 6%, var(--st-surface));
    transform: translateY(-1px);
  }
}

/* Layers list */
.studio-layers { display: flex; flex-direction: column; gap: .3rem; max-height: 15rem; overflow-y: auto; }
.studio-layer {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .4rem .55rem;
  border: 1px solid var(--st-border);
  border-radius: .6rem;
  background: var(--st-surface);
  color: var(--st-text);
  font-size: .78rem;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--st-dur-ui) var(--st-ease-out), background-color var(--st-dur-ui) var(--st-ease-out);
}
.studio-layer .studio-icon { color: var(--st-muted); flex: 0 0 auto; }
.studio-layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.studio-layer-pos { margin-left: auto; font-size: .66rem; color: var(--st-muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.studio-layer.is-active {
  border-color: var(--st-accent);
  background: color-mix(in srgb, var(--st-accent) 8%, var(--st-surface));
  font-weight: 650;
}
.studio-layer.is-active .studio-icon { color: var(--st-accent); }
.studio-layer.is-locked .studio-layer-name { color: var(--st-muted); }
@media (hover: hover) {
  .studio-layer:hover { background: color-mix(in srgb, var(--st-accent) 5%, var(--st-surface)); }
}

/* Accordion groups (native details) */
.studio-group {
  border: 1px solid var(--st-border);
  border-radius: .75rem;
  background: var(--st-surface);
  margin-bottom: .6rem;
}
.studio-group > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .8rem;
  cursor: pointer;
  font-weight: 650;
  font-size: .85rem;
  border-radius: .75rem;
  user-select: none;
}
.studio-group > summary::-webkit-details-marker { display: none; }
.studio-group > summary > .studio-icon:first-child { color: var(--st-accent); }
.studio-group-meta { margin-left: auto; font-size: .72rem; font-weight: 500; color: var(--st-muted); }
.studio-group > summary::after {
  content: "";
  width: .5rem;
  height: .5rem;
  margin-left: .25rem;
  border-right: 2px solid var(--st-muted);
  border-bottom: 2px solid var(--st-muted);
  transform: rotate(-45deg);
  transition: transform var(--st-dur-ui) var(--st-ease-out);
  flex: 0 0 auto;
}
.studio-group[open] > summary::after { transform: rotate(45deg); }
.studio-group[open] > summary { border-bottom: 1px solid var(--st-border); border-radius: .75rem .75rem 0 0; background: var(--st-surface-raised); }
@media (hover: hover) { .studio-group > summary:hover { background: rgba(15, 23, 42, .04); } }
.studio-group-body { padding: .75rem .8rem .85rem; }
.studio-group-body .field-label { display: block; margin: .5rem 0 .25rem; font-size: .74rem; font-weight: 650; color: var(--label); }
.studio-group-body .field-label:first-child { margin-top: 0; }
.studio-group-body input:not([type="checkbox"]):not([type="radio"]),
.studio-group-body textarea,
.studio-group-body select { width: 100%; }
.studio-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.studio-field-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.studio-field-grid input[type="color"] { width: 100%; height: 2rem; padding: 0; border: 1px solid var(--st-border); border-radius: .4rem; background: transparent; }
.studio-check { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; margin: .5rem .75rem .2rem 0; cursor: pointer; }

/* Selected-object card */
.studio-selected-card {
  border: 1px solid var(--st-accent);
  border-radius: .75rem;
  background: var(--st-surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-accent) 12%, transparent);
  margin-bottom: .6rem;
  overflow: hidden;
}
.studio-selected-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .8rem;
  background: color-mix(in srgb, var(--st-accent) 6%, var(--st-surface));
  border-bottom: 1px solid var(--st-border);
  font-size: .8rem;
}
.studio-selected-head strong { font-weight: 700; }
.studio-selected-head .studio-type-badge {
  margin-left: auto;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--st-accent-dark);
  background: color-mix(in srgb, var(--st-accent) 12%, transparent);
  border-radius: 999px;
  padding: .15rem .5rem;
}
.studio-selected-body { padding: .6rem .8rem .75rem; }
.studio-selected-actions { display: flex; flex-wrap: wrap; gap: .3rem; }

/* Preset chips */
.studio-presets { display: flex; flex-wrap: wrap; gap: .4rem; }
.studio-preset {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .32rem .65rem;
  border: 1px solid var(--st-border);
  border-radius: 999px;
  background: var(--st-surface);
  color: var(--st-text);
  font-size: .76rem;
  font-weight: 650;
  cursor: pointer;
  transition: border-color var(--st-dur-ui) var(--st-ease-out), background-color var(--st-dur-ui) var(--st-ease-out);
}
.studio-preset--primary { border-color: var(--st-accent); color: var(--st-accent-dark); background: color-mix(in srgb, var(--st-accent) 10%, transparent); }
@media (hover: hover) { .studio-preset:hover { border-color: var(--st-accent); background: color-mix(in srgb, var(--st-accent) 8%, var(--st-surface)); } }

/* Empty states */
.studio-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--st-muted);
  border: 1px dashed var(--st-border-strong);
  border-radius: .9rem;
  background: var(--st-surface-raised);
}
.studio-empty > .studio-icon { color: var(--st-accent); width: 32px; height: 32px; opacity: .8; }
.studio-empty-title { font-weight: 700; font-size: 1rem; color: var(--st-text); }
.studio-empty-text { max-width: 30rem; font-size: .85rem; }
.studio-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-top: .35rem; }
.studio-empty--overlay { position: absolute; inset: 0; border: 0; background: transparent; pointer-events: none; justify-content: center; }

/* ---------- Canvas backdrop, guides, handles ---------- */
.studio-canvas-backdrop {
  background:
    radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--st-accent) 10%, transparent), transparent 55%),
    var(--st-surface-muted);
}
.studio-guide { position: absolute; background: var(--st-guide); pointer-events: none; z-index: 70; }
.studio-guide--v { top: 0; bottom: 0; width: 1px; }
.studio-guide--h { left: 0; right: 0; height: 1px; }
.studio-safe-guide { position: absolute; inset: 40px; border: 1px dashed rgba(8, 127, 117, .35); pointer-events: none; z-index: 0; }
.studio-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--st-accent);
  border: 2px solid #fff;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  z-index: 60;
  touch-action: none;
}
.studio-handle--nw { top: -6px; left: -6px; cursor: nwse-resize; }
.studio-handle--n { top: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.studio-handle--ne { top: -6px; right: -6px; cursor: nesw-resize; }
.studio-handle--e { top: calc(50% - 5px); right: -6px; cursor: ew-resize; }
.studio-handle--se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.studio-handle--s { bottom: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.studio-handle--sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.studio-handle--w { top: calc(50% - 5px); left: -6px; cursor: ew-resize; }
.studio-size-badge {
  position: absolute;
  left: 50%;
  bottom: -1.6rem;
  transform: translateX(-50%);
  padding: .12rem .4rem;
  border-radius: .35rem;
  background: var(--st-text);
  color: #fff;
  font: 600 .64rem/1.3 ui-monospace, Menlo, Consolas, monospace;
  white-space: nowrap;
  pointer-events: none;
  z-index: 61;
}

/* ---------- Template gallery ---------- */
.studio-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
.studio-gallery-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1.5px solid var(--st-border);
  border-radius: .85rem;
  background: var(--st-surface);
  color: inherit;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color var(--st-dur-ui) var(--st-ease-out),
    box-shadow var(--st-dur-ui) var(--st-ease-out),
    transform var(--st-dur-press) var(--st-ease-out);
}
.studio-gallery-card:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.studio-gallery-card.is-selected {
  border-color: var(--st-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-accent) 14%, transparent);
}
@media (hover: hover) {
  .studio-gallery-card:hover { border-color: var(--st-accent); box-shadow: var(--st-shadow-sm); transform: translateY(-2px); }
}
.studio-gallery-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--st-surface-muted);
  border-bottom: 1px solid var(--st-border);
  color-scheme: light;
}
.studio-gallery-thumb--cert { aspect-ratio: 1056 / 816; }
.studio-gallery-thumb-inner { position: absolute; top: 0; left: 0; transform-origin: top left; pointer-events: none; }
.studio-gallery-body { padding: .6rem .75rem .7rem; }
.studio-gallery-name { display: block; font-weight: 700; font-size: .86rem; }
.studio-gallery-desc { display: block; font-size: .74rem; color: var(--st-muted); margin-top: .15rem; line-height: 1.4; }
.studio-gallery-tag {
  position: absolute;
  top: .5rem;
  left: .5rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #fff;
  background: var(--st-text);
  opacity: .85;
}
.studio-gallery-filter { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .85rem; }
.studio-dialog { max-width: 64rem; width: min(96vw, 64rem); max-height: 90vh; overflow: auto; margin: auto; }
.studio-dialog-lede { margin: -.25rem 0 1rem; font-size: .85rem; color: var(--st-muted); }

/* Simple template-card grid (survey / quiz starters) */
.studio-starter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.studio-starter {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .7rem .8rem;
  border: 1.5px solid var(--st-border);
  border-radius: .8rem;
  background: var(--st-surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--st-dur-ui) var(--st-ease-out), box-shadow var(--st-dur-ui) var(--st-ease-out), transform var(--st-dur-press) var(--st-ease-out);
}
.studio-starter .studio-icon { color: var(--st-accent); }
.studio-starter strong { font-size: .84rem; }
.studio-starter span { font-size: .72rem; color: var(--st-muted); line-height: 1.4; }
.studio-starter-meta { margin-top: auto; font-size: .66rem; color: var(--st-muted); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .studio-starter:hover { border-color: var(--st-accent); box-shadow: var(--st-shadow-sm); transform: translateY(-1px); } }
.studio-starter:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ---------- Checks / validation panel ---------- */
.studio-checks {
  border: 1px solid var(--st-border);
  border-left-width: 4px;
  border-radius: .75rem;
  padding: .65rem .85rem;
  margin-bottom: .85rem;
  background: var(--st-surface);
  font-size: .82rem;
}
.studio-checks--ok { border-left-color: var(--st-success); }
.studio-checks--warn { border-left-color: var(--st-warn); }
.studio-checks--error { border-left-color: var(--st-danger); }
.studio-checks-head { display: flex; align-items: center; gap: .45rem; font-weight: 700; }
.studio-checks--ok .studio-checks-head { color: #046c4e; }
.studio-checks--warn .studio-checks-head { color: var(--st-warn); }
.studio-checks--error .studio-checks-head { color: var(--st-danger); }
.studio-checks ul { margin: .4rem 0 0; padding-left: 1.2rem; color: var(--st-muted); }
.studio-checks li + li { margin-top: .15rem; }

/* ---------- Card lists (survey, quiz) ---------- */
.studio-card-list { display: flex; flex-direction: column; gap: .75rem; }
.studio-item-card {
  position: relative;
  border: 1px solid var(--st-border);
  border-radius: .85rem;
  background: var(--st-surface);
  overflow: hidden;
  transition: border-color var(--st-dur-ui) var(--st-ease-out), box-shadow var(--st-dur-ui) var(--st-ease-out);
}
.studio-item-card:focus-within { border-color: var(--st-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-accent) 12%, transparent); }
@media (hover: hover) { .studio-item-card:hover { box-shadow: var(--st-shadow-sm); } }
.studio-item-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .55rem .75rem .5rem .9rem;
  border-bottom: 1px solid var(--st-border);
  background: var(--st-surface-raised);
}
.studio-item-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 .4rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 750;
  color: #fff;
  background: var(--st-accent);
}
.studio-item-title { font-weight: 700; font-size: .85rem; }
.studio-item-badge {
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--st-accent-dark);
  background: color-mix(in srgb, var(--st-accent) 12%, transparent);
  border-radius: 999px;
  padding: .15rem .5rem;
}
.studio-item-badge--alt { color: #956013; background: #fff4dc; }
.studio-item-actions { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.studio-item-body { padding: .75rem .9rem .9rem; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .studio-tool, .studio-tool:hover, .studio-gallery-card, .studio-gallery-card:hover,
  .studio-starter, .studio-starter:hover, .studio-btn, .studio-btn--icon, .studio-preset {
    transition: none;
    transform: none;
  }
}

/* ---------- Small screens ---------- */
@media (max-width: 575.98px) {
  .studio-hero { padding: .9rem 1rem .85rem; }
  .studio-hero-icon { width: 2.25rem; height: 2.25rem; border-radius: .7rem; }
  .studio-hero-title { font-size: 1.1rem; }
  .studio-hero-end { align-items: stretch; width: 100%; }
  .studio-pills, .studio-hero-actions { justify-content: flex-start; }
  .studio-hero--sticky { position: static; }
  .studio-toolbar { padding: .45rem .5rem; }
}

/* =====================================================================
   Certificate builder specifics (overrides the older cert-* rules in app.css)
   ===================================================================== */
.cert-studio {
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(280px, 320px);
  min-height: min(80dvh, 60rem);
  border-radius: .9rem;
  box-shadow: var(--st-shadow-sm);
}
.cert-studio-rail,
.cert-studio-inspector {
  padding: .85rem .85rem 1.2rem;
  max-height: min(80dvh, 60rem);
  background: var(--st-surface-raised);
}
.cert-studio-stage { background: transparent; }
.cert-canvas-scroll {
  padding: 1.5rem 1.25rem 2rem;
  min-height: 30rem;
  align-items: flex-start;
}
.cert-preview-fit { transition: none; }
.cert-preview-stage {
  box-shadow: 0 18px 50px rgba(15, 23, 42, .22), 0 2px 6px rgba(15, 23, 42, .12);
}
.cert-stage-host.is-drop-target .cert-stage,
.cert-stage.is-drop-target { outline: 2px dashed var(--st-accent); outline-offset: -4px; }
.cert-stage .cert-el { cursor: move; transition: outline-color 120ms ease; }
.cert-stage .cert-el:hover { outline: 1px solid color-mix(in srgb, var(--st-accent) 55%, transparent); outline-offset: 1px; }
.cert-stage .cert-el[data-locked="1"] { cursor: default; }
.cert-stage .cert-el.cert-selected {
  outline: 2px solid var(--st-accent);
  outline-offset: 0;
  overflow: visible;
  z-index: 500 !important;
}
.cert-stage .cert-el.cert-selected-locked { outline-style: dashed; }
.cert-stage .cert-el.is-dragging { opacity: .92; }
.cert-stage .cert-image-empty { transition: background 120ms ease; }
.cert-handle { display: none; }
.cert-stage-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .45rem .9rem;
  border-top: 1px solid var(--st-border);
  background: color-mix(in srgb, var(--st-surface) 88%, transparent);
  font-size: .74rem;
  color: var(--st-muted);
}
.cert-logo-preview {
  display: grid;
  place-items: center;
  height: 6rem;
  margin-bottom: .5rem;
  border: 1px dashed var(--st-border-strong);
  border-radius: .6rem;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%, transparent 75%, #f1f5f9 75%),
    linear-gradient(45deg, #f1f5f9 25%, #fff 25%, #fff 75%, #f1f5f9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.cert-logo-preview img { max-width: 90%; max-height: 90%; object-fit: contain; }
.cert-studio .file-button { cursor: pointer; }
.cert-preview-dialog { max-width: 72rem; width: min(96vw, 72rem); max-height: 92vh; overflow: auto; margin: auto; }
@media (max-width: 1200px) {
  .cert-studio { grid-template-columns: minmax(200px, 230px) minmax(0, 1fr); }
  .cert-studio-inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--st-border);
    max-height: none;
  }
}
@media (max-width: 900px) {
  .cert-studio { grid-template-columns: 1fr; min-height: 0; box-shadow: none; }
  .cert-studio-rail, .cert-studio-inspector { max-height: none; }
  .cert-canvas-scroll { min-height: 50dvh; padding: 1rem .75rem 1.5rem; }
}

/* ---------- Survey & quiz card refinements ---------- */
.builder-question-card .card-header .studio-item-actions { margin-left: auto; }
.builder-question-card .card-header .type-picker { flex: 1 1 12rem; }
.builder-question-card:focus-within { border-color: var(--st-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-accent) 12%, transparent); }
@media (hover: hover) { .builder-question-card:hover { box-shadow: var(--st-shadow-sm); } }
.survey-builder .studio-toolbar--card { margin-bottom: 0; }
.quiz-question-list.studio-card-list { list-style: none; padding: 0; margin: .85rem 0 0; }
.quiz-question-list.studio-card-list > li { margin: 0; }
.quiz-option { display: flex; align-items: center; gap: .5rem; padding: .3rem .4rem; border-radius: .5rem; transition: background-color var(--st-dur-ui) var(--st-ease-out); }
.quiz-option.is-correct { background: color-mix(in srgb, var(--st-success) 10%, transparent); }
.quiz-option input[type="text"], .quiz-option input:not([type]) { flex: 1; min-width: 0; }
.quiz-options { border: 1px solid var(--st-border); border-radius: .75rem; padding: .6rem .75rem .75rem; margin: .5rem 0; }
.quiz-options legend { font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--st-muted); padding: 0 .35rem; }
.quiz-options .studio-btn { margin-top: .35rem; }
.quiz-options small { display: block; margin-top: .4rem; }
