/* Totem Maker — Minecraft UI (шрифты подключаются в HTML, без блокирующего @import) */

:root {
  --mc-sign-bg: #312921;
  --bg-deep: #312921;
  --bg-mid: #312921;
  --surface: #312921;
  --surface-solid: #312921;
  --border: #1a1a1a;
  --border-strong: #ffffff;
  --border-dark: #3a3a3a;
  --text: #ffffff;
  --muted: #a0a0a0;
  --accent: #55ff55;
  --accent-soft: rgba(85, 255, 85, 0.12);
  --accent-hover: #77ff77;
  --danger: #ff5555;
  --radius-lg: 0;
  --radius-md: 0;
  --radius-pill: 0;
  --shadow-lg: 6px 6px 0 rgba(0, 0, 0, 0.62);
  --font: "Press Start 2P", "Minecraft", "Courier New", monospace;
  --mono: "Press Start 2P", "Minecraft", "Courier New", monospace;
  --mc-btn: #7e7e7e;
  --mc-btn-hover: #8f8f8f;
  --mc-btn-active: #6b6b6b;
  --mc-btn-primary: #5a9a3a;
  --mc-btn-primary-hover: #6bb04a;
  --mc-btn-primary-active: #4a8230;
  --mc-text-shadow: 2px 2px 0 #3f3f3f;
  --mc-panel-inset: inset 3px 3px 0 rgba(255, 255, 255, 0.18), inset -3px -3px 0 rgba(0, 0, 0, 0.5);
  --totem-marquee-duration: 28s;
  --totem-marquee-visible-rows: 2;
  /* 6 рядов + 5 зазоров по ~50% высоты тотема ≈ как на макете */
  --totem-marquee-gap-ratio: 0.38;
  --totem-marquee-item: min(
    clamp(104px, 8.5vw, 168px),
    calc(
      100vh /
        (
          var(--totem-marquee-visible-rows) +
            (var(--totem-marquee-visible-rows) - 1) * var(--totem-marquee-gap-ratio)
        )
    )
  );
  --totem-marquee-gap: calc(var(--totem-marquee-item) * var(--totem-marquee-gap-ratio));
  --totem-marquee-col-gap: clamp(5px, 0.45vw, 9px);
  --totem-marquee-panel-w: clamp(
    calc(3 * var(--totem-marquee-item) + 2 * var(--totem-marquee-col-gap) + clamp(14px, 1.6vw, 28px)),
    27vw,
    520px
  );
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

html,
button,
input,
select,
textarea {
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  text-shadow: var(--mc-text-shadow);
  background-color: var(--mc-sign-bg);
  image-rendering: pixelated;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-shell--stretch {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.glass-panel {
  background: var(--mc-sign-bg);
  border: 4px solid #120d08;
  outline: 3px solid #c6b79b;
  border-radius: var(--radius-lg);
  box-shadow: var(--mc-panel-inset), var(--shadow-lg);
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: #101010;
  border: 2px solid var(--border-dark);
  border-top-color: #555;
  border-left-color: #555;
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  text-shadow: var(--mc-text-shadow);
}

.brand-chip--tagline {
  text-transform: none;
}

.landing-panel {
  padding: clamp(28px, 6vw, 44px);
  max-width: 520px;
  width: 100%;
  text-align: center;
}

.landing-panel .brand-chip--tagline {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0 0 24px;
  padding: 20px 22px;
  font-size: clamp(13px, 4vw, 19px);
  line-height: 1.75;
  text-align: center;
  box-sizing: border-box;
}

.landing-panel h1 {
  margin-top: 0;
  font-weight: bold;
}

.landing-hero {
  flex-direction: column;
  align-items: center;
}

.landing-hero > .landing-subtitle {
  margin: 0 0 clamp(14px, 3vw, 22px);
  padding: 0 clamp(12px, 4vw, 24px);
  max-width: 560px;
  width: 100%;
  font-size: clamp(8px, 2.2vw, 11px);
  line-height: 1.7;
  font-weight: normal;
  color: var(--mc-sign-bg);
  text-align: center;
  text-shadow: none;
  box-sizing: border-box;
}

.landing-panel .lead {
  max-width: none;
}

.landing-panel .landing-upload-btn {
  width: 100%;
  max-width: none;
  min-height: 56px;
  margin: 0;
}

.btn--mc-block {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
  padding: 14px 16px 12px;
  font-size: 13px;
  border-width: 4px;
  border-radius: 0;
}

.btn--mc-block:last-child {
  margin-bottom: 0;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(1rem, 3.5vw, 1.45rem);
  font-weight: normal;
  line-height: 1.5;
  text-shadow: var(--mc-text-shadow);
}

h2 {
  font-weight: normal;
  text-shadow: var(--mc-text-shadow);
}

.lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  max-width: 40ch;
  text-align: center;
  text-shadow: var(--mc-text-shadow);
}

.btn {
  appearance: none;
  font-family: var(--font);
  cursor: pointer;
  border-radius: var(--radius-md);
  border: 2px solid;
  border-color: #ffffff #3a3a3a #3a3a3a #ffffff;
  background: var(--mc-btn);
  color: #ffffff;
  font-size: 14px;
  font-weight: normal;
  padding: 12px 18px 10px;
  letter-spacing: 0.02em;
  text-shadow: 2px 2px 0 #202020;
  box-shadow: 0 4px 0 #242424, inset 2px 2px 0 rgba(255, 255, 255, 0.25), inset -2px -2px 0 rgba(0, 0, 0, 0.35);
  transition: background 0.08s, border-color 0.08s, transform 0.08s, box-shadow 0.08s;
}

.btn:hover {
  background: var(--mc-btn-hover);
  color: #ffffa0;
}

.btn:active {
  border-color: #3a3a3a #ffffff #ffffff #3a3a3a;
  background: var(--mc-btn-active);
  transform: translateY(3px);
  box-shadow: 0 1px 0 #242424, inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.18);
}

.btn--ghost {
  background: #5a5a5a;
  border-color: #aaaaaa #2a2a2a #2a2a2a #aaaaaa;
  color: #e0e0e0;
}

.btn--ghost:hover {
  background: #6a6a6a;
  color: #ffffff;
}

.btn.btn--mc-gray,
.frame-picker-card .btn.btn--ghost {
  background: #7e7e7e;
  border: 4px solid;
  border-color: #d8d8d8 #3a3a3a #1a1a1a #d8d8d8;
  color: #ffffff;
  box-shadow:
    0 4px 0 #242424,
    inset 2px 2px 0 rgba(255, 255, 255, 0.22),
    inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}

.btn.btn--mc-gray:hover,
.frame-picker-card .btn.btn--ghost:hover {
  background: #8f8f8f;
  border-color: #ffffa0 #3a3a3a #1a1a1a #ffffa0;
  color: #ffffff;
}

.btn.btn--mc-gray:active,
.frame-picker-card .btn.btn--ghost:active {
  border-color: #3a3a3a #d8d8d8 #d8d8d8 #3a3a3a;
  background: #6b6b6b;
  transform: translateY(3px);
  box-shadow: 0 1px 0 #242424, inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.18);
}

.btn.btn--mc-green,
.frame-picker-card .btn.btn--mc-green {
  background: #5da13a;
  border: 4px solid;
  border-color: #9fdf7a #2d5018 #1a3810 #9fdf7a;
  color: #ffffff;
  box-shadow:
    0 4px 0 #1f3518,
    inset 2px 2px 0 rgba(255, 255, 255, 0.22),
    inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}

.btn.btn--mc-green:hover,
.frame-picker-card .btn.btn--mc-green:hover {
  background: #6bb04a;
  color: #ffffff;
}

.btn.btn--mc-green:active,
.frame-picker-card .btn.btn--mc-green:active {
  border-color: #2d5018 #9fdf7a #9fdf7a #2d5018;
  background: #4a8230;
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1f3518, inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.18);
}

.btn.btn--mc-red-muted {
  background: #a83232;
  border: 4px solid;
  border-color: #e87878 #6b1818 #4a1010 #e87878;
  color: #ffffff;
  box-shadow:
    0 4px 0 #4a1010,
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}

.btn.btn--mc-red-muted:hover {
  background: #c04040;
  border-color: #ff9999 #6b1818 #4a1010 #ff9999;
  color: #ffffff;
}

.btn.btn--mc-red-muted:active {
  border-color: #6b1818 #e87878 #e87878 #6b1818;
  background: #8a2828;
  transform: translateY(3px);
  box-shadow: 0 1px 0 #4a1010, inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.15);
}

.btn.btn--mc-orange {
  background: #e87820;
  border: 4px solid;
  border-color: #ffcc88 #9a4a10 #6a3008 #ffcc88;
  color: #ffffff;
  text-decoration: none;
  box-shadow:
    0 4px 0 #6a3008,
    inset 2px 2px 0 rgba(255, 255, 255, 0.22),
    inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}

.btn.btn--mc-orange:hover {
  background: #ff9830;
  border-color: #ffe0a0 #9a4a10 #6a3008 #ffe0a0;
  color: #ffffff;
}

.btn.btn--mc-orange:active {
  border-color: #9a4a10 #ffcc88 #ffcc88 #9a4a10;
  background: #c86818;
  transform: translateY(3px);
  box-shadow: 0 1px 0 #6a3008, inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.15);
}

.upload-drop {
  width: min(280px, 100%);
  min-height: 78px;
  margin: 0 auto;
  border: 4px solid;
  border-color: #ffffff #3a3a3a #3a3a3a #ffffff;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25% 50%, rgba(0, 0, 0, 0.1) 50% 75%, transparent 75%),
    #5a5a5a;
  background-size: 16px 16px;
  text-shadow: var(--mc-text-shadow);
  box-shadow: 0 4px 0 #242424, inset 2px 2px 0 rgba(255, 255, 255, 0.22), inset -2px -2px 0 rgba(0, 0, 0, 0.35);
  transition: border-color 0.1s, color 0.1s, background 0.1s, transform 0.1s, box-shadow 0.1s;
}

.upload-drop:hover {
  border-color: #ffffa0 #3a3a3a #3a3a3a #ffffa0;
  color: #ffffa0;
  background-color: #6a6a6a;
}

.upload-drop:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #242424, inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.18);
}

