/* =====================================================
   小羊拼豆 · 施工图工作台样式
   Phase 1：三栏工作台布局 + 统一设计规范
   ===================================================== */

/* ---------------- 设计规范 ---------------- */
:root {
  /* 颜色 */
  --bg: #f4f5f7;            /* 浅灰米白背景 */
  --surface: #ffffff;       /* 白色主体 */
  --surface-alt: #f8f9fb;   /* 次级表面 */
  --border: #e4e6eb;        /* 边框 */
  --border-strong: #d0d3da;

  --text: #2b2b33;          /* 深灰主文字 */
  --text-secondary: #6b7280;/* 中灰辅助文字 */
  --text-light: #9aa0a8;    /* 浅灰弱文字 */

  --primary: #4a7ba6;       /* 低饱和品牌蓝 */
  --primary-hover: #3f6f99;
  --primary-soft: #eaf2f9;

  --success: #3f9d63;
  --danger: #d9534f;
  --danger-soft: #fdecea;

  /* 尺寸 */
  --topbar-h: 48px;
  --left-w: 320px;
  --right-w: 300px;
  --radius: 6px;
  --radius-sm: 4px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06);
  --shadow-md: 0 2px 8px rgba(20, 24, 40, .08);

  /* 字体 */
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-mono: Consolas, "Courier New", monospace;
}

/* ---------------- Reset ---------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden; /* 工作台自身滚动，不产生整页滚动 */
}

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

/* ---------------- 顶部工具栏 ---------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.back-btn {
  font-size: 18px;
  line-height: 1;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.back-btn:hover { background: var(--surface-alt); color: var(--text); }

.brand-logo { font-size: 20px; }

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .3px;
  white-space: nowrap;
}

.page-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
}

.top-actions { display: flex; gap: 8px; }

.top-btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.top-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.top-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- 顶部授权状态栏 ---- */
.license-session {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 10px;
  padding: 4px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.license-session.is-authorized {
  background: #eef7f1;
  border-color: #cde8d6;
}

.license-session[data-status="blocked"] {
  background: var(--danger-soft);
  border-color: #f0c9c7;
  color: var(--danger);
}

.ls-item { line-height: 1.4; }

.ls-status { font-weight: 600; }

.license-session.is-authorized .ls-status { color: var(--success); }

.ls-key {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

.ls-logout {
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  margin-left: 2px;
}

.ls-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ---------------- 三栏工作台骨架 ---------------- */
.workspace {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  display: flex;
  overflow: hidden;
}

.side-panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

.panel-header {
  flex: 0 0 auto;
  height: 42px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }

/* 左栏：参数 */
.left-panel {
  width: var(--left-w);
  flex: 0 0 var(--left-w);
  border-right: 1px solid var(--border);
}

/* 右栏：信息 */
.right-panel {
  width: var(--right-w);
  flex: 0 0 var(--right-w);
  border-left: 1px solid var(--border);
}

/* 中栏：画布 */
.canvas-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.canvas-toolbar {
  flex: 0 0 auto;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.canvas-title { font-weight: 600; font-size: 14px; }

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.canvas-zoom { display: flex; align-items: center; gap: 6px; }

.zoom-label {
  min-width: 52px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.zoom-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }

/* ---------------- 在线编辑工具栏（Phase 5） ---------------- */
.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* 修复：.tool-group 的 display:flex 会覆盖 HTML hidden 属性，
   导致未生成图纸时编辑工具组仍显示。显式优先隐藏。 */
.tool-group[hidden] {
  display: none !important;
}

.edit-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  transition: background .12s, color .12s, border-color .12s;
}

.edit-btn:hover:not(:disabled) { background: var(--surface); color: var(--text); border-color: var(--border-strong); }

.edit-btn:disabled { opacity: .35; cursor: not-allowed; }

.edit-btn.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary) inset;
}

.current-color {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: default;
}

.cc-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.cc-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* 编辑提示条（Phase 5：工具操作说明） */
.edit-hint-bar {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.edit-hint-bar.is-visible { display: flex; }

.edit-hint-bar kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
}

.edit-hint-mode {
  font-weight: 600;
  color: var(--primary);
}

.edit-hint-badge {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(74, 123, 166, .3);
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
}

.icon-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.viewport {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  min-height: 0;
  scrollbar-width: thin;
  background:
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
}

.output-area { min-height: 100%; padding: 20px; }

/* ---------------- 空状态 ---------------- */
.empty-state {
  height: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-icon { font-size: 48px; opacity: .6; }
.empty-state h3 { font-size: 18px; color: var(--text); }
.empty-state p { font-size: 13px; color: var(--text-secondary); }

/* ---------------- 输出卡片 ---------------- */
.output-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}

.output-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.output-card h3 span { display: inline-flex; align-items: center; gap: 8px; }

.download-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
}

.download-btn:hover { border-color: var(--primary); color: var(--primary); }

.output-card canvas { display: block; max-width: 100%; height: auto; }

/* ---------------- 画布查看器（Phase 4） ---------------- */
.output-card--viewer { display: flex; flex-direction: column; }

