/* styles.css — без стилей каталога */
/* Основные переменные */
:root{
  --primary: #e1ded0;
  --secondary: #4d4d4d;
  --accent: #ff416c;
  --accent-dark: #b3243d;
  --bg: #f0eee5;
  --card: #ffffff;
  --text: #000000;
  --muted: #b3ad9e;
  --light-accent: #d14966;
  --transition: all 0.25s ease;

  /* Тёмная тема — запасные значения */
  --dark-primary: #2d2d2d;
  --dark-secondary: #1a1a1a;
  --dark-accent: #ff6b8b;
  --dark-accent-dark: #d14966;
  --dark-bg: #121212;
  --dark-card: #1e1e1e;
  --dark-text: #e1ded0;
  --dark-muted: #5a5a5a;
  --dark-light-accent: #a83c56;
}

/* Тёмная тема — переопределение переменных */
body.dark-theme {
  --primary: var(--dark-primary);
  --secondary: var(--dark-secondary);
  --accent: var(--dark-accent);
  --accent-dark: var(--dark-accent-dark);
  --bg: var(--dark-bg);
  --card: var(--dark-card);
  --text: var(--dark-text);
  --muted: var(--dark-muted);
  --light-accent: var(--dark-light-accent);
}

/* Небольшие фиксы для некоторых элементов в тёмной теме */
body.dark-theme .preset-btn { color: var(--dark-text); }
body.dark-theme .glyph { background: rgba(30,30,30,0.7); color: var(--dark-text); }
body.dark-theme .font-preview { filter: invert(1); }
body.dark-theme .slider-header { color: var(--dark-text); }
body.dark-theme .feature-btn { color: var(--dark-text); }

/* Шрифты */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../public/fonts/Inter.ttf')
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../public/fonts/InterSemiBold.ttf')
}

/* Сброс и базовая типографика */
*{ box-sizing: border-box; margin:0; padding:0; font-family: 'Inter', sans-serif; }
body{
  display:flex;
  flex-direction:column;
  min-height:100vh;
  background:var(--bg);
  color:var(--text);
  line-height:1.6;
  transition: background-color .3s, color .3s;
}
.container{
  flex:1;
  display:flex;
  flex-direction:column;
  position:relative;
  overflow:hidden;
}

/* Заголовок */
.compact-header{
  background:var(--secondary);
  color:#fff;
  padding:10px 20px;
  user-select:none;
  border-bottom:1px solid var(--accent);
}
.header-content{
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  gap:15px;
}
.header-left{
  padding-left:0;
  margin-left:-5px;
  display:flex;
  align-items:center;
  gap:20px;
  width:360px;
}
.header-actions{ display:flex; align-items:center; gap:12px; }

/* Иконки в заголовке */
.btn-icon{
  background:none; border:none; color:white; cursor:pointer;
  padding:5px; display:flex; align-items:center; justify-content:center;
  border-radius:50%; transition:background .2s; width:36px; height:36px;
}
.btn-icon:hover{ background: rgba(255,255,255,0.15); }

.btn-header{
  background: rgba(255,255,255,0.15); padding:8px 15px; border-radius:20px;
  font-size:.9rem; border:none; color:white; cursor:pointer; transition:background .2s;
}
.btn-header:hover{ background: rgba(255,255,255,0.25); }

.btn-catalog{
  display:flex; align-items:center; gap:8px;
  background: rgba(255,255,255,0.15);
  padding:8px 15px; border-radius:20px; font-size:.9rem; border:none;
  color:white; cursor:pointer; width:100%; justify-content:center;
}
.btn-catalog:hover{ background: rgba(255,255,255,0.25); }

/* Основное содержимое */
.main-content{
  flex:1; display:flex; min-height:0; padding:15px; gap:15px;
}

/* Панель управления */
.controls-wrapper{
  flex:0 0 360px;
  max-height:
  calc(100vh - 70px);
  overflow-y:auto;
  overflow-x: hidden; /* Запрещаем горизонтальную прокрутку */  
  padding:20px;
  background:var(--card);
  border-radius:10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.05);
  display:flex;
  flex-direction:column;
}
.controls{ flex:1; display:flex; flex-direction:column; gap:25px; }
.control-group{ margin-bottom:0; }

