/* PixelCraft · 布局与主题
 * 顶部工具栏 / 左侧工具 / 中间画布 / 右侧属性
 */

:root {
  --bg: #080d18;
  --bg-deep: #060a12;
  --panel: #0f1728;
  --panel-2: #16223a;
  --panel-3: #1d2b47;
  --line: #26344f;
  --line-soft: rgba(139, 92, 246, 0.16);
  --line-strong: #35486b;
  --text: #e9eef9;
  --text-dim: #8b9ab8;
  --text-faint: #6b7b98;
  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-2: #22d3ee;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-2-soft: rgba(34, 211, 238, 0.14);
  --danger: #ef5b6b;
  --success: #34d399;
  --warning: #fbbf24;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.32);
  --shadow-float: 0 22px 48px rgba(0, 0, 0, 0.5);
  --ring-accent: 0 0 0 3px rgba(139, 92, 246, 0.18);
  --font: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "Consolas", "Courier New", monospace;

  /* 由 renderer.layout() 按画布尺寸写入 */
  --cell: 16px;
  --canvas-w: 512px;
  --canvas-h: 512px;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  overflow: auto;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ 整体栅格 ============ */

.app {
  display: flex;
  height: 100vh;
  min-width: 0;
}

.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.view {
  flex: 1;
  min-height: 0;
}

.view[hidden] {
  display: none !important;
}

/* ============ 顶部工具栏 ============ */

.header {
  display: none;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 56px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(22, 34, 58, 0.96), rgba(12, 20, 36, 0.98));
  border-bottom: 1px solid #2a3a58;
  box-shadow: 0 1px 0 rgba(139, 92, 246, 0.08);
}

body[data-view="editor"] .header {
  display: flex;
}

.header-context {
  display: flex;
  align-items: center;
  gap: 10px;
}

.context-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.context-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.context-text strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.context-text small {
  font-size: 11px;
  color: var(--text-dim);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark { display: block; }

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-input {
  width: 150px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #2b3b5c;
  border-radius: 9px;
  background: #0e182b;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.name-input:focus {
  border-color: rgba(139, 92, 246, 0.8);
  outline: none;
  box-shadow: var(--ring-accent);
}

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

/* ============ 导出精灵图 ============ */

.sheet-info {
  margin-top: 4px;
}

.inline-number {
  width: 64px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #2b3b5c;
  border-radius: 9px;
  background: #0e182b;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.inline-number:focus {
  border-color: rgba(139, 92, 246, 0.8);
  outline: none;
  box-shadow: var(--ring-accent);
}

/* ============ 作品库 ============ */

.library-card {
  max-width: 560px;
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 52vh;
  overflow-y: auto;
  margin-top: 4px;
}

.library-empty {
  margin: 0;
  padding: 30px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

.work-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.work-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.work-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.work-actions {
  display: flex;
  gap: 6px;
}

.btn-danger {
  color: #ff8a80;
  border-color: rgba(229, 83, 75, 0.45);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(229, 83, 75, 0.14);
  border-color: var(--danger);
}

/* ============ 轻提示 ============ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: 70vw;
  padding: 10px 16px 10px 14px;
  border: 1px solid #31415f;
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: linear-gradient(180deg, #1a2740, #111b2e);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-float);
  animation: toast-in 0.22s ease both;
}

.toast[hidden] {
  display: none;
}

.toast.is-success {
  border-left-color: var(--success);
}

.toast.is-error {
  border-left-color: var(--danger);
  color: #ffb4ae;
}

.toast.is-success::before {
  content: "✓";
  margin-right: 8px;
  color: var(--success);
  font-weight: 700;
}

.toast.is-error::before {
  content: "!";
  margin-right: 8px;
  color: var(--danger);
  font-weight: 700;
}

/* ============ 按钮 ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid #2a3a58;
  border-radius: 9px;
  background: linear-gradient(180deg, #1a2742, #131e34);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s,
    transform 0.12s, box-shadow 0.16s, opacity 0.16s;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #223356, #17243d);
  border-color: #3b527d;
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  background: #12203a;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-accent);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, #9a6bff 0%, #7c3aed 58%, #6d28d9 100%);
  border-color: rgba(167, 139, 250, 0.65);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 6px 18px rgba(109, 40, 217, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #a97cff 0%, #8b5cf6 58%, #7c3aed 100%);
  border-color: #c4b5fd;
  box-shadow: 0 8px 22px rgba(124, 58, 237, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:active:not(:disabled) {
  box-shadow: 0 3px 12px rgba(124, 58, 237, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.btn-block { width: 100%; }

.btn-ghost {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.28);
}

/* ============ 左右面板 ============ */

.panel {
  background: linear-gradient(180deg, rgba(22, 34, 58, 0.55), rgba(11, 18, 32, 0.72));
  overflow-y: auto;
}

.panel-left {
  grid-area: tools;
  border-right: 1px solid #2a3a58;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-right {
  grid-area: props;
  border-left: 1px solid #2a3a58;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.panel-title::before {
  content: "";
  flex: 0 0 auto;
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.35);
}

.panel-hint {
  margin: auto 0 0;
  padding: 0 4px;
  font-size: 10px;
  line-height: 1.6;
  color: var(--text-dim);
  text-align: center;
}

.history-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.history-actions .btn {
  width: 100%;
  height: 30px;
  padding: 0 4px;
  font-size: 11px;
}

/* ============ 工具按钮 ============ */

.tool-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 11px 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.tool-btn:hover {
  background: rgba(139, 92, 246, 0.1);
  color: var(--text);
}

.tool-btn.is-active {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.3), rgba(139, 92, 246, 0.1));
  border-color: rgba(167, 139, 250, 0.55);
  color: #f4f0ff;
  box-shadow: 0 8px 20px rgba(109, 40, 217, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tool-btn.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.tool-btn.is-active svg {
  color: var(--accent-2);
}

/* ============ 画布区 ============ */

.stage {
  grid-area: stage;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 42%, rgba(139, 92, 246, 0.13), transparent 60%),
    radial-gradient(circle at 50% 42%, rgba(34, 211, 238, 0.05), transparent 72%),
    #070c16;
}

