/* ==========================================================================
   Stampzio — design system
   Mobile-first. Teal accent on a clean neutral canvas.
   ========================================================================== */

:root {
  --accent:        #0d9488;
  --accent-dark:   #0f766e;
  --accent-darker: #115e59;
  --accent-light:  #ccfbf1;
  --accent-tint:   #f0fdfa;

  --ink:      #0f172a;
  --ink-soft: #334155;
  --muted:    #64748b;
  --line:     #e2e8f0;
  --line-soft:#eef2f6;
  --bg:       #ffffff;
  --surface:  #f8fafc;
  --surface-2:#f1f5f9;

  --danger:  #dc2626;
  --success: #16a34a;

  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.10);
  --shadow-md: 0 4px 6px rgba(15,23,42,.05), 0 10px 24px rgba(15,23,42,.08);
  --shadow-lg: 0 20px 45px rgba(15,23,42,.13);

  --maxw: 1160px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.18; color: var(--ink); font-weight: 700; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); letter-spacing: -.015em; }
h3 { font-size: 1.18rem; }
p { color: var(--ink-soft); }
ul { padding: 0; list-style: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 1000;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  transition: top .15s;
}
.skip-link:focus { top: 8px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: inherit; font-weight: 600; line-height: 1;
  padding: .82em 1.35em; border-radius: 999px; border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; transition: transform .08s, box-shadow .15s, background .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: #fff; color: var(--accent-dark); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--accent); background: var(--accent-tint); }
.btn--light { background: rgba(255,255,255,.16); color:#fff; border-color: rgba(255,255,255,.4); }
.btn--light:hover { background: rgba(255,255,255,.26); }
.btn--block { display: flex; width: 100%; }
.btn--lg { font-size: 1.06rem; padding: 1em 1.7em; }
.btn--sm { padding: .5em .9em; font-size: .86rem; }

/* ---- header / nav ---- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255,255,255,.9); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent-dark); font-weight: 800; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); flex: none; }
.brand-name { font-size: 1.25rem; letter-spacing: -.02em; color: var(--ink); }
.primary-nav { margin-inline-start: auto; display: flex; align-items: center; gap: 22px; }
.primary-nav > ul { display: flex; align-items: center; gap: 4px; }
.primary-nav a {
  color: var(--ink-soft); font-weight: 600; font-size: .96rem;
  padding: 8px 12px; border-radius: 8px; display: inline-block;
}
.primary-nav a:hover { color: var(--accent-dark); background: var(--accent-tint); text-decoration: none; }
.primary-nav a[aria-current="page"] { color: var(--accent-dark); background: var(--accent-tint); }

.lang-switch { display: inline-flex; gap: 2px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.lang-opt { font-size: .82rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; color: var(--muted); }
.lang-opt:hover { color: var(--accent-dark); text-decoration: none; }
.lang-opt.is-active { background: #fff; color: var(--accent-dark); box-shadow: var(--shadow-sm); }

.nav-toggle { display: none; }

/* ---- sections ---- */
.section { padding: clamp(48px, 7vw, 88px) 0; }
.section--surface { background: var(--surface); }
.section--tint { background: var(--accent-tint); }
.section-head { text-align: center; max-width: 720px; margin: 0 auto clamp(28px, 4vw, 52px); }
.section-head p { font-size: 1.08rem; color: var(--muted); margin-top: 12px; }
.eyebrow { color: var(--accent-dark); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; }

/* ---- hero ---- */
.hero { position: relative; overflow: hidden; background:
   radial-gradient(1200px 500px at 80% -10%, var(--accent-tint), transparent 60%),
   radial-gradient(900px 500px at 0% 0%, #eff6ff, transparent 55%); }
.hero-inner { display: grid; gap: 34px; padding: clamp(34px, 6vw, 70px) 0 clamp(30px, 5vw, 56px); }
.hero-copy { text-align: center; max-width: 760px; margin-inline: auto; }
.hero-copy h1 { margin-bottom: 18px; }
.hero-lead { font-size: clamp(1.05rem, 2.2vw, 1.28rem); color: var(--ink-soft); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 26px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; margin-top: 24px; }
.badge { display: inline-flex; align-items: center; gap: 7px; font-size: .9rem; font-weight: 600; color: var(--ink-soft); }
.badge svg { color: var(--accent); flex: none; }

/* ==========================================================================
   Layer editor (v2)
   ========================================================================== */
.editor {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; max-width: 1120px; margin-inline: auto;
}
.editor__toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.add-menu { display: flex; flex-wrap: wrap; gap: 7px; }
.add-btn {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px;
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--ink-soft); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; transition: .12s;
}
.add-btn:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-tint); }
.add-btn span { color: var(--accent); font-weight: 800; }

.editor__body { display: grid; grid-template-columns: 1fr; }
.editor__col { padding: 16px; }
.editor__layers { border-bottom: 1px solid var(--line); }
.editor__props-pane { border-top: 1px solid var(--line); background: var(--surface); }
.col-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 800; margin-bottom: 10px; }