/* Step 1 — 3D */
#previewContainer {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.scene {
  width: min(500px, 90vw);
  height: min(500px, 90vw);
  perspective: 1000px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scene:active {
  cursor: grabbing;
}

.scene--frame-picker {
  width: min(260px, 70vw);
  height: min(260px, 70vw);
  margin: 0 auto 18px;
}

.scene--frame-picker #totemStack {
  width: 220px;
  height: 220px;
}

#totemStack {
  position: relative;
  width: 320px;
  height: 320px;
}

.totem-voxel-stack {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.totem-preview-host {
  display: block;
}

.totem-preview-host canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}

/* Editor layout — Minecraft UI */
.editor-page {
  --editor-chrome-h: 56px;
  --editor-sidebar-w: 76px;
  --editor-preview-w: 360px;
  --editor-ink: #ffffff;
  --editor-muted: #a0a0a0;
  --editor-line: #1a1a1a;
  --editor-surface: #2a2218;
  --editor-hover: #3d3226;
  --editor-active: #4a3d2e;
  --editor-active-line: #55ff55;
}

body.editor-page {
  text-shadow: var(--mc-text-shadow);
}

.editor-header {
  height: var(--editor-chrome-h);
  background: var(--editor-surface);
  border-bottom: 2px solid #000;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
  color: var(--editor-ink);
  box-shadow: 0 2px 0 #000;
}

