/* =========================================================
   AI 3D Studio · 样式表（第一阶段）
   风格：像 Apple 官网那样干净 —— 大留白、浅灰底、圆角、毛玻璃
   结构：变量 → 基础 → 顶部栏 → 左右面板 → 提示条 → 响应式
   ========================================================= */

/* ---------- 1. 设计变量（改这里就能整体换风格） ---------- */
:root {
  --bg: #F5F5F7;                     /* 页面底色 */
  --ink: #1D1D1F;                    /* 主要文字 */
  --ink-2: #5A5A5F;                  /* 次要文字（保证对比度足够） */
  --ink-3: #636368;                  /* 占位文字 */
  --accent: #0071E3;                 /* 少量蓝色强调 */
  --accent-hover: #0068D2;
  --accent-press: #005CB8;
  --ok: #2E9E4F;                     /* 状态小圆点用的绿色 */
  --panel: rgba(255, 255, 255, 0.72);
  --panel-line: rgba(0, 0, 0, 0.06);
  --hairline: rgba(0, 0, 0, 0.07);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 14px;
  --shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.04),
                  0 12px 32px rgba(0, 0, 0, 0.08),
                  0 32px 64px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04),
                 0 6px 16px rgba(0, 0, 0, 0.05);
  --ease: cubic-bezier(0.22, 0.7, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
          "Segoe UI", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
}

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

/* 带 hidden 属性的元素一定不显示（否则会被 CSS 里的 display 覆盖） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  /* 很淡的底色变化，让 3D 区有"空间"的感觉 */
  background:
    radial-gradient(120% 90% at 50% 0%, #FFFFFF 0%, var(--bg) 55%, #EFEFF1 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 你没画的部分，也要管起来：文字选区 / 焦点环 / 滚动条 */
::selection { background: rgba(0, 113, 227, 0.18); }

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

/* 屏幕阅读器专用文字（视觉上隐藏） */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 3D 画布：铺满整个窗口，在面板的下面一层 */
#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
}
#scene canvas { display: block; }

/* ---------- 3. 顶部栏 ---------- */
.topbar {
  position: fixed;
  top: 20px;
  left: 24px;
  right: 24px;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;   /* 中间空着的地方不挡住 3D 操作 */
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  stroke: var(--ink);
  stroke-width: 1.6;
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-tagline {
  font-size: 11.5px;
  color: var(--ink-2);
}

.mode-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: var(--shadow-card);
}
.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(46, 158, 79, 0.15);
}

/* ---------- 4. 左右两块毛玻璃面板 ---------- */
.panel {
  position: fixed;
  top: 88px;
  bottom: 24px;
  z-index: 10;
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: var(--shadow-panel);
}
.panel-left { left: 24px; }
.panel-right { right: 24px; }

.panel-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 22px;
  /* 主题化滚动条 */
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
}
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.panel-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-lead {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}

.section-title {
  margin: 26px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- 5. 创建表单 ---------- */
.create-form {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.create-input {
  width: 100%;
  height: 46px;
  padding: 0 15px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.create-input::placeholder { color: var(--ink-3); }
.create-input:hover { border-color: rgba(0, 0, 0, 0.14); }
.create-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
}

.btn-primary {
  width: 100%;
  height: 46px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 6px 16px rgba(0, 113, 227, 0.22);
  cursor: pointer;
  transition: background 160ms var(--ease), transform 120ms var(--ease),
              box-shadow 160ms var(--ease);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active {
  background: var(--accent-press);
  transform: scale(0.98);
}
.btn-primary:disabled {
  color: #8E8E93;
  background: #E6E6EA;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* ---------- 6. 模板卡片 ---------- */
.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.template-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding: 14px;
  min-height: 104px;
  text-align: left;
  font-family: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 160ms var(--ease), border-color 160ms var(--ease),
              box-shadow 160ms var(--ease);
}
.template-card:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 113, 227, 0.35);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 10px 24px rgba(0, 113, 227, 0.10);
}
.template-card:active {
  transform: translateY(0) scale(0.98);
}
.template-card.is-active {
  border-color: rgba(0, 113, 227, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12), var(--shadow-card);
}

.tpl-icon {
  width: 26px;
  height: 26px;
  stroke: var(--ink);
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.is-soon .tpl-icon { stroke: var(--ink-2); }

.tpl-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tpl-meta {
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.tpl-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-2);
  background: #F0F0F3;
  border-radius: 999px;
  white-space: nowrap;
}
.tpl-tag-done {
  color: #FFFFFF;
  background: var(--accent);
}

/* ---------- 6.5 修改零件（第三阶段） ---------- */
.modify-hint {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-3);
}

