/* ============================================================
   Carpet Studio — 苹果风设计系统
   ============================================================ */

:root {
  --bg: #f5f5f7;
  --canvas-bg: #eef0f2;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --accent: #0e7c66;
  --accent-hover: #0a6a57;
  --accent-soft: rgba(14, 124, 102, 0.10);
  --separator: rgba(0, 0, 0, 0.08);
  --hairline: rgba(0, 0, 0, 0.06);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --toolbar-h: 60px;
  --inspector-w: 416px;
  --ease-out: cubic-bezier(0.32, 0.72, 0.35, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro SC",
          "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-display: "SF Pro Display", -apple-system, BlinkMacSystemFont,
          "Helvetica Neue", "Segoe UI Variable Display", "Segoe UI",
          "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 触屏：去掉双击缩放（消除点按延迟与连点误放大），保留单指滚动与双指捏合 */
button, a, input, select, label { touch-action: manipulation; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden; /* 桌面端应用式框架：侧栏内部滚动 */
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; /* 触屏点按不闪灰色高亮 */
}

body.admin-page { overflow: auto; }

/* ---------- 顶部工具栏 ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--toolbar-h);
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}

.toolbar-inner {
  height: 100%;
  padding: 0 20px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5px;
  width: 32px;
  height: 32px;
  padding: 4px;
  border-radius: 9px;
  background: #fff;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.07);
  flex-shrink: 0;
}

.brand-mark i {
  border-radius: 3px;
}
.brand-mark i:nth-child(1) { background: #a7ba8a; }
.brand-mark i:nth-child(2) { background: #d0a76c; }
.brand-mark i:nth-child(3) { background: #9a999f; }
.brand-mark i:nth-child(4) { background: #c86f3e; }

.brand-text { line-height: 1.2; min-width: 0; }

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 980px; /* Apple 胶囊 */
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s ease, transform 0.1s ease, opacity 0.18s ease;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2.5px rgba(0, 0, 0, 0.12);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-secondary:hover:not(:disabled) { background: rgba(14, 124, 102, 0.16); }

.btn-ghost {
  background: transparent;
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: rgba(0, 0, 0, 0.05); }

.btn-danger { color: #c0392b; }
.btn-danger:hover:not(:disabled) { background: rgba(192, 57, 43, 0.08); }

.btn-block {
  width: 100%;
  padding: 10px 16px;
  margin-top: 14px;
}

/* ---------- 应用式工作台框架 ---------- */

.workspace {
  display: flex;
  height: calc(100vh - var(--toolbar-h));
  height: calc(100dvh - var(--toolbar-h)); /* 手机地址栏收起/展开时高度不跳动 */
  min-height: 0;
}

/* ---------- 画布区 ---------- */

.canvas-area {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(rgba(29, 29, 31, 0.05) 1px, transparent 1.4px) 0 0 / 24px 24px,
    radial-gradient(1400px 800px at 50% 18%, rgba(14, 124, 102, 0.05), transparent 62%),
    var(--canvas-bg);
}

#preview-canvas {
  border-radius: 6px;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.10),
    0 28px 70px rgba(0, 0, 0, 0.20);
  cursor: crosshair;
  touch-action: none;
  /* 长按不触发系统选择/放大镜（iOS） */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.canvas-pill {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 48px);
  white-space: nowrap;
  padding: 9px 20px;
  border-radius: 980px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 0.5px solid var(--hairline);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.10);
  font-size: 12.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.dot-sep { opacity: 0.5; }

.zoom-badge {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) scale(0.96);
  padding: 6px 14px;
  border-radius: 980px;
  background: rgba(29, 29, 31, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.zoom-badge.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.pill-hint {
  margin-left: 10px;
  padding-left: 14px;
  border-left: 0.5px solid var(--separator);
  font-size: 12px;
  opacity: 0.85;
}

/* ---------- 右侧检查器侧栏 ---------- */

.inspector {
  width: var(--inspector-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card);
  border-left: 0.5px solid var(--separator);
}

.ins-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ins-scroll::-webkit-scrollbar { width: 10px; }
.ins-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 5px;
  border: 3px solid var(--card);
}
.ins-scroll::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.24); }

.ins-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px 16px;
  border-top: 0.5px solid var(--separator);
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.ins-section {
  padding: 20px 24px 22px;
}

.ins-section + .ins-section {
  border-top: 0.5px solid var(--separator);
}

.ins-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.ins-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.ins-title-row .ins-title { margin-bottom: 0; }

.badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 980px;
  white-space: nowrap;
}

/* ---------- 表单控件 ---------- */

.field { display: block; min-width: 0; }

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-width: 0; /* 覆盖表单控件的固有最小宽度，防窄屏溢出 */
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

/* 触屏设备：输入控件字号必须 ≥16px，否则 iOS 聚焦时会强制放大页面，
   选完还得手动捏合还原，极易误触 */
@media (pointer: coarse) {
  input[type="number"],
  input[type="text"],
  select {
    font-size: 16px;
  }
}

.select-wrap { position: relative; }

