/* =========================================================
   THEME SETTINGS — плавающая панель
   Маленькое окно, которое можно таскать за шапку.
   ========================================================= */

.theme-panel {
  position: fixed;
  z-index: 8500;
  width: 300px;
  max-width: calc(100vw - 24px);
  background: #0d0d10;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: #e5e5e5;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  overflow: hidden;
  user-select: none;

  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.98);
  transition:
    opacity   0.22s ease,
    transform 0.28s cubic-bezier(.2, .9, .3, 1.05);
}
.theme-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.theme-panel.dragging {
  transition: none;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

/* ── Шапка ── */
.theme-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: grab;
  touch-action: none;
}
.theme-panel-header:active,
.theme-panel.dragging .theme-panel-header {
  cursor: grabbing;
}

.theme-panel-grip {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.16);
  transition: color 0.2s;
}
.theme-panel-header:hover .theme-panel-grip {
  color: rgba(255, 255, 255, 0.32);
}

.theme-panel-title {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #e5e5e5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-panel-close {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.theme-panel-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.theme-panel-close:active {
  background: rgba(255, 255, 255, 0.1);
}
.theme-panel-close svg {
  width: 14px;
  height: 14px;
}

/* ── Тело ── */
.theme-panel-body {
  padding: 20px 16px 22px;
}

.theme-panel-empty {
  font-size: 12px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.38);
  text-align: center;
  padding: 12px 4px;
}
.theme-panel-empty strong {
  display: block;
  color: rgba(255, 255, 255, 0.62);
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
/* =========================================================
   THEME CONTROLS — цветовые поля + кнопки
   ========================================================= */

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.theme-row-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.62);
  letter-spacing: 0.2px;
  white-space: nowrap;
  user-select: none;
}
.theme-row + .theme-row { margin-top: 2px; }

/* ── Поле цвета: свотч + hex ── */
.theme-color-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Свотч — открывает системную палитру */
.theme-color-input {
  -webkit-appearance: none;
          appearance: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.theme-color-input:hover {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03);
}
.theme-color-input:active { transform: scale(0.94); }
.theme-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.theme-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}
.theme-color-input::-moz-color-swatch {
  border: none;
  border-radius: 5px;
}

/* Hex-поле */
.theme-color-hex {
  width: 82px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  color: #e5e5e5;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: 11.5px;
  letter-spacing: 0.4px;
  text-align: center;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.15s, background 0.15s;
}
.theme-color-hex:focus {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.05);
}
.theme-color-hex.error {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  animation: themeShake 0.35s ease;
}
@keyframes themeShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

/* Разделитель между секциями */
.theme-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
  margin: 18px 0 16px;
}

/* ── Кнопки ── */
.theme-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.theme-btn {
  padding: 10px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.1s,
    opacity 0.15s;
}
.theme-btn:active { transform: scale(0.98); }
.theme-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.theme-btn-primary {
  flex: 1;
  background: #e5e5e5;
  color: #0a0a0a;
}
.theme-btn-primary:hover:not(:disabled) { background: #fff; }
.theme-btn-primary:active:not(:disabled) { background: #d4d4d4; }

.theme-btn-ghost {
  flex: 0 0 auto;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
}
.theme-btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Тонкий hint под кнопками */
.theme-hint {
  margin-top: 12px;
  font-size: 10.5px;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.28);
  text-align: center;
  line-height: 1.5;
}
/* =========================================================
   THEME — GRADIENT STOPS
   ========================================================= */

/* Секция «Задний фон» + «+» */
.theme-stop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.theme-add-stop {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.theme-add-stop:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-color: rgba(255,255,255,0.22);
}
.theme-add-stop:active:not(:disabled) { transform: scale(0.9); }
.theme-add-stop:disabled { opacity: 0.28; cursor: not-allowed; }
.theme-add-stop svg { width: 13px; height: 13px; }

/* Ряды со стопами */
.theme-stops-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.theme-stop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: themeStopIn 0.28s cubic-bezier(.2,.9,.3,1.05);
}
@keyframes themeStopIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.theme-stop-row .theme-color-field { flex: 1; min-width: 0; }
.theme-stop-row .theme-color-input { width: 30px; height: 30px; }
.theme-stop-row .theme-color-hex   { flex: 1; width: auto; }