.canvas-frame {
  position: relative;
  width: var(--canvas-w);
  height: var(--canvas-h);
  border: 1px solid #3a4d72;
  border-radius: 6px;
  overflow: hidden;
  background-color: #20242c;
  background-image:
    linear-gradient(45deg, #272c35 25%, transparent 25%, transparent 75%, #272c35 75%),
    linear-gradient(45deg, #272c35 25%, transparent 25%, transparent 75%, #272c35 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.16),
    0 24px 60px rgba(0, 0, 0, 0.5),
    0 0 70px rgba(34, 211, 238, 0.06);
}

#paint-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.canvas-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.10) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.10) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

/* 单元格过小（大画布）时隐藏网格，避免整块被网格线覆盖 */
.canvas-frame.no-grid .canvas-grid { display: none; }

.stage-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* ============ 时间轴 ============ */

.timeline {
  grid-area: timeline;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 12px;
  background: linear-gradient(180deg, rgba(17, 26, 44, 0.96), rgba(10, 17, 31, 0.98));
  border-top: 1px solid #2a3a58;
}

.timeline-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.frame-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.timeline-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.timeline-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

/* ============ 播放控制 ============ */

.playback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

/* 播放状态：暂停按钮可用即表示正在播放，用青色强化当前状态 */
.playback .btn:not(.btn-primary):not(:disabled) {
  border-color: rgba(34, 211, 238, 0.38);
}

#btn-pause:not(:disabled) {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.22), rgba(34, 211, 238, 0.1));
  border-color: rgba(34, 211, 238, 0.6);
  color: #e6feff;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.18), 0 4px 14px rgba(34, 211, 238, 0.16);
}

.timeline:has(#btn-pause:not(:disabled)) .frame-count::after {
  content: " · 播放中";
  color: var(--accent-2);
}

.fps-control {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.fps-control input[type="range"] {
  width: 84px;
  accent-color: var(--accent);
  cursor: pointer;
}

.fps-control input[type="number"] {
  width: 48px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid #2b3b5c;
  border-radius: 9px;
  background: #0e182b;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.fps-control input[type="number"]:focus {
  border-color: rgba(139, 92, 246, 0.8);
  outline: none;
  box-shadow: var(--ring-accent);
}

.canvas-frame.is-locked #paint-canvas {
  cursor: not-allowed;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.frame-list {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 6px;
}

.frame-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 6px;
  border: 1px solid #2a3a58;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(29, 43, 71, 0.7), rgba(18, 28, 48, 0.9));
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s, transform 0.12s;
}

.frame-item:hover {
  border-color: #3b527d;
  transform: translateY(-1px);
}

.frame-item.is-active {
  border-color: rgba(167, 139, 250, 0.8);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.3), rgba(139, 92, 246, 0.12));
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.45), 0 6px 16px rgba(109, 40, 217, 0.24);
  color: #f4f0ff;
}