.output-card--viewer h3 { flex: 0 0 auto; }

.output-card--viewer .viewer-container {
  height: calc(100vh - var(--topbar-h) - 42px - 49px - 40px);
  min-height: 320px;
}

.viewer-container {
  flex: 1 1 auto;
  position: relative;
  overflow: auto;
  touch-action: none;
  background:
    linear-gradient(#eceef2 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, #eceef2 1px, transparent 1px) 0 0 / 24px 24px,
    #fafbfc;
  cursor: grab;
  scrollbar-width: thin;
}

.viewer-container.is-dragging { cursor: grabbing; }
.viewer-container.is-dragging * { user-select: none; }

.viewer-holder { position: relative; transform-origin: 0 0; }

.viewer-stage { transform-origin: 0 0; }

.viewer-stage canvas { display: block; background: #fff; box-shadow: var(--shadow-md); }

/* ---------------- 左侧：折叠模块 ---------------- */
.acc { border-bottom: 1px solid var(--border); }

.acc summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  background: var(--surface);
}

.acc summary::-webkit-details-marker { display: none; }

.acc summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-light);
  font-size: 12px;
  transition: transform .15s ease;
}

.acc[open] summary::after { transform: rotate(180deg); }

.acc summary:hover { background: var(--surface-alt); }

.acc-body { padding: 4px 16px 14px; }

/* ---------------- 表单控件 ---------------- */
.form-group { margin: 12px 0; }

.form-group:first-child { margin-top: 4px; }
.form-group:last-child { margin-bottom: 4px; }

.form-group > label:not(.radio-label):not(.checkbox-label) {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group label + input[type="text"],
.form-group label + select,
.form-group label + textarea,
.form-group label + input[type="number"] {
  margin-top: 6px;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(74, 123, 166, .15);
}

textarea { height: auto; padding: 8px 10px; resize: vertical; }

select { appearance: auto; }

input[type="number"] { font-family: var(--font-mono); }

/* 单选 / 复选行 */
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 8px 0;
}

.radio-label,
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.radio-label input,
.checkbox-label input { accent-color: var(--primary); cursor: pointer; }

/* 两列输入 */
.two-cols { display: flex; gap: 10px; }
.two-cols > div { flex: 1; min-width: 0; }

/* 滑块 */
input[type="range"] {
  width: 100%;
  margin: 6px 0 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-val {
  display: inline-block;
  min-width: 34px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 0;
}

.hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}

.hint:not(:first-of-type) { margin-top: 4px; }

/* tooltip 图标 */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--text-light);
  font-size: 10px;
  cursor: help;
  vertical-align: middle;
}

/* ---------------- 上传区域 ---------------- */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.drop-zone:hover { border-color: var(--primary); background: var(--primary-soft); }

.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-icon { font-size: 32px; margin-bottom: 8px; }
.drop-zone p { font-size: 13px; color: var(--text-secondary); }

.image-actions {
  display: flex;
  gap: 8px;
}

.image-actions button { flex: 1; }

#preview-thumb {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  background: var(--surface-alt);
}

/* ---------------- AI 像素化：处理方式 / 预览 / 大图 ---------------- */
.ai-panel-title {
  font-size: 14px;
  font-weight: 600;
  margin: 10px 0 8px;
}

.ai-detect {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 6px 0;
  font-size: 13px;
}
.ai-detect-line { color: var(--text); }
.ai-detect-reco { color: var(--text-secondary); margin-top: 4px; }

.ai-mode-row { margin: 8px 0; }
.ai-radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.ai-radio:hover { border-color: var(--border-strong); }
.ai-radio input { margin-top: 3px; }
.ai-radio b { display: block; font-size: 14px; color: var(--text); }
.ai-radio em { display: block; font-style: normal; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.ai-mode-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 0;
  line-height: 1.5;
}

/* 原图 | AI像素图 预览：完整显示，不裁切、不变形（object-fit: contain） */
.ai-preview {
  margin-top: 12px;
  border-top: 1px dashed var(--border-strong);
  padding-top: 12px;
}
.ai-preview-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ai-preview-fig {
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ai-preview-fig img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.ai-preview-fig img.ai-zoomable { cursor: zoom-in; }
.ai-preview-fig figcaption {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.ai-preview-arrow { color: var(--text-light); font-size: 14px; line-height: 1; }
.ai-preview-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 6px 0;
  text-align: center;
  line-height: 1.5;
}
.ai-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.ai-preview-actions button { flex: 1 1 auto; }

/* AI 大图预览 Modal：覆盖全屏、图片完整显示、保持比例 */
.ai-zoom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(17, 20, 26, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.ai-zoom-overlay img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #ffffff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.ai-zoom-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 38px;
  text-align: center;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}
.ai-zoom-close:hover { background: rgba(255, 255, 255, 0.32); }

/* ---------------- 安全边距视觉预览 ---------------- */
.margin-preview {
  position: relative;
  width: 100%;
  height: 64px;
  margin-top: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px; /* 模拟边距 */
}

.margin-preview-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 3px;
  color: var(--primary);
  font-size: 12px;
}

