*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #1a1a2e; --panel: #16213e; --accent: #0f3460;
  --red: #e94560; --text: #e0e0e0; --muted: #8892a4;
}
body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif;
       font-size: 14px; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
nav { background: var(--panel); border-bottom: 1px solid var(--accent); padding: 0 16px;
      height: 44px; display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
nav a { color: var(--red); text-decoration: none; font-weight: 600; font-size: 14px; }
nav a:hover { text-decoration: underline; }
.nav-title { font-weight: 700; font-size: 16px; }
.nav-status { margin-left: auto; font-size: 11px; color: var(--muted); }
.main { display: flex; flex: 1; overflow: hidden; }
.sidebar { width: 290px; background: var(--panel); border-right: 1px solid var(--accent);
           overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; flex-shrink: 0; }
.canvas-area { flex: 1; position: relative; overflow: hidden; }
h3 { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
input[type="text"] { width: 100%; background: var(--bg); border: 1px solid var(--accent);
                     border-radius: 6px; padding: 8px 10px; color: var(--text); font-size: 16px;
                     font-weight: 700; letter-spacing: 0.04em; outline: none; transition: border-color 0.2s; }
input[type="text"]:focus { border-color: var(--red); }
select { width: 100%; padding: 7px 10px; border: 1px solid var(--accent); border-radius: 6px;
         background: var(--bg); color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s; }
select:focus { border-color: var(--red); }
select option { background: var(--bg); color: var(--text); }
/* Mode picker (icon buttons) */
.mode-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mode-btn {
  padding: 10px 4px; background: #1a2a4a; border: 2px solid var(--accent);
  border-radius: 8px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 4px; font-size: 10px; color: var(--muted);
  transition: all 0.2s; text-align: center;
}
.mode-btn:hover { border-color: #1f5099; color: #fff; }
.mode-btn.active { border-color: var(--red); color: #fff; background: rgba(233,69,96,0.12); }
.mode-btn svg { width: 40px; height: 30px; }
.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-row input[type="range"] {
  flex: 1; -webkit-appearance: none; height: 4px; border-radius: 2px;
  background: #0f3460; outline: none; cursor: pointer;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--red); cursor: pointer;
}
.slider-row input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: none;
  background: var(--red); cursor: pointer;
}
.slider-val { min-width: 38px; text-align: right; color: var(--red); font-size: 13px; font-weight: 600; cursor: text; }
.slider-val-input {
  width: 48px; background: rgba(233,69,96,0.1); border: none; border-radius: 4px;
  color: var(--red); font-size: 13px; font-weight: 600; text-align: right;
  outline: none; padding: 1px 4px; font-family: inherit; -moz-appearance: textfield;
}
.slider-val-input::-webkit-inner-spin-button,
.slider-val-input::-webkit-outer-spin-button { display: none; }
.toggle-row { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.toggle-row input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--red); cursor: pointer; }
.toggle-row label { margin: 0; cursor: pointer; color: var(--text); }
.btn { display: block; width: 100%; padding: 10px; border: none; border-radius: 8px;
       cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.15s; }
.btn + .btn { margin-top: 6px; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #ff5a73; }
.btn-secondary { background: var(--accent); color: var(--text); }
.btn-secondary:hover { background: #1a4a80; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.separator { height: 1px; background: var(--accent); }
.notice { font-size: 10px; color: var(--muted); line-height: 1.5; }
/* Project buttons */
#projectBtns { display: flex; gap: 8px; }
.project-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; background: #1a2a4a; border: 1px solid var(--accent);
  border-radius: 8px; color: var(--muted); cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.project-btn:hover { background: var(--accent); color: #fff; border-color: #1f5099; }
.project-btn-icon { font-size: 18px; line-height: 1; }
.project-btn-label { font-size: 11px; font-weight: 500; }
/* SVG upload zone */
.svg-upload-zone {
  border: 2px dashed var(--accent); border-radius: 8px; padding: 20px;
  text-align: center; cursor: pointer; transition: all 0.2s;
  color: var(--muted); font-size: 12px;
}
.svg-upload-zone:hover, .svg-upload-zone.dragover { border-color: var(--red); color: var(--red); }
.svg-upload-zone.has-file { border-color: var(--red); border-style: solid; }
/* Radio group */
.radio-group { display: flex; gap: 4px; align-items: stretch; }
.radio-group label {
  flex: 1; padding: 6px 6px; border: 1px solid var(--accent);
  border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: 500;
  text-transform: none; color: var(--muted); transition: all 0.2s;
  /* Center text both horizontally and vertically so labels that wrap to 2
     lines (e.g. "Без крепежа") align with single-line neighbours. */
  display: flex; align-items: center; justify-content: center; text-align: center;
  line-height: 1.2; min-height: 30px;
}
.radio-group input[type="radio"] { display: none; }
.radio-group input[type="radio"]:checked + label {
  background: var(--red); border-color: var(--red); color: #fff;
}
/* Color swatches — wrap to multiple rows so all swatches are visible at
   once. Earlier we used a horizontal-scroll carousel but users couldn't
   tell the row was scrollable, so half the colors were unreachable.
   flex-wrap keeps circles at a fixed 28px (no squish) and shows every
   swatch above the fold. */
.color-swatches {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px; margin-bottom: 8px;
  padding: 4px 2px 6px 2px;
  align-items: center;
  flex-shrink: 0;
}
.color-swatch {
  flex: 0 0 28px;
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: all 0.2s; outline: none;
}
.color-swatch:hover { border-color: var(--muted); }
.color-swatch.active { border-color: var(--red); box-shadow: 0 0 0 2px rgba(233,69,96,0.4); }
/* Case buttons */
.case-buttons { display: flex; gap: 4px; margin-top: 4px; }
.case-btn {
  flex: 1; padding: 5px 6px; border: 1px solid var(--accent); border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer; text-align: center; transition: all 0.2s; font-family: inherit;
}
.case-btn:hover { border-color: var(--red); color: var(--red); }
.case-btn.active { background: var(--red); border-color: var(--red); color: #fff; }
/* Font picker */
.font-row { display: flex; gap: 6px; }
.font-row .weight-select { width: 110px; flex-shrink: 0; }
.font-picker { position: relative; flex: 1; min-width: 0; }
.font-picker-display {
  width: 100%; padding: 7px 28px 7px 10px; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 14px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-sizing: border-box;
  transition: border-color 0.2s; position: relative;
}
.font-picker-display::after {
  content: '\25BE'; position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: #8888aa; pointer-events: none;
}
.font-picker-display:hover, .font-picker.open .font-picker-display { border-color: var(--red); }
.font-picker-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; margin-top: 2px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 1000; overflow: hidden;
}
.font-picker.open .font-picker-dropdown { display: block; }
.font-picker-search {
  width: 100%; padding: 8px 10px; border: none; border-bottom: 1px solid var(--accent);
  background: var(--bg); color: var(--text); font-size: 13px; outline: none; box-sizing: border-box;
}
.font-picker-search::placeholder { color: #556; }
.font-picker-cats { display: flex; gap: 3px; padding: 6px 6px 4px; flex-wrap: wrap; }
.font-picker-cat {
  padding: 2px 7px; border: 1px solid var(--accent); border-radius: 10px;
  background: transparent; color: #8888aa; font-size: 11px; cursor: pointer;
  white-space: nowrap; transition: all 0.15s;
}
.font-picker-cat:hover { color: var(--text); border-color: #335; }
.font-picker-cat.active { background: var(--red); border-color: var(--red); color: #fff; }
.font-picker-list {
  max-height: 280px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--accent) transparent;
}
.font-picker-list::-webkit-scrollbar { width: 6px; }
.font-picker-list::-webkit-scrollbar-track { background: transparent; }
.font-picker-list::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }
.font-picker-item {
  padding: 5px 10px; cursor: pointer; font-size: 13px; color: #ccc;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.font-picker-item:hover { background: #1a2744; color: #fff; }
.font-picker-item.selected { background: var(--red); color: #fff; }
.font-picker-empty { padding: 12px 10px; color: #556; font-size: 12px; text-align: center; }
/* Upload button — matches namecraft: full-width, uppercase, prominent. */
.upload-btn {
  display: block; width: 100%; padding: 10px 12px; background: var(--accent); border: 1px solid var(--accent);
  border-radius: 6px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; cursor: pointer; text-align: center; transition: all 0.2s; box-sizing: border-box;
}
.upload-btn:hover { background: var(--red); border-color: var(--red); color: #fff; }
#fontUpload, #fontUpload2 { display: none; }
/* Language toggle */
.lang-toggle {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
}
.lang-toggle span {
  font-size: 12px; color: #556; cursor: pointer; padding: 2px 6px;
  border-radius: 4px; transition: all 0.2s; user-select: none;
}
.lang-toggle span.active { color: var(--red); font-weight: 700; }
.lang-toggle span:hover { color: var(--red); }
/* View tools */
#view-tools {
  position: absolute; top: 14px; right: 14px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 5; user-select: none;
}
.view-btn {
  border: 1px solid #0f3460; background: rgba(18,33,62,0.88); color: #c8d4e6;
  border-radius: 8px; height: 30px; min-width: 40px; padding: 0 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px; cursor: pointer; transition: all 0.2s;
}
.view-btn:hover { border-color: #e94560; color: #fff; }
.view-btn.active { border-color: #e94560; background: rgba(233,69,96,0.18); color: #e94560; }
#viewGrid { display: grid; grid-template-columns: repeat(3, 40px); gap: 6px; justify-content: end; }
#viewGrid [data-view="bottom"] { grid-column: 2; }
#fitViewBtn { width: 132px; justify-self: end; }
#screenshotBtn { width: 132px; font-size: 14px; }
/* Overlays */
#loading-overlay {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; background: rgba(26,26,46,0.75); z-index: 12;
  pointer-events: none; color: var(--red); font-size: 13px; text-align: center;
}
#loading-overlay.visible { display: flex; }
#loading-overlay::before {
  content: ''; width: 32px; height: 32px;
  border: 3px solid rgba(233,69,96,0.3); border-top-color: var(--red);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
#regen-overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(26,26,46,0.45); z-index: 11; pointer-events: none;
}
#regen-overlay.active { display: flex; }
#regen-overlay::after {
  content: ''; width: 28px; height: 28px;
  border: 3px solid rgba(233,69,96,0.3); border-top-color: var(--red);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#error-msg {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #c73e54; color: #fff; padding: 8px 16px; border-radius: 6px;
  font-size: 13px; display: none; z-index: 20;
}
#export-notice {
  position: absolute; bottom: 56px; left: 50%; transform: translateX(-50%);
  background: #b8890a; color: #fff; padding: 8px 32px 8px 14px; border-radius: 6px;
  font-size: 12px; max-width: 360px; text-align: center; z-index: 20;
  white-space: normal; line-height: 1.4;
}
#export-notice-close {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0;
}
/* Pattern parameter containers */
.pattern-params { margin-top: 8px; }
/* Mode section visibility */
.mode-section { display: none; }
.mode-section.active { display: block; }
/* Author link */
.author-link { color: #8892a4; text-decoration: underline; transition: color 0.15s; }
.author-link:hover { color: #e94560; }
