/* ============================================================
   MC 绿幕工作台 · 视觉系统
   深色专业工具外壳 + 克制的 Minecraft 方块质感
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  /* 背景层级：从最深到抬起 */
  --void: #0a0d11;
  --panel: #141922;
  --panel-2: #1a212b;
  --raised: #202834;
  --inset: #0d1116;
  --well: #10151b;

  /* 描边 / 斜角 */
  --stroke: #262f3b;
  --stroke-soft: #202832;
  --stroke-strong: #38455670;
  --bevel-light: rgba(255, 255, 255, 0.05);
  --bevel-dark: rgba(0, 0, 0, 0.45);

  /* 文字 */
  --text: #eef3f9;
  --text-dim: #9fadbc;
  --text-mute: #66727f;

  /* MC 功能色 */
  --diamond: #34d3e6; /* 主强调 · 选中 */
  --diamond-soft: #0e2e36;
  --emerald: #3ad07f; /* 播放 · 成功 */
  --gold: #ffcf5c; /* 提示 · 高亮 */
  --redstone: #ff5d5d; /* 录制 · 危险 */
  --lapis: #4a8bff; /* 信息 */
  --chroma: #00ff00; /* 绿幕颜色 */

  --shadow-panel: 0 1px 0 var(--bevel-light) inset, 0 -1px 0 var(--bevel-dark) inset;
  --shadow-drop: 0 18px 44px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 12px 30px rgba(0, 0, 0, 0.5);

  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 13px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --pad: 14px;

  --header-h: 56px;
  --rail-left: 316px;
  --rail-right: 340px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body.gsm-page {
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
  margin: 0;
  min-height: 100%;
}

html:not([data-theme="day"]) body.gsm-page {
  background: var(--void);
}

html:not([data-theme="day"]) body.gsm-page::before {
  background:
    radial-gradient(1200px 600px at 72% -10%, rgba(52, 211, 230, 0.06), transparent 60%),
    radial-gradient(900px 500px at 8% 110%, rgba(58, 208, 127, 0.05), transparent 60%),
    var(--void);
  filter: none;
  transform: translateZ(0);
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: #2a3441;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: #34424f;
  background-clip: padding-box;
}

/* ============================================================
   应用外壳
   ============================================================ */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

/* ---------- 顶栏 ---------- */
.appbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(180deg, #171d26, #12171f);
  box-shadow: 0 1px 0 var(--bevel-dark);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-cube {
  width: 34px;
  height: 34px;
  flex: none;
  position: relative;
  image-rendering: pixelated;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 44%),
    linear-gradient(#7cc15a 0 36%, #6ab04c 36% 44%, #8d6e44 44% 100%);
  border: 2px solid #0c1116;
  box-shadow: 0 0 0 1px #3c4a3a, inset -3px -3px 0 rgba(0, 0, 0, 0.28), inset 3px 3px 0 rgba(255, 255, 255, 0.14);
}

.brand-text {
  min-width: 0;
}
.brand-text h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
  white-space: nowrap;
}
.brand-text p {
  font-size: 11.5px;
  color: var(--text-mute);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-spacer {
  flex: 1;
}

.health {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--inset);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
}
.health .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 207, 92, 0.16);
  transition: background 0.3s, box-shadow 0.3s;
}
.health[data-state="ready"] .dot {
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(58, 208, 127, 0.18);
}
.health[data-state="error"] .dot {
  background: var(--redstone);
  box-shadow: 0 0 0 3px rgba(255, 93, 93, 0.18);
}
.health[data-state="loading"] .dot {
  animation: blink 1s var(--ease) infinite;
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

.kbd-hint {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--text-mute);
  font-size: 11.5px;
  font-weight: 600;
}
.kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  text-align: center;
  border: 1px solid var(--stroke-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--raised);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
}

/* ============================================================
   主体三栏
   ============================================================ */
.workspace {
  display: grid;
  grid-template-columns: var(--rail-left) minmax(0, 1fr) var(--rail-right);
  min-height: 0;
  min-width: 0;
}