.frame-thumb {
  display: block;
  border-radius: 3px;
  background-color: #20242c;
  background-image:
    linear-gradient(45deg, #2b313b 25%, transparent 25%, transparent 75%, #2b313b 75%),
    linear-gradient(45deg, #2b313b 25%, transparent 25%, transparent 75%, #2b313b 75%);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  image-rendering: pixelated;
}

.frame-label {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
}

/* ============ 右侧属性 ============ */

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(42, 58, 88, 0.75);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(26, 39, 66, 0.42), rgba(13, 21, 37, 0.55));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.color-current {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-swatch {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background-color: #000;
}

.color-value {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.color-pick {
  position: relative;
  overflow: hidden;
}

.color-pick input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.swatch {
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.1s, outline-color 0.1s;
}

.swatch:hover {
  transform: translateY(-1px);
}

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

.info-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.info-list dt {
  color: var(--text-dim);
}

.info-list dd {
  margin: 0;
  text-align: right;
  font-family: var(--mono);
}

/* ============ 洋葱皮 ============ */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.toggle-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.opacity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.opacity-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.opacity-value {
  min-width: 32px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
}

/* ============ 新建画布对话框 ============ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 9, 17, 0.78);
  backdrop-filter: blur(6px);
}

.modal[hidden] { display: none; }

.modal:not([hidden]) {
  animation: modal-fade 0.18s ease both;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  border: 1px solid #31415f;
  border-radius: 16px;
  background: linear-gradient(180deg, #121d33, #0c1526);
  box-shadow: var(--shadow-float), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.modal:not([hidden]) .modal-card {
  animation: modal-card-in 0.22s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.modal-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.modal-desc {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-dim);
}

.size-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.size-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 4px;
  border: 1px solid #2a3a58;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(29, 43, 71, 0.7), rgba(18, 28, 48, 0.9));
  color: var(--text);
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, transform 0.12s, box-shadow 0.16s;
}

.size-card strong {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.size-card span {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.size-card:hover {
  border-color: rgba(167, 139, 250, 0.7);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.24), rgba(139, 92, 246, 0.08));
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(109, 40, 217, 0.18);
}

/* ============ 自定义尺寸 ============ */

.custom-size {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.custom-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.custom-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field > span {
  font-size: 11px;
  color: var(--text-dim);
}

.field input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #2b3b5c;
  border-radius: 9px;
  background: #0e182b;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.field input:focus {
  border-color: rgba(139, 92, 246, 0.8);
  outline: none;
  box-shadow: var(--ring-accent);
}

.field input.is-invalid {
  border-color: var(--danger);
}

.times {
  padding-bottom: 9px;
  color: var(--text-dim);
  font-size: 13px;
}

.form-hint {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
}

.form-error {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--danger);
}

.form-error[hidden] { display: none; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.modal-actions:empty { display: none; }

/* ============ 滚动条 ============ */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #33425f;
  border: 2px solid var(--bg);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: #44577c; }

/* ============================================================
   PixelCraft Studio · 工作室外壳
   ============================================================ */

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 620px at 10% -10%, rgba(139, 92, 246, 0.16), transparent 62%),
    radial-gradient(760px 520px at 100% 0%, rgba(34, 211, 238, 0.09), transparent 60%),
    radial-gradient(rgba(139, 92, 246, 0.07) 1px, transparent 1px);
  background-size: auto, auto, 22px 22px;
  background-attachment: fixed, fixed, fixed;
}

/* 编辑器在 workspace 中占满剩余高度 */
.editor-view {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 264px;
  grid-template-rows: minmax(0, 1fr) 140px;
  grid-template-areas:
    "tools    stage    props"
    "timeline timeline timeline";
  overflow: hidden;
}

/* ---------- 左侧主导航 ---------- */

.studio-nav {
  flex: 0 0 216px;
  width: 216px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px 16px;
  background: linear-gradient(180deg, #0f1729 0%, #0b1220 100%);
  border-right: 1px solid var(--line);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid var(--line);
}

.nav-logo {
  display: block;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.35), 0 6px 16px rgba(0, 0, 0, 0.4);
}

.nav-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.nav-brand-text strong {
  font-size: 15px;
  letter-spacing: 0.3px;
}

.nav-brand-text small {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--accent-2);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-item[hidden] {
  display: none;
}

.nav-item:hover {
  background: rgba(139, 92, 246, 0.1);
  color: var(--text);
}

.nav-item svg {
  flex: 0 0 auto;
  opacity: 0.9;
}

.nav-item.is-active {
  border-color: rgba(139, 92, 246, 0.35);
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.22), rgba(139, 92, 246, 0.05));
  color: #fff;
}

.nav-item-new {
  margin-top: 10px;
  border: 1px dashed rgba(34, 211, 238, 0.35);
  color: var(--accent-2);
}

.nav-item-new:hover {
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.6);
  color: #d9fbff;
}

.nav-foot {
  margin: auto 0 0;
  padding: 12px 6px 0;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.8;
}

/* ---------- 首页 ---------- */

.studio-view,
.gallery-view {
  overflow-y: auto;
  padding: 34px 40px 48px;
}

.studio-inner,
.gallery-inner {
  width: 100%;
  min-width: 0;
  max-width: 1180px;
  margin: 0 auto;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 28px 32px 26px;
  border: 1px solid #2a3b5e;
  border-radius: 18px;
  background:
    radial-gradient(120% 150% at 0% 0%, rgba(139, 92, 246, 0.26), transparent 55%),
    radial-gradient(110% 140% at 100% 0%, rgba(34, 211, 238, 0.14), transparent 58%),
    linear-gradient(160deg, #131e34, #0d1526 72%);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* 右上角像素装饰：只用装饰层，不参与内容布局 */
.hero::after {
  content: "";
  position: absolute;
  top: 26px;
  right: 30px;
  width: 74px;
  height: 74px;
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(139, 92, 246, 0.9)) 0 0 / 22px 22px no-repeat,
    linear-gradient(135deg, rgba(34, 211, 238, 0.85), rgba(34, 211, 238, 0.85)) 26px 0 / 18px 18px no-repeat,
    linear-gradient(135deg, rgba(255, 119, 168, 0.8), rgba(255, 119, 168, 0.8)) 0 26px / 14px 22px no-repeat,
    linear-gradient(135deg, rgba(94, 234, 212, 0.7), rgba(94, 234, 212, 0.7)) 28px 26px / 34px 30px no-repeat;
  opacity: 0.5;
  pointer-events: none;
  animation: hero-pixels-float 7s ease-in-out infinite;
}

.hero-deco {
  position: absolute;
  inset: auto 0 0 0;
  height: 72px;
  background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
  background-size: 12px 12px;
  opacity: 0.55;
  pointer-events: none;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-logo {
  display: block;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.4), 0 10px 26px rgba(0, 0, 0, 0.45);
}

.hero-brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.4px;
}