.control-group h3{
  font-size:.9rem; margin-bottom:12px; color:var(--text);
  border-bottom:2px solid var(--primary); padding-bottom:6px; font-weight:600;
  margin-bottom: 15px;
}

#current-studio{ font-weight:600; color:var(--accent); }

.form-group{ margin-bottom:18px; display:flex; flex-direction:column; }
label{ font-weight:600; font-size:.9rem; line-height:1.6; margin-bottom:6px; user-select:none; }

select, input[type="range"]{
  width:100%; padding:12px; border:2px solid var(--muted); border-radius:6px;
  font-size:.9rem; transition:border .3s; background:var(--card); color:var(--text);
}
select:focus, input[type="range"]:focus{ outline:none; border-color:var(--accent); }

input[type="range"]{
  background:var(--muted); height:6px; cursor:pointer; border:none; padding:0;
}

/* Кнопки */
.btn{
  background: linear-gradient(90deg, var(--light-accent), var(--accent));
  color:white; border:none; padding:10px 15px; border-radius:6px; cursor:pointer;
  font-weight:600; transition:var(--transition);
}
.btn:hover{ opacity:.95; }
.btn-reset{ background:var(--bg); color:var(--text); padding:8px; width:100%; margin-top:15px; }
.btn-secondary{ background:var(--light-accent); color:white; }

/* Presets / features */
.presets-row{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:15px; }
.preset-btn{
  flex:1; min-width:90px; padding:6px 10px; font-size:.8rem; border-radius:6px;
  background:var(--primary); border:1px solid var(--muted); cursor:pointer;
  transition:var(--transition); text-align:center;
}
.preset-btn:hover{ background:var(--muted); }
.preset-btn.active{ background:var(--accent-dark); color:#fff; border-color:var(--accent-dark); }

.features-grid{
  display:grid; grid-template-columns: repeat(auto-fill, minmax(90px,1fr)); gap:8px; margin-top:8px;
}
.feature-btn{
  padding:6px 4px; border-radius:6px; background:var(--primary); border:1px solid var(--muted);
  cursor:pointer; transition:all .2s ease; font-size:.8rem; text-align:center;
}
.feature-btn:hover{ background:var(--muted); }
.feature-btn.active{ background:var(--accent-dark); color:white; border-color:var(--accent-dark); }

/* Превью */
.preview{
  position:relative; width: 100%; flex:1; background:var(--card); border-radius:10px;
  box-shadow:0 3px 10px rgba(0,0,0,0.05); display:flex; flex-direction:column;
}
.preview-header{
  padding:10px 15px; width: 100%; background:var(--primary); border-bottom:1px solid var(--muted);
  display:none; justify-content:space-between; align-items:center;
}
.preview-actions{ display:flex; gap:8px; }

/* Контейнер превью */
.preview-container{ display:grid; width:100%; height:100%; gap:10px; padding:10px; overflow: hidden;}

/* Режимы сравнения */
.preview-container.single{ grid-template-columns:1fr; grid-template-rows:1fr; }
.preview-container.vertical-2{ grid-template-columns:1fr 1fr; grid-template-rows:1fr; }
.preview-container.vertical-3{ grid-template-columns:1fr 1fr 1fr; grid-template-rows:1fr; }
.preview-container.horizontal-2{ grid-template-columns:1fr; grid-template-rows:1fr 1fr; }
.preview-container.mixed{ grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr; }
.preview-container.grid-4{ grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr; }

/* Специальное размещение для mixed */
.preview-container.mixed .viewport:nth-child(1){ grid-column:1 / 3; grid-row:1; }
.preview-container.mixed .viewport:nth-child(2){ grid-column:1; grid-row:2; }
.preview-container.mixed .viewport:nth-child(3){ grid-column:2; grid-row:2; }

/* Вьюпорты */
.viewport{
  position:relative; 
  border:1px solid var(--muted); 
  border-radius:8px; 
  overflow:auto; 
  background:var(--card);
  contain: content;
  overflow: auto !important;  
}
.viewport.active{ border:2px solid var(--accent); }

.viewport-content{
  padding:20px; 
  font-size:50px; 
  text-align:center; 
  color:var(--text); 
  outline:none; 
  cursor:text;
  display:flex; 
  align-items:flex-start; 
  justify-content:center; 
  overflow:auto; 
  width:100%; 
  height:100%;
  white-space: pre-wrap; /* сохраняем переносы */
  user-select: text;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;  
}
.viewport-content:focus{ box-shadow: inset 0 0 0 2px var(--accent); }

/* Фоны сеток и текстур */
.viewport-content.grid-bg-10{
  background-image:
    linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size:10px 10px;
}
.viewport-content.grid-bg-50{
  background-image:
    linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size:50px 50px;
}
.viewport-content.grid-bg-100{
  background-image:
    linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size:100px 100px;
}
.viewport-content.texture-bg{
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23cac6b9' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-size:300px;
}

/* Security notice badge */
.security-notice{
  position:absolute; bottom:10px; right:10px;
  background: rgba(255,255,255,0.8); padding:4px 8px; border-radius:4px;
  font-size:10px; color:var(--accent);
}

/* Footer */
footer{ text-align:center; padding:10px 0; color:var(--muted); font-size:.8rem; display: flex; justify-content: center; align-items: center; position: relative;}
.footer-content{ display:flex; justify-content:center; padding:0 20px; width: 100%; position: relative; }
.footer-meta{ opacity:.7; display:flex; gap:15px; }
.version{ opacity:.8; }

#theme-toggle {
  position: absolute;
  left: 20px;            /* Отступ от левого края */
  top: -12px;  
  background: rgba(0, 0, 0, 0.1); /* Темный фон на светлой теме */
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

/* Темный вариант для светлой темы */
body:not(.dark-theme) #theme-toggle {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

/* Светлый вариант для темной темы */
body.dark-theme #theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* Эффекты при наведении */
#theme-toggle:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.1);
}