.rail {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rail--left {
  border-right: 1px solid var(--stroke);
}
.rail--right {
  border-left: 1px solid var(--stroke);
}

/* ---------- 面板分组 ---------- */
.section {
  padding: 16px 16px 18px;
  border-bottom: 1px solid var(--stroke-soft);
}
.section:last-child {
  border-bottom: 0;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}
.section-head .tick {
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: var(--diamond);
  box-shadow: 0 0 10px rgba(52, 211, 230, 0.5);
}
.section-head h2 {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.section-head .sub {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
}

/* ============================================================
   模板画廊
   ============================================================ */
.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tpl {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  text-align: left;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  background: var(--panel-2);
  box-shadow: var(--shadow-panel);
  cursor: pointer;
  transition: transform 0.14s var(--ease), border-color 0.14s var(--ease), background 0.14s var(--ease);
}
.tpl:hover {
  transform: translateY(-1px);
  border-color: #3a4756;
  background: var(--raised);
}
.tpl:active {
  transform: translateY(0);
}
.tpl-ico {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: radial-gradient(circle at 50% 35%, #223, #10151b);
  border: 1px solid var(--stroke);
  overflow: hidden;
}
.tpl-ico img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}
.tpl-txt {
  min-width: 0;
}
.tpl-name {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
}
.tpl-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-mute);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tpl[aria-pressed="true"] {
  border-color: var(--diamond);
  background: linear-gradient(180deg, #123039, var(--diamond-soft));
  box-shadow: 0 0 0 1px var(--diamond) inset, 0 8px 22px rgba(52, 211, 230, 0.16);
}
.tpl[aria-pressed="true"] .tpl-name {
  color: #d7fbff;
}
.tpl[aria-pressed="true"] .tpl-tag {
  color: #7fd8e5;
}
.tpl[aria-pressed="true"] .tpl-ico {
  border-color: #2f7b88;
  background: radial-gradient(circle at 50% 35%, #16414c, #0c2830);
}

.tpl-hint {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-sm);
  background: var(--inset);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
}

/* ============================================================
   素材库
   ============================================================ */
.current-asset {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  background: var(--inset);
}
.current-asset .thumb {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: repeating-conic-gradient(#161b22 0% 25%, #1b212a 0% 50%) 50% / 14px 14px;
  border: 1px solid var(--stroke);
}
.current-asset .thumb img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
}
.current-asset .meta {
  min-width: 0;
}
.current-asset .meta .k {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.current-asset .meta .v {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.current-asset .meta .f {
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 三物品槽位 */
.slots {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.slots.show {
  display: grid;
}
.slot {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 4px;
  padding: 8px 6px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease);
}
.slot img {
  width: 100%;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
}
.slot span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-align: center;
}
.slot[aria-pressed="true"] {
  border-color: var(--diamond);
  background: var(--diamond-soft);
  box-shadow: 0 0 0 1px var(--diamond) inset;
}
.slot[aria-pressed="true"] span {
  color: #a9ecf4;
}

/* 搜索 + 分类 */
.searchbar {
  position: relative;
  margin-bottom: 10px;
}
.searchbar input {
  padding-left: 32px;
}
.searchbar .ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
  font-size: 13px;
  pointer-events: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.chip {
  padding: 5px 11px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.14s var(--ease), color 0.14s var(--ease), background 0.14s var(--ease);
}
.chip:hover {
  border-color: #3a4756;
}
.chip[aria-pressed="true"] {
  border-color: var(--diamond);
  color: #c7f6fc;
  background: var(--diamond-soft);
}

/* 素材网格 */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 7px;
  max-height: 264px;
  overflow-y: auto;
  padding: 4px;
}
.asset {
  position: relative;
  aspect-ratio: 1;
  padding: 7px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  cursor: pointer;
  transition: transform 0.12s var(--ease), border-color 0.12s var(--ease), background 0.12s var(--ease);
}
.asset:hover {
  transform: translateY(-2px);
  border-color: #3a4756;
  background: var(--raised);
}
.asset img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.asset[aria-pressed="true"] {
  border-color: var(--diamond);
  background: var(--diamond-soft);
  box-shadow: 0 0 0 1px var(--diamond) inset, 0 6px 16px rgba(52, 211, 230, 0.18);
}

.asset-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 4px 0;
  font-size: 11px;
  color: var(--text-mute);
}
.asset-pager-btn {
  padding: 4px 10px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.asset-pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.asset-pager-meta {
  font-weight: 600;
  white-space: nowrap;
}
.asset[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--diamond);
  box-shadow: 0 0 8px var(--diamond);
}

/* 收藏星标 */
.fav-star {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1;
  color: #5a6472;
  background: rgba(6, 10, 14, 0.5);
  opacity: 0;
  transition: opacity 0.12s var(--ease), color 0.12s var(--ease), background 0.12s var(--ease);
}
.asset:hover .fav-star {
  opacity: 1;
}
.fav-star:hover {
  color: var(--gold);
  background: rgba(6, 10, 14, 0.85);
}
.fav-star.on {
  opacity: 1;
  color: var(--gold);
}

/* 最近使用 */
.recent {
  margin-bottom: 12px;
}
.recent-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-mute);
  margin-bottom: 7px;
}
.recent-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 3px;
}
.recent-item {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 6px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  cursor: pointer;
  transition: transform 0.12s var(--ease), border-color 0.12s var(--ease);
}
.recent-item:hover {
  transform: translateY(-2px);
  border-color: #3a4756;
}
.recent-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* 素材骨架屏 */
.asset.skeleton {
  cursor: default;
  border-color: var(--stroke-soft);
  background: linear-gradient(100deg, var(--panel-2) 30%, var(--raised) 50%, var(--panel-2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.asset.skeleton:hover {
  transform: none;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.upload {
  margin-top: 12px;
}

/* ============================================================
   通用表单控件
   ============================================================ */
.field {
  display: grid;
  gap: 6px;
}
.field > label,
.control-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

input[type="text"],
input[type="search"],
select {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm);
  background: var(--well);
  color: var(--text);
  outline: none;
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
input:focus,
select:focus {
  border-color: var(--diamond);
  box-shadow: 0 0 0 3px rgba(52, 211, 230, 0.14);
}

/* 颜色选择器 */
.color-field {
  display: grid;
  gap: 6px;
}
.color-input {
  position: relative;
  height: 36px;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
}
.color-input input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}
.color-input .swatch-label {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  pointer-events: none;
  text-transform: uppercase;
}

/* 分段切换控件 */
.segmented {
  display: flex;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm);
  background: var(--well);
  overflow: hidden;
}
.segmented button {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.segmented button + button {
  border-left: 1px solid var(--stroke-strong);
}
.segmented button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.segmented button[aria-pressed="true"] {
  color: #d7fbff;
  background: var(--diamond-soft);
  box-shadow: 0 0 0 1px var(--diamond) inset;
}
.segmented.sm button {
  height: 34px;
  font-size: 11.5px;
  font-weight: 700;
}

.field-note {
  margin-top: 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-mute);
}

.is-dim {
  opacity: 0.4;
  transition: opacity 0.2s var(--ease);
}

/* 文件上传 */
.file-drop {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px dashed var(--stroke-strong);
  border-radius: var(--r-md);
  background: var(--inset);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease), color 0.14s var(--ease);
}
.file-drop:hover {
  border-color: var(--diamond);
  color: var(--text);
  background: var(--diamond-soft);
}
.file-drop .plus {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--raised);
  color: var(--diamond);
  font-size: 17px;
  font-weight: 800;
}
.file-drop input {
  display: none;
}