.hero-sub {
  margin: 3px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--accent-2);
}

.hero-main {
  position: relative;
  margin-top: 26px;
  max-width: 660px;
}

.hero-main h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.5px;
}

.hero-main p {
  margin: 10px 0 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.hero-actions .btn-primary {
  box-shadow: 0 12px 28px rgba(109, 40, 217, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.hero-actions .btn-lg {
  border-color: #33476c;
  background: linear-gradient(180deg, rgba(29, 43, 71, 0.9), rgba(17, 27, 47, 0.95));
}

.hero-actions .btn-primary.btn-lg {
  border-color: rgba(167, 139, 250, 0.65);
  background: linear-gradient(135deg, #9a6bff 0%, #7c3aed 58%, #6d28d9 100%);
}

.btn-lg {
  height: 44px;
  padding: 0 22px;
  font-size: 14px;
  border-radius: 10px;
}

.stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 14px 16px 14px 18px;
  border: 1px solid #2a3a58;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(30, 44, 72, 0.55), rgba(13, 21, 37, 0.75));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), rgba(34, 211, 238, 0.5));
}

.stat:nth-child(2)::before {
  background: linear-gradient(180deg, var(--accent-2), rgba(139, 92, 246, 0.5));
}

.stat:nth-child(3)::before {
  background: linear-gradient(180deg, #ff77a8, rgba(139, 92, 246, 0.5));
}

.stat-value {
  display: block;
  font-family: var(--mono);
  font-size: 27px;
  color: #fff;
  letter-spacing: 0.5px;
  text-shadow: 0 0 18px rgba(139, 92, 246, 0.25);
}

.stat small {
  font-size: 11px;
  color: var(--text-dim);
}

.studio-section {
  margin-top: 30px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.section-head h2::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

/* ---------- 画廊 ---------- */

.gallery-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(42, 58, 88, 0.6);
}

.gallery-title-block h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.4px;
}

.gallery-title-block p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.gallery-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #2b3b5c;
  border-radius: 10px;
  background: rgba(14, 24, 43, 0.8);
  color: var(--text-dim);
  transition: border-color 0.16s, box-shadow 0.16s;
}

.search-box:focus-within {
  border-color: rgba(139, 92, 246, 0.8);
  box-shadow: var(--ring-accent);
  color: var(--accent-2);
}

.search-box input {
  width: 168px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.segmented {
  display: flex;
  padding: 3px;
  border: 1px solid #2b3b5c;
  border-radius: 10px;
  background: rgba(14, 24, 43, 0.8);
}

.segmented button {
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.is-active {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.38), rgba(139, 92, 246, 0.18));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.28);
}

.sort-box {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #2b3b5c;
  border-radius: 10px;
  background: rgba(14, 24, 43, 0.8);
  font-size: 11px;
  color: var(--text-dim);
  transition: border-color 0.16s, box-shadow 0.16s;
}

.sort-box:focus-within {
  border-color: rgba(139, 92, 246, 0.7);
  box-shadow: var(--ring-accent);
}

.sort-box select {
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.sort-box select option {
  background: #101b2f;
  color: var(--text);
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 16px;
}

/* ---------- 作品卡片 ---------- */

.work-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #263553;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(22, 34, 58, 0.82), rgba(11, 18, 32, 0.92));
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.work-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
  z-index: 1;
}

.work-card:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(139, 92, 246, 0.12);
}

.work-card:hover::before {
  opacity: 0.9;
}