.select-wrap::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.6px solid var(--text-secondary);
  border-bottom: 1.6px solid var(--text-secondary);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

select { cursor: pointer; padding-right: 32px; }

.field-note {
  font-size: 12px;
  color: var(--accent);
  margin-top: 10px;
}

/* 分段控件（地毯基础尺寸） */

.segmented {
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.045);
  border-radius: var(--radius-sm);
  padding: 2.5px;
}

.seg-btn {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.seg-btn.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10), inset 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

/* ---------- 系列与色卡 ---------- */

.series-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 10px;
}

.series-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 4px;
}

.series-price .per-sqm {
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 8px;
}

.swatch-section-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 16px 0 10px;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.swatch {
  position: relative;
  border: none;
  border-radius: var(--radius-md);
  aspect-ratio: 1 / 1;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  background-size: cover;
  outline: none;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}

.swatch:hover { transform: scale(1.05); }

/* 触屏没有悬停：hover 放大会在点按后卡在放大态，只在真悬停设备启用 */
@media (hover: none) {
  .swatch:hover { transform: none; }
  .swatch:active { transform: scale(0.96); }
}

.swatch.selected {
  box-shadow:
    inset 0 0 0 0.5px rgba(0, 0, 0, 0.08),
    0 0 0 2px var(--card),
    0 0 0 4.5px var(--accent);
}

.swatch .swatch-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 5px 4px;
  font-size: 9.5px;
  line-height: 1.25;
  text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.42));
  color: rgba(255, 255, 255, 0.95);
  pointer-events: none;
}

.swatch .swatch-label b {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.swatch.light-swatch .swatch-label {
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.55));
  color: rgba(40, 40, 40, 0.9);
}

.palette-empty {
  font-size: 12.5px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  text-align: center;
}

/* ---------- 型号统计列表 ---------- */

.stats-list { list-style: none; }

.stats-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.stats-list li + li {
  border-top: 0.5px solid var(--separator);
}

.stats-swatch {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background-size: cover;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}

.stats-info { flex: 1; min-width: 0; }

.stats-info b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
}

