/* =============================================================================
   像素记忆 · 设计系统层（DESIGN SYSTEM LAYER）
   -----------------------------------------------------------------------------
   继承主仓 BrickArt/style.css 的设计系统：
     - Token 体系沿用主仓【结构】（背景4层 / 文字3级 / 描边2级 / 3阴影 / 4圆角 / AI强调色），
       值替换为像素记忆 wabi-sabi（米白 / 苔绿 / 陶土 + 雾紫 AI 色）。
     - 组件类沿用主仓【类名】（.property-section / .segment-btn / .canvas-hud / .overlay-tools …），
       app 层 DOM 直接挂这套，长得像主仓。

   规则（写进 CLAUDE.md，所有 IDE 遵守）：
     1. 本文件是设计系统层，index.html 必须在 style.css 之前 link 它。
     2. app 层（style.css）只许【消费】这里的 token 与组件，禁止自造 token、禁止重定义颜色/阴影/圆角。
     3. 新组件先看本文件有没有可复用的；没有再在本文件按同样规范【补 delta】，不在 app 层散落硬编码。
     4. 主仓设计系统升级时，本文件的 token 结构同步跟进。
   ============================================================================= */

:root {
  /* ---- 背景 4 层（对应主仓 --bg / -soft / -card / -card-strong）---- */
  --bg:            #FBF8F2;
  --bg-soft:       #FDFCF8;
  --bg-card:       rgba(255, 253, 248, 0.92);
  --bg-card-strong:#FFFDF9;

  /* ---- 文字 3 级（对应主仓 --text / -soft / -muted）---- */
  --text:      #3A3A34;
  --text-soft: #7C786C;
  --text-muted:#9E998F;

  /* ---- 描边 2 级 ---- */
  --line:        rgba(120, 110, 95, 0.16);
  --line-strong: rgba(120, 110, 95, 0.30);

  /* ---- 主色 苔绿（对应主仓 --primary）---- */
  --primary:      #5D7052;
  --primary-dark: #47573E;
  --primary-soft: rgba(93, 112, 82, 0.14);
  --primary-tint: #EEF0E9;

  /* ---- 点缀 陶土（像素记忆品牌强调，主操作/徽章）---- */
  --terra:      #C67B5C;
  --terra-dark: #B0613F;
  --terra-soft: rgba(198, 123, 92, 0.14);

  /* ---- AI 强调（对应主仓 --purple，魔法/AI 处理专用，wabi 雾紫）---- */
  --ai:      #9D7CA5;
  --ai-dark: #84638C;
  --ai-soft: rgba(157, 124, 165, 0.14);

  /* ---- 语义色 ---- */
  --accent-red:  #C25B52;
  --accent-gold: #C5A059;
  --mint:        #DCEBE4;

  /* ---- 阴影 3 级（对应主仓 pill / card / soft，暖色调）---- */
  --pill-shadow: 0 14px 34px -16px rgba(93, 112, 82, 0.22);
  --card-shadow: 0 24px 56px -28px rgba(82, 68, 49, 0.20);
  --soft-shadow: 0 10px 24px -14px rgba(88, 73, 52, 0.14);
  --inset-hi:    inset 0 1px 0 rgba(255, 255, 255, 0.7);

  /* ---- 圆角 4 级（对应主仓 xl/lg/md/sm）---- */
  --r-xl: 36px;
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --r-pill: 999px;

  /* ---- 间距阶 ---- */
  --sp-1: 6px;  --sp-2: 10px; --sp-3: 14px; --sp-4: 18px;
  --sp-5: 24px; --sp-6: 32px;

  /* ---- 字体 ---- */
  --serif: 'Fraunces', Georgia, serif;
  --sans:  'Nunito', system-ui, 'PingFang SC', sans-serif;
}

/* =============================================================================
   BASE
   ============================================================================= */