.work-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.card-thumb {
  position: relative;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
  border-bottom: 1px solid #24334f;
  border-radius: 14px 14px 0 0;
  background-color: #0a1220;
  background-image:
    linear-gradient(45deg, #15203a 25%, transparent 25%),
    linear-gradient(-45deg, #15203a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #15203a 75%),
    linear-gradient(-45deg, transparent 75%, #15203a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.thumb-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
  transition: transform 0.24s ease;
}

.work-card:hover .thumb-canvas {
  transform: scale(1.05);
}

.card-thumb.is-broken::after {
  content: "无法预览";
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 11px;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px 8px;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-name {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #4c5a76;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.fav-btn:hover {
  background: rgba(255, 209, 102, 0.1);
  border-color: rgba(255, 209, 102, 0.28);
  color: #ffd166;
  transform: translateY(-1px);
}

.fav-btn.is-on {
  color: #ffd166;
  background: rgba(255, 209, 102, 0.12);
  border-color: rgba(255, 209, 102, 0.4);
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.12);
}

.card-meta {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.card-time {
  margin: 0;
  font-size: 11px;
  color: #6b7893;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px 12px;
  margin-top: auto;
  border-top: 1px solid rgba(42, 58, 88, 0.45);
}

.work-card.is-compact .card-thumb {
  height: 118px;
}

/* 卡片更多操作 */

.card-menu {
  position: relative;
}

.card-menu summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

.card-menu summary::-webkit-details-marker {
  display: none;
}

.card-menu[open] summary {
  border-color: var(--accent);
  color: #fff;
}

.menu-list {
  position: absolute;
  right: 0;
  bottom: 36px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
  padding: 6px;
  border: 1px solid #31415f;
  border-radius: 11px;
  background: linear-gradient(180deg, #16223a, #0e182b);
  box-shadow: var(--shadow-float);
}

.menu-item {
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(139, 92, 246, 0.16);
}

.menu-item.is-danger {
  color: #ff8a95;
}

.menu-item.is-danger:hover {
  background: rgba(239, 91, 107, 0.14);
}

.empty-note {
  padding: 54px 20px;
  border: 1px dashed #2c3d60;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 34, 58, 0.5), rgba(11, 18, 32, 0.55));
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.8;
  text-align: center;
}

.empty-note::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 14px;
  border-radius: 9px;
  background:
    linear-gradient(var(--accent), var(--accent)) 4px 4px / 14px 14px no-repeat,
    linear-gradient(var(--accent-2), var(--accent-2)) 22px 4px / 14px 14px no-repeat,
    linear-gradient(rgba(255, 119, 168, 0.8), rgba(255, 119, 168, 0.8)) 4px 22px / 14px 14px no-repeat,
    linear-gradient(rgba(94, 234, 212, 0.7), rgba(94, 234, 212, 0.7)) 22px 22px / 14px 14px no-repeat,
    rgba(9, 14, 26, 0.65);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.28);
  opacity: 0.9;
}

/* 小屏（笔记本宽度）下的紧凑调整 */

@media (max-width: 1320px) {
  .studio-view,
  .gallery-view {
    padding: 26px 26px 40px;
  }

  .hero {
    padding: 24px 24px 22px;
  }

  .hero-main h2 {
    font-size: 26px;
  }

  .studio-nav {
    flex-basis: 200px;
    width: 200px;
  }
}

/* ============================================================
   PixelCraft Studio · 作品详情与独立预览
   ============================================================ */

.detail-view {
  overflow-y: auto;
  padding: 26px 36px 46px;
}

/* 详情页不受编辑器最小宽度约束，窄窗口可自然收缩 */
body[data-view="detail"] .app {
  min-width: 0;
}

.detail-inner {
  width: 100%;
  max-width: 1180px;
  min-width: 0;
  margin: 0 auto;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.detail-top-actions {
  display: flex;
  gap: 10px;
}

.detail-fav.is-on {
  border-color: rgba(255, 209, 102, 0.55);
  color: #ffd166;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
  gap: 22px;
  align-items: start;
  min-width: 0;
}

.preview-card {
  overflow: hidden;
  min-width: 0;
  border: 1px solid #2c3d60;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 34, 58, 0.8), rgba(10, 17, 31, 0.92));
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.preview-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 30px;
  min-width: 0;
  background-color: #080f1c;
  background-image:
    radial-gradient(circle at 50% 45%, rgba(139, 92, 246, 0.1), transparent 62%),
    linear-gradient(45deg, #15203a 25%, transparent 25%),
    linear-gradient(-45deg, #15203a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #15203a 75%),
    linear-gradient(-45deg, transparent 75%, #15203a 75%);
  background-size: auto, 16px 16px, 16px 16px, 16px 16px, 16px 16px;
  background-position: 0 0, 0 0, 0 8px, 8px -8px, -8px 0;
}

.preview-stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, 0.55));
}

.preview-badge {
  position: absolute;
  right: 14px;
  bottom: 12px;
  padding: 4px 10px;
  border: 1px solid rgba(139, 92, 246, 0.38);
  border-radius: 999px;
  background: rgba(8, 13, 24, 0.78);
  color: #d7e2f5;
  font-family: var(--mono);
  font-size: 11px;
  backdrop-filter: blur(4px);
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  padding: 12px 16px;
  border-top: 1px solid #2a3a58;
  background: linear-gradient(180deg, rgba(20, 32, 54, 0.85), rgba(11, 18, 32, 0.9));
}

.preview-controls .btn:not(.btn-primary):not(:disabled) {
  border-color: rgba(34, 211, 238, 0.3);
}

#detail-pause:not(:disabled) {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.22), rgba(34, 211, 238, 0.1));
  border-color: rgba(34, 211, 238, 0.6);
  color: #e6feff;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.16);
}

.preview-controls:has(#detail-pause:not(:disabled)) .preview-fps::before {
  content: "● ";
  color: var(--accent-2);
  animation: playing-pulse 1.2s ease-in-out infinite;
}

.loop-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.preview-fps {
  margin-left: auto;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 11px;
}

.detail-info {
  padding: 22px;
  border: 1px solid #2c3d60;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(24, 37, 63, 0.72), rgba(11, 18, 32, 0.88));
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  min-width: 0;
}

.detail-kicker {
  margin: 0;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2.4px;
}

.detail-name {
  margin: 8px 0 6px;
  font-size: 26px;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: #f4f7ff;
  text-shadow: 0 0 24px rgba(139, 92, 246, 0.12);
}

.detail-fav-state {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 12px;
}

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 18px;
  padding: 16px 0;
  border-top: 1px solid rgba(42, 58, 88, 0.7);
  border-bottom: 1px solid rgba(42, 58, 88, 0.7);
}

.detail-meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
}

.detail-meta div + div {
  padding-top: 10px;
  border-top: 1px solid rgba(42, 58, 88, 0.4);
}

.detail-meta dt {
  color: var(--text-dim);
}

.detail-meta dd {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.detail-note {
  margin: 0;
  padding: 10px 12px;
  border-left: 2px solid rgba(139, 92, 246, 0.45);
  border-radius: 0 8px 8px 0;
  background: rgba(139, 92, 246, 0.06);
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.7;
}

.detail-error {
  margin-top: 32px;
  padding: 48px 24px;
  border: 1px dashed #2c3d60;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 34, 58, 0.5), rgba(11, 18, 32, 0.55));
  text-align: center;
}

.detail-error h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.detail-error p {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.7;
}

/* 窄窗口：左侧导航变为顶部条，详情页单列显示 */
@media (max-width: 900px) {
  body[data-view="detail"] .app {
    flex-direction: column;
  }

  body[data-view="detail"] .studio-nav {
    flex: 0 0 auto;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  body[data-view="detail"] .nav-brand {
    margin-right: auto;
    padding: 0 8px 0 0;
    border-bottom: 0;
  }

  body[data-view="detail"] .nav-brand-text small {
    display: none;
  }

  body[data-view="detail"] .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
  }

  body[data-view="detail"] .nav-item {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  body[data-view="detail"] .nav-item svg {
    display: none;
  }

  body[data-view="detail"] .nav-item-new {
    margin-top: 0;
  }

  body[data-view="detail"] .nav-foot {
    display: none;
  }

  body[data-view="detail"] .workspace {
    height: auto;
    min-height: 0;
    flex: 1;
  }
}

@media (max-width: 600px) {
  body[data-view="detail"] .detail-view {
    padding: 14px 12px 28px;
  }

  body[data-view="detail"] .detail-topbar {
    gap: 8px;
    margin-bottom: 12px;
  }

  body[data-view="detail"] .detail-top-actions {
    width: 100%;
  }

  body[data-view="detail"] .detail-top-actions .btn {
    flex: 1 1 0;
  }

  body[data-view="detail"] .preview-stage {
    min-height: 220px;
    padding: 12px;
  }

  body[data-view="detail"] .preview-controls {
    gap: 8px;
    padding: 10px 12px;
  }

  body[data-view="detail"] .preview-controls .btn {
    padding: 0 10px;
  }

  body[data-view="detail"] .preview-fps {
    margin-left: 0;
  }

  body[data-view="detail"] .detail-info {
    padding: 18px 16px;
  }

  body[data-view="detail"] .detail-name {
    font-size: 21px;
  }
}

@media (max-width: 1100px) {
  .detail-view {
    padding: 22px 22px 38px;
  }

  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-stage {
    min-height: 300px;
    padding: 20px;
  }
}

/* ============================================================
   PixelCraft Studio · 开场动画
   ============================================================ */

body.is-splashing {
  overflow: hidden;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(70% 60% at 50% 42%, rgba(139, 92, 246, 0.16), transparent 70%),
    radial-gradient(50% 45% at 78% 18%, rgba(34, 211, 238, 0.1), transparent 70%),
    #070b14;
  opacity: 1;
  transition: opacity 0.42s ease, visibility 0.42s ease;
}

/* 像素点阵只做轻微质感，不干扰 Logo */
.splash::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(139, 92, 246, 0.1) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(60% 60% at 50% 45%, #000, transparent 75%);
  mask-image: radial-gradient(60% 60% at 50% 45%, #000, transparent 75%);
  pointer-events: none;
}

.splash[hidden] {
  display: none;
}

.splash.is-leaving {
  opacity: 0;
  visibility: hidden;
}

.splash-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.splash-particle {
  position: absolute;
  border-radius: 1px;
  opacity: 0;
  animation-name: splash-particle-in;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
}

@keyframes splash-particle-in {
  0% { opacity: 0; transform: translateY(8px) scale(0.6); }
  55% { opacity: 0.7; }
  100% { opacity: 0.3; transform: none; }
}

.splash-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px;
}

.splash-logo {
  --px: clamp(13px, 3.2vw, 22px);
  display: grid;
  grid-template-columns: repeat(5, var(--px));
  grid-template-rows: repeat(5, var(--px));
  gap: 2px;
}

.splash-cell {
  background: var(--accent);
  opacity: 0;
  transform: scale(0.2);
  border-radius: 2px;
  animation: splash-cell-in 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.25) forwards;
  animation-delay: var(--d, 0ms);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.28);
}

.splash-cell.is-cyan {
  background: var(--accent-2);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.3);
}