#theme-toggle svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.5;
}

/* Навигация по страницам глифов внутри presets-row */
.glyphs-nav-inline {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 0px;
}

/* Кнопки навигации */
.glyphs-nav-btn {
    /* Размеры */
    min-width: 50px;     /* Минимальная ширина */
    height: 28px;        /* Высота кнопок */
    padding: 8px 12px;   /* Внутренние отступы */
	
    background: var(--accent-dark);
    color: white;
    border: none;

    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s ease;

    display: flex;
    align-items: center;
    justify-content: center;
}

.glyphs-nav-btn:hover {
    background: var(--accent);
}

/* Контейнер для информации о странице */
.page-info-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 4px;
}

/* Метка "страница" */
.page-info-label {
    font-size: 0.8rem;
    color: var(--text);
    white-space: nowrap;
}

/* Информация о номере страницы */
.page-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-dark);
    min-width: 60px;
    text-align: center;
    font-variant-numeric: tabular-nums; /* Обеспечивает одинаковую ширину цифр */
}

/* Для темной темы */
body.dark-theme .glyphs-nav-btn {
    background: var(--dark-accent-dark);
}

body.dark-theme .glyphs-nav-btn:hover {
    background: var(--dark-accent);
}

body.dark-theme .page-info-label {
    color: var(--dark-text);
}

body.dark-theme .page-info {
    color: var(--dark-accent);
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .glyphs-nav-inline {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }
    
    .presets-row {
        flex-wrap: wrap;
    }
}

/* Глифы — grid */
.viewport-content.glyphs-grid{
  display:grid !important;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap:15px; align-content:start; padding:20px; font-size:45px;
  align-items:center; justify-content:center;
}
.glyph{ display:flex; align-items:center; justify-content:center; min-height:60px; background: rgba(255,255,255,0.7); border-radius:8px; box-shadow:0 2px 5px rgba(0,0,0,0.05); }

