* {
  box-sizing: border-box;
}

:root {
  --bg: #0a0b12;
  --panel: #141623;
  --panel-2: #1b1e30;
  --line: #262a41;
  --text: #e9ebf5;
  --muted: #9aa0bd;
  --accent: #c8ff00;
  --accent-2: #7c5cff;
}

html,
body {
  margin: 0;
  min-height: 100vh;
}

body {
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 400px at 15% 0%, rgba(124, 92, 255, 0.22), transparent 70%),
    radial-gradient(700px 500px at 90% 20%, rgba(200, 255, 0, 0.1), transparent 70%);
  z-index: 0;
}

/* ---------- Топбар ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.brand {
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand__mark {
  color: var(--accent);
  animation: spin 6s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.topbar__actions {
  display: flex;
  gap: 0.6rem;
}

/* ---------- Кнопки ---------- */
.btn {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 14px;
  padding: 0.7rem 1.15rem;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn:active {
  transform: scale(0.96);
}

.btn--primary {
  background: var(--accent);
  color: #10120a;
  border-color: transparent;
  box-shadow: 0 6px 24px rgba(200, 255, 0, 0.25);
}

.btn--primary:hover {
  box-shadow: 0 8px 32px rgba(200, 255, 0, 0.45);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn--wide {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Раскладка ---------- */
.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  padding: 0 1.5rem 2rem;
  max-width: 1500px;
  margin: 0 auto;
}

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* ---------- Сцена ---------- */
.stage {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.stage__frame {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  background: #000;
  aspect-ratio: 16 / 9;
  transition: aspect-ratio 0.3s;
}

#preview {
  width: 100%;
  height: 100%;
  display: block;
}

.stage__badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  color: var(--accent);
  letter-spacing: 0.05em;
}

.stage__meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.stage__meta #presetName {
  color: var(--accent);
}

#status {
  color: var(--accent-2);
  font-weight: 700;
}

#status.is-error {
  color: #ff4f6b;
}

.dot {
  opacity: 0.5;
}

/* ---------- Чипы соотношений ---------- */
.ratio-row,
.text-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  font-family: 'Manrope', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent-2);
}

.chip--active {
  background: var(--accent);
  color: #10120a;
  border-color: transparent;
}

.text-row input[type='text'] {
  flex: 1;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  font-family: 'Manrope', sans-serif;
  font-size: 0.92rem;
  outline: none;
}

.text-row input[type='text']:focus {
  border-color: var(--accent);
}

.text-row input[type='color'] {
  width: 52px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  cursor: pointer;
  padding: 4px;
}

/* ---------- Панель ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-self: start;
  position: sticky;
  top: 1rem;
}

.panel__title {
  font-family: 'Unbounded', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.panel__title:first-child {
  margin-top: 0;
}

/* Пресеты */
.presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.preset {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #000;
  aspect-ratio: 16 / 10;
  transition: transform 0.15s, border-color 0.15s;
}

.preset:hover {
  transform: translateY(-2px);
  border-color: var(--accent-2);
}

.preset--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 255, 0, 0.2);
}

.preset canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.preset__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.35rem 0.4rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  color: #fff;
  text-align: left;
}

/* Контролы */
.control {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.control label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.control .val {
  color: var(--accent);
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--panel-2);
  outline: none;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(200, 255, 0, 0.6);
}

.control--switch {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.switch {
  appearance: none;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--panel-2);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid var(--line);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: all 0.2s;
}

.switch:checked {
  background: var(--accent);
  border-color: transparent;
}

.switch:checked::after {
  left: 22px;
  background: #10120a;
}

/* Палитры */
.palettes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.palette {
  width: 58px;
  height: 30px;
  border-radius: 10px;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}

.palette:hover {
  transform: scale(1.08);
}

.palette--active {
  border-color: var(--accent);
}

.export-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.hint {
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0;
}

/* ---------- Модалка экспорта ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 6, 12, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal__box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 2rem;
  width: min(420px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  align-items: center;
}

.modal__box h3 {
  font-family: 'Unbounded', sans-serif;
  font-size: 1rem;
  margin: 0;
}

.modal__box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid var(--panel-2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.progress {
  width: 100%;
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.15s;
}
