/* 《妙豆工坊 Pro / BeadCraft Pro》极简工业风深色高质感微边框 + 明亮画布自适应样式表 */
:root {
  --bg-app: #0b0f17;
  --bg-panel: #111724;
  --bg-card: #172032;
  --bg-input: #0c121d;
  --border-subtle: #212c40;
  --border-strong: #334361;
  --text-main: #f1f5f9;
  --text-sub: #94a3b8;
  --text-muted: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --canvas-well: #e6ecf4;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  user-select: none;
}

/* 滚动条微缩美化 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #29364f; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #3e5275; }

/* 顶部导航栏 */
.topbar {
  height: 50px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
  z-index: 30;
}

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

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 5px;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
  flex-shrink: 0;
}
.brand-logo span {
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(15, 23, 42, 0.35);
}
.brand-logo span:nth-child(2) { background: #fde047; }
.brand-logo span:nth-child(3) { background: #fb7185; }

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-sub);
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* 三态视图胶囊切换器 */
.view-switcher {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}
.view-pill {
  border: none;
  background: transparent;
  color: var(--text-sub);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.view-pill:hover { color: var(--text-main); }
.view-pill.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 6px rgba(59, 130, 246, 0.4);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lic-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  transition: all 0.15s;
  white-space: nowrap;
}
.lic-badge.pro {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: #1e293f; }
.btn:active { transform: translateY(0.5px); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-glow {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #34d399;
  color: #fff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}
.btn-glow:hover { filter: brightness(1.08); }

/* 主工作区三栏布局 */
.workspace {
  display: grid;
  grid-template-columns: 306px 1fr 336px;
  height: calc(100% - 50px);
  width: 100%;
  overflow: hidden;
}

.side-panel {
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side-left { border-right: 1px solid var(--border-subtle); }
.side-right { border-left: 1px solid var(--border-subtle); }

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 11px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 12.5px;
  margin-bottom: 9px;
  color: #e2e8f0;
}

/* 示例图缩略条 */
.sample-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.sample-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  border-radius: 7px;
  padding: 4px;
  cursor: pointer;
  text-align: center;
  font-size: 11px;
  color: var(--text-sub);
  transition: all 0.15s;
}
.sample-btn img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  object-fit: cover;
  display: block;
  margin-bottom: 3px;
}
.sample-btn.active, .sample-btn:hover {
  border-color: var(--primary);
  color: #fff;
}

/* 表单控件 */
.ctrl-row {
  margin-bottom: 8px;
}
.ctrl-row:last-child { margin-bottom: 0; }
.ctrl-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.ctrl-val {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: #93c5fd;
  font-weight: 600;
}

select, input[type="text"], input[type="number"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12px;
  outline: none;
}
select:focus, input:focus { border-color: var(--primary); }

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  height: 5px;
  cursor: pointer;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chip {
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-sub);
  cursor: pointer;
}
.chip:hover, .chip.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.16);
  color: #fff;
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mode-card {
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  cursor: pointer;
  transition: all 0.15s;
}
.mode-card.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.14);
}
.mode-card-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-main);
}
.mode-card-desc {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

/* 中央高清明亮画布视口 */
.canvas-stage {
  position: relative;
  background: var(--canvas-well);
  background-image: radial-gradient(rgba(100, 116, 139, 0.22) 1px, transparent 1px);
  background-size: 18px 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: none;
}

.stage-hud-top {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
  gap: 8px;
}
.hud-pill {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.86);
  backdrop-filter: blur(8px);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.15);
}

#viewportCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* 底部悬浮像素画师精修工具箱 */
.floating-toolbox {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.35);
  z-index: 12;
  max-width: calc(100% - 20px);
  overflow-x: auto;
}
.tool-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.tool-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tool-btn.active {
  background: var(--primary);
  color: #fff;
}
.tool-sep {
  width: 1px;
  height: 20px;
  background: #334155;
  margin: 0 3px;
  flex-shrink: 0;
}

/* 跟拼激活时的顶部沉浸状态横幅 */
.follow-banner {
  display: none;
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid #10b981;
  border-radius: 10px;
  padding: 8px 14px;
  color: #f8fafc;
  z-index: 15;
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.25);
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
.follow-banner.show { display: flex; }
.progress-track {
  width: 140px;
  height: 8px;
  border-radius: 99px;
  background: #1e293b;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  width: 0%;
  transition: width 0.2s;
}

/* 右侧色号采购与跟拼清单 */
.bom-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 2px;
}
.bom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.12s;
}
.bom-row:hover { border-color: #475569; }
.bom-row.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.16);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4) inset;
}
.bom-row.completed {
  opacity: 0.52;
}
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

/* 弹窗通用蒙层 */
.modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.76);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-mask.open { display: flex; }
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.modal-head h3 { margin: 0; font-size: 16px; }

/* 豆仓网格 */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 2px;
}
.inv-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  cursor: pointer;
  font-size: 11px;
  font-family: ui-monospace, Consolas, monospace;
}
.inv-cell.off {
  opacity: 0.32;
  text-decoration: line-through;
}

/* 手机 / iPad 竖屏触控自适应 (< 1024px) */
.mobile-dock {
  display: none;
}

@media (max-width: 1023px) {
  .brand-sub { display: none; }
  .topbar {
    height: auto;
    min-height: 46px;
    padding: 6px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .view-switcher {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
  .view-pill { flex: 1; text-align: center; padding: 4px 6px; font-size: 11px; }

  .workspace {
    display: flex;
    flex-direction: column;
    height: calc(100% - 82px - 54px);
    position: relative;
  }

  .canvas-stage {
    flex: 1;
    min-height: 52%;
  }

  .floating-toolbox {
    bottom: 8px;
    padding: 4px 6px;
  }

  .side-panel {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 54px;
    height: 46vh;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-strong);
    border-left: none;
    border-right: none;
    z-index: 45;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  }
  .side-panel.mobile-open {
    display: flex;
  }

  .follow-banner {
    top: 44px;
    font-size: 11px;
    padding: 6px 10px;
    max-width: 94%;
    overflow-x: auto;
  }

  .mobile-dock {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: 54px;
    background: #0d131f;
    border-top: 1px solid var(--border-subtle);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
  }
  .dock-tab {
    border: none;
    background: transparent;
    color: var(--text-sub);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
  }
  .dock-tab.active {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
  }
}
