/* 色彩迁移：按 Framer 设计规范重做 —— 黑色画布、白色主按钮、电光蓝功能色 */
:root {
  --canvas: #000000;
  --panel: #111111;
  --stage: #171717;
  --raised: #1a1a1a;
  --chip: #141414;
  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.07);
  --ink: #ffffff;
  --nav-text: #cccccc;
  --muted: #999999;
  --blue: #0099ff;

  --f-12: 12px;
  --f-14: 14px;
  --f-18: 18px;

  --r-btn: 8px;
  --r-media: 15px;
  --r-window: 18px;
  --r-shell: 25px;

  --display: "DM Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --ui: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --in: 200ms;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: var(--f-14)/1.4 var(--ui);
  letter-spacing: -0.007em;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(0, 153, 255, 0.35); }

.app { display: flex; flex-direction: column; min-height: 100%; }

/* ---------- 导航 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  flex: 0 0 auto;
  height: 64px;
  background: var(--canvas);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1200px, calc(100% - 40px));
  height: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--display);
  font-size: var(--f-18);
  font-weight: 500;
  letter-spacing: -0.03em;
}

.badge {
  padding: 2px 6px;
  font-family: var(--ui);
  font-size: var(--f-12);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--blue);
  border: 1px solid rgba(0, 153, 255, 0.4);
  border-radius: 6px;
}

/* ---------- 页面与工作台 ---------- */
.page {
  display: flex;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  padding: 120px 0;
}

.shell {
  display: flex;
  flex: 0 1 1200px;
  width: min(1200px, calc(100% - 40px));
  min-height: 0;
  margin: 0 auto;
}

/* 演示外框：1px 细线、25px 圆角、10px 内边距 */
.demo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 10px;
  width: 100%;
  min-height: 0;
  padding: 10px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--r-shell);
}

/* ---------- 左：工作区 ---------- */
.stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--stage);
  border-radius: var(--r-media);
  overflow: hidden;
}

.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.canvas-wrap.ready #orig { display: block; }
.canvas-wrap.applied #orig { clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0); }
.canvas-wrap.applied #out { display: block; }

.tag {
  position: absolute;
  top: 12px;
  padding: 3px 8px;
  font-size: var(--f-12);
  line-height: 1.4;
  border-radius: 6px;
  display: none;
}

.tag.left { left: 12px; color: var(--nav-text); background: rgba(255, 255, 255, 0.08); }
.tag.right { right: 12px; color: #000; background: #fff; }
.canvas-wrap.ready .tag.left { display: block; }
.canvas-wrap.applied .tag.right { display: block; }

.canvas-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.canvas-bottom {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.ref-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  padding: 0;
  font: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.ref-badge:hover .ref-thumb { border-color: rgba(255, 255, 255, 0.5); }

.ref-badge[hidden] { display: none; }

.ref-thumb {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font-size: var(--f-14);
  line-height: 1;
  color: var(--muted);
  border-radius: var(--r-btn);
  background: rgba(0, 0, 0, 0.4) center / cover no-repeat;
  box-shadow: 0 0 0 1px var(--line);
  transition: border-color var(--in) var(--ease), color var(--in) var(--ease);
}

.ref-thumb.is-empty {
  border: 1px dashed rgba(255, 255, 255, 0.32);
  box-shadow: none;
}

.ref-badge:hover .ref-thumb { color: #fff; }

.ref-label {
  padding: 3px 8px;
  font-size: var(--f-12);
  color: var(--nav-text);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: var(--f-18);
  letter-spacing: -0.02em;
  color: var(--muted);
}

.canvas-wrap.ready .empty { display: none; }

/* 对比条：1px 蓝色选区线 + 局部辉光 */
.handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split, 50%);
  width: 1px;
  margin-left: -0.5px;
  background: var(--blue);
  box-shadow: 0 0 8px rgba(0, 153, 255, 0.7), 0 0 30px rgba(0, 153, 255, 0.25);
  cursor: ew-resize;
  display: none;
}

.handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 3px;
  background: var(--blue);
  box-shadow: 0 0 8px rgba(0, 153, 255, 0.7), 0 0 30px rgba(0, 153, 255, 0.25);
  transition: transform var(--in) var(--ease);
}

.handle:hover::after { transform: scale(1.15); }
.canvas-wrap.applied .handle { display: block; }

/* 强度条 */
.strength {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: center;
  width: 296px;
  height: 28px;
}

input[type="range"] {
  flex: 1 1 auto;
  height: 22px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background:
    linear-gradient(var(--blue), var(--blue)) 0 0 / var(--pct, 50%) 100% no-repeat,
    rgba(255, 255, 255, 0.38);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 1px 4px rgba(0, 0, 0, 0.6);
  transition: transform 140ms var(--ease);
}

