/* ==========================================================================
   拼豆工坊 · 视觉体系
   风格：可爱像素风 —— 粗描边 + 实心投影 + 糖果色 + 圆角
   主题：浅色
   ========================================================================== */

:root {
  /* 墨色与纸张 */
  --ink: #2b2b3a;
  --ink-soft: #61617a;
  --ink-faint: #9a9ab0;
  --paper: #fff8ee;
  --paper-2: #ffefdd;
  --card: #ffffff;
  --line: #eadfcd;
  --line-strong: #d9c9ae;

  /* 糖果色 */
  --pink: #ff7a9c;
  --pink-d: #ef4d7e;
  --teal: #35c4b8;
  --teal-d: #1fa89d;
  --yellow: #ffc94a;
  --purple: #a98bf5;
  --blue: #5fb8f5;
  --green: #6fd48a;
  --orange: #ff9a5b;
  --red: #ff6b5e;

  /* 实心投影 */
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-lg: 6px 6px 0 var(--ink);

  --r-lg: 20px;
  --r: 16px;
  --r-sm: 12px;
  --r-xs: 8px;

  --nav-h: 68px;
  --max: 1200px;

  --font: "Nunito", "Quicksand", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas,
    "Liberation Mono", Menlo, monospace;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(43, 43, 58, 0.07) 1px, transparent 0);
  background-size: 18px 18px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: 0.2px; line-height: 1.25; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--yellow); color: var(--ink); }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }

.mono { font-family: var(--mono); }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 3px solid var(--ink);
}
.site-header .container {
  height: 100%; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 19px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  border: 3px solid var(--ink);
  background:
    linear-gradient(var(--pink), var(--pink)) 0 0 / 50% 50% no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) 100% 0 / 50% 50% no-repeat,
    linear-gradient(var(--teal), var(--teal)) 0 100% / 50% 50% no-repeat,
    linear-gradient(var(--purple), var(--purple)) 100% 100% / 50% 50% no-repeat;
  background-color: #fff;
  box-shadow: var(--shadow-sm);
  flex: none;
}
.nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14.5px;
  color: var(--ink-soft); border: 3px solid transparent; transition: all 0.12s;
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--paper-2); }
.nav a.active { color: var(--ink); background: var(--yellow); border-color: var(--ink); box-shadow: var(--shadow-sm); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--ink);
  display: grid; place-items: center; font-weight: 900; color: #fff; flex: none;
  box-shadow: var(--shadow-sm);
}

/* 移动端菜单 */
.nav-toggle { display: none; }
@media (max-width: 900px) {
  .nav {
    position: fixed; inset: var(--nav-h) 0 auto 0; flex-direction: column; align-items: stretch;
    background: #fff; border-bottom: 3px solid var(--ink); padding: 10px 16px 16px; gap: 6px;
    transform: translateY(-120%); transition: transform 0.2s; box-shadow: 0 12px 24px rgba(43,43,58,.12);
  }
  .nav.open { transform: translateY(0); }
  .nav a { text-align: center; }
  .nav-toggle {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
    border: 3px solid var(--ink); background: #fff; box-shadow: var(--shadow-sm); cursor: pointer;
  }
}

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--r-sm);
  border: 3px solid var(--ink); background: #fff; color: var(--ink);
  font-weight: 800; font-size: 14.5px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform 0.1s, box-shadow 0.1s;
  user-select: none; white-space: nowrap;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); }