/* ============================================================
   参数滑块（右栏）
   ============================================================ */
.param {
  margin-bottom: 15px;
  transition: opacity 0.2s var(--ease);
}
.param:last-child {
  margin-bottom: 0;
}
.param-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.param-head label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
.param-val {
  min-width: 44px;
  padding: 2px 8px;
  border: 1px solid var(--stroke);
  border-radius: 5px;
  background: var(--well);
  color: var(--diamond);
  font-size: 11.5px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.param.inactive {
  opacity: 0.38;
}
.param.inactive .param-val {
  color: var(--text-mute);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--diamond) var(--fill, 0%), #232c37 var(--fill, 0%));
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: #232c37;
}
input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--diamond);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -6px;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: #eaf7fa;
  border: 2px solid #0c2a30;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--diamond);
  transition: transform 0.12s var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: #eaf7fa;
  border: 2px solid #0c2a30;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--diamond);
}

/* ============================================================
   中央舞台
   ============================================================ */
.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--void);
}

.stage-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(180deg, #12171f, #0e131a);
}
.stage-bar .title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 13.5px;
}
.stage-bar .title .rec-dot {
  display: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--redstone);
}
.stage.is-recording .stage-bar .title .rec-dot {
  display: inline-block;
  animation: recpulse 1s var(--ease) infinite;
}
@keyframes recpulse {
  50% {
    opacity: 0.25;
  }
}
.stage-bar .spacer {
  flex: 1;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  background: var(--inset);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge b {
  color: var(--text);
}
.badge .lab {
  color: var(--text-mute);
  font-weight: 700;
}

/* 画布区 */
.canvas-area {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.014) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px) 0 0 / 26px 26px,
    radial-gradient(700px 400px at 50% 40%, rgba(52, 211, 230, 0.04), transparent 70%),
    #090c10;
}
#preview {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-sm);
  border: 1px solid #2a3340;
  background: var(--chroma);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03);
}
.stage.is-recording #preview {
  box-shadow: 0 0 0 2px var(--redstone), 0 0 34px rgba(255, 93, 93, 0.32), 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* 拖拽导入高亮 */