/* 修改后的一句话提示：就在输入框下面，不做弹窗 */
.modify-msg {
  margin: 10px 0 0;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: 10px;
}
.modify-msg.is-ok {
  color: #1F7A3D;
  background: rgba(46, 158, 79, 0.10);
}
.modify-msg.is-warn {
  color: #9A4B00;
  background: rgba(255, 149, 0, 0.13);
}

/* ---------- 7. 右侧：模型信息 ---------- */
.info-empty {
  margin-top: 10px;
  padding: 6px 0;
}
.empty-icon {
  width: 30px;
  height: 30px;
  margin-bottom: 12px;
  stroke: #B9B9C0;
  stroke-width: 1.5;
  fill: none;
  stroke-linejoin: round;
}
.empty-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.empty-text {
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

.model-name {
  margin: 6px 0 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.model-size {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.info-subtitle {
  margin: 22px 0 6px;
  font-size: 13px;
  font-weight: 600;
}

.part-hint {
  margin: 0 0 6px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

.part-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 结构里的每一行都是一个按钮：点一下 = 选中这个零件（或这一组零件） */
.part-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  font-family: inherit;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 140ms var(--ease);
}
.part-row:hover { background: rgba(0, 0, 0, 0.05); }
/* 选中的行：很淡的蓝色，不刺眼 */
.part-row.is-selected { background: rgba(0, 113, 227, 0.10); }
.part-row.is-selected .part-name { color: var(--accent); }

.part-name {
  font-size: 13.5px;
  font-weight: 500;
}
.part-size {
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 选中零件后出现的详细信息卡 */
.part-info {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 113, 227, 0.2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.part-info-name {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.part-info-line {
  display: flex;
  gap: 10px;
  margin: 0 0 5px;
  font-size: 12.5px;
  line-height: 1.6;
}
.part-info-line:last-child { margin-bottom: 0; }
.part-info-label {
  flex: none;
  width: 32px;
  color: var(--ink-2);
}
.part-info-value {
  font-variant-numeric: tabular-nums;
}

/* 颜色：一个小圆点 + 颜色名字 */
.part-info-color {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #DBDBE0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.ai-note {
  margin-top: 18px;
  padding: 14px 16px;
  background: rgba(0, 113, 227, 0.06);
  border-radius: var(--radius-md);
}
.ai-note-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.ai-note-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: #3E3E43;
}

/* ---------- 8. 底部操作提示 / 提示条 / 报错 ---------- */
.hint {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: var(--shadow-card);
  pointer-events: none;
}
.hint-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translate(-50%, 8px);
  z-index: 30;
  max-width: min(80vw, 460px);
  padding: 11px 20px;
  font-size: 13px;
  line-height: 1.5;
  color: #FFFFFF;
  background: rgba(29, 29, 31, 0.92);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}
.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.webgl-error {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  max-width: 320px;
  padding: 22px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-panel);
}
.webgl-error-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.webgl-error-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

/* ---------- 9. 响应式：小一点的屏幕 ---------- */
@media (max-width: 1200px) {
  .topbar { left: 16px; right: 16px; }
  .panel { width: 288px; }
  .panel-left { left: 16px; }
  .panel-right { right: 16px; }
}

/* 窄屏：左边面板变成底部抽屉，右边变成顶部小卡片，把中间留给 3D */
@media (max-width: 920px) {
  .panel {
    /* 小屏上 3D 模型离面板更近，把毛玻璃调实一点，文字才看得清 */
    background: rgba(255, 255, 255, 0.88);
  }
  .panel-left {
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-height: 44vh;
  }
  .panel-right {
    left: 12px;
    right: 12px;
    top: 84px;
    bottom: auto;
    width: auto;
    max-height: 32vh;
  }
  .template-grid { grid-template-columns: repeat(4, 1fr); }
  .template-card { min-height: 92px; padding: 12px; }
  .tpl-meta { display: none; }
  .hint { display: none; }
  .toast { bottom: calc(44vh + 26px); }
}

/* 更窄：顶部信息卡先收起来，3D 区域优先 */
@media (max-width: 640px) {
  .panel-right { display: none; }
  .brand-tagline { display: none; }
  .toast { bottom: calc(44vh + 22px); }
}

/* 系统设置里开了"减少动态效果"：把动画都关掉 */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}