/* Стили кастомного селекта */
.custom-select{ position:relative; width:100%; margin-bottom:15px; }
.select-header{
  position:relative; display:flex; align-items:center; padding:8px 20px 8px 15px;
  border:2px solid var(--muted); border-radius:6px; cursor:pointer; min-height:50px;
}
.selected-preview {
  position: absolute;
  left: 8px; 
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  height: 30px; /* Немного уменьшаем высоту */
  display: flex;
  justify-content: flex-end; /* Выравнивание по правому краю */
}

.selected-preview img {
  max-height: 90%;
  max-width: 90;
  transform: scale(0.87);
  transform-origin: left center; /* Меняем точку трансформации */
}

.select-header svg{ position:absolute; right:3px; top:50%; transform:translateY(-50%); }

/* Опции */
.select-option{ display:flex; justify-content:center; align-items:center; height:90px; }
.font-preview{ max-width:120%; max-height:120%; object-fit:contain; }
.select-header:hover{ border-color: var(--accent); }
.custom-select.open .select-header svg{ transform: rotate(180deg); }

.select-option .font-preview {
    transform: translate(10px, -15px);	/* Дополнительный сдвиг */
    max-width: 100%; /* Уменьшаем максимальную ширину */
    max-height: 100%; /* Уменьшаем максимальную высоту */
    transform: scale(0.8); /* Добавляем уменьшение масштаба */
    transform-origin: center;
}

/* Опции выпадающего списка (fixed для перекрытия содержимого) */
.select-options{
  position: fixed; top:0; left:0; max-height:500px; overflow-y:auto;
  background:var(--card); border:1px solid var(--muted); border-radius:6px;
  box-shadow:0 5px 25px rgba(0,0,0,0.1); z-index:1000; display:none;
}
.custom-select.open .select-options{ display:block; }