.btn:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--pink); color: #fff; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-yellow { background: var(--yellow); }
.btn-purple { background: var(--purple); color: #fff; }
.btn-ghost { background: #fff; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; box-shadow: 2px 2px 0 var(--ink); }
.btn-sm:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn-lg { padding: 15px 30px; font-size: 17px; border-radius: var(--r); }
.btn-block { width: 100%; }

.card {
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 20px;
}
.card-flat { box-shadow: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; border: 2.5px solid var(--ink);
  background: #fff; font-size: 12.5px; font-weight: 700; cursor: pointer;
  transition: all 0.12s; user-select: none;
}
.chip:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.chip.active { background: var(--teal); color: #fff; box-shadow: 2px 2px 0 var(--ink); }
.chip-static { cursor: default; }
.chip-static:hover { transform: none; box-shadow: none; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--paper-2); border: 2px solid var(--line-strong);
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
}

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  border-radius: 999px; border: 2.5px solid var(--ink); background: var(--yellow);
  font-size: 12px; font-weight: 800;
}

.field { display: block; margin-bottom: 16px; }
.field > .label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13.5px; font-weight: 800; margin-bottom: 7px;
}
.field .hint { font-size: 12px; font-weight: 600; color: var(--ink-faint); }
/* 通用小字提示：色卡页的数据说明、弹窗脚注都用它，不放在 .field 里也能正常显示 */
.hint { font-size: 13px; font-weight: 600; color: var(--ink-faint); }

.input, .select, .textarea {
  width: 100%; padding: 10px 13px; border-radius: var(--r-sm);
  border: 3px solid var(--ink); background: #fff; outline: none;
  transition: box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus { box-shadow: var(--shadow-sm); }
.textarea { resize: vertical; min-height: 84px; }
.select { appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
                    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 19px) 20px, calc(100% - 13px) 20px;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
  padding-right: 38px;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px;
  background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 999px; border: 2.5px solid var(--ink); background: #fff;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px;
  border-radius: 50%; background: var(--pink); border: 3px solid var(--ink);
  box-shadow: 1px 1px 0 var(--ink);
}
input[type="range"]::-moz-range-track {
  height: 10px; border-radius: 999px; border: 2.5px solid var(--ink); background: #fff;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--pink);
  border: 3px solid var(--ink);
}

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13.5px; font-weight: 700; }
.switch input { display: none; }
.switch .track {
  width: 44px; height: 24px; border-radius: 999px; border: 3px solid var(--ink);
  background: #fff; position: relative; transition: background 0.15s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 1px; left: 1px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--ink-faint); transition: all 0.15s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { left: 22px; background: var(--ink); }

/* ---------- 页面骨架 ---------- */
.page { padding: 34px 0 70px; }
/*
 * 工作台专用：1200 的容器减去两侧 320 + 300 的侧栏和间距，中间只剩约 500px，
 * 而默认 40 格 × 16px 的图纸就要 668px —— 一进来就必须横向滚，看着就是「挤」。
 * 单独给它更宽的容器，画布区能到 ~740px，默认尺寸整张放得下。
 */
.page-wide .container { max-width: 1440px; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 30px; }
.page-head p { color: var(--ink-soft); margin-top: 6px; }

.section { margin-top: 46px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 22px; }
.section-head .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; }