/* ---------------- 尺寸预览 ---------------- */
.size-preview-line {
  font-size: 13px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.size-preview-line strong { color: var(--primary); font-family: var(--font-mono); }

/* ---------------- 底部生成按钮固定区 ---------------- */
.generate-bar {
  flex: 0 0 auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.param-dirty {
  font-size: 12px;
  color: var(--danger);
  padding: 6px 10px;
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  border: 1px solid #f3c6c4;
}

/* 主题按钮 */
.primary-btn {
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .5px;
  transition: background .15s;
}

.primary-btn:hover:not(:disabled) { background: var(--primary-hover); }
.primary-btn:disabled { opacity: .6; cursor: not-allowed; }

.secondary-btn {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  text-align: center;
}

.secondary-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.secondary-btn:disabled { opacity: .5; cursor: not-allowed; }

.danger-btn {
  height: 34px;
  padding: 0 12px;
  border: 1px solid #ecc7c5;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--danger);
  font-size: 13px;
}

.danger-btn:hover { background: var(--danger-soft); }

/* 状态栏 */
.status {
  min-height: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.status.error { color: var(--danger); font-weight: 500; }

/* ---------------- 右侧：信息面板 ---------------- */
.info-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.info-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 图纸信息 */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-item {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.stat-item .stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.stat-item strong {
  font-size: 15px;
  font-family: var(--font-mono);
  color: var(--text);
}

/* 颜色用量列表 */
.color-usage-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.color-usage-list::-webkit-scrollbar { width: 6px; }
.color-usage-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.color-usage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.color-usage-item:last-child { border-bottom: none; }
.color-usage-item::before {
  content: "";
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--swatch, var(--surface));
}

.color-code {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
  min-width: 40px;
}

.color-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.color-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* 颜色用量占比进度条（Phase 6） */
.usage-bar {
  flex: 1 1 100%;
  height: 4px;
  margin: 2px 0 0 24px;
  border-radius: 2px;
  background: var(--surface-alt);
  overflow: hidden;
}

.usage-bar > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--usage-color, var(--primary));
  transition: width .15s ease;
}

/* 采购清单：余量说明行（Phase 6） */
.purchase-rate-line {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px dashed var(--border-strong);
}

.purchase-rate-line strong {
  font-family: var(--font-mono);
  color: var(--primary);
}

/* 采购清单：合计行（Phase 6） */
.purchase-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.purchase-total strong {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--primary);
}

.list-placeholder {
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-light);
}

/* 导出中心 */
.export-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-actions .secondary-btn { width: 100%; text-align: center; }

/* ---------------- 响应式（Phase 8） ---------------- */
/* 右栏关闭按钮：桌面三栏布局下隐藏 */
.panel-close {
  display: none;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.panel-close:hover { border-color: var(--primary); color: var(--primary); }

/* 信息面板遮罩（仅平板抽屉模式显示） */
.panel-overlay {
  display: none;
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(20, 24, 40, .38);
  z-index: 80;
  opacity: 0;
  transition: opacity .2s ease;
}

.panel-overlay.is-visible { display: block; opacity: 1; }

/* 平板：右栏变为右侧滑入抽屉 */
@media (max-width: 1100px) {
  .right-panel {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    flex: none;
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateX(100%);
    transition: transform .22s ease;
    z-index: 90;
  }

  .right-panel.is-open { transform: translateX(0); }

  .panel-close { display: inline-flex; }

  .page-name { max-width: 140px; }

  .top-btn--icon {
    width: 34px;
    padding: 0;
    justify-content: center;
    text-align: center;
  }
}

/* 手机：三栏纵向堆叠为「参数 → 画布 → 信息面板」单栏 */
@media (max-width: 720px) {
  :root { --topbar-h: 44px; }

  body { overflow: auto; }

  .workspace {
    position: static;
    display: block;
    min-height: calc(100vh - var(--topbar-h));
  }

  .left-panel {
    width: 100%;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel-scroll { max-height: none; }

  .generate-bar { position: sticky; bottom: 0; }

  .canvas-panel { width: 100%; flex: none; }

  .viewport { height: 70vh; }

  .brand-name { font-size: 14px; }
  .page-name { display: none; }

  /* 信息面板恢复为普通入流布局（显示在画布下方，可滚动浏览） */
  .right-panel {
    position: static;
    width: 100%;
    max-width: none;
    transform: none;
    border-left: none;
    border-top: 1px solid var(--border);
    box-shadow: none;
    transition: none;
  }

  .panel-close { display: none; }

  /* 画布顶部工具栏：允许横向滚动，避免挤压 */
  .canvas-toolbar {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .toolbar-left { flex-wrap: nowrap; }
  .tool-group { flex-wrap: nowrap; }

  .edit-hint-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  /* 触摸目标优化：编辑/缩放按钮加大 */
  .edit-btn, .icon-btn {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
  }

  .top-btn { height: 34px; }

  #btn-info, #btn-export { width: 36px; }

  /* 查看器高度适配手机视口 */
  .output-card--viewer .viewer-container {
    height: calc(70vh - 140px);
    min-height: 260px;
  }
}