input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.2); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.05); }

.num {
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
  padding: 0 2px;
  font: 500 var(--f-12)/1 var(--ui);
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--r-btn);
}

.num:hover { border-color: rgba(255, 255, 255, 0.45); }
.num:focus { border-color: var(--blue); }

/* 预设轨 */
.rail-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 0 0 auto;
  height: 104px;
  border-top: 1px solid var(--line-soft);
}

.rail-nav {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 32px;
  padding: 0;
  color: var(--nav-text);
  background: rgba(255, 255, 255, 0.06);
  border: 0;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: background var(--in) var(--ease), color var(--in) var(--ease), opacity var(--in) var(--ease);
}

.rail-nav svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-nav:hover:not(:disabled) { background: rgba(0, 153, 255, 0.18); color: #fff; }
.rail-nav:active:not(:disabled) { transform: scale(0.96); }
.rail-nav:disabled { opacity: 0.22; cursor: default; }

.rail-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
}

.rail {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  height: 100%;
  padding: 10px 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar { display: none; }

.rail-wrap::after,
.rail-wrap::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--in) var(--ease);
}

.rail-wrap::after { right: 0; background: linear-gradient(90deg, transparent, var(--canvas) 72%); }
.rail-wrap::before { left: 0; z-index: 1; background: linear-gradient(270deg, transparent, var(--canvas) 72%); }
.rail-wrap.more::after { opacity: 1; }
.rail-wrap.less::before { opacity: 1; }

.tile-wrap { position: relative; flex: 0 0 auto; }

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 72px;
  height: 84px;
  padding: 0;
  font: inherit;
  color: var(--muted);
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.tile .sw {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: var(--r-btn);
  background-color: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform var(--in) var(--ease), box-shadow var(--in) var(--ease);
}

.tile .nm {
  font-size: var(--f-12);
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--in) var(--ease);
}

.tile:hover .sw { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); }
.tile:hover .nm { color: var(--ink); }

.tile[aria-checked="true"] .sw {
  box-shadow: inset 0 0 0 1px var(--blue), 0 0 12px rgba(0, 153, 255, 0.45);
}

.tile[aria-checked="true"] .nm { color: var(--ink); }
.tile:active .sw { transform: translateY(0) scale(0.98); }

.tile.blank .sw {
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  font-size: var(--f-14);
  line-height: 1;
}

.tile.blank:hover .sw { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28); color: var(--ink); }

.tile-add .sw {
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.tile-add:hover .sw { color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }

.tile-ref .sw svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile-del {
  position: absolute;
  top: -8px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  font: 500 var(--f-12)/1 var(--ui);
  color: var(--muted);
  background: var(--raised);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--in) var(--ease), color var(--in) var(--ease);
}

.tile-wrap:hover .tile-del,
.tile-wrap:focus-within .tile-del,
.tile-del:focus-visible { opacity: 1; }

.tile-del:hover { color: #fff; }

.rail-sep {
  flex: 0 0 auto;
  width: 1px;
  height: 72px;
  margin: 0 2px;
  background: var(--line);
}

/* ---------- 右：控制面板 ---------- */
.panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 0;
  padding: 15px;
  background: var(--panel);
  border-radius: var(--r-window);
  overflow-y: auto;
}

.field { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; }

.field-label { font-size: var(--f-12); color: var(--muted); }

.drop {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 140px;
  padding: 10px;
  background: var(--stage);
  border: 1px solid var(--line);
  border-radius: var(--r-media);
  cursor: pointer;
  overflow: hidden;
  transition: background var(--in) var(--ease), border-color var(--in) var(--ease);
}

.drop:hover { border-color: rgba(255, 255, 255, 0.24); background: #1b1b1b; }

.drop.over {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(0, 153, 255, 0.35), 0 0 20px rgba(0, 153, 255, 0.18);
}

.drop-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke var(--in) var(--ease);
}