* { box-sizing: border-box; }
html { scrollbar-width: thin; scrollbar-color: #ded8cf transparent; scrollbar-gutter: stable; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ded8cf; border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: #c18c5d; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at top right, rgba(227, 205, 173, 0.22), transparent 24%),
    radial-gradient(circle at 84% 8%, rgba(244, 231, 210, 0.28), transparent 20%),
    radial-gradient(circle at 18% 88%, rgba(215, 225, 208, 0.18), transparent 22%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
}
/* 颗粒噪点（视觉红线：颗粒质感）*/
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .022; z-index: 9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
h1, h2, h3, .serif { font-family: var(--serif); font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

/* =============================================================================
   工作台骨架（沿用主仓类名 / 结构）
   ============================================================================= */
.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(340px, 25vw, 420px);
  grid-template-areas: "center right";
  gap: clamp(20px, 2vw, 32px);
  align-items: stretch;
}
.canvas-panel--center { grid-area: center; position: relative; display: flex; flex-direction: column; }
.workspace-sidebar--right { grid-area: right; }
.workspace-sidebar { display: flex; flex-direction: column; }
.sidebar-scroller { display: flex; flex-direction: column; }

@media (max-width: 880px) {
  .workspace-layout { grid-template-columns: 1fr; grid-template-areas: "center" "right"; }
}

/* ---- 卡片基元 ---- */
.ds-card,
.canvas-panel {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--inset-hi), var(--card-shadow);
}

/* ---- 右栏分组（沿用主仓 .property-section）---- */
.property-section { padding: var(--sp-5) var(--sp-4); }
.property-section + .property-section { border-top: 1px solid var(--line); }
.property-section__header-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.property-section__title {
  margin: 0; font-family: var(--sans); font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
}
.property-section__hint { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.property-divider {
  height: 1px; margin: 0; border: 0;
  background: linear-gradient(90deg, transparent, var(--line-strong) 12%, var(--line-strong) 88%, transparent);
}

/* =============================================================================
   顶部 overlay 工具条（沿用主仓 .overlay-tools / .overlay-btn）
   ============================================================================= */
.overlay-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.overlay-tools__left, .overlay-tools__right { display: flex; align-items: center; gap: 6px; }
.overlay-tools__center { flex: 1; text-align: center; }
.overlay-tools__helper { font-size: 13px; color: var(--text-soft); }
.overlay-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg-card-strong);
  color: var(--text-soft); transition: all 160ms ease;
}
.overlay-btn:hover { color: var(--primary); border-color: var(--primary); }
.overlay-btn:disabled { opacity: .4; cursor: not-allowed; }

/* =============================================================================
   底部 HUD（沿用主仓 .canvas-hud）
   ============================================================================= */
.canvas-hud {
  display: flex; align-items: center; gap: 16px; padding: 8px 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 252, 247, 0.82); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--soft-shadow), inset 0 1px 1px rgba(255, 255, 255, 0.8);
}
.hud-group { display: flex; align-items: center; gap: 6px; }
.hud-btn { height: 38px; padding: 0 16px; border-radius: var(--r-pill); color: var(--text-soft); font-weight: 800; border: 1px solid transparent; transition: all 160ms ease; }
.hud-btn:hover { background: var(--primary-tint); color: var(--text); }

/* =============================================================================
   分段控件（沿用主仓 .segmented-group / .segment-btn）—— 档位/视图切换通用
   ============================================================================= */
.segmented-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segmented-group--dual { grid-template-columns: repeat(2, 1fr); }
.segment-btn {
  display: flex; align-items: center; justify-content: center; height: 38px; padding: 0 12px;
  border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg-card-strong);
  color: var(--text-muted); font-size: 13px; font-weight: 800;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.segment-btn:hover { color: var(--text-soft); }
.segment-btn.is-active {
  border-color: var(--primary); color: var(--primary); background: var(--bg-card-strong);
  box-shadow: inset 0 0 0 1px var(--primary-soft);
}

/* =============================================================================
   通用基元：按钮 / pill / 徽章 / 输入 / 缩略图选择器
   ============================================================================= */