.splash-cell.is-empty {
  background: transparent;
  box-shadow: none;
  animation: none;
  opacity: 0;
}

@keyframes splash-cell-in {
  to { opacity: 1; transform: scale(1); }
}

.splash-wordmark {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(9px, 1.1vw, 12px);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: #c9d6ef;
  opacity: 0;
  animation: splash-fade-up 0.5s ease 0.95s forwards;
}

.splash-progress {
  width: clamp(150px, 24vw, 230px);
  height: 3px;
  border-radius: 2px;
  background: rgba(139, 92, 246, 0.16);
  overflow: hidden;
  opacity: 0;
  animation: splash-fade-up 0.3s ease 1s forwards;
}

.splash-bar {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: splash-load 1.5s cubic-bezier(0.4, 0, 0.2, 1) 0.8s forwards;
}

@keyframes splash-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes splash-load {
  to { width: 100%; }
}

.splash-skip {
  position: absolute;
  top: 22px;
  right: 24px;
  min-width: 78px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(139, 92, 246, 0.45);
  border-radius: 10px;
  background: rgba(17, 26, 44, 0.72);
  color: #cfd8ea;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.splash-skip:hover {
  background: rgba(139, 92, 246, 0.18);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(109, 40, 217, 0.24);
}

.splash-skip:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.splash-sound {
  position: absolute;
  top: 22px;
  right: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 10px;
  background: rgba(17, 26, 44, 0.62);
  color: #8b9ab8;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    box-shadow 0.16s ease, transform 0.12s ease;
}