.editor-header--dock {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
}

.editor-page .editor-header .btn--ghost {
  font-size: 13px;
  padding: 8px 12px;
}

.editor-page .editor-header .btn-header-resource-pack {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 10px;
  padding: 10px 14px 8px;
  line-height: 1.4;
  text-transform: uppercase;
}

.editor-body {
  display: flex;
  flex-grow: 1;
  overflow: hidden;
  min-height: 0;
  margin-top: var(--editor-chrome-h);
}

.sidebar {
  width: var(--editor-sidebar-w);
  background: var(--editor-surface);
  border-right: 2px solid #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 12px;
  gap: 4px;
  flex-shrink: 0;
  color: var(--editor-muted);
  box-shadow: 2px 0 0 #000;
}

.sidebar--dock {
  position: fixed;
  top: var(--editor-chrome-h);
  left: 0;
  height: calc(100vh - var(--editor-chrome-h));
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 30;
}

.viewport--with-sidebar {
  margin-left: var(--editor-sidebar-w);
}

.viewport--with-preview {
  margin-right: var(--editor-preview-w);
}

.tool-btn {
  width: 48px;
  height: 36px;
  min-height: 36px;
  background: #5a5a5a;
  border: 2px solid;
  border-color: #aaaaaa #2a2a2a #2a2a2a #aaaaaa;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 2px 0 #1c1c1c, inset 2px 2px 0 rgba(255, 255, 255, 0.18), inset -2px -2px 0 rgba(0, 0, 0, 0.32);
}

.tool-btn img {
  width: 44px;
  height: 32px;
  display: block;
  pointer-events: none;
  object-fit: contain;
  object-position: center;
  background: transparent;
}

.tool-btn:hover {
  background: #6a6a6a;
}

.tool-btn.active {
  background: var(--editor-active);
  border-color: #2a2a2a #aaaaaa #aaaaaa #2a2a2a;
  box-shadow: inset 0 0 0 1px var(--editor-active-line);
}