/* layer list */
.layer-list { display: flex; flex-direction: column; gap: 6px; }
.layer {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; cursor: pointer; transition: .12s;
}
.layer:hover { border-color: var(--accent); }
.layer.is-sel { border-color: var(--accent); background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); }
.layer__type { flex: none; width: 24px; height: 24px; display: grid; place-items: center; background: var(--surface-2); border-radius: 6px; font-weight: 800; font-size: .72rem; color: var(--accent-dark); }
.layer__name { flex: 1; min-width: 0; font-size: .88rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* actions appear only on the hovered / selected layer, so names get the full row */
.layer__actions { display: none; gap: 1px; flex: none; }
.layer:hover .layer__actions,
.layer:focus-within .layer__actions,
.layer.is-sel .layer__actions { display: flex; }
.layer__btn { border: 0; background: transparent; width: 22px; height: 22px; border-radius: 5px; cursor: pointer; color: var(--muted); font-size: .74rem; display: grid; place-items: center; }
.layer__btn:hover { background: var(--surface-2); color: var(--accent-dark); }
.layer__btn:disabled { opacity: .3; cursor: default; }
.layer__btn--del:hover { background: #fee2e2; color: var(--danger); }
/* stacked full-width buttons: labels never truncate in the narrow column */
.stage-actions { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 14px; }

/* canvas + ruler */
.editor__canvas { display: grid; grid-template-columns: 20px 1fr; grid-template-rows: 20px 1fr auto; max-width: 460px; margin-inline: auto; width: 100%; }
.ruler-corner { grid-area: 1 / 1; background: var(--surface-2); border-radius: 4px 0 0 0; }
.ruler { background: var(--surface-2); overflow: hidden; }
.ruler--x { grid-area: 1 / 2; }
.ruler--y { grid-area: 2 / 1; }
.canvas-stage {
  grid-area: 2 / 2; padding: 10px;
  background:
    linear-gradient(0deg, transparent 0, transparent calc(100% - 1px), rgba(15,23,42,.05) 100%),
    linear-gradient(90deg, rgba(15,23,42,.05) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(0deg, rgba(15,23,42,.05) 1px, transparent 1px) 0 0 / 16px 16px,
    #fff;
  border: 1px solid var(--line);
}
.editor__preview { width: 100%; aspect-ratio: 1 / 1; display: grid; place-items: center; touch-action: none; filter: drop-shadow(0 6px 14px rgba(15,23,42,.12)); }
.editor__preview svg { width: 100%; height: 100%; cursor: grab; }
.editor__preview svg [data-lid] { cursor: grab; }
.size-readout { grid-area: 3 / 1 / 4 / 3; text-align: center; margin-top: 12px; font-weight: 600; color: var(--ink-soft); font-size: .9rem; }
.size-readout b { color: var(--accent-dark); font-variant-numeric: tabular-nums; }

/* properties panel */
.props { display: block; }
.props__title { font-size: 1rem; font-weight: 800; color: var(--ink); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.props__delete { margin-top: 6px; color: var(--danger); border-color: #fecaca; }
.props__delete:hover { background: #fef2f2; border-color: var(--danger); }
.toggles { display: flex; gap: 8px; }
.toggle-btn { width: 40px; height: 36px; border: 1.5px solid var(--line); background: #fff; border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem; color: var(--ink-soft); }
.toggle-btn.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pos-hint .hint { font-size: .8rem; color: var(--muted); background: var(--accent-tint); padding: 8px 10px; border-radius: 8px; }

.export-box { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }

.field { margin-bottom: 16px; }
.field > label, .field-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 7px; color: var(--ink); }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.control-row { display: flex; align-items: center; gap: 12px; }
.control-row .value { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; min-width: 42px; text-align: end; }

input[type="text"], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink);
  padding: .6em .7em; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
input[type="text"]:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-light); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: .92rem; cursor: pointer; }

/* choice chips (shapes, fonts, separators) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px;
  font: inherit; font-size: .86rem; font-weight: 600; color: var(--ink-soft); cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* shape picker grid */
.shape-grid, .icon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.shape-opt, .icon-opt {
  border: 1.5px solid var(--line); background: #fff; border-radius: var(--radius-sm); padding: 10px 4px;
  cursor: pointer; display: grid; place-items: center; gap: 5px; color: var(--ink-soft); transition: .12s;
  font-size: .72rem; font-weight: 600;
}
.shape-opt:hover, .icon-opt:hover { border-color: var(--accent); color: var(--accent-dark); }
.shape-opt.is-active, .icon-opt.is-active { border-color: var(--accent); background: var(--accent-tint); color: var(--accent-dark); box-shadow: inset 0 0 0 1px var(--accent); }
.shape-opt svg, .icon-opt svg { width: 26px; height: 26px; }

/* color swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; }
.swatch.is-active { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px var(--accent-light); }

/* center-line rows */
.line-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.line-row input { flex: 1; }
.line-row .icon-btn { flex: none; }
.icon-btn { border: 1.5px solid var(--line); background: #fff; border-radius: 8px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { border-color: var(--accent); color: var(--accent-dark); }

/* stacked: the props pane is narrow and "Download SVG" must never clip */
.export-formats { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 6px; }

/* ---- feature cards ---- */
.grid { display: grid; gap: 18px; }
.grid--3 { grid-template-columns: 1fr; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card__icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-tint); color: var(--accent-dark); margin-bottom: 14px; }
.card__icon svg { width: 24px; height: 24px; }
.card h3 { margin-bottom: 7px; }
.card p { font-size: .96rem; color: var(--muted); }

/* ---- steps ---- */
.steps { display: grid; gap: 16px; grid-template-columns: 1fr; counter-reset: step; }
.step { display: flex; gap: 16px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.step__num { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; display: grid; place-items: center; }
.step h3 { font-size: 1.05rem; margin-bottom: 4px; }
.step p { font-size: .93rem; color: var(--muted); }

/* ---- template cards ---- */
.tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.tpl-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: .15s; display: flex; flex-direction: column; min-width: 0; }
.tpl-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.tpl-card:hover { text-decoration: none; }
.tpl-card__thumb { aspect-ratio: 1/1; display: grid; place-items: center; background: var(--surface); padding: 18px; min-width: 0; overflow: hidden; }
.tpl-card__thumb svg { width: 82%; height: 82%; }
.tpl-card__body { padding: 14px 16px 18px; border-top: 1px solid var(--line-soft); }
.tpl-card__body h3 { font-size: 1rem; color: var(--ink); }
.tpl-card__body p { font-size: .84rem; color: var(--muted); margin-top: 3px; }

/* ---- use cases ---- */
.uc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.uc { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 15px 16px; font-weight: 600; color: var(--ink); }
.uc svg { color: var(--accent); flex: none; width: 22px; height: 22px; }

/* ---- FAQ accordion ---- */
.faq { max-width: 820px; margin-inline: auto; display: grid; gap: 10px; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.faq summary { cursor: pointer; padding: 16px 18px; font-weight: 700; color: var(--ink); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; color: var(--accent); font-weight: 400; line-height: 1; }
.faq details[open] summary::after { content: "\2212"; }
.faq details[open] summary { color: var(--accent-dark); }
.faq .faq__a { padding: 0 18px 18px; color: var(--ink-soft); font-size: .96rem; }

/* ---- CTA band ---- */
.cta-band { background: linear-gradient(120deg, var(--accent-dark), var(--accent)); color: #fff; border-radius: var(--radius-lg); padding: clamp(32px, 5vw, 56px); text-align: center; }
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.9); margin: 12px auto 24px; max-width: 560px; }

/* ---- article / prose ---- */
.page-hero { padding: clamp(34px, 5vw, 60px) 0 0; }
.page-hero h1 { max-width: 820px; }
.page-hero .lead { font-size: 1.14rem; color: var(--muted); margin-top: 14px; max-width: 720px; }
.breadcrumbs { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent-dark); }

.prose { max-width: 760px; margin-inline: auto; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.5em; }
.prose p, .prose li { color: var(--ink-soft); }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
.prose ul { list-style: disc; } .prose ol { list-style: decimal; }
.prose li + li { margin-top: .4em; }
.prose a { color: var(--accent-dark); text-decoration: underline; }
.prose blockquote { border-inline-start: 4px solid var(--accent); background: var(--accent-tint); padding: 12px 18px; border-radius: 8px; color: var(--ink-soft); }
.prose table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 9px 12px; text-align: start; }
.prose th { background: var(--surface); }
.note { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--accent); border-radius: 8px; padding: 14px 16px; font-size: .92rem; }