.stats-info span {
  display: block;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-num { text-align: right; }

.stats-num b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats-num span {
  display: block;
  font-size: 11.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.total-price {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transform-origin: left center;
}

.total-price.bump {
  animation: price-bump 0.32s cubic-bezier(0.34, 1.4, 0.44, 1);
}

@keyframes price-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.total-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---------- 开屏欢迎动效 ---------- */

.welcome {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(14, 124, 102, 0.05), transparent 62%),
    var(--bg);
  animation: welcome-out 0.6s cubic-bezier(0.4, 0, 0.2, 1) 2.05s both;
}

.welcome-inner {
  text-align: center;
  padding: 0 24px;
}

.welcome-mark {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 30px;
}

.welcome-mark span {
  width: 17px;
  height: 17px;
  border-radius: 4.5px;
  animation: mark-pop 0.55s cubic-bezier(0.34, 1.45, 0.5, 1) both;
}
.welcome-mark span:nth-child(1) { background: #a7ba8a; animation-delay: 0.10s; }
.welcome-mark span:nth-child(2) { background: #d0a76c; animation-delay: 0.19s; }
.welcome-mark span:nth-child(3) { background: #9a999f; animation-delay: 0.28s; }
.welcome-mark span:nth-child(4) { background: #c86f3e; animation-delay: 0.37s; }

/* 动画放在包裹层：filter/transform 会让元素进合成层，
   与 background-clip: text 冲突导致渐变文字不绘制（Chromium 问题） */
.welcome-reveal {
  animation: welcome-title 1s cubic-bezier(0.22, 0.61, 0.21, 1) 0.5s both;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: clamp(44px, 5.6vw, 78px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  background: linear-gradient(94deg, #1d1d1f 8%, #0e7c66 58%, #2c5d8f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.welcome-sub {
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: clamp(16px, 1.6vw, 21px);
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--text-secondary);
  animation: welcome-sub 0.8s var(--ease-out) 1s both;
}

@keyframes mark-pop {
  0%   { opacity: 0; transform: scale(0.2); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes welcome-title {
  from { opacity: 0; filter: blur(16px); transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; filter: blur(0);    transform: none; }
}

@keyframes welcome-sub {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes welcome-out {
  to { opacity: 0; visibility: hidden; transform: scale(1.02); }
}

/* 页面元素入场：欢迎层淡出时依次浮现 */

.toolbar { animation: enter-down 0.6s var(--ease-out) 1.8s both; }
.canvas-area { animation: enter-fade 0.8s var(--ease-out) 1.9s both; }
.canvas-pill { animation: enter-up 0.7s var(--ease-out) 2.4s both; }
.inspector { animation: enter-left 0.7s var(--ease-out) 2s both; }

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

@keyframes enter-up {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes enter-down {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes enter-left {
  from { opacity: 0; transform: translateX(26px); }
  to   { opacity: 1; transform: none; }
}

/* 后台页与「点击跳过」：不播放入场动画，直接呈现 */
body.admin-page .toolbar,
body.intro-skip .toolbar,
body.intro-skip .canvas-area,
body.intro-skip .canvas-pill,
body.intro-skip .inspector { animation: none; }

/* 系统开启「减弱动态效果」时不播放开屏动画（URL 加 ?motion=1 可强制播放） */
@media (prefers-reduced-motion: reduce) {
  body:not(.force-motion) .welcome { display: none; }
  body:not(.force-motion) .toolbar,
  body:not(.force-motion) .canvas-area,
  body:not(.force-motion) .canvas-pill,
  body:not(.force-motion) .inspector,
  body:not(.force-motion) .total-price.bump { animation: none; }
}

/* ---------- 后台配置页 ---------- */

.admin-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.admin-note {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--card);
  border: 0.5px solid rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  line-height: 1.7;
}

.admin-note strong { color: var(--text); }

.series-card {
  background: var(--card);
  border: 0.5px solid rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  padding: 22px 24px;
  margin-bottom: 20px;
}

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

.series-head strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.aform {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.aform .span-3 { grid-column: 1 / -1; }

.color-rows { margin-top: 6px; }

.color-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 0.85fr) minmax(0, 0.85fr) minmax(0, 1fr) 44px minmax(76px, auto) 36px;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
}

.color-row + .color-row { border-top: 0.5px solid var(--hairline); }

.color-preview {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.10);
}

.color-row input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 3px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.035);
  cursor: pointer;
}

.color-row .btn { padding: 6px; }

.color-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 0.85fr) minmax(0, 0.85fr) minmax(0, 1fr) 44px minmax(76px, auto) 36px;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-secondary);
  padding-bottom: 6px;
  border-bottom: 0.5px solid var(--separator);
}

.tex-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tex-btn {
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.add-color-btn { margin-top: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 80px);
  z-index: 500;
  padding: 11px 22px;
  border-radius: 980px;
  background: rgba(29, 29, 31, 0.88);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s var(--ease-out), opacity 0.35s ease;
  max-width: min(640px, calc(100vw - 48px));
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error { background: rgba(160, 42, 32, 0.92); }

/* ---------- 细节 ---------- */

::selection { background: rgba(14, 124, 102, 0.18); }

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

.swatch:focus-visible {
  box-shadow:
    inset 0 0 0 0.5px rgba(0, 0, 0, 0.08),
    0 0 0 2px var(--card),
    0 0 0 4.5px var(--accent);
}

/* ---------- 响应式 ---------- */

@media (max-width: 1280px) {
  :root { --inspector-w: 372px; }
}

@media (max-width: 1080px) {
  body { overflow: auto; }
  .workspace {
    flex-direction: column;
    height: auto;
  }
  .canvas-area {
    height: 58vh;
    height: 58dvh; /* 手机地址栏收起/展开时不跳动 */
    min-height: 340px;
  }
  .inspector {
    width: auto;
    border-left: none;
    border-top: 0.5px solid var(--separator);
  }
  .ins-scroll { overflow: visible; }
  .ins-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    /* iPhone 底部小横条不遮住总价 */
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .pill-hint { display: none; }
}

/* 触屏：加大点按目标，减少误触 */
@media (pointer: coarse) {
  .btn { padding: 10px 16px; }
  .seg-btn { padding: 10px 10px; }
  .swatch-grid { gap: 12px; }
  input[type="number"],
  input[type="text"],
  select { padding: 11px 12px; }
}

@media (max-width: 560px) {
  .toolbar-inner { padding: 0 12px 0 14px; }
  .brand-sub { display: none; }
  .btn { padding: 10px 12px; } /* 窄而不矮：宽度紧凑，点按高度保留 */
  .btn-label { display: none; } /* 小屏只留图标 */
  .ins-section { padding: 18px 16px; }
  .swatch-grid { gap: 8px; }
  .aform { grid-template-columns: 1fr 1fr; }
  .canvas-pill { font-size: 11.5px; padding: 8px 14px; }
  .admin-page .brand-text { display: none; } /* 后台页小屏工具栏按钮多，让位 */
}

/* 后台色号行：手机上 7 列挤不下，改为两行布局 */
@media (max-width: 720px) {
  .color-head { display: none; }
  .color-row {
    grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1fr) 44px;
    grid-template-areas:
      "pv code name del"
      "pick hex  tex  tex";
    row-gap: 8px;
    padding: 12px 0;
  }
  .color-row > :nth-child(1) { grid-area: pv; }   /* 预览 */
  .color-row > :nth-child(2) { grid-area: code; } /* 型号 */
  .color-row > :nth-child(3) { grid-area: name; } /* 名称 */
  .color-row > :nth-child(4) { grid-area: hex; }  /* 色值 */
  .color-row > :nth-child(5) { grid-area: pick; width: 36px; height: 36px; } /* 取色 */
  .color-row > :nth-child(6) { grid-area: tex; justify-self: end; } /* 贴图 */
  .color-row > :nth-child(7) { grid-area: del; justify-self: end; } /* 删除 */
}