.hist-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.hist-btn {
  width: 28px;
  height: 28px;
  background: var(--mc-btn);
  border: 2px solid;
  border-color: #ffffff #3a3a3a #3a3a3a #ffffff;
  color: #ffffff;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-shadow: var(--mc-text-shadow);
  box-shadow: 0 2px 0 #1c1c1c;
}

.hist-btn:active:not(:disabled) {
  border-color: #3a3a3a #ffffff #ffffff #3a3a3a;
  background: var(--mc-btn-active);
}

.hist-btn svg {
  width: 18px;
  height: 18px;
}

.hist-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.viewport {
  flex-grow: 1;
  background-color: var(--mc-sign-bg);
  image-rendering: pixelated;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--mc-btn) #0a0a0a;
}

.viewport::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.viewport::-webkit-scrollbar-track {
  background: #0a0a0a;
  border: 1px solid #333;
}

.viewport::-webkit-scrollbar-thumb {
  background: var(--mc-btn);
  border: 2px solid;
  border-color: #fff #3a3a3a #3a3a3a #fff;
}

.editor-page .viewport {
  scrollbar-width: none;
}

.editor-page .viewport::-webkit-scrollbar {
  display: none;
}

.editor-workspace {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  max-width: 100%;
  margin: 0 auto;
}

.editor-wrapper {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  transform-origin: top center;
  transition: transform 0.1s ease-out;
  flex-shrink: 0;
}

.editor-preview-panel--dock {
  position: fixed;
  top: var(--editor-chrome-h);
  right: 0;
  width: var(--editor-preview-w);
  height: calc(100vh - var(--editor-chrome-h));
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 14px 20px;
  box-sizing: border-box;
  background: var(--editor-surface);
  border-left: 2px solid #000;
  box-shadow: -2px 0 0 #000;
  overflow-y: auto;
  overflow-x: hidden;
}

.editor-preview-title {
  margin: 0 0 14px;
  font-size: 11px;
  color: var(--editor-muted);
  text-transform: uppercase;
  text-align: center;
  text-shadow: var(--mc-text-shadow);
  flex-shrink: 0;
}

.scene--editor-preview {
  width: min(320px, calc(var(--editor-preview-w) - 28px));
  height: min(320px, calc(100vh - var(--editor-chrome-h) - 200px));
  min-height: 240px;
  flex: 1 1 auto;
  margin: 0 auto 16px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scene--editor-preview #totemStack {
  width: 100%;
  height: 100%;
  max-width: 320px;
  max-height: 320px;
}

.preview-speed-control {
  width: 100%;
  max-width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 10px;
  background: #101010;
  border: 2px solid #000;
  outline: 1px solid #555;
  box-shadow: var(--mc-panel-inset);
}

.preview-speed-control label {
  font-size: 11px;
  color: var(--editor-muted);
  text-transform: uppercase;
  text-shadow: var(--mc-text-shadow);
}

.preview-speed-unit {
  font-size: 11px;
  color: var(--editor-muted);
  text-shadow: var(--mc-text-shadow);
}

.preview-rotate-mode {
  width: 100%;
  max-width: 300px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.preview-rotate-toggle {
  width: 100%;
  font-size: 12px;
  padding: 10px 14px;
}

.preview-rotate-toggle--active {
  background: var(--mc-btn-primary);
  border-color: #9fdf7a #2d5018 #2d5018 #9fdf7a;
  color: #fff;
}

.preview-rotate-toggle--active:hover {
  background: var(--mc-btn-primary-hover);
  color: #ffffa0;
}

.mc-stepper {
  display: flex;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}

.mc-step-btn {
  width: 36px;
  min-height: 36px;
  flex-shrink: 0;
  padding: 0;
  background: var(--mc-btn);
  border: 2px solid;
  border-color: #ffffff #3a3a3a #3a3a3a #ffffff;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: var(--mc-text-shadow);
  box-shadow: 0 2px 0 #1c1c1c, inset 2px 2px 0 rgba(255, 255, 255, 0.18), inset -2px -2px 0 rgba(0, 0, 0, 0.32);
}

.mc-step-btn svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.mc-step-btn:hover {
  background: var(--mc-btn-hover);
  color: #ffffa0;
}

.mc-step-btn:active {
  border-color: #3a3a3a #ffffff #ffffff #3a3a3a;
  background: var(--mc-btn-active);
  transform: translateY(2px);
  box-shadow: 0 0 0 #1c1c1c, inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.18);
}

.mc-step-field {
  flex: 1;
  min-width: 0;
  background: #0d0d0d;
  border: 2px solid;
  border-color: #3a3a3a #ffffff #ffffff #3a3a3a;
  color: var(--editor-ink);
  padding: 8px 6px;
  border-radius: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 14px;
  text-shadow: var(--mc-text-shadow);
  -moz-appearance: textfield;
  appearance: textfield;
}

.mc-step-field::-webkit-outer-spin-button,
.mc-step-field::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.mc-step-field:focus {
  outline: none;
  border-color: var(--editor-active-line) #2a5a2a #2a5a2a var(--editor-active-line);
}

.frame-highlight {
  position: absolute;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 7;
  box-sizing: border-box;
  border: 2px solid #a8a8a8;
  background: transparent;
  box-shadow: none;
}

.frame-label--active {
  color: var(--accent);
}

.canvas-container {
  --canvas-bg: #0d0f14;
  position: relative;
  border: 2px solid #000;
  outline: 2px solid var(--border-dark);
  background-color: var(--canvas-bg);
  line-height: 0;
  border-radius: 0;
  overflow: hidden;
  touch-action: none;
  box-shadow: var(--mc-panel-inset), var(--shadow-lg);
}

.canvas-container.cursor-crosshair {
  cursor: crosshair;
}

.canvas-container.cursor-zoom {
  cursor: zoom-in;
}

.brush-preview {
  position: absolute;
  pointer-events: none;
  z-index: 8;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.9);
  outline: none;
  opacity: 0.55;
  mix-blend-mode: normal;
}