/* ---- blog list ---- */
.post-list { display: grid; grid-template-columns: 1fr; gap: 18px; }
.post-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); transition: .15s; }
.post-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.post-card__tag { font-size: .74rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-dark); }
.post-card h3 { margin: 8px 0 6px; font-size: 1.2rem; }
.post-card h3 a { color: var(--ink); }
.post-card p { font-size: .95rem; color: var(--muted); }
.post-meta { font-size: .82rem; color: var(--muted); margin-top: 12px; display: flex; gap: 12px; }

/* ---- forms ---- */
.form { max-width: 620px; }
.form .field { margin-bottom: 18px; }
.form-note { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .92rem; margin-bottom: 18px; }
.form-note--ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.form-note--err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ---- footer ---- */
.site-footer { background: var(--ink); color: #cbd5e1; padding: clamp(40px, 5vw, 60px) 0 28px; margin-top: 20px; }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 32px; }
.footer-brand .brand-name { color: #fff; }
.footer-brand .brand-mark { color: var(--accent); }
.footer-about { color: #94a3b8; font-size: .92rem; margin-top: 12px; max-width: 40ch; }
.footer-col h2 { color: #fff; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 12px; }
.footer-col a { color: #cbd5e1; font-size: .95rem; display: inline-block; padding: 4px 0; }
.footer-col a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); margin-top: 34px; padding-top: 20px; display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: space-between; }
.footer-bottom p { color: #94a3b8; font-size: .84rem; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (min-width: 620px) {
  .grid--3 { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
  .post-list { grid-template-columns: 1fr 1fr; }
  .tpl-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .steps { grid-template-columns: repeat(4, 1fr); }
  .uc-grid { grid-template-columns: repeat(3, 1fr); }
  .tpl-grid { grid-template-columns: repeat(4, 1fr); }
  .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
@media (min-width: 960px) {
  .editor__body { grid-template-columns: 264px minmax(0, 1fr) 316px; align-items: stretch; }
  .editor__layers { border-bottom: 0; border-inline-end: 1px solid var(--line); }
  .editor__props-pane { border-top: 0; border-inline-start: 1px solid var(--line); }
  .editor__canvas { position: sticky; top: 74px; align-self: start; }
}

/* ---- mobile nav ---- */
@media (max-width: 899px) {
  .nav-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
    margin-inline-start: auto; width: 44px; height: 44px; border: 1px solid var(--line);
    background: #fff; border-radius: 10px; cursor: pointer; padding: 0 11px;
  }
  .nav-toggle span { height: 2px; background: var(--ink); border-radius: 2px; transition: .2s; }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .primary-nav {
    position: fixed; inset: 64px 0 auto 0; margin: 0; flex-direction: column; align-items: stretch; gap: 0;
    background: #fff; border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lg);
    padding: 10px 20px 20px; max-height: calc(100vh - 64px); overflow-y: auto;
    transform: translateY(-8px); opacity: 0; visibility: hidden; transition: .18s;
  }
  .primary-nav.is-open { transform: none; opacity: 1; visibility: visible; }
  .primary-nav > ul { flex-direction: column; align-items: stretch; gap: 2px; }
  .primary-nav a { padding: 12px 10px; font-size: 1.02rem; }
  .lang-switch { margin-top: 12px; align-self: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---- template gallery filters ---- */
.tpl-filters { display: flex; flex-direction: column; gap: 14px; margin-bottom: 26px; }
.tpl-search { max-width: 380px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.filter-row .chips { gap: 6px; }
.tpl-empty { text-align: center; color: var(--muted); padding: 50px 0; font-weight: 600; }

input[type="search"] {
  font: inherit; font-size: .95rem; color: var(--ink);
  padding: .55em .8em; border: 1.5px solid var(--line); border-radius: 999px; background: #fff;
}
input[type="search"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-light); }

/* ---- gallery card actions ---- */
.tpl-card__main { display: block; }
.tpl-card__main:hover { text-decoration: none; }
.tpl-card__links { display: flex; gap: 8px; margin-top: 12px; }
.tpl-card__links .btn { flex: 1; padding: .5em .4em; font-size: .8rem; }

/* ---- in-editor template picker modal ---- */
body.modal-open { overflow: hidden; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-modal { position: fixed; inset: 0; z-index: 300; display: none; }
.tpl-modal.is-open { display: block; }
.tpl-modal__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); }
.tpl-modal__panel {
  position: relative; margin: 4vh auto; width: min(980px, 94vw); max-height: 92vh;
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.tpl-modal__head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.tpl-modal__head h2 { font-size: 1.15rem; margin-inline-end: auto; }
.tpl-modal__search { width: min(240px, 100%); }
.tpl-modal__filters { padding: 12px 20px; border-bottom: 1px solid var(--line-soft); gap: 6px; }
.tpl-modal__grid {
  padding: 16px 20px 24px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px;
}
.tpl-pick {
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  cursor: pointer; padding: 10px 8px; display: grid; gap: 8px; font: inherit; transition: .12s;
  min-width: 0; /* let the grid track shrink below the SVG's intrinsic 300px */
}
.tpl-pick:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.tpl-pick__thumb { display: grid; place-items: center; aspect-ratio: 1 / 1; width: 100%; min-width: 0; overflow: hidden; }
.tpl-pick__thumb svg { width: 100%; height: 100%; }
.tpl-pick__name { font-size: .78rem; font-weight: 600; color: var(--ink); text-align: center; line-height: 1.3; }
.tpl-modal__empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 30px 0; font-weight: 600; }