.splash-sound svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.splash-sound .spk-body {
  fill: currentColor;
  stroke: none;
}

.splash-sound .spk-slash {
  opacity: 0;
}

.splash-sound[aria-pressed="false"] .spk-wave {
  opacity: 0;
}

.splash-sound[aria-pressed="false"] .spk-slash {
  opacity: 1;
}

.splash-sound[aria-pressed="true"] {
  color: var(--accent-2);
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.1);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.12);
}

.splash-sound:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.18);
  border-color: var(--accent);
  color: #fff;
}

.splash-sound[aria-pressed="true"]:hover:not(:disabled) {
  border-color: var(--accent-2);
  color: #e6feff;
}

.splash-sound:active:not(:disabled) {
  transform: scale(0.94);
}

.splash-sound:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.splash-sound:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.splash-sound:disabled:hover {
  background: rgba(17, 26, 44, 0.62);
  border-color: rgba(139, 92, 246, 0.28);
  color: #8b9ab8;
}

.splash-audio-prompt {
  position: absolute;
  top: calc(100% + 20px);
  left: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 20px;
  border: 1px solid rgba(167, 139, 250, 0.75);
  border-radius: 999px;
  background: linear-gradient(135deg, #9a6bff 0%, #7c3aed 60%, #6d28d9 100%);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  transform: translateX(-50%);
  box-shadow: 0 10px 26px rgba(109, 40, 217, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: splash-prompt-in 0.28s ease both;
}

.splash-audio-prompt[hidden] {
  display: none;
}

.splash-audio-prompt svg {
  width: 17px;
  height: 17px;
}

.splash-audio-prompt:hover {
  border-color: #c4b5fd;
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.splash-audio-prompt:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

@keyframes splash-prompt-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 520px) {
  .splash-center {
    gap: 16px;
  }

  .splash-skip {
    top: 16px;
    right: 16px;
    height: 40px;
  }

  .splash-sound {
    top: 16px;
    right: 104px;
    width: 40px;
    height: 40px;
  }

  .splash-audio-prompt {
    top: calc(100% + 16px);
    height: 40px;
    padding: 0 16px;
    font-size: 12px;
  }

  .splash-wordmark {
    letter-spacing: 0.3em;
    text-indent: 0.3em;
  }
}

/* 减少动态效果：不播放开场，直接进入首页 */
@media (prefers-reduced-motion: reduce) {
  .splash {
    display: none !important;
  }

  .splash * {
    animation: none !important;
  }
}

/* ============================================================
   PixelCraft Studio · 阶段三：交互过渡与响应式统一
   ============================================================ */

/* 页面切换与反馈动画（轻量，不影响操作） */
.view:not([hidden]) {
  animation: view-in 0.24s ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes hero-pixels-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes playing-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* ---------- 中等宽度：编辑器顶栏自动换行，避免按钮溢出 ---------- */

@media (max-width: 1180px) {
  body[data-view="editor"] .header {
    flex: 0 0 auto;
    flex-wrap: wrap;
    padding: 8px 16px;
    row-gap: 8px;
  }

  body[data-view="editor"] .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

/* ---------- 窄窗口：导航转为顶部条，四页共享 ---------- */

@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }

  .studio-nav {
    flex: 0 0 auto;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid #2a3a58;
  }

  .nav-brand {
    margin-right: auto;
    padding: 0 8px 0 0;
    border-bottom: 0;
  }

  .nav-brand-text small {
    display: none;
  }

  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
  }

  .nav-item {
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  .nav-item svg {
    display: none;
  }

  .nav-item-new {
    margin-top: 0;
  }

  .nav-foot {
    display: none;
  }

  .workspace {
    height: auto;
    min-height: 0;
    flex: 1;
  }

  /* 编辑器：改为纵向堆叠，避免三栏被压缩或横向溢出 */
  body[data-view="editor"] .workspace {
    overflow-y: auto;
  }

  body[data-view="editor"] .header {
    padding: 10px 12px;
  }

  body[data-view="editor"] .header-context {
    display: none;
  }

  body[data-view="editor"] .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  body[data-view="editor"] .name-input {
    flex: 1 1 140px;
    width: auto;
    min-width: 0;
  }

  body[data-view="editor"] .editor-view {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  body[data-view="editor"] .panel-left {
    order: 1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid #2a3a58;
    overflow: visible;
  }

  body[data-view="editor"] .panel-left .panel-title,
  body[data-view="editor"] .panel-hint {
    display: none;
  }

  body[data-view="editor"] .tool-list {
    flex-direction: row;
    gap: 6px;
  }

  body[data-view="editor"] .tool-btn {
    flex-direction: row;
    gap: 6px;
    padding: 8px 12px;
  }

  body[data-view="editor"] .tool-btn.is-active::before {
    top: auto;
    left: 18%;
    right: 18%;
    bottom: 0;
    width: auto;
    height: 2px;
    border-radius: 2px 2px 0 0;
  }

  body[data-view="editor"] .history-actions {
    flex-direction: row;
    gap: 6px;
    margin-left: auto;
    padding-top: 0;
    border-top: 0;
  }

  body[data-view="editor"] .history-actions .btn {
    width: auto;
    padding: 0 10px;
  }

  body[data-view="editor"] .stage {
    order: 2;
    min-height: 300px;
    padding: 18px;
  }

  body[data-view="editor"] .timeline {
    order: 3;
    flex: 0 0 auto;
    padding: 10px 12px;
  }

  body[data-view="editor"] .timeline-head {
    flex-wrap: wrap;
    overflow: visible;
    row-gap: 8px;
  }

  body[data-view="editor"] .timeline-actions {
    margin-left: 0;
  }

  body[data-view="editor"] .frame-list {
    flex: 0 0 auto;
    min-height: 78px;
  }

  body[data-view="editor"] .panel-right {
    order: 4;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    padding: 12px;
    border-left: 0;
    border-top: 1px solid #2a3a58;
    overflow: visible;
  }
}

/* ---------- 手机宽度：首页 / 画廊 / 编辑器紧凑排布 ---------- */

@media (max-width: 600px) {
  .studio-view,
  .gallery-view {
    padding: 18px 14px 34px;
  }

  .hero {
    padding: 20px 16px 22px;
  }

  .hero::after {
    display: none;
  }

  .hero-brand h1 {
    font-size: 20px;
  }

  .hero-main {
    margin-top: 20px;
  }

  .hero-main h2 {
    font-size: 22px;
  }

  .hero-main p {
    font-size: 13px;
  }

  .hero-actions {
    flex-wrap: wrap;
    gap: 10px;
  }

  .hero-actions .btn {
    flex: 1 1 140px;
  }

  .stats {
    gap: 8px;
    margin-top: 20px;
  }

  .stat {
    padding: 12px 10px 12px 14px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat small {
    font-size: 10px;
    line-height: 1.4;
  }

  .studio-section {
    margin-top: 22px;
  }

  .gallery-head {
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 14px;
  }

  .gallery-tools {
    width: 100%;
  }

  .search-box {
    flex: 1 1 100%;
  }

  .search-box input {
    flex: 1;
    width: 100%;
    min-width: 0;
  }

  .search-box,
  .segmented,
  .sort-box {
    height: 34px;
  }

  .work-grid {
    gap: 12px;
  }

  .empty-note {
    padding: 38px 16px;
  }

  body[data-view="editor"] .stage {
    min-height: 260px;
    padding: 14px;
  }

  body[data-view="editor"] .panel-right {
    grid-template-columns: 1fr;
  }

  body[data-view="editor"] .timeline {
    padding: 8px 10px 10px;
  }

  body[data-view="editor"] .playback {
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 0;
  }

  body[data-view="editor"] .fps-control {
    width: 100%;
    margin-left: 0;
  }

  body[data-view="editor"] .fps-control input[type="range"] {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  body[data-view="editor"] .timeline-actions {
    flex-wrap: wrap;
  }
}

/* 系统要求减少动态效果时，关闭本轮新增的过渡与装饰动画 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .hero::after {
    animation: none !important;
  }
}