.brush-preview--eraser {
  background: var(--canvas-bg);
  opacity: 0.55;
}

.brush-preview--fill,
.brush-preview--picker {
  opacity: 0.45;
}

#editorCanvas {
  width: 160px;
  height: calc(var(--editor-frame-count, 11) * 160px);
  display: block;
  image-rendering: pixelated;
}

.labels-column {
  display: flex;
  flex-direction: column;
  margin-left: 16px;
}

.frame-label {
  height: calc(var(--editor-frame-display, 160) * 1px);
  display: flex;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: var(--mc-text-shadow);
}

.selection-box {
  position: absolute;
  border: 1px dashed rgba(255, 255, 255, 0.95);
  pointer-events: none;
  display: none;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.08);
  z-index: 6;
  box-sizing: border-box;
}

.selection-box--active {
  background: rgba(255, 255, 255, 0.1);
  animation: selection-dash 0.6s linear infinite;
}

@keyframes selection-dash {
  to {
    border-color: rgba(255, 255, 255, 0.45);
  }
}

#selectionCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.frame-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}

.frame-picker-modal[hidden] {
  display: none;
}

.frame-picker-modal__backdrop {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--totem-marquee-panel-w);
  right: var(--totem-marquee-panel-w);
  background: var(--mc-sign-bg);
  pointer-events: auto;
}

.frame-picker-card {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  padding: clamp(24px, 5vw, 36px);
  max-width: 380px;
  width: 100%;
  text-align: center;
  background: var(--mc-sign-bg);
  border: 4px solid #120d08;
  outline: 3px solid #c6b79b;
  box-shadow: var(--mc-panel-inset), var(--shadow-lg);
}

.frame-picker-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.frame-picker-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  text-shadow: var(--mc-text-shadow);
}

.frame-picker-range {
  width: 100%;
  margin: 0 0 8px;
  accent-color: var(--mc-btn-primary);
}

input[type="range"] {
  height: 20px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: #101010;
  border: 2px solid #555;
  box-shadow: inset 2px 2px 0 #000;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  background: var(--mc-btn);
  border: 2px solid;
  border-color: #ffffff #3a3a3a #3a3a3a #ffffff;
  border-radius: 0;
}

.frame-picker-value {
  display: block;
  font-size: 1.75rem;
  color: var(--accent);
  margin-bottom: 20px;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--mc-text-shadow);
}

.editor-page .hist-row--header {
  margin-top: 0;
  gap: 2px;
  background: #1a1a1a;
  padding: 3px 8px;
  border-radius: 0;
  border: 2px solid #000;
  outline: 1px solid #555;
}

.editor-page .hist-row--header .hist-btn {
  background: transparent;
  border: none;
}

.editor-page .hist-row--header .hist-btn:hover:not(:disabled) {
  background: var(--editor-hover);
}

.color-wheel {
  position: relative;
  width: 31px;
  height: 31px;
  padding: 0;
  border: 2px solid #000;
  outline: 1px solid #888;
  border-radius: 0;
  background: conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: pointer;
  box-shadow: inset 0 0 0 2px #333;
  image-rendering: pixelated;
}