.drop:hover .drop-icon { stroke: #fff; }

.drop-hint { font-size: var(--f-12); color: var(--muted); }

.drop .thumb {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.drop.has-image { border-color: transparent; padding: 0; }
.drop.has-image .thumb { display: block; }
.drop.has-image .drop-icon,
.drop.has-image .drop-hint { display: none; }

.meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 16px;
  font-size: var(--f-12);
  color: var(--muted);
}

.meta .dim { font-variant-numeric: tabular-nums; }
.meta:empty { display: none; }

/* 主操作 */
.cta-block { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.cta-block[hidden] { display: none; }

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 34px;
  padding: 0 14px;
  font: 400 var(--f-14)/1 var(--ui);
  letter-spacing: -0.02em;
  color: #001018;
  background: var(--blue);
  border: 0;
  border-radius: var(--r-btn);
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(160, 222, 255, 0.85),
    0 0 22px rgba(0, 153, 255, 0.55),
    0 0 60px rgba(0, 153, 255, 0.22);
  transition: background var(--in) var(--ease), transform 120ms var(--ease), box-shadow var(--in) var(--ease);
}

.cta svg { width: 13px; height: 13px; fill: currentColor; }

.cta:hover:not(:disabled) {
  background: #4db8ff;
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(150, 215, 255, 0.85),
    0 0 26px rgba(0, 153, 255, 0.65),
    0 0 64px rgba(0, 153, 255, 0.28);
}

.cta:active:not(:disabled) { transform: translateY(0) scale(0.99); box-shadow: none; }
.cta:disabled {
  background: rgba(0, 153, 255, 0.16);
  color: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 0 1px rgba(0, 153, 255, 0.3);
  cursor: default;
}

.hint { margin: 0; font-size: var(--f-12); color: var(--muted); text-align: center; }

.tuning { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.tuning[hidden] { display: none; }

.check { display: flex; align-items: center; gap: 7px; font-size: var(--f-12); color: var(--muted); cursor: pointer; }
.check:hover { color: #fff; }
.check input { accent-color: var(--blue); }

.actions { display: flex; flex-direction: column; gap: 8px; }
.actions[hidden] { display: none; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.primary, .ghost {
  height: 34px;
  padding: 0 14px;
  font: 400 var(--f-14)/1 var(--ui);
  letter-spacing: -0.02em;
  border: 0;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: background var(--in) var(--ease), transform 120ms var(--ease), box-shadow var(--in) var(--ease), color var(--in) var(--ease);
}

.primary {
  color: #001018;
  background: var(--blue);
  box-shadow:
    0 0 0 1px rgba(160, 222, 255, 0.85),
    0 0 22px rgba(0, 153, 255, 0.55),
    0 0 60px rgba(0, 153, 255, 0.22);
}

.primary:hover:not(:disabled) {
  background: #4db8ff;
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(150, 215, 255, 0.85),
    0 0 26px rgba(0, 153, 255, 0.65),
    0 0 64px rgba(0, 153, 255, 0.28);
}

.ghost { color: #fff; background: rgba(255, 255, 255, 0.1); }
.ghost:hover:not(:disabled) {
  background: rgba(0, 153, 255, 0.16);
  color: #dff1ff;
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(0, 153, 255, 0.55), 0 0 20px rgba(0, 153, 255, 0.25);
}

.primary:active:not(:disabled),
.ghost:active:not(:disabled) { transform: translateY(0) scale(0.99); box-shadow: none; }

.primary[disabled], .ghost[disabled] { opacity: 0.35; cursor: default; }
.wide { width: 100%; }

.note { margin: 0; font-size: var(--f-12); color: var(--muted); min-height: 16px; }

/* 说明 */
.info {
  position: relative;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  padding: 0;
  font: 500 var(--f-12)/1 var(--ui);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: help;
  transition: color var(--in) var(--ease);
}

.info:hover { color: #fff; }

.info::after {
  content: attr(data-tip);
  position: absolute;
  top: 22px;
  right: 0;
  z-index: 10;
  width: 220px;
  padding: 10px 12px;
  font: 400 var(--f-12)/1.5 var(--ui);
  letter-spacing: 0;
  color: var(--nav-text);
  text-align: left;
  background: var(--raised);
  border-radius: var(--r-btn);
  box-shadow: 0 0 0 1px var(--line), 0 12px 30px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--in) var(--ease);
}

.info:hover::after, .info:focus-visible::after { opacity: 1; }

/* 焦点 */
.cta:focus-visible,
.primary:focus-visible,
.rail-nav:focus-visible,
.ghost:focus-visible,
.num:focus-visible,
input[type="range"]:focus-visible,
.handle:focus-visible,
.tile:focus-visible,
.tile-del:focus-visible,
.info:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1280px) {
  .page { padding: 60px 0; }
}

@media (max-width: 1000px) {
  .app { min-height: 100%; }
  .page { padding: 30px 0 40px; }
  .shell { width: calc(100% - 32px); }
  .demo {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }
  .canvas-wrap { height: 52vh; flex: 0 0 auto; }
  .rail-wrap { height: 100px; }
  .panel { max-height: none; }
}

@media (max-width: 760px) {
  .canvas-bottom { grid-template-columns: auto minmax(0, 1fr); }
  .strength { width: 100%; justify-self: stretch; }
}

@media (max-width: 620px) {
  .nav-inner, .shell { width: calc(100% - 24px); }
  .page { padding: 16px 0 24px; }
  .canvas-wrap { height: 44vh; }
  .drop { height: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
