@media (max-width: 600px) {
  .navbar-title {
    display: none;
  }
}
@font-face {
font-family: 'Lab Grotesque';
font-style: normal;
font-weight: 100;
font-display: swap;
src: url(../fonts/labgrotesque-thin.woff2) format('woff2'),
url(../fonts/labgrotesque-thin.woff) format('woff');
}

@font-face {
font-family: 'Lab Grotesque';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(../fonts/labgrotesque-light.woff2) format('woff2'),
url(../fonts/labgrotesque-light.woff) format('woff');
}

@font-face {
font-family: 'Lab Grotesque';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../fonts/labgrotesque-regular.woff2) format('woff2'),
url(../fonts/labgrotesque-regular.woff) format('woff');
}

@font-face {
font-family: 'Lab Grotesque';
font-style: normal;
font-weight: 500;
font-display: swap;
src: url(../fonts/labgrotesque-medium.woff2) format('woff2'),
url(../fonts/labgrotesque-medium.woff) format('woff');
}

@font-face {
font-family: 'Lab Grotesque';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(../fonts/labgrotesque-bold.woff2) format('woff2'),
url(../fonts/labgrotesque-bold.woff) format('woff');
}

@font-face {
font-family: 'Lab Grotesque';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(../fonts/labgrotesque-bold.woff2) format('woff2'),
url(../fonts/labgrotesque-bold.woff) format('woff');
}

@font-face {
font-family: 'Lab Grotesque';
font-style: normal;
font-weight: 900;
font-display: swap;
src: url(../fonts/labgrotesque-black.woff2) format('woff2'),
url(../fonts/labgrotesque-black.woff) format('woff');
}
:root {
  --bg: #f5f5f7;
  --text: #111;
  --surface: #fff;
  --accent: #0a84ff;
  --border: #ddd;
  --mask-active: #0a84ff;
  --navbar-bg: #ffffff;
  --btn-hover-bg: #e0e0e0;
  --btn-hover-shadow: 0 2px 8px rgba(0,0,0,0.12);
  --btn-active-bg: #d0d0d0;
  --btn-active-shadow: 0 1px 4px rgba(0,0,0,0.2);
  --input-bg: #ffffff;
  --gradient-speed: 3s;
  --gradient-blur: 10px;
  --border-width: 2px;
}