.color-wheel input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.color-wheel span {
  position: absolute;
  right: -5px;
  top: -5px;
  width: 13px;
  height: 13px;
  border-radius: 0;
  background: var(--mc-btn);
  border: 2px solid;
  border-color: #fff #3a3a3a #3a3a3a #fff;
  color: #fff;
  font-size: 10px;
  line-height: 9px;
  text-align: center;
  pointer-events: none;
  text-shadow: var(--mc-text-shadow);
}

.active-colors {
  position: relative;
  width: 36px;
  height: 36px;
  margin: 5px 0 2px;
}

.active-color {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 0;
  border: 2px solid #000;
  padding: 0;
  cursor: pointer;
  image-rendering: pixelated;
}

.active-color--primary {
  left: 0;
  top: 0;
  z-index: 2;
  background: #ffcc00;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #111;
}

.active-color--secondary {
  right: 0;
  bottom: 0;
  background: #ffffff;
}

.palette {
  display: grid;
  grid-template-columns: repeat(2, 15px);
  gap: 6px 9px;
  padding: 2px 0 4px;
}

.color-swatch {
  width: 15px;
  height: 15px;
  border-radius: 0;
  cursor: pointer;
  border: 2px solid #000;
  padding: 0;
  image-rendering: pixelated;
}