/* Улучшаем внешний вид опций */
.select-option{ display:block; padding:0; cursor:pointer; transition:background .2s; min-height:100px; height:80px; overflow:hidden; }
.select-option:hover{ background:var(--primary); }
.select-option.selected{ background:var(--accent-dark); color:#fff; }
.selected-preview{ height:40px; }
.font-preview{ width:100%; height:90%; }

/* Стили слайдеров */
input[type="range"]{ -webkit-appearance:none; appearance:none; background:transparent; cursor:pointer; height:6px; margin:12px 0; border-radius:3px; background:var(--muted); }
input[type="range"]::-webkit-slider-runnable-track{ height:6px; border-radius:3px; background:var(--muted); }
input[type="range"]::-moz-range-track{ height:6px; border-radius:3px; background:var(--muted); }
input[type="range"]::-webkit-slider-thumb{ -webkit-appearance:none; appearance:none; width:18px; height:18px; border-radius:50%; background:var(--accent); border:2px solid var(--card); box-shadow:0 2px 4px rgba(0,0,0,0.2); margin-top:-6px; transition: transform .2s, box-shadow .2s; }
input[type="range"]::-moz-range-thumb{ width:18px; height:18px; border-radius:50%; background:var(--accent); border:2px solid var(--card); box-shadow:0 2px 4px rgba(0,0,0,0.2); transition: transform .2s, box-shadow .2s; }
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:focus::-webkit-slider-thumb{ transform: scale(1.15); box-shadow: 0 3px 6px rgba(0,0,0,0.25); }
input[type="range"]:hover::-moz-range-thumb, input[type="range"]:focus::-moz-range-thumb{ transform: scale(1.15); box-shadow: 0 3px 6px rgba(0,0,0,0.25); }

/* Навигация в хедере */
#glyphs-navigation{ display:flex; align-items:center; gap:10px; margin-left:15px; padding:4px 10px; background: rgba(255,255,255,0.1); border-radius:20px; border:1px solid rgba(255,255,255,0.2); }
.header-actions .btn-nav{ width:28px; height:28px; display:flex; align-items:center; justify-content:center; padding:0; border-radius:50%; background:var(--accent); color:white; border:none; cursor:pointer; }
.header-actions .page-info{ font-size:.8rem; min-width:70px; text-align:center; }

/* Адаптивность */
@media (max-width:768px){
  .main-content{ flex-direction:column; }
  .controls-wrapper{ width:100%; max-height:none; }
  .preview{ height:50vh; }
  .viewport-content{ padding:15px; font-size:40px; }
  .viewport-content.glyphs-grid{ grid-template-columns: repeat(auto-fill, minmax(50px,1fr)); font-size:35px; }
  .header-actions{ display:none; }
  #glyphs-navigation{ margin-left:0; margin-top:8px; width:100%; justify-content:center; }
}

@media (max-width:480px){
  .header-content{ flex-direction:column; align-items:flex-start; }
  .preset-btn, .feature-btn{ font-size:.7rem; }
  .btn{ padding:8px 12px; font-size:.8rem; }
  .header-left, .header-center, .header-actions{ display:flex !important; justify-content:center; width:100%; margin-top:10px; }
  .header-center{ order:3; margin-top:10px; }
}

/* Выравнивание кнопок */
.align-buttons{ display:flex; gap:8px; }
.align-btn{ flex:1; min-width:auto; padding:6px; }
.align-btn.active{ background:var(--accent-dark); color:white; border-color:var(--accent-dark); }

/* Прочие мелочи */
.preview-container .viewport{ overflow: visible !important; }

/* Скрытие элементов */
.hidden{ display:none !important; }

/* Красная кнопка каталога */
.catalog-btn-red {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: center;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}

/* Для темной темы добавляем инверсию */
body.dark-theme .selected-preview img {
  filter: invert(1);
}

.catalog-btn-red:hover { background: var(--accent-dark); transform: translateY(-2px); box-shadow: 0 3px 4px rgba(0,0,0,0.15); }
.catalog-btn-red:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
body.dark-theme .catalog-btn-red { background: var(--dark-accent); }
body.dark-theme .catalog-btn-red:hover { background: var(--dark-accent-dark); }
#no-studio-message .catalog-btn-red { margin: 15px auto; max-width: 300px; }

/* Точная позиция подписи "Шрифт:" */
.form-group label[for="font-select-label"] { margin-top: 6px !important; display: block; }

/* Более точное позиционирование */
#no-studio-message { position: relative; }
#no-studio-message .catalog-btn-red { position: relative; top: -35px; }

/* Общие улучшения карточек и анимаций (не конфликтуют с поведением панели) */
@keyframes cardAppear { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } }

/* Мелкие улучшения адаптивности */
@media (max-width: 768px) {
  .catalog-content { grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); }
}

/* Glyphs grid — принудительная сетка для режима "Набор знаков" */
.viewport-content.glyphs-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr); /* 12 колонок x 10 строк = 120 ячеек */
  gap: 8px;
  align-items: center;
  justify-items: center;
  padding: 10px;
  box-sizing: border-box;
}

/* отдельная ячейка-глиф */
.viewport-content.glyphs-grid .glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  min-width: 0;
  font-size: 36px;
  user-select: text;
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02);
  padding: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* заглушка для пустых ячеек (если символов < 120) */
.viewport-content.glyphs-grid .glyph.placeholder {
  opacity: 0.25;
  color: rgba(255,255,255,0.25);
  font-size: 14px;
  align-items: center;
  justify-content: center;
}

/* адаптив: на узких экранах уменьшаем колонки */
@media (max-width: 1100px) {
  .viewport-content.glyphs-grid { grid-template-columns: repeat(8, 1fr); } /* 8 кол. */
}
@media (max-width: 700px) {
  .viewport-content.glyphs-grid { grid-template-columns: repeat(4, 1fr); } /* 4 кол. */
}

.slider-container {
  margin-bottom: 30px;
}

/* Обертка для слайдера и крайних значений */
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-top: 8px;
}

/* Стили для подписей крайних значений */
.axis-min, .axis-max {
  font-size: 0.7rem;
  color: var(--muted);
  min-width: 30px;
  text-align: center;
}