/* ---------- 首页 ---------- */
.hero {
  position: relative; overflow: hidden;
  border: 3px solid var(--ink); border-radius: 26px; background: #fff;
  box-shadow: var(--shadow-lg); padding: 46px 42px; margin-top: 8px;
}
.hero-grid {
  position: absolute; inset: 0; opacity: 0.5; pointer-events: none;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(43, 43, 58, 0.13) 1px, transparent 0);
  background-size: 16px 16px;
  mask-image: linear-gradient(105deg, #000 0%, transparent 62%);
  -webkit-mask-image: linear-gradient(105deg, #000 0%, transparent 62%);
}
.hero-inner { position: relative; display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 40px; align-items: center; }
.hero h1 { font-size: 44px; line-height: 1.15; }
.hero h1 .hl {
  background: linear-gradient(transparent 62%, var(--yellow) 62%);
  padding: 0 4px; border-radius: 4px;
}
.hero .lead { margin-top: 16px; font-size: 16.5px; color: var(--ink-soft); max-width: 46ch; }
.hero-cta { margin-top: 26px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats { margin-top: 26px; display: flex; gap: 26px; flex-wrap: wrap; }
.hero-stats .stat b { display: block; font-size: 24px; font-family: var(--mono); }
.hero-stats .stat span { font-size: 12.5px; color: var(--ink-faint); font-weight: 700; }

/* 首屏拼豆画布装饰 */
.hero-art { display: grid; place-items: center; }
.bead-board {
  display: grid; gap: 3px; padding: 14px; background: #fff;
  border: 3px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow-lg);
  transform: rotate(-2.5deg);
}
.bead {
  width: 20px; height: 20px; border-radius: 50%; position: relative;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}
.bead::after {
  content: ""; position: absolute; inset: 32%; border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
}

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature {
  background: #fff; border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 22px; transition: transform 0.12s, box-shadow 0.12s;
}
.feature:hover { transform: translate(-3px, -3px); box-shadow: 8px 8px 0 var(--ink); }
.feature .icon {
  width: 52px; height: 52px; border-radius: 14px; border: 3px solid var(--ink);
  display: grid; place-items: center; font-size: 24px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.feature h3 { font-size: 17.5px; margin-bottom: 8px; }
.feature p { color: var(--ink-soft); font-size: 14px; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; counter-reset: s; }
.step { position: relative; padding: 24px 20px 20px; background: #fff; border: 3px dashed var(--line-strong); border-radius: var(--r); }
.step::before {
  counter-increment: s; content: counter(s);
  position: absolute; top: -18px; left: 18px; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--teal); color: #fff;
  font-weight: 900; font-family: var(--mono); box-shadow: var(--shadow-sm);
}
.step h3 { font-size: 16px; margin: 4px 0 6px; }
.step p { color: var(--ink-soft); font-size: 13.5px; }

.swatch-wall { display: flex; flex-wrap: wrap; gap: 5px; }
.swatch-wall i {
  width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--ink);
  display: block; transition: transform 0.12s;
}
.swatch-wall i:hover { transform: scale(1.22) rotate(-6deg); z-index: 2; }

/* ---------- 工作台 ---------- */
/*
 * minmax(0, 1fr) + .studio > * { min-width: 0 } 是这里的命门。
 * 网格项默认 min-width:auto，会被「画布本身的最小内容宽度」顶住（40 格 × 16px 就 668px），
 * 于是 1fr 缩不下去，整行把页面撑出横向滚动条 —— 手机上尤其明显。
 */
.studio { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.studio > * { min-width: 0; }
.studio-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--nav-h) + 20px); min-width: 0; }

.panel { background: #fff; border: 3px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 3px solid var(--ink); background: var(--paper-2);
  border-radius: 13px 13px 0 0; font-weight: 800; font-size: 14.5px;
}
.panel-body { padding: 16px; }
.panel-body + .panel-body { border-top: 3px dashed var(--line); }