.color-swatch:hover {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.color-swatch--primary {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.color-swatch--secondary {
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px #666;
}

.color-swatch--empty {
  background: #2a2218;
  cursor: default;
  opacity: 0.45;
}

.color-swatch--empty:hover {
  outline: none;
}

.size-control label {
  color: var(--editor-muted);
  font-size: 11px;
  line-height: 1.3;
  text-shadow: var(--mc-text-shadow);
  text-transform: uppercase;
}

.size-control {
  width: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.size-control input {
  width: 45px;
  accent-color: #2f7dd1;
}

.size-control strong {
  color: var(--editor-ink);
  font-size: 12px;
  text-shadow: var(--mc-text-shadow);
}

.size-control input {
  accent-color: var(--mc-btn-primary);
}

/* Preview step */
.preview-header {
  position: absolute;
  top: 0;
  width: 100%;
  height: 56px;
  background: var(--surface-solid);
  border-bottom: 4px solid #000;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
  box-shadow: 0 4px 0 #000;
}

.preview-header a {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-family: var(--font);
  text-shadow: var(--mc-text-shadow);
  padding: 6px 12px;
  background: var(--mc-btn);
  border: 2px solid;
  border-color: #fff #3a3a3a #3a3a3a #fff;
}

.preview-header a:hover {
  background: var(--mc-btn-hover);
  color: #ffffa0;
  text-decoration: none;
}

.preview-header a:active {
  border-color: #3a3a3a #fff #fff #3a3a3a;
  background: var(--mc-btn-active);
}

#previewContainer.preview-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 360px;
  padding-top: 72px;
}

#previewContainer.preview-step--form-only {
  max-width: 520px;
  width: 100%;
  padding-left: 16px;
  padding-right: 16px;
  box-sizing: border-box;
}

.controls-card--resource-pack {
  max-width: 100%;
  align-items: center;
  text-align: center;
  padding: 28px 24px 24px;
  gap: 18px;
  outline-color: #c6b79b;
  background: var(--mc-sign-bg);
}

.controls-card--resource-pack .input-group {
  width: 100%;
  max-width: 380px;
  align-items: center;
  text-align: center;
}

.controls-card--resource-pack label {
  width: 100%;
  text-align: center;
}

.controls-card--resource-pack .hint {
  text-align: center;
  max-width: 36ch;
  margin-left: auto;
  margin-right: auto;
}

.controls-card--resource-pack input,
.controls-card--resource-pack select {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.controls-card--resource-pack .input-group--pack-icon {
  margin-top: 0;
  max-width: 420px;
}

.controls-card--resource-pack .pack-icon-row {
  justify-content: center;
  align-items: center;
  width: 100%;
}

.controls-card--resource-pack .pack-icon-actions {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  justify-content: center;
  align-items: center;
}

.controls-card--resource-pack .pack-icon-upload-row {
  margin-top: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.controls-card--resource-pack .grid-2 {
  margin-top: 0;
  width: 100%;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
  justify-items: center;
}

.controls-card--resource-pack .input-group--version,
.controls-card--resource-pack .input-group--speed {
  align-items: center;
  text-align: center;
  width: 100%;
}

.controls-card--resource-pack .input-group--version select {
  text-align: center;
  text-align-last: center;
}

.controls-card--resource-pack .input-group--speed .time-badge {
  padding: 10px 0;
  width: 100%;
  text-align: center;
}

.controls-card--resource-pack .btn--mc-block {
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

.controls-card {
  background:
    linear-gradient(rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.08)),
    var(--surface);
  border: 4px solid #120d08;
  outline: 3px solid #5b452e;
  padding: 20px;
  border-radius: var(--radius-lg);
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--mc-panel-inset), var(--shadow-lg);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.controls-card label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  text-shadow: var(--mc-text-shadow);
}

.controls-card input,
.controls-card select {
  background: #0d0d0d;
  border: 2px solid;
  border-color: #3a3a3a #fff #fff #3a3a3a;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 0;
  font-size: 12px;
  outline: none;
  font-family: var(--font);
  text-shadow: var(--mc-text-shadow);
}

.controls-card input:focus,
.controls-card select:focus {
  border-color: var(--accent) #2a5a2a #2a5a2a var(--accent);
}

.controls-card select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #aaa 50%),
    linear-gradient(135deg, #aaa 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.time-badge {
  color: var(--accent);
  font-size: 14px;
  font-family: var(--mono);
  text-shadow: var(--mc-text-shadow);
}

.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
  text-shadow: var(--mc-text-shadow);
}

.hint a,
.export-card a {
  color: var(--accent);
  text-decoration: none;
}

.hint a:hover,
.export-card a:hover {
  color: var(--accent-hover);
}

.pack-icon-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pack-icon-actions {
  flex: 1;
  min-width: 180px;
  min-height: 112px;
  display: flex;
  align-items: center;
}

.pack-icon-upload-row {
  margin-top: 6px;
}

.controls-card--resource-pack .btn--pack-icon {
  font-size: 13px;
  padding: 13px 20px 11px;
  border-width: 4px;
  border-radius: 0;
}

.pack-icon-size-hint:empty {
  display: none;
  margin: 0;
}

.pack-version-hint {
  margin: 0;
  text-align: center;
  font-size: 10px;
  line-height: 1.6;
  max-width: 28ch;
}

.pack-icon-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.pack-icon-preview-wrap {
  flex-shrink: 0;
  width: 112px;
  height: 112px;
  border-radius: 0;
  border: 4px solid #000;
  outline: 2px solid #777;
  background-color: var(--mc-sign-bg);
  image-rendering: pixelated;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.pack-icon-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.pack-icon-preview-placeholder {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 8px;
  line-height: 1.35;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Export card */
.export-card {
  background: var(--mc-sign-bg);
  border: 4px solid #120d08;
  outline: 3px solid #c6b79b;
  padding: 36px 28px;
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--mc-panel-inset), var(--shadow-lg);
}

.export-done-title {
  margin: 0 0 16px;
  font-size: clamp(1rem, 3.5vw, 1.35rem);
  font-weight: bold;
}

.export-done-desc {
  margin: 0 0 20px;
}

.export-card--done .btn--mc-block {
  margin-bottom: 10px;
}

.export-download-btn {
  display: inline-block;
  text-decoration: none;
}

.export-download-btn--compact {
  margin: 4px auto 0;
  padding: 10px 22px 8px;
  font-size: 11px;
  border-width: 3px;
  width: auto;
  max-width: 200px;
}

.export-restart {
  margin: 20px 0 0;
}

.export-restart a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.export-restart a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.loader {
  width: 48px;
  height: 48px;
  border: 4px solid #000;
  border-radius: 0;
  background:
    linear-gradient(90deg, var(--accent) 0 50%, transparent 50% 100%),
    linear-gradient(#3a3a3a 0 50%, #101010 50% 100%);
  background-size: 16px 16px, 100% 100%;
  animation: spin 0.8s steps(4) infinite;
  margin: 20px auto;
  image-rendering: pixelated;
}

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

.status-text {
  font-size: 16px;
  margin-bottom: 8px;
  text-shadow: var(--mc-text-shadow);
}

.desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.65;
  text-shadow: var(--mc-text-shadow);
}

.export-card code {
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--accent);
}

.btn-ready {
  background: var(--mc-btn-primary);
  color: #fff;
  border: 2px solid;
  border-color: #9fdf7a #2d5018 #2d5018 #9fdf7a;
  padding: 14px 28px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  display: none;
  text-decoration: none;
  transition: background 0.08s, border-color 0.08s, transform 0.08s, box-shadow 0.08s;
  font-family: var(--font);
  text-shadow: var(--mc-text-shadow);
  box-shadow: 0 4px 0 #1f3518, inset 2px 2px 0 rgba(255, 255, 255, 0.22), inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}

.btn-ready:hover {
  background: var(--mc-btn-primary-hover);
  color: #ffffa0;
  text-decoration: none;
}

.btn-ready:active {
  border-color: #2d5018 #9fdf7a #9fdf7a #2d5018;
  background: var(--mc-btn-primary-active);
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1f3518, inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.18);
}

.frame-picker-range {
  accent-color: var(--mc-btn-primary);
}

input[type="range"] {
  accent-color: var(--mc-btn-primary);
}

strong {
  font-weight: normal;
  text-shadow: var(--mc-text-shadow);
}

.flex-spacer {
  flex-grow: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* —— Кнопка «Поддержать автора» —— */
body.has-site-support {
  padding-bottom: 72px;
}

.lang-switcher {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  gap: 0;
  border: 2px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  background: var(--mc-btn);
}

.lang-switcher__btn {
  font-family: var(--font);
  font-size: 10px;
  line-height: 1;
  padding: 8px 12px 6px;
  border: none;
  background: var(--mc-btn);
  color: var(--text);
  cursor: pointer;
  text-shadow: var(--mc-text-shadow);
}

.lang-switcher__btn:hover {
  background: var(--mc-btn-hover);
}

.lang-switcher__btn.is-active {
  background: var(--mc-btn-primary);
  color: #fff;
}

.lang-switcher__btn.is-active:hover {
  background: var(--mc-btn-primary-hover);
}

.lang-switcher__btn + .lang-switcher__btn {
  border-left: 2px solid var(--border-strong);
}

.site-support-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 220;
  width: min(420px, calc(100vw - 48px));
  pointer-events: none;
}

.site-support-bar .btn--site-support {
  pointer-events: auto;
  display: block;
  width: 100%;
  padding: 12px 18px 10px;
  font-size: 12px;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.editor-page.has-site-support {
  padding-bottom: 0;
}

.editor-page .editor-header .btn-header-support {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 10px;
  padding: 10px 14px 8px;
  line-height: 1.4;
  text-transform: uppercase;
  text-decoration: none;
  margin-left: 8px;
}

/* —— Боковые ленты тотемов (landing) —— */
body.landing-with-marquee .app-shell,
body.landing-with-marquee .preview-header {
  position: relative;
  z-index: 2;
}

.totem-marquee-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--totem-marquee-panel-w);
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  background: rgba(12, 10, 8, 0.42);
  border: 2px solid rgba(0, 0, 0, 0.65);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 11%,
    #000 89%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 11%,
    #000 89%,
    transparent 100%
  );
}