.canvas-area.drag-over::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--diamond);
  border-radius: var(--r-md);
  background: rgba(52, 211, 230, 0.06);
  pointer-events: none;
  z-index: 5;
}
.drop-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 6;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(9, 12, 16, 0.92);
  border: 1px solid var(--diamond);
  color: #d7fbff;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}
.canvas-area.drag-over .drop-hint {
  display: block;
}

/* 舞台角标（相机取景框感） */
.canvas-area .corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.canvas-area .corner.tl {
  top: 12px;
  left: 12px;
  border-right: 0;
  border-bottom: 0;
}
.canvas-area .corner.tr {
  top: 12px;
  right: 12px;
  border-left: 0;
  border-bottom: 0;
}
.canvas-area .corner.bl {
  bottom: 12px;
  left: 12px;
  border-right: 0;
  border-top: 0;
}
.canvas-area .corner.br {
  bottom: 12px;
  right: 12px;
  border-left: 0;
  border-top: 0;
}

/* REC 浮标 */
.rec-flag {
  position: absolute;
  top: 18px;
  left: 18px;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(20, 6, 6, 0.82);
  border: 1px solid var(--redstone);
  color: #ffdada;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  z-index: 3;
}
.stage.is-recording .rec-flag {
  display: inline-flex;
}
.rec-flag .blip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--redstone);
  animation: recpulse 1s var(--ease) infinite;
}