.dark-theme {
  --bg: #1c1c1e;
  --text: #fff;
  --surface: #2c2c2e;
  --border: #444;
  --navbar-bg: #1c1c1e;
  --btn-hover-bg: #3a3a3c;
  --btn-hover-shadow: 0 2px 8px rgba(255,255,255,0.08);
  --btn-active-bg: #4a4a4c;
  --btn-active-shadow: 0 1px 4px rgba(255,255,255,0.15);
  --input-bg: #3a3a3c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

/* ===== ОБЩИЕ КНОПКИ ===== */
.btn, button {
  border-radius: 999px;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
  position: relative;
  z-index: 0;
}
.btn:hover, button:hover {
  background: var(--btn-hover-bg);
  box-shadow: var(--btn-hover-shadow);
}
.btn:active, button:active {
  background: var(--btn-active-bg);
  box-shadow: var(--btn-active-shadow);
  transform: translateY(1px);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover { background: #0a7ae0; }
.btn-accent:active { background: #0969c7; }

input[type="text"], select { border-radius: 999px; }

/* ===== ГРАДИЕНТНАЯ ОБВОДКА ===== */
.gradient-border::before {
  content: '';
  position: absolute;
  inset: calc(var(--border-width) * -1);
  background: linear-gradient(90deg, #FC5630 0%, #BB88EC 25%, #61D9C7 50%, #4F7DF5 75%, #FC5630 100%);
  background-size: 400% 100%;
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s;
  animation: gradientMove var(--gradient-speed) linear infinite paused;
}
.gradient-border:hover::before { opacity: 1; animation-play-state: running; }
@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  100% { background-position: 400% 50%; }
}

.glow-export::after {
  content: '';
  position: absolute;
  inset: calc(var(--border-width) * -1 - 6px);
  background: linear-gradient(90deg, #FC5630 0%, #BB88EC 25%, #61D9C7 50%, #4F7DF5 75%, #FC5630 100%);
  background-size: 400% 100%;
  border-radius: inherit;
  z-index: -2;
  filter: blur(var(--gradient-blur));
  opacity: 0;
  transition: opacity 0.3s;
  animation: gradientMove var(--gradient-speed) linear infinite paused;
}
.glow-export:hover::after { opacity: 0.65; animation-play-state: running; }

/* ===== НАВБАР ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}
.navbar-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.navbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.navbar-brand { display: inline-flex; align-items: center; flex-shrink: 0; }
.navbar-logo { height: 30px; width: auto; display: block; }
.navbar-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.theme-toggle { position: relative; width: 72px; height: 36px; padding: 3px;
  border: 1px solid var(--border); border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-around; background: var(--input-bg); }
.theme-toggle > span:not(.theme-thumb) { z-index: 1; width: 28px; font-size: 21px; line-height: 1; }
.theme-thumb { position: absolute; left: 3px; top: 3px; width: 28px; height: 28px;
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 5px #0002; transition: transform .2s; }
.theme-toggle[aria-checked="true"] .theme-thumb { transform: translateX(36px); }
.theme-toggle .theme-sun { color: #a15a00; }
.theme-toggle .theme-moon { color: var(--text); }
.dark-theme .theme-toggle .theme-sun { color: #ffd06a; }

/* ===== ГЛАВНАЯ ===== */
.page { display: none; width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px; }
.page.active { display: block; }
.hero { text-align: center; padding: clamp(28px, 6vw, 72px) 20px 36px; margin: 0 auto 28px; max-width: 900px; }
.hero-eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .2em; color: var(--accent); }
.hero h1 { font-size: clamp(1.85rem, 4vw, 3.3rem); line-height: 1.12; letter-spacing: -.04em; margin: 16px 0 20px; }
.hero-description { max-width: 660px; margin: 0 auto; line-height: 1.65; color: var(--muted); font-size: 1.05rem; }
.hero-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
.hero-tags span { padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: .8rem; background: var(--surface); }
.catalog-heading { font-size: 1.35rem; margin: 0 0 20px; letter-spacing: -.02em; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 0;
}
@media (min-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.template-card {
  aspect-ratio: 12 / 5;
  height: auto;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.3s;
  position: relative;
  z-index: 0;
  overflow: hidden;
}
.template-card:hover { transform: translateY(-2px); border-color: transparent; }
.template-card svg { width: 100%; height: 100%; display: block; border-radius: inherit; }

/* ===== РЕДАКТОР ===== */
.editor-page { display: flex; flex-direction: column; align-items: center; }
.editor-page.active { display: flex; }
.editor-vertical { display: flex; flex-direction: column; gap: 24px; align-items: stretch; }
.editor-main { background: var(--surface); padding: clamp(12px, 2.5vw, 28px); border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; min-width: 0; width: 100%; overflow: visible; border: 1px solid var(--border); }
#previewContainer { width: 100%; max-width: 1040px; }
#previewContainer svg { width: 100%; height: auto; display: block; }
.editor-panel { display: grid; grid-template-columns: 1fr; gap: 20px; padding: 0; background: none; border: 0; border-radius: 0;
  width: 100%; min-width: 0; align-items: start; overflow: visible; }
@media (min-width: 800px) { .editor-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .editor-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* ===== МАСКИ ===== */
.mask-outline { stroke: #888; stroke-width: 2; stroke-dasharray: 4 2; pointer-events: none; fill: none; }
.mask-wrapper.active .mask-outline { stroke: var(--mask-active); stroke-dasharray: none; stroke-width: 3; }
.mask-wrapper:hover .mask-outline { stroke: var(--mask-active); stroke-dasharray: none; }
.editor-panel fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px; width: 100%; }
.editor-panel input[type="range"] { width: 100%; }
.char-counter { font-size: 0.8rem; color: var(--accent); margin-left: 8px; }

/* ===== ДОПОЛНИТЕЛЬНЫЕ СТИЛИ ===== */
.mask-select {
  width: 100%; padding: 12px 16px; font-size: 1rem; border-radius: 12px;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text); margin-bottom: 12px;
}
.tool-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mask-tools button { margin: 4px 0; }
.field-group .color-row { margin-left: 8px; }
.field-group .color-row { margin-left: 8px; }

.template-folder { margin: 28px 0 42px; }
.template-folder h2 { margin: 0 0 14px; font-size: 1.35rem; }
.template-folder-empty { opacity: 0.65; padding: 18px 0; }
.mask-label { fill: var(--mask-active); font-family: 'Lab Grotesque', sans-serif; font-size: 22px; font-weight: 600; pointer-events: none; opacity: 0.8; }
.mask-wrapper:not(.active) .mask-label { opacity: 0.55; }
.mask-wrapper.drop-target .mask-outline { stroke: var(--accent); stroke-width: 5; stroke-dasharray: none; }
.emoji-picker-field { position: relative; display: flex; flex-direction: column; gap: 6px; }
.emoji-picker-button { width: 100%; justify-content: center; }
.emoji-picker-popup { position: absolute; z-index: 20; top: 54px; left: 0; width: min(330px, 90vw); max-height: 260px; overflow: auto; display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.emoji-option { min-width: 0; width: 32px; height: 32px; padding: 3px; border-radius: 7px; }
.emoji-option img { width: 100%; height: 100%; object-fit: contain; }
.inline-text-editor { position: absolute; z-index: 30; min-width: 180px; min-height: 48px; resize: both; padding: 8px; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--accent); border-radius: 8px; }
.editable-text { cursor: text; }

/* ===== СХЕМЫ И КАСТОМНЫЙ ВЫБОР ===== */
.scheme-btn { position: relative; width: 48px; height: 48px; cursor: pointer; }
.scheme-btn .upper, .scheme-btn .lower {
  border: 2px solid transparent;
  border-radius: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.scheme-btn.active .upper,
.scheme-btn.active .lower {
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}


#previewContainer { position: relative; }
.emoji-picker-popup[hidden] { display: none; }
.mask-wrapper.has-image .mask-label { opacity: 0; }
.mask-wrapper.has-image:hover .mask-label { opacity: .9; paint-order: stroke; stroke: white; stroke-width: 4px; }
.mask-wrapper { cursor: grab; }
.custom-color-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.custom-color-editor input[type=color] { width: 50px; height: 36px; border: 1px solid var(--border); border-radius: 8px; }

.template-folder summary { cursor: pointer; font-size: 1.2rem; font-weight: 600; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 16px; }

/* Unified editor controls */
:root { --muted: #60646c; --disabled: #70757e; }
.dark-theme { --muted: #b1b5bf; --disabled: #adb3c0; }
.editor-tip { margin: 16px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.5; text-align: center; }
.editor-actions { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.template-navigation, .export-actions { display: flex; gap: 8px; align-items: center; }
.template-navigation button:first-child, .template-navigation button:last-child { min-width: 44px; padding: 8px 12px; font-size: 20px; }
.export-actions { margin-left: auto; flex-wrap: wrap; }
.export-actions select { max-width: 180px; border-radius: 10px; min-height: 44px; }
.export-actions .btn-export { min-height: 44px; border-radius: 10px !important; padding: 10px 18px !important; }
.editor-panel > fieldset { margin: 0; min-width: 0; border-radius: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--border); }
.editor-panel legend { font-size: 1rem; font-weight: 650; padding: 0 8px; }
.editor-panel button, .editor-panel select, .editor-actions button { min-height: 44px; }
.editor-panel > fieldset > div:not(.scheme-grid) { min-width: 0; }
.scheme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.scheme-option { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px;
  padding: 10px 6px; border-radius: 12px !important; border: 2px solid var(--border); background: var(--surface); min-width: 0; width: 100%; }
.scheme-name { font-size: .75rem; line-height: 1.35; font-weight: 500; white-space: normal; }
.scheme-pair { position: relative; display: block; width: 44px; height: 44px; flex-shrink: 0; }
.pair-rainbow > div { background: linear-gradient(135deg, #ff4949 0%, #ffb300 20%, #f1fc00 30%, #36e23b 45%, #00c9f4 65%, #3952fb 80%, #e53beb 100%); }
.pair-rainbow > div:first-child { filter: brightness(.5); }
.pair-tone > div { background: #d1d1d1; }
.pair-tone > div:first-child { background: #7d7d7d; }
.scheme-option[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.custom-color-editor { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; font-size: .85rem; padding-top: 8px; }
.custom-color-editor input { width: 100%; min-height: 40px; border-radius: 8px; }
.image-utility { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.image-utility button { font-size: .75rem; padding: 7px 10px; margin: 0 !important; border-radius: 9px; }
.mask-select { width: 100%; margin-bottom: 10px; border-radius: 9px; }
.image-controls { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.transform-section { padding-top: 14px; border-top: 1px solid var(--border); }
.transform-section h3 { font-size: .8rem; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.position-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.transform-control { display: grid; grid-template-columns: 30px minmax(40px, 1fr) 22px; align-items: center; gap: 4px;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 9px; padding: 4px; min-width: 0; }
.scrub-label { display: grid; place-items: center; font-size: 21px; height: 34px; cursor: ew-resize; touch-action: none; user-select: none; position: relative; }
.transform-control input[type="number"] { min-width: 0; width: 100%; border: 0; border-radius: 4px; padding: 7px 2px; background: transparent; color: var(--text); font: inherit; font-size: .9rem; }
.control-unit { color: var(--muted); font-size: .7rem; }
.touch-range { display: none; grid-column: 1 / -1; width: 100%; margin: 8px 0; accent-color: var(--accent); }
.transform-buttons { display: flex; gap: 8px; margin-top: 8px; }
.icon-action { min-width: 44px; border-radius: 9px; padding: 7px 12px; position: relative; }
.icon-action[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.control-hint { margin: 10px 0 0; font-size: .75rem; line-height: 1.5; color: var(--muted); }
[data-tooltip] { position: relative; }
@media (hover: hover) {
  [data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 0;
    font: 12px/1.4 system-ui, sans-serif; color: white; background: #22252b; padding: 7px 10px; border-radius: 7px;
    width: max-content; max-width: 210px; z-index: 200; pointer-events: none; }
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .65; cursor: wait; }
@media (max-width: 600px) {
  .page { padding: 16px; }
  .navbar-content { height: 60px; }
  .hero { padding: 32px 0 24px; }
  .hero-description { font-size: .95rem; }
  .editor-actions { gap: 12px; justify-content: center; }
  .template-navigation { justify-content: center; width: 100%; }
  .export-actions { width: 100%; margin-left: 0; justify-content: center; flex-wrap: nowrap; }
  .export-actions select { flex: 1; min-width: 0; }
  .export-actions .btn-export { flex-shrink: 0; font-size: .85rem; }
  .editor-tip { font-size: .72rem; }
  .editor-panel > fieldset { padding: 18px; }
}
@media (pointer: coarse), (max-width: 600px) { .touch-range { display: block; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

@media (pointer: coarse), (max-width: 600px) {
  .transform-control:focus-within::after { content: attr(data-control-name); grid-column: 1 / -1; font-size: .72rem; color: var(--muted); padding: 2px 4px 6px; }
}

/* Compact, stateful editor controls */
.scheme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.scheme-option { min-height: 84px; padding: 7px 4px; gap: 5px; }
.scheme-pair { width: 36px; height: 36px; }
.scheme-pair > div { width: 26px !important; height: 26px !important; border-radius: 7px !important; }
.scheme-name { font-size: .68rem; line-height: 1.18; }
.scheme-option[aria-pressed="true"] { border-color: var(--accent) !important; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent); }
.scheme-option[aria-pressed="true"] .scheme-pair::after { content: '✓'; position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.text-field-input { height: 42px; min-height: 42px !important; max-height: 92px; line-height: 1.35; transition: height .15s; }
.text-field-input:focus { height: 76px; }
.editor-panel .char-counter, .editor-panel [style*="font-size: 0.8rem"] { color: var(--muted) !important; font-size: .72rem !important; }
.mask-label { font-size: 16px; font-weight: 600; opacity: .82; }
.mask-wrapper.has-image .mask-label { display: none; }
.mask-wrapper:not(.has-image) .mask-label { display: block; }
.mask-wrapper:not(.has-image) .mask-outline { stroke-dasharray: 5 4; }
.mask-wrapper.drop-target .mask-label { display: block; fill: var(--accent); font-size: 18px; opacity: 1; }
.mask-wrapper.drop-target .mask-outline { stroke-width: 5; stroke: var(--accent); filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 55%, transparent)); }
@media (max-width: 799px) { .scheme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 420px) { .scheme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