.theme-remove-stop {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.theme-remove-stop:hover {
  background: rgba(239,68,68,0.1);
  color: #f87171;
  border-color: rgba(239,68,68,0.25);
}
.theme-remove-stop:active { transform: scale(0.9); }
.theme-remove-stop svg { width: 12px; height: 12px; }

/* Полоса градиента */
.theme-gradient-wrap {
  display: none;
  margin-top: 14px;
}
.theme-gradient-wrap.show {
  display: block;
  animation: themeStopIn 0.28s cubic-bezier(.2,.9,.3,1.05);
}
.theme-gradient-bar {
  position: relative;
  height: 38px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
  user-select: none;
  touch-action: none;
}

/* Маркеры-кружки */
.theme-gradient-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow:
    0 1px 3px rgba(0,0,0,0.5),
    0 0 0 1px rgba(0,0,0,0.35);
  cursor: grab;
  touch-action: none;
  transition: transform 0.12s cubic-bezier(.2,.9,.3,1.05);
  z-index: 2;
}
.theme-gradient-marker:hover { transform: translate(-50%, -50%) scale(1.15); }
.theme-gradient-marker.dragging {
  transform: translate(-50%, -50%) scale(1.3);
  cursor: grabbing;
  z-index: 3;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.7),
    0 0 0 1px rgba(0,0,0,0.35),
    0 0 0 4px rgba(255,255,255,0.18);
}

/* Тултип с процентом */
.theme-gradient-marker::after {
  content: attr(data-pos);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.theme-gradient-marker:hover::after,
.theme-gradient-marker.dragging::after { opacity: 1; }

.theme-gradient-hint {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 0.3px;
  color: rgba(255,255,255,0.28);
  text-align: center;
  user-select: none;
}
/* =========================================================
   AUTOSTART — чекбокс (только desktop)
   ========================================================= */

.theme-autostart {
  display: none;                  /* включается из JS только на desktop */
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 4px;
  cursor: pointer;
  user-select: none;
}
.theme-autostart.show { display: flex; }

.theme-autostart-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.62);
  letter-spacing: 0.2px;
  line-height: 1.3;
}

.theme-autostart-switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.theme-autostart-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.theme-autostart-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.2s, border-color 0.2s;
}
.theme-autostart-track::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #d4d4d4;
  transition: transform 0.22s cubic-bezier(.3, 1.3, .5, 1), background 0.2s;
}
.theme-autostart-switch input:checked + .theme-autostart-track {
  background: #6366f1;
  border-color: rgba(99, 102, 241, 0.6);
}
.theme-autostart-switch input:checked + .theme-autostart-track::after {
  transform: translateX(16px);
  background: #fff;
}
/* input никогда не disabled физически, только помеченный busy */
.theme-autostart-switch input:disabled + .theme-autostart-track {
  opacity: 0.55;
}
/* =========================================================
   THEME SLIDER — ползунок прозрачности
   ========================================================= */

.theme-opacity-row {
  margin-top: -6px;         /* тянет ближе к «Карточки» */
  margin-bottom: 14px;      /* как у всех остальных строк */
}

.theme-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 0;
}

/* Тонкий ползунок в стиле panel */
.theme-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.theme-slider:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Трек */
.theme-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}
.theme-slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

/* Thumb — белый круг */
.theme-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
  margin-top: -5px;            /* (4px track - 14px thumb) / 2 */
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s cubic-bezier(.2, .9, .3, 1.2);
}
.theme-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.theme-slider:active::-webkit-slider-thumb {
  transform: scale(1.25);
}

.theme-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s cubic-bezier(.2, .9, .3, 1.2);
}
.theme-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
}

/* Значение справа */
.theme-slider-value {
  min-width: 36px;
  text-align: right;
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  flex-shrink: 0;
  transition: color 0.15s ease;
}
.theme-slider:active ~ .theme-slider-value {
  color: #fff;
}

/* ── Мобильная адаптация ── */
@media (max-width: 400px) {
  .theme-slider { width: 100px; }
  .theme-slider-value { min-width: 32px; font-size: 11px; }
}
/* Пока идёт запрос к нативу — лёгкий «пульс», без блокировки курсора */
.theme-autostart.busy {
  cursor: progress;
  opacity: 0.75;
}
.theme-autostart.busy .theme-autostart-track {
  animation: themeAutostartPulse 1s ease-in-out infinite;
}
/* =========================================================
   CARD COLOR — кастомный цвет карточек
   Использует переменные --card-bg и --card-bg-hover,
   которые theme.js ставит из настроек пользователя.
   !important нужен, потому что .card определён в index.html
   в инлайн-<style> ниже этого файла.
   ========================================================= */
.card {
  background: var(--card-bg, var(--bg-elevated)) !important;
}
.card:hover {
  background: var(--card-bg-hover, var(--bg-surface-hover)) !important;
}
@keyframes themeAutostartPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
/* Тонкая подпись-пояснение под чекбоксом */
.theme-autostart-hint {
  display: none;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.3);
  margin-top: -4px;
  margin-bottom: 10px;
  line-height: 1.4;
  letter-spacing: 0.2px;
}
.theme-autostart-hint.show { display: block; }

/* ── Мобилка ── */
@media (max-width: 480px) {
  .theme-color-hex { width: 76px; font-size: 11px; }
  .theme-color-input { width: 28px; height: 28px; }
}

/* ── Мобилка ── */
@media (max-width: 480px) {
  .theme-panel { width: calc(100vw - 32px); }
  .theme-panel-body { padding: 16px 14px 18px; }
}