.totem-marquee-panel--left {
  left: 0;
  border-right-color: #1a1510;
  border-left: none;
}

.totem-marquee-panel--right {
  right: 0;
  border-left-color: #1a1510;
  border-right: none;
}

.totem-marquee-panel__inner {
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0 clamp(6px, 0.8vw, 14px);
  width: 100%;
}

.totem-marquee-panel__cols {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: var(--totem-marquee-col-gap);
  height: 100%;
  width: 100%;
}

.totem-marquee-col {
  flex: 0 0 auto;
  width: var(--totem-marquee-item);
  height: 100%;
  overflow: hidden;
}

.totem-marquee-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--totem-marquee-gap);
  width: 100%;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
  contain: layout style;
}

.totem-marquee-track--loading {
  visibility: hidden;
}

.totem-marquee-col--up .totem-marquee-track:not(.totem-marquee-track--loading) {
  animation: totem-marquee-up var(--totem-marquee-duration) linear infinite;
}

.totem-marquee-col--down .totem-marquee-track:not(.totem-marquee-track--loading) {
  animation: totem-marquee-down var(--totem-marquee-duration) linear infinite;
}

@keyframes totem-marquee-up {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(0, calc(0px - var(--marquee-shift, 0px)), 0);
  }
}

@keyframes totem-marquee-down {
  from {
    transform: translate3d(0, calc(0px - var(--marquee-shift, 0px)), 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

.totem-marquee-item {
  flex: 0 0 auto;
  width: var(--totem-marquee-item);
  height: var(--totem-marquee-item);
  display: flex;
  align-items: center;
  justify-content: center;
}

.totem-marquee-item img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  image-rendering: pixelated;
  display: block;
}

@media (max-width: 768px) {
  .totem-marquee-panel {
    display: none;
  }

  .frame-picker-modal__backdrop {
    left: 0;
    right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .totem-marquee-col--up .totem-marquee-track,
  .totem-marquee-col--down .totem-marquee-track {
    animation: none;
  }
}