/* 加载 / 错误 遮罩 */
.stage-overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(9, 12, 16, 0.78);
  backdrop-filter: blur(3px);
  z-index: 4;
}
.stage-overlay.show {
  display: grid;
}
.stage-overlay .box {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
  padding: 26px 34px;
}
.spinner {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 44%),
    linear-gradient(#7cc15a 0 36%, #8d6e44 36% 100%);
  border: 2px solid #0c1116;
  image-rendering: pixelated;
  animation: spin 1.1s steps(8) infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.stage-overlay .msg {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.stage-overlay .sub {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 600;
  max-width: 320px;
  line-height: 1.5;
}
.stage-overlay.error .spinner {
  animation: none;
  background: #2a1414;
  border-color: var(--redstone);
}

/* ---------- 时间轴 + 走带 ---------- */
.transport {
  border-top: 1px solid var(--stroke);
  background: linear-gradient(180deg, #12171f, #0d1219);
  padding: 12px 18px 14px;
  display: grid;
  gap: 11px;
}

.timeline {
  position: relative;
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.timeline .track {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #1a222c;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.timeline .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2aa7b8, var(--diamond));
}
.timeline .playhead {
  position: absolute;
  top: 50%;
  left: 0;
  width: 6px;
  height: 22px;
  border-radius: 3px;
  background: #eaf7fa;
  border: 1px solid #0c2a30;
  box-shadow: 0 0 0 1px var(--diamond), 0 2px 6px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.stage.is-recording .timeline {
  cursor: not-allowed;
  opacity: 0.7;
}
.stage.is-recording .timeline .fill {
  background: linear-gradient(90deg, #b83a3a, var(--redstone));
}

.transport-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.transport-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tbtn {
  min-width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--stroke-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease), background 0.14s var(--ease);
}
.tbtn:hover:not(:disabled) {
  color: var(--text);
  border-color: #46545f;
  background: #26303c;
}
.tbtn:active:not(:disabled) {
  transform: translateY(1px);
  border-bottom-width: 1px;
}
.tbtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tbtn.play {
  min-width: 92px;
  color: #06231a;
  background: var(--emerald);
  border-color: #1f6b46;
  font-size: 13px;
}
.tbtn.play:hover:not(:disabled) {
  background: #4bdd8c;
  color: #06231a;
}
.tbtn.play[data-mode="pause"] {
  color: var(--text);
  background: var(--raised);
  border-color: var(--stroke-strong);
}

.readout {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.readout .chip-read {
  padding: 6px 11px;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  background: var(--well);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.readout .chip-read b {
  color: var(--diamond);
}

/* ============================================================
   导出（右栏）
   ============================================================ */
.export-block {
  display: grid;
  gap: 12px;
}
.btn-record {
  position: relative;
  width: 100%;
  height: 52px;
  border: 1px solid #8a2f2f;
  border-bottom-width: 3px;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #ff6b6b, var(--redstone));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.1s var(--ease), filter 0.14s var(--ease);
}
.btn-record:hover:not(:disabled) {
  filter: brightness(1.06);
}
.btn-record:active:not(:disabled) {
  transform: translateY(2px);
  border-bottom-width: 1px;
}
.btn-record:disabled {
  cursor: default;
  background: linear-gradient(180deg, #3a2530, #2a1a22);
  border-color: #4a2a2a;
  color: #ffd6d6;
}
.btn-record .rec-label {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.btn-record .rec-label .rc {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}
.btn-record .prog {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: rgba(255, 255, 255, 0.18);
  z-index: 1;
}

.result {
  display: none;
  padding: 13px;
  border: 1px solid var(--emerald);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #10281d, #0d1f17);
  box-shadow: 0 0 0 1px rgba(58, 208, 127, 0.2) inset;
}
.result.show {
  display: block;
  animation: rise 0.28s var(--ease);
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.result .r-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 800;
  color: #b6f2d1;
}
.result .r-head .ok {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--emerald);
  color: #06231a;
  font-size: 12px;
  font-weight: 900;
}
.result .r-meta {
  font-size: 11.5px;
  color: #7dcfa4;
  font-weight: 600;
  margin-bottom: 11px;
  font-variant-numeric: tabular-nums;
}
.result .r-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.btn {
  height: 40px;
  padding: 0 14px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--stroke-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s var(--ease), background 0.14s var(--ease), border-color 0.14s var(--ease);
}
.btn:hover {
  background: #29333f;
  border-color: #46545f;
}
.btn:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
}
.btn.download {
  background: var(--emerald);
  border-color: #1f6b46;
  color: #06231a;
}
.btn.download:hover {
  background: #4bdd8c;
}
.btn.ghost {
  background: transparent;
}

.export-note {
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
}

/* ============================================================
   预设方案
   ============================================================ */
.preset-save {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}
.preset-list {
  display: grid;
  gap: 7px;
}
.preset-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-mute);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px dashed var(--stroke-strong);
  border-radius: var(--r-md);
}
.preset-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  background: var(--panel-2);
  transition: border-color 0.14s var(--ease);
}
.preset-item:hover {
  border-color: #3a4756;
}
.preset-item .p-info {
  min-width: 0;
}
.preset-item .p-name {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-item .p-meta {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-item .p-load {
  height: 30px;
  padding: 0 12px;
  border: 1px solid #1f6b46;
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--emerald);
  color: #06231a;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.12s var(--ease), transform 0.1s var(--ease);
}
.preset-item .p-load:hover {
  filter: brightness(1.08);
}
.preset-item .p-load:active {
  transform: translateY(1px);
}
.preset-item .p-del {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-mute);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease);
}
.preset-item .p-del:hover {
  color: var(--redstone);
  border-color: var(--redstone);
}

/* ============================================================
   提示（toast）
   ============================================================ */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--stroke-strong);
  border-left: 3px solid var(--diamond);
  border-radius: var(--r-md);
  background: rgba(24, 30, 39, 0.96);
  box-shadow: var(--shadow-pop);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
  max-width: 460px;
  animation: toastin 0.26s var(--ease);
}
.toast.out {
  animation: toastout 0.26s var(--ease) forwards;
}
.toast.info {
  border-left-color: var(--diamond);
}
.toast.ok {
  border-left-color: var(--emerald);
}
.toast.warn {
  border-left-color: var(--gold);
}
.toast.err {
  border-left-color: var(--redstone);
}
.toast .ti {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--diamond);
  flex: none;
}
.toast.ok .ti {
  background: var(--emerald);
}
.toast.warn .ti {
  background: var(--gold);
}
.toast.err .ti {
  background: var(--redstone);
}
@keyframes toastin {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}
@keyframes toastout {
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ============================================================
   响应式
   ============================================================ */
/* 中等：收窄右栏 */
@media (max-width: 1240px) {
  :root {
    --rail-left: 288px;
    --rail-right: 300px;
  }
}

/* ============================================================
   转场选择画廊（进入工作台前的选择页，风格对齐绿幕素材库）
   ============================================================ */
.gsm-gallery {
  display: none;
}

body.gsm-choose-mode .gsm-gallery {
  display: block;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.gsm-choose-mode .workspace,
body.gsm-choose-mode .gsm-mobile-app,
body.gsm-choose-mode .gsm-embed .appbar {
  display: none !important;
}

/* 选择模式下 .app 不再保留顶栏行高，画廊占满 */
body.gsm-choose-mode .gsm-embed {
  display: flex;
  flex-direction: column;
}

.gsm-gallery-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px calc(40px + env(safe-area-inset-bottom));
}

.gsm-gallery-head {
  margin-bottom: 20px;
}

.gsm-gallery-home {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  margin-bottom: 10px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
}

.gsm-gallery-home:hover {
  border-color: var(--diamond);
  color: var(--text);
}

/* 画廊加载占位 */
.gsm-gallery-loading {
  grid-column: 1 / -1;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-mute);
  font-size: 14px;
  font-weight: 700;
}