/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: var(--r-sm);
  font-weight: 800; font-size: 13px; transition: all 160ms ease; border: 1px solid var(--line);
  background: var(--bg-card-strong); color: var(--text);
  white-space: nowrap; flex-shrink: 0;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn--primary { background: var(--terra); color: #fff; border: 0; box-shadow: var(--pill-shadow); }
.btn--primary:hover { background: var(--terra-dark); color: #fff; }
.btn--ai { background: var(--ai); color: #fff; border: 0; box-shadow: var(--pill-shadow); }
.btn--ai:hover { background: var(--ai-dark); color: #fff; }
.btn--ghost { background: var(--bg-soft); border: 1.5px dashed var(--line-strong); color: var(--primary); }
.btn--ghost:hover { background: var(--primary-tint); border-style: dashed; }
.btn--icon { width: 38px; padding: 0; }

/* pill（档位/预设）*/
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-card-strong); color: var(--text-soft); font-size: 12px; font-weight: 700;
  transition: all 140ms ease;
}
.pill:hover { color: var(--text); border-color: var(--line-strong); }
.pill.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pill:disabled { opacity: .4; cursor: not-allowed; }

/* 徽章（免费 等）*/
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--r-pill); font-size: 10.5px; font-weight: 800; }
.badge--free { background: var(--terra); color: #fff; box-shadow: var(--soft-shadow); }
.badge--ai { background: var(--ai-soft); color: var(--ai-dark); }

/* 输入 */
.field {
  width: 100%; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg-card-strong); color: var(--text);
  font-size: 13px; transition: border-color 140ms ease;
}
.field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field::placeholder { color: var(--text-muted); }

/* 缩略图选择器（装饰边框/风格 这类"看效果选"的控件，非文字）*/
.thumb-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb-pick__item {
  position: relative; border-radius: var(--r-sm); border: 2px solid transparent;
  overflow: hidden; cursor: pointer; background: var(--bg-card-strong); transition: all 140ms ease;
}
.thumb-pick__item:hover { transform: translateY(-2px); box-shadow: var(--soft-shadow); }
.thumb-pick__item.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.thumb-pick__label { display: block; text-align: center; font-size: 11px; font-weight: 700; color: var(--text-soft); padding: 4px 0 6px; }

/* 选项卡片（前置门 二选一 / 路由 这类大卡选择，沿用主仓 .route-option 思路）*/
.option-card {
  position: relative; display: grid; gap: 4px; padding: 16px 14px; text-align: center;
  border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--bg-card-strong);
  transition: all 180ms ease; cursor: pointer;
}
.option-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow); }
.option-card.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.option-card--ai { border-color: var(--ai-soft); }
.option-card--ai.is-active { border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-soft); }

/* =============================================================================
   居中弹窗（.ds-modal 系列）—— AI 优化等临时编辑场，backdrop 暖色半透明
   只消费既有 token：--bg-card-strong / --r-lg / --card-shadow / --ai …
   ============================================================================= */
.ds-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
}
.ds-modal[hidden] { display: none !important; }
.ds-modal__backdrop {
  position: absolute; inset: 0;
  /* 暖色半透明遮罩（基于陶土暖调，非纯黑）*/
  background: rgba(58, 48, 36, 0.42);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: dsModalFade 180ms ease;
}
.ds-modal__panel {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px;
  max-height: calc(100vh - 2 * var(--sp-4));
  overflow-y: auto;
  background: var(--bg-card-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--inset-hi), var(--card-shadow);
  animation: dsModalPop 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dsModalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dsModalPop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

.ds-modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.ds-modal__title {
  margin: 0; font-family: var(--serif); font-size: 1.15rem; color: var(--text);
  display: inline-flex; align-items: center; gap: 8px;
}
.ds-modal__title .ai-spark { color: var(--ai); }
.ds-modal__close {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--r-pill); border: 1px solid transparent;
  color: var(--text-muted); transition: all 160ms ease;
}
.ds-modal__close:hover { color: var(--text); background: var(--primary-tint); }

.ds-modal__body { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.ds-modal__body[hidden] { display: none !important; }
.ds-modal__state-center { align-items: center; text-align: center; gap: var(--sp-2); padding-top: var(--sp-6); padding-bottom: var(--sp-6); }

.ds-modal__footer { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-1); }
.ds-modal__footer--center { justify-content: center; }
.ds-modal__footer .btn { flex: 0 0 auto; }
