:root {
  --bg: #f5f4f0;
  --card: #fff;
  --soft: #f8f7f4;
  --ink: #242521;
  --mute: #85867f;
  --line: #e7e6df;
  --acc: #27352f;
  --onacc: #fff;
  --accent: #b8d3c3;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Системная темная тема по умолчанию при включенном темном режиме устройства */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #171a18;
    --card: #202521;
    --soft: #282e2a;
    --ink: #f0f1eb;
    --mute: #a2aaa2;
    --line: #353d37;
    --acc: #dce9df;
    --onacc: #202521;
    --accent: #6b9b80;
  }
}

:root[data-theme='dark'] {
  --bg: #171a18;
  --card: #202521;
  --soft: #282e2a;
  --ink: #f0f1eb;
  --mute: #a2aaa2;
  --line: #353d37;
  --acc: #dce9df;
  --onacc: #202521;
  --accent: #6b9b80;
}

:root[data-theme='light'] {
  --bg: #f5f4f0;
  --card: #fff;
  --soft: #f8f7f4;
  --ink: #242521;
  --mute: #85867f;
  --line: #e7e6df;
  --acc: #27352f;
  --onacc: #fff;
  --accent: #b8d3c3;
}

* {
  box-sizing: border-box;
}
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.5 Inter,
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  transition:
    background 0.25s,
    color 0.25s;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
.logo {
  font:
    600 26px Fraunces,
    Georgia,
    serif;
  letter-spacing: -0.04em;
}
.logo:after {
  content: '.';
  color: #78a58b;
}
header span {
  color: var(--mute);
  font-size: 13px;
}
.act {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  padding: 20px 24px 28px;
  max-width: 1500px;
  margin: auto;
  align-items: start;
}
.stage {
  position: relative;
  background: radial-gradient(ellipse at 50% 42%, #f3e9d9, #eeede6 72%);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(39, 45, 37, 0.045);
}
:root[data-theme='dark'] .stage {
  background: radial-gradient(ellipse at 50% 42%, #302e29, #202521 72%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .stage {
    background: radial-gradient(ellipse at 50% 42%, #302e29, #202521 72%);
  }
}

#room {
  display: block;
  width: 100%;
  height: auto;
  max-height: 78vh;
  touch-action: none;
  user-select: none;
}

.ctrl-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.panel-sec {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.panel-sec:first-child {
  padding-top: 0;
}
.panel-title {
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--ink);
  font-weight: 700;
  text-transform: none;
}
.row {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.bar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px;
  box-shadow: 0 12px 35px rgba(30, 35, 30, 0.14);
  max-width: calc(100% - 24px);
  flex-wrap: wrap;
  justify-content: center;
  z-index: 5;
}
.bar b {
  font-weight: 600;
  min-width: 84px;
}
.bar .hint {
  color: var(--mute);
}
.sw {
  display: flex;
  gap: 7px;
  align-items: center;
}
.sw i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--line);
}
.sw i.on {
  box-shadow: 0 0 0 2px #78a58b;
}
.bar.off .sw,
.bar.off .btn,
.bar.off .vr,
.bar.off .inp-lbl {
  opacity: 0.3;
  pointer-events: none;
}

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 11px;
  padding: 9px 13px;
  font:
    600 12px Inter,
    sans-serif;
  cursor: pointer;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover {
  background: var(--soft);
  border-color: #c9cec5;
  transform: translateY(-1px);
}
.btn.d {
  background: var(--acc);
  border-color: var(--acc);
  color: var(--onacc);
}
.btn.d:hover {
  opacity: 0.88;
  background: var(--acc);
}
.btn-sm {
  padding: 7px 11px;
  font-size: 12px;
}

/* Боковое меню с вкладками */
aside {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  align-self: start;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 28px rgba(39, 45, 37, 0.035);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}
.nav-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--mute);
  font:
    600 12px/1 Inter,
    sans-serif;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s ease;
  text-align: center;
}
.nav-tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tab-content {
  display: none;
  overflow-y: auto;
  padding-right: 2px;
}
.tab-content.active {
  display: block;
}

