:root {
  --bg: #fffbf2;
  --surface: #ffffff;
  --surface-alt: #fff7e6;
  --text: #1e293b;
  --muted: #64748b;
  --border: #f1dec2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e0f2fe;
  --orange: #f97316;
  --orange-dark: #c2410c;
  --yellow: #facc15;
  --yellow-dark: #ca8a04;
  --danger: #dc2626;
  --radius: 22px;
  --shadow: 0 8px 24px rgba(180, 120, 40, 0.09);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  /* 淡淡的乐高底板圆点纹理 */
  background-image: radial-gradient(#ecdcb9 1.3px, transparent 1.3px);
  background-size: 24px 24px;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* 顶部导航栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(255, 251, 242, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--border);
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow: 0 3px 0 #1d4ed8;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.5px;
}

.brand-sub {
  display: inline-block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: #c2410c;
  background: #ffedd5;
  padding: 1px 8px;
  border-radius: 999px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  background: #fef3c7;
  padding: 5px;
  border-radius: 16px;
  border: 2px solid #fde68a;
}

.nav-btn {
  border: none;
  background: transparent;
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #78350f;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn.active {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 3px 0 var(--orange-dark);
}

.icon-btn {
  border: 2px solid var(--border);
  background: var(--surface);
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 var(--border);
}

/* 主容器 */
.main-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 16px 36px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* 搜索区 */
.search-card {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.search-row {
  display: flex;
  gap: 10px;
}

.search-row input {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  font-size: 16px;
  border: 2.5px solid #cbd5e1;
  border-radius: 16px;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
}

.search-row input:focus {
  border-color: var(--primary);
  background: #fff;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.mode-pills, .chip-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.pill.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.chip-label { font-size: 13px; font-weight: 700; color: var(--muted); }

.chip {
  border: 2px dashed #fdba74;
  background: #fff7ed;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: #9a3412;
}

.chip:hover { background: #ffedd5; border-style: solid; }

/* 乐高积木立体按钮 */
.btn {
  border: none;
  border-radius: 15px;
  padding: 13px 22px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 0 var(--primary-dark);
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--primary-dark); }

.btn-yellow {
  background: var(--yellow);
  color: #713f12;
  box-shadow: 0 4px 0 var(--yellow-dark);
}
.btn-yellow:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--yellow-dark); }

.btn-secondary {
  background: #e0f2fe;
  color: #0369a1;
  box-shadow: 0 3px 0 #bae6fd;
}

.btn-warn {
  background: #fef3c7;
  color: #b45309;
  border: 2px solid #fbbf24;
}

.btn-small { padding: 8px 14px; font-size: 14px; border-radius: 11px; }
.btn-block { width: 100%; }

/* 探索工作区 */
.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.science-pane { display: flex; flex-direction: column; gap: 14px; }
.science-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.badge {
  display: inline-block;
  background: #fef3c7;
  color: #b45309;
  border: 1.5px solid #fde68a;
  font-size: 12.5px;
  font-weight: 800;
  padding: 4px 11px;
  border-radius: 999px;
}

.status-pill { font-size: 12px; font-weight: 700; color: var(--muted); }
.science-card h2 { margin: 0 0 8px; font-size: 21px; }
.science-summary { margin: 0; font-size: 15px; line-height: 1.65; color: #334155; }

.parts-wrap { margin-top: 14px; border-top: 2px dashed var(--border); padding-top: 12px; }
.parts-wrap h3 { margin: 0 0 8px; font-size: 15px; }
.parts-list { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.65; color: #334155; }
.parts-list li { margin-bottom: 5px; }

.funfact {
  margin-top: 12px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 2px solid #fde68a;
  border-radius: 14px;
  font-size: 14px;
  color: #92400e;
  line-height: 1.55;
}

.followup-card label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.followup-row { display: flex; gap: 8px; }
.followup-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
}

/* 画布区 */
.canvas-pane {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border-bottom: 2px solid var(--border);
}

.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; gap: 8px; }

.mini-btn {
  border: 2px solid var(--border);
  background: var(--surface);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}

.sandbox-box {
  position: relative;
  width: 100%;
  height: 540px;
  background: #fbfbfa;
}

.sandbox-box iframe { width: 100%; height: 100%; border: none; display: block; }

.sandbox-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(255, 251, 242, 0.95);
  padding: 24px;
  text-align: center;
  z-index: 2;
  font-size: 15px;
  font-weight: 600;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 5px solid #fed7aa;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #fef2f2;
  border-top: 2px solid #fecaca;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

/* 欢迎空状态 */
.empty-hero {
  text-align: center;
  padding: 46px 24px;
  background: linear-gradient(180deg, #ffffff 0%, #fff7ed 100%);
  border: 3px dashed #fdba74;
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.empty-art { font-size: 54px; margin-bottom: 12px; letter-spacing: 6px; }
.empty-hero h2 { margin: 0 0 10px; font-size: 24px; font-weight: 800; color: #0f172a; }
.empty-hero p { max-width: 560px; margin: 0 auto 20px; font-size: 15.5px; line-height: 1.7; color: #475569; }
.muted { color: var(--muted); font-size: 14px; }

/* 精品馆藏卡片 */
.section-head { margin-bottom: 16px; }
.section-head h2 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.item-card {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: transform 0.15s;
}

.item-card:hover { transform: translateY(-3px); border-color: #fdba74; }
.item-card h3 { margin: 10px 0 6px; font-size: 19px; font-weight: 800; color: #0f172a; }
.item-card p { margin: 0; font-size: 14.5px; color: #475569; line-height: 1.65; }
.item-actions { display: flex; gap: 8px; }

.empty-state {
  text-align: center;
  padding: 44px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--muted);
}

/* 弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 14px;
}

.modal-card {
  width: min(490px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.gate-card { text-align: center; }
.gate-icon { font-size: 48px; margin-bottom: 8px; }
.gate-card input {
  width: 100%;
  padding: 13px;
  margin: 12px 0;
  border: 2.5px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  text-align: center;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 19px; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 5px; }
.form-group input, .form-group select {
  width: 100%;
  padding: 11px 12px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  font-size: 14.5px;
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.pin-input {
  width: 100%;
  padding: 12px;
  font-size: 24px;
  letter-spacing: 0.5em;
  text-align: center;
  border: 2.5px solid var(--border);
  border-radius: 14px;
  margin: 12px 0;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.error-text { color: var(--danger); font-size: 13.5px; font-weight: 600; margin: 6px 0; }
.feedback-text { font-size: 14px; margin-top: 10px; font-weight: 700; }

/* 全屏查看器 */
.viewer-shell {
  position: relative;
  width: min(1280px, 100%);
  height: 92vh;
  background: #f8f1e4;
  border: 3px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viewer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--surface-alt);
  border-bottom: 2px solid var(--border);
  font-size: 16px;
  flex-shrink: 0;
}

.viewer-shell iframe {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  border: none;
  background: #f8f1e4;
}

.viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #f8f1e4;
  color: #5c4d3c;
  font-size: 15px;
  font-weight: 700;
  padding: 20px;
  text-align: center;
}

.viewer-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #e5d5bc;
  border-top-color: #e3562a;
  border-radius: 50%;
  animation: viewer-spin 0.8s linear infinite;
}

@keyframes viewer-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .sandbox-box { height: 430px; }
}

@media (max-width: 960px), (max-height: 600px) {
  #viewer-modal {
    padding: 0;
    display: block;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .viewer-shell {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
  }
  .viewer-bar { display: none; }
  .viewer-shell iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 12px; }
  .nav-tabs { order: 3; width: 100%; justify-content: space-around; }
  .nav-btn { flex: 1; padding: 9px 6px; font-size: 14px; }
  .search-row { flex-direction: column; }
  .form-row-2 { grid-template-columns: 1fr; }
  .sandbox-box { height: 390px; }
}

/* AI 需求确认卡 & 愿望清单 */
.clarify-card {
  margin-bottom: 18px;
  border-color: #fbbf24;
  background: linear-gradient(180deg, #fffdf5 0%, #ffffff 100%);
}
.clarify-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.clarify-card h2 { margin: 0 0 10px; font-size: 20px; color: #0f172a; }
.choice-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.choice-btn {
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.choice-btn.active {
  background: #dbeafe;
  border-color: var(--primary);
  color: var(--primary-dark);
}
.clarify-edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.clarify-edit-row input {
  width: 100%;
  padding: 11px 13px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14.5px;
}
.clarify-actions { display: flex; justify-content: flex-end; gap: 10px; }

.wish-section { margin-top: 8px; }
.wish-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.wish-header h2 { margin: 0 0 4px; font-size: 21px; font-weight: 800; }
.wish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.wish-card {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wish-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wish-status { font-size: 12.5px; font-weight: 700; color: #ea580c; }
.wish-card h3 { margin: 0; font-size: 18px; font-weight: 800; color: #0f172a; }
.wish-detail { margin: 0; font-size: 14px; color: #475569; line-height: 1.5; }
.wish-card-actions { display: flex; gap: 8px; margin-top: auto; }
@media (max-width: 640px) { .clarify-edit-row { grid-template-columns: 1fr; } }

/* 顶部账号胶囊与 20 灵感点子盒 */
.top-actions { display: flex; align-items: center; gap: 8px; }
.account-pill {
  border: 2px solid var(--border);
  background: var(--surface);
  color: #0f172a;
  height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--border);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ideas-box { margin-top: 14px; padding-top: 12px; border-top: 2px dashed var(--border); }
.ideas-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.shuffle-btn {
  border: 2px solid #fbbf24;
  background: #fef9c3;
  color: #854d0e;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.shuffle-btn:hover { background: #fef08a; }

.wish-status.done {
  color: #15803d;
  background: #dcfce7;
  padding: 2px 9px;
  border-radius: 999px;
}