/* 预览栏当前转场名 */
.stage-tpl-name {
  color: var(--diamond);
  font-weight: 800;
}

/* 预览栏返回按钮（移动端用顶栏的返回，隐藏这个） */
.stage-back {
  margin-right: 12px;
}

body.gsm-mobile-mode .stage-back {
  display: none;
}

/* 工作台返回按钮 */
.btn-back {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 14px;
  margin-right: 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
}

.btn-back:hover {
  border-color: var(--diamond);
  color: var(--text);
}

.gsm-gallery-head h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 6px;
}

.gsm-gallery-head p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

.gsm-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.gsm-gallery-card {
  display: block;
  width: 100%;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.gsm-gallery-card:hover,
.gsm-gallery-card:focus-visible {
  border-color: var(--diamond);
  transform: translateY(-3px);
  box-shadow: var(--shadow-drop);
}

.gsm-gallery-card:active {
  transform: translateY(-1px);
}

.gsm-gallery-cover {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  /* 透明背景棋盘格，动态封面直接叠在上面 */
  background: repeating-conic-gradient(#454b55 0% 25%, #353a42 0% 50%) 50% / 20px 20px;
  overflow: hidden;
}

/* 动态封面画布（实时循环渲染，透明背景） */
.gsm-gallery-cover .gsm-live {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 画廊分组标题（整行） */
.gsm-gallery-group-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 10px;
}

.gsm-gallery-group-head:first-child {
  margin-top: 0;
}

.gsm-gallery-group-head h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  padding-left: 10px;
  border-left: 3px solid var(--diamond);
}

.gsm-gallery-group-head span {
  font-size: 12px;
  color: var(--text-mute);
}

.gsm-gallery-txt {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gsm-gallery-tag {
  font-size: 11px;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 左栏模板分组小标签 */
.tpl-group-label {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-mute);
  letter-spacing: 0.06em;
  padding: 8px 2px 0;
}

/* 首帧渲染前的占位闪烁 */
.gsm-gallery-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, var(--panel-2) 40%, var(--raised) 50%, var(--panel-2) 60%);
  background-size: 200% 100%;
  animation: gsmShimmer 1.1s linear infinite;
  z-index: 1;
}

.gsm-gallery-cover.has-img::before {
  display: none;
}

@keyframes gsmShimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.gsm-gallery-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}

.gsm-gallery-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.gsm-gallery-go {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--diamond);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--diamond-soft);
}

@media (max-width: 640px) {
  .gsm-gallery-inner {
    padding: 18px 14px calc(32px + env(safe-area-inset-bottom));
  }

  .gsm-gallery-head h2 {
    font-size: 18px;
  }

  .gsm-gallery-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .gsm-gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 尊重系统减弱动画设置 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