aside h2 {
  margin: 12px 0 3px;
  font:
    600 22px Fraunces,
    Georgia,
    serif;
  letter-spacing: -0.03em;
}
aside p {
  margin: 0 0 14px;
  color: var(--mute);
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.it {
  background: var(--soft);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 9px 5px 11px;
  text-align: center;
  cursor: grab;
  transition: 0.18s;
}
.it:hover {
  border-color: #a8c4b2;
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(35, 55, 43, 0.06);
}
.it svg {
  width: 100%;
  height: 58px;
  display: block;
}
.it span {
  font-size: 11px;
  font-weight: 600;
  display: block;
  margin-top: 5px;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 0 14px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar {
  display: none;
}
.chip {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--mute);
  border-radius: 9px;
  padding: 6px 10px;
  font:
    600 11px Inter,
    sans-serif;
  cursor: pointer;
  transition: 0.15s;
  whitespace: nowrap;
  flex-shrink: 0;
}
.chip.on {
  background: var(--acc);
  border-color: var(--acc);
  color: var(--onacc);
}
.it[hidden] {
  display: none;
}
.vr {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.vr:empty {
  display: none;
}
.vr .chip {
  padding: 6px 9px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  background: var(--acc);
  color: var(--onacc);
  padding: 11px 18px;
  border-radius: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 9;
  box-shadow: 0 8px 24px #0002;
}
.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.color-picker-wrapper {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: none;
  cursor: pointer;
  flex-shrink: 0;
}
.color-picker-wrapper input[type='color'] {
  position: absolute;
  inset: -5px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  border: 0;
  padding: 0;
}
.pat-opt {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid var(--line);
  cursor: pointer;
  transition: 0.15s;
  position: relative;
}
.pat-opt:hover {
  transform: translateY(-1px);
}
.pat-opt.on {
  border-color: #6e9a7e;
  box-shadow:
    0 0 0 2px var(--card),
    0 0 0 4px #6e9a7e;
}
.inp-lbl {
  font-size: 12px;
  color: var(--mute);
  display: flex;
  align-items: center;
  gap: 8px;
}
.inp-range {
  width: 100%;
  accent-color: #709780;
  cursor: pointer;
}
.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}
.range-row input {
  grid-column: 1/-1;
}
.range-value {
  font-size: 11px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}
.toggle-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.toggle {
  accent-color: #709780;
  width: 16px;
  height: 16px;
}
.neon-presets {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.neon-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--card);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  padding: 0;
  transition: 0.15s;
}
.neon-swatch.on {
  box-shadow: 0 0 0 2px #709780;
  transform: scale(1.08);
}
.upload-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed #c8cec5;
  background: var(--soft);
  padding: 13px;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s;
}
.upload-drop:hover {
  border-color: #709780;
  background: color-mix(in srgb, var(--soft) 80%, #c8e1d0);
}
.upload-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--card);
  font-size: 20px;
  flex-shrink: 0;
}
.upload-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.upload-copy strong {
  font-size: 12px;
}
.upload-copy small {
  font-size: 10px;
  color: var(--mute);
}
.custom-upload {
  display: none;
}
.photo-status {
  font-size: 11px;
  color: var(--mute);
  margin-top: 8px;
  overflow-wrap: anywhere;
}
.section-kicker {
  font-size: 10px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 700;
  margin-bottom: 4px;
}
.sidebar-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.count-pill {
  font-size: 10px;
  color: var(--mute);
  background: var(--soft);
  border-radius: 7px;
  padding: 4px 7px;
}

.mote {
  animation: mt 8s ease-in-out infinite;
}
@keyframes mt {
  0%,
  100% {
    transform: translate(0, 0);
    opacity: 0.05;
  }
  50% {
    transform: translate(7px, -14px);
    opacity: 0.85;
  }
}
.tw {
  animation: tw 3.4s ease-in-out infinite;
}
@keyframes tw {
  50% {
    opacity: 0.4;
  }
}
.gl {
  animation: br 5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes br {
  50% {
    opacity: 0.75;
    transform: scale(1.06);
  }
}
.selr {
  animation: dash 1s linear infinite;
}
@keyframes dash {
  to {
    stroke-dashoffset: -20;
  }
}
.cur {
  transform-box: fill-box;
  transform-origin: 50% 0;
  animation: sw 6s ease-in-out infinite;
}
@keyframes sw {
  50% {
    transform: skewX(2deg);
  }
}

@media (max-width: 1050px) {
  main {
    grid-template-columns: minmax(0, 1fr) 340px;
    padding: 18px;
    gap: 16px;
  }
  aside {
    padding: 16px;
  }
}
@media (max-width: 850px) {
  main {
    grid-template-columns: 1fr;
    padding: 14px;
  }
  aside {
    position: static;
    max-height: none;
  }
  .stage {
    min-height: 360px;
  }
  #room {
    max-height: none;
  }
  header {
    padding: 15px 18px;
  }
}
@media (max-width: 520px) {
  header {
    align-items: flex-start;
  }
  .logo {
    font-size: 24px;
  }
  .act {
    gap: 5px;
    justify-content: flex-end;
  }
  .btn {
    padding: 8px 9px;
    font-size: 11px;
  }
  main {
    padding: 10px;
    gap: 12px;
  }
  .stage {
    border-radius: 18px;
    min-height: 280px;
  }
  aside {
    padding: 14px;
    border-radius: 18px;
  }
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .bar {
    bottom: 8px;
    border-radius: 14px;
  }
  .ctrl-panel {
    margin-bottom: 14px;
  }
}