.dropzone {
  border: 3px dashed var(--line-strong); border-radius: var(--r-sm); background: var(--paper);
  padding: 26px 16px; text-align: center; cursor: pointer; transition: all 0.14s;
}
.dropzone:hover, .dropzone.over { border-color: var(--pink); background: #fff0f4; transform: translateY(-2px); }
.dropzone .big { font-size: 30px; }
.dropzone b { display: block; margin-top: 8px; font-size: 14.5px; }
.dropzone span { font-size: 12.5px; color: var(--ink-faint); }

.stage {
  background: #fff; border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; min-height: 560px; min-width: 0;
  display: flex; flex-direction: column;
}
.stage-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 3px solid var(--ink); background: var(--paper-2); flex-wrap: wrap;
}
.stage-bar .spacer { flex: 1; min-width: 0; }
/* 缩放组：− / 尺寸下拉 / ＋ / 适应宽度 */
.stage-zoom { display: flex; align-items: center; gap: 6px; flex: none; }
.select-mini {
  width: auto; padding: 6px 26px 6px 9px; font-size: 12.5px; font-weight: 700;
  border-width: 2.5px; border-radius: 10px;
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
}
.stage-canvas-wrap {
  flex: 1; display: flex; padding: 20px; overflow: auto;
  min-width: 0;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background-color: #fdfbf7;
  background-image:
    linear-gradient(45deg, rgba(43,43,58,.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(43,43,58,.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(43,43,58,.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(43,43,58,.035) 75%);
  background-size: 22px 22px; background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  min-height: 420px;
}
/* margin:auto 让画布在滚动容器里既居中、放大后又不会把左上角裁掉 */
.stage-canvas-wrap > * { margin: auto; }
#stageCanvas { image-rendering: pixelated; cursor: crosshair; border-radius: 4px; }
.stage-empty { text-align: center; color: var(--ink-faint); }
.stage-empty .big { font-size: 42px; margin-bottom: 10px; }

.tool {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px;
  border: 2.5px solid var(--ink); background: #fff; cursor: pointer; font-size: 16px;
  box-shadow: 2px 2px 0 var(--ink); transition: all 0.1s; flex: none;
}
.tool:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.tool.active { background: var(--teal); color: #fff; }
.tool:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: 2px 2px 0 var(--ink); }
.tool-sep { width: 3px; height: 26px; background: var(--line-strong); border-radius: 2px; margin: 0 3px; }

.palette-strip {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 12px 14px;
  border-top: 3px solid var(--ink); background: #fff; max-height: 138px; overflow-y: auto;
}
.palette-strip .sw {
  width: 26px; height: 26px; border-radius: 7px; border: 2.5px solid var(--ink);
  cursor: pointer; position: relative; transition: transform 0.1s;
}
.palette-strip .sw:hover { transform: scale(1.18); z-index: 3; }
.palette-strip .sw.active { outline: 3px solid var(--pink); outline-offset: 2px; transform: scale(1.1); z-index: 4; }

.material-list { max-height: 260px; overflow-y: auto; }
.material-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 4px;
  border-bottom: 2px dashed var(--line); font-size: 13.5px;
}
.material-row:last-child { border-bottom: 0; }
.material-row .dot { width: 20px; height: 20px; border-radius: 6px; border: 2.5px solid var(--ink); flex: none; }
.material-row .code { font-family: var(--mono); font-weight: 700; min-width: 46px; }
.material-row .count { margin-left: auto; font-family: var(--mono); font-weight: 700; }
.material-row .pct { color: var(--ink-faint); font-size: 12px; min-width: 44px; text-align: right; }

.stat-row { display: flex; gap: 10px; }
.stat-box {
  flex: 1; text-align: center; padding: 10px 6px; border-radius: var(--r-sm);
  border: 2.5px solid var(--ink); background: var(--paper);
}
.stat-box b { display: block; font-family: var(--mono); font-size: 17px; }
.stat-box span { font-size: 11.5px; color: var(--ink-faint); font-weight: 700; }

@media (max-width: 1150px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .studio-side { position: static; }
  .stage { min-height: 0; }
}

/* ---------- 手机 / 小平板 ---------- */
@media (max-width: 760px) {
  .container { padding: 0 14px; }
  .page { padding: 22px 0 52px; }
  .page-head { margin-bottom: 18px; }
  .page-head h1 { font-size: 24px; }
  .page-head p { font-size: 13.5px; }

  .studio { gap: 14px; }
  .stage { border-radius: var(--r-sm); min-height: 0; }
  .stage-bar { padding: 8px 10px; gap: 6px; }
  .tool { width: 34px; height: 34px; font-size: 15px; border-width: 2px; }
  .tool-sep { margin: 0 1px; height: 22px; }
  /* 左右留窄一点，宽度都让给图纸；下面多留一点，手指有地方拖页面而不是画到图上 */
  .stage-canvas-wrap { padding: 12px 10px 26px; min-height: 300px; }
  .palette-strip { padding: 10px; max-height: 112px; }
  .palette-strip .sw { width: 24px; height: 24px; }
  .panel-body { padding: 13px; }
  .panel-head { padding: 11px 13px; font-size: 13.5px; }
  .modal-mask { padding: 10px; }
  .modal { max-height: 92vh; }
  /* 按钮换行后让它们自己撑满整行，别都挤在右边 */
  .modal-foot { justify-content: flex-start; padding: 12px 14px; }
  .modal-foot > .btn { flex: 1 1 auto; }
  .modal-body { padding: 14px; }
  .preview-box { padding: 10px; max-height: 46vh; }
}

@media (max-width: 420px) {
  .tool { width: 32px; height: 32px; font-size: 14px; }
  .select-mini { padding: 5px 24px 5px 8px; background-position: calc(100% - 13px) 13px, calc(100% - 8px) 13px; }
  /* 最窄屏优先把这一行让给缩放控件 */
  .stage-bar .spacer + #cursorInfo { display: none; }
  .stat-row { gap: 7px; }
  .stat-box { padding: 8px 3px; }
}

/* ---------- 作品社区 ---------- */
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 18px; }
.work-card {
  background: #fff; border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s; display: flex; flex-direction: column;
}
.work-card:hover { transform: translate(-3px, -3px); box-shadow: 8px 8px 0 var(--ink); }
.work-cover {
  aspect-ratio: 4 / 3; padding: 14px; overflow: hidden;
  border-bottom: 3px solid var(--ink); background-color: var(--paper-2);
  background-image: radial-gradient(circle at 1px 1px, rgba(43,43,58,.1) 1px, transparent 0);
  background-size: 14px 14px;
}
.work-cover img, .work-cover canvas { image-rendering: pixelated; display: block; width: 100%; height: 100%; object-fit: contain; }
.work-body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.work-title { font-weight: 800; font-size: 15px; }
.work-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-faint); font-weight: 700; }
.work-foot { margin-top: auto; display: flex; align-items: center; gap: 12px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.work-foot .act { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; border-radius: 999px; padding: 2px 8px; transition: background 0.12s; }
.work-foot .act:hover { background: var(--paper-2); }
.work-foot .act.on { color: var(--pink-d); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar .group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-bar .group > b { font-size: 12.5px; color: var(--ink-faint); margin-right: 2px; }
/* 折叠开关只在窄屏出现；桌面端排序 / 色卡 / 标签一直铺开 */
.filters-toggle { display: none; }
@media (max-width: 640px) {
  .filters-toggle { display: inline-flex; margin-top: 10px; }
  .gallery-filters:not(.open) .filters-body { display: none; }
}

/* ---------- 色卡 ---------- */
/*
 * 色系筛选（A~Z 共 26 个 chip）和搜索框并排时，窄屏上搜索框的 min-width:220px
 * 会把色系那一组挤到只剩 ~130px —— 26 个字母只能一列排下去，白占一屏高度。
 * 窄屏让两者各占一整行，字母就能横向铺开。
 */
.colors-tools .filter-bar { flex: 1 1 320px; }
.colors-tools .search-wrap { flex: 1 1 220px; }
@media (max-width: 640px) {
  .colors-tools .filter-bar,
  .colors-tools .search-wrap { flex-basis: 100%; min-width: 0; }
}
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.swatch {
  border: 3px solid var(--ink); border-radius: var(--r-sm); overflow: hidden; background: #fff;
  box-shadow: var(--shadow-sm); cursor: pointer; transition: transform 0.12s, box-shadow 0.12s;
}
.swatch:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.swatch .c { height: 62px; position: relative; border-bottom: 3px solid var(--ink); }
.swatch .c .ref {
  position: absolute; right: 5px; bottom: 5px; font-size: 10.5px; font-weight: 800;
  background: rgba(255,255,255,.88); border: 2px solid var(--ink); border-radius: 6px; padding: 0 4px;
  font-family: var(--mono);
}
.swatch .i { padding: 7px 9px; }
.swatch .i b { display: block; font-family: var(--mono); font-size: 14px; }
.swatch .i span { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }

/* ---------- 我的 ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 3px solid var(--ink); margin-bottom: 22px; flex-wrap: wrap; }
.tabs button {
  padding: 10px 18px; border: 3px solid var(--ink); border-bottom: 0;
  border-radius: 12px 12px 0 0; background: var(--paper-2); font-weight: 800;
  cursor: pointer; margin-bottom: -3px; font-size: 14px;
}
.tabs button.active { background: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-head .avatar { width: 76px; height: 76px; font-size: 30px; }

/* ---------- 模态框 / 提示 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px;
  background: rgba(43, 43, 58, 0.42); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity 0.16s;
}
.modal-mask.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto; background: #fff;
  border: 3px solid var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(0.98); transition: transform 0.18s;
}
.modal-mask.open .modal { transform: none; }
.modal.wide { width: min(880px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 3px solid var(--ink); background: var(--paper-2);
  border-radius: 17px 17px 0 0; position: sticky; top: 0; z-index: 2;
}
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px; }
/*
 * 页脚必须能换行 + 常驻可见。
 * 作品详情有 6~7 个按钮（点赞/收藏/分色拼装/复制清单/导出图纸/复制到工作台/删除），
 * 一排排不下时 flex 会**从左边溢出**（justify-content: flex-end 把溢出量全推到左端），
 * 而 .modal 的 overflow 会把它裁掉 —— 手机上「分色拼装」按钮直接就没了，滚都滚不到。
 * 所以：flex-wrap 换行，再用 sticky 让它一直贴在弹窗底部。
 */
.modal-foot {
  padding: 14px 20px; border-top: 3px solid var(--ink);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  background: var(--paper); border-radius: 0 0 17px 17px;
  position: sticky; bottom: 0; z-index: 2;
}
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
  border: 2.5px solid var(--ink); background: #fff; cursor: pointer; font-size: 16px; flex: none;
}
.icon-btn:hover { background: var(--paper-2); }

/* ---------- 作品预览（照着拼） ---------- */
/*
 * 预览区要能滚动：照着拼模式下格子最小 10px（再小网格和辅助线就糊成一片），
 * 一张 40×71 的图纸就是 400×710，塞不进弹窗里，所以给它一个高度上限自己滚。
 * 用 flex + 子元素 margin:auto（和 .stage-canvas-wrap 同一套路数）：
 * 装得下时居中，装不下时不会把左上角裁掉、滚不到。
 */
.preview-box {
  display: flex; padding: 16px; border-radius: var(--r);
  border: 3px solid var(--ink); background: var(--paper);
  overflow: auto; max-height: 54vh;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.preview-box > canvas { margin: auto; flex: none; }
.preview-modes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.preview-modes .hint { flex: 1 1 100%; font-size: 12.5px; }

#toastHost { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 11px 20px; border-radius: 999px; border: 3px solid var(--ink);
  background: var(--ink); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow); animation: pop 0.22s ease-out;
}
.toast.ok { background: var(--teal); color: #fff; }
.toast.warn { background: var(--yellow); color: var(--ink); }
.toast.err { background: var(--red); color: #fff; }
@keyframes pop { from { transform: translateY(14px) scale(0.94); opacity: 0; } }

.empty {
  text-align: center; padding: 54px 20px; border: 3px dashed var(--line-strong);
  border-radius: var(--r); background: #fff;
}
.empty .big { font-size: 44px; margin-bottom: 12px; }
.empty h3 { font-size: 17px; margin-bottom: 6px; }
.empty p { color: var(--ink-soft); font-size: 14px; margin-bottom: 18px; }

/* ---------- 页脚 ---------- */
.site-footer { margin-top: 60px; border-top: 3px solid var(--ink); background: #fff; padding: 30px 0; }
.site-footer .inner { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--ink-soft); }
.site-footer .links { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a:hover { color: var(--pink-d); }

/* ---------- 分色拼装播放器 ---------- */
.step-player { display: flex; flex-direction: column; gap: 14px; }
.step-stage {
  border: 3px solid var(--ink); border-radius: var(--r-sm); background: #fff;
  padding: 12px; overflow: auto; max-height: 46vh; display: grid; place-items: center;
}
.step-canvas { display: block; image-rendering: pixelated; max-width: 100%; }
.step-bar {
  border: 3px solid var(--ink); border-radius: var(--r-sm); background: var(--paper);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.step-progress-text { font-weight: 800; font-size: 13.5px; font-family: var(--mono); }
.step-now {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px;
  border: 2.5px solid var(--ink); border-radius: 999px; background: #fff;
  font-size: 13px; box-shadow: var(--shadow-sm);
}
.step-now.is-empty { box-shadow: none; border-style: dashed; }
.step-dot {
  width: 16px; height: 16px; border-radius: 5px; border: 2px solid var(--ink);
  flex: none; display: inline-block;
}
.step-slider { width: 100%; accent-color: var(--teal); }
.step-mini { width: auto; padding: 6px 10px; font-size: 12.5px; }
.step-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.step-list {
  border: 3px solid var(--ink); border-radius: var(--r-sm); background: #fff;
  max-height: 232px; overflow-y: auto;
}
.step-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; border: 0; border-bottom: 2px dashed var(--line);
  background: transparent; cursor: pointer; font: inherit; font-size: 13px;
}
.step-row:last-child { border-bottom: 0; }
.step-row:hover { background: var(--paper); }
.step-row.done { opacity: 0.55; }
.step-row.now { background: #eafaf8; box-shadow: inset 4px 0 0 var(--teal); opacity: 1; }
.step-code { font-weight: 800; min-width: 52px; }
.step-hex { font-size: 11.5px; }
.step-count { margin-left: auto; font-weight: 700; }
.step-state { min-width: 52px; text-align: right; font-size: 12px; font-weight: 700; color: var(--ink-faint); }
.step-row.now .step-state { color: var(--teal-d); }

/* ---------- 加载态 ---------- */
/*
 * 转圈圈：糖果色的环，色序跟站点 2×2 拼豆 logo 一致（粉/黄/青/紫）。
 * 页面内容基本都是「等一个网络往返」，没有加载态的话就是一块白，
 * 用户不知道是在加载还是坏了。
 */
.spinner {
  display: inline-block; flex: none; vertical-align: middle;
  width: 30px; height: 30px; border-radius: 50%;
  border: 4px solid var(--line-strong);
  border-top-color: var(--pink);
  border-right-color: var(--yellow);
  border-bottom-color: var(--teal);
  border-left-color: var(--purple);
  animation: spin 0.85s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 3px; }
.spinner-lg { width: 46px; height: 46px; border-width: 5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 居中加载块。放进 .work-grid 时用 grid-column 横跨整行 */
.loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 44px 20px; text-align: center;
  border: 3px dashed var(--line-strong); border-radius: var(--r); background: #fff;
  grid-column: 1 / -1;
}
.loading-text { font-size: 13.5px; font-weight: 700; color: var(--ink-soft); }
/* 行内小号：塞进按钮、下拉、窄容器里用 */
.loading-compact {
  flex-direction: row; gap: 9px; padding: 10px 2px;
  border: 0; background: transparent; justify-content: flex-start;
}

/* 骨架卡片：作品网格的占位，比一个转圈圈更贴近最终布局 */
.skeleton-card {
  background: #fff; border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; padding-bottom: 16px;
}
.skeleton-cover {
  aspect-ratio: 4 / 3; border-bottom: 3px solid var(--ink);
  background: linear-gradient(100deg, var(--paper-2) 30%, #fff7ec 50%, var(--paper-2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton-line {
  height: 12px; margin: 13px 14px 0; border-radius: 999px;
  background: linear-gradient(100deg, var(--paper-2) 30%, #fff7ec 50%, var(--paper-2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer {
  from { background-position: 140% 0; }
  to { background-position: -40% 0; }
}

/* 顶部进度条：boot 期间（拉色卡 + 连后端）一直跑，页面就绪就收掉 */
.bootbar {
  position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 400;
  background: var(--paper-2); overflow: hidden;
}
.bootbar::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: linear-gradient(90deg, var(--pink), var(--yellow), var(--teal), var(--purple));
  animation: bootSlide 1.15s ease-in-out infinite;
}
@keyframes bootSlide {
  from { transform: translateX(-100%); }
  to { transform: translateX(350%); }
}

/* 动效敏感的用户：放慢而不是停掉 —— 停掉的转圈圈看起来像卡死了 */
@media (prefers-reduced-motion: reduce) {
  .spinner, .skeleton-cover, .skeleton-line, .bootbar::after { animation-duration: 2.6s; }
}

/* ---------- 工具类 ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.grow { flex: 1; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .feature-grid, .steps { grid-template-columns: 1fr; }
  .hero { padding: 32px 24px; }
  .hero h1 { font-size: 32px; }
}
@media print {
  .site-header, .site-footer, .studio-side, .stage-bar, .palette-strip, #toastHost { display: none !important; }
}