/* Стили для текущего значения */
.slider-value {
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent);
  margin-left: 8px;
  min-width: 50px;
  display: inline-block;
  text-align: right;
}

/* Стили для выбора цвета */
.color-controls-row {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.color-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-control label {
    font-size: 0.8rem;
    margin-bottom: 5px;
    color: var(--text);
    font-weight: 600;
}

.color-preview:hover {
    transform: scale(1.05);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

.color-formats {
    flex: 1;
    font-size: 0.9rem;
    font-family: monospace;
    padding: 8px;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
    min-height: 40px;
    display: flex;
    align-items: center;
}

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--card);
    border-radius: 10px;
    width: 330px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.color-picker-main {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#color-input {
    width: 100%;
    height: 60px;
    border: 1px solid var(--muted);
    border-radius: 8px;
    cursor: pointer;
    align-self: center;
}

.color-picker-preview {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    border: 1px solid var(--muted);
    background: var(--card);
}

.color-picker-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--muted);
    text-align: center;
}

.color-values {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.color-value-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-value-group label {
    width: 40px;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.color-value-input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--muted);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid var(--muted);
    border-radius: 4px;
    cursor: pointer;
}

.color-formats {
    display: none !important;
}

.color-picker-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.color-palette {
    position: relative;
    width: 100%;
    height: 200px;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    cursor: crosshair;
}

#color-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.color-cursor {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.color-hue-slider {
    padding: 0 10px;
    position: relative;
    height: 20px;
}

.color-hue-slider input[type="range"] {
    width: 100%;
    height: 20px;
    -webkit-appearance: none;
    background: transparent;
    margin: 0;
}

.color-hue-slider input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 20px;
    cursor: pointer;
    background: linear-gradient(to right, 
        #ff0000, #ff7f00, #ffff00, #80ff00, 
        #00ff00, #00ff80, #00ffff, #0080ff, 
        #0000ff, #7f00ff, #ff00ff, #ff007f, #ff0000);
    border-radius: 10px;
}

.color-hue-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
    position: relative;
    top: 6px;
}


.selected-color-preview {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.current-color, .new-color {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    border: 1px solid var(--muted);
}

.current-color {
    background-color: currentColor;
}

.new-color {
    background-color: var(--selected-color, #000000);
}

/* Адаптивность для модального окна */
@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .color-palette {
        height: 150px;
    }
}



.preset-btn[data-preset="glyphs"].hidden {
    display: none !important;
}

.dark-theme .selected-preview img {
	filter: invert(1);
}

.rgb-spacer {
    height: 1px; /* Добавили отступ под полем RGB */
}

/* контейнер с вариантами семейства */
.family-variants-wrapper { padding: 10px; border-top: 1px solid var(--muted); background: transparent; }

/* подписи под превью */
.select-label {
  font-size: 12px;
  text-align: center;
  margin-top: 6px;
  color: var(--text-muted, #dcdcdc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* светлое, незасиливающее выделение (лучше видно SVG на тёмно-красном фоне) */
.select-option.selected {
  background-color: rgba(255,65,108,0.15); /* лёгкая подсветка */
  backdrop-filter: blur(0.5px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

/* контейнер с вариантами семьи — теперь 2 колонки */
.family-variants { 
  display: grid; 
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* две колонки */
  gap: 12px; 
  margin-top: 8px;
}

/* делаем превью крупнее для более чётких SVG */
.family-variant .font-preview,
.select-option .font-preview {
  height: 110px;
  width: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  transform: scale(0.6); /* Добавляем уменьшение масштаба */
  transform-origin: left;
  margin-left: 10px;  
}

/* маленькие стили для заголовка */
.family-variants-header {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent, #ff8a80);
  font-size: 13px;
}

/* Стили для логотипа */
.preview-logo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: var(--card);
}

.logo-svg {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

/* Скрываем текст при отображении логотипа */
.preview-logo-active .viewport-content {
    visibility: hidden;
}

/* Добавляем стили для анимации загрузки */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 65, 108, 0.2);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Улучшаем отображение вьюпортов */
.viewport-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
}