/* ============ 谷子样机 样式 ============ */
:root {
  --bg: #17131f;
  --bg-2: #221c2e;
  --card: #2a2338;
  --card-2: #332a44;
  --line: #3d3350;
  --txt: #f3eefb;
  --txt-dim: #a89ec2;
  --accent: #ff5c8a;
  --accent-2: #8a6cff;
  --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--txt);
}

/* ---------- 顶部类型栏 ---------- */
#type-bar {
  padding: calc(10px + var(--safe-top)) 0 8px;
  flex-shrink: 0;
}
.type-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 14px;
  scrollbar-width: none;
}
.type-scroll::-webkit-scrollbar { display: none; }

.type-chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--txt-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .18s;
}
.type-chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

/* ---------- 中部预览区 ---------- */
#stage-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
#stage-inner {
  position: relative;
  width: min(100%, 720px);
  aspect-ratio: 1 / 1;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#stage {
  width: 100%;
  height: 100%;
  touch-action: none;
  border-radius: 12px;
}

/* ---------- CSS 3D 卡片（平面谷子类型）---------- */
#stage-inner { perspective: 1100px; }
#card3d {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  will-change: transform;
}
#card3d.hidden { display: none; }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.card-face canvas { display: block; }
.card-back { transform: rotateY(180deg); }

#drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s;
}
#drop-hint.show { opacity: 1; }
.hint-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px dashed var(--txt-dim);
  position: relative;
}
.hint-icon::before {
  content: "";
  position: absolute;
  inset: 18px;
  background: var(--txt-dim);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  border-radius: 2px;
}
.hint-text { font-size: 15px; color: var(--txt); font-weight: 600; }
.hint-sub { font-size: 12px; color: var(--txt-dim); }

#rotate-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--txt-dim);
  opacity: .8;
  pointer-events: none;
  white-space: nowrap;
}

.stage-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  color: var(--txt);
  font-size: 12px;
  border: 1px solid var(--line);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all .18s;
}
.stage-btn:active { transform: scale(.94); }

/* ---------- 底部面板 ---------- */
#panel {
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding-bottom: var(--safe-bottom);
}
#tab-bar {
  display: flex;
  padding: 8px 14px 0;
  gap: 4px;
}
.tab {
  flex: 1;
  padding: 8px 0;
  background: none;
  border: none;
  color: var(--txt-dim);
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .18s;
}
.tab.active {
  color: var(--txt);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

#tab-pages { padding: 12px 14px 16px; }
.tab-page { display: none; }
.tab-page.active { display: block; }

/* 选项行（效果/背景/字体 横滑） */
.opt-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: none;
}
.opt-row::-webkit-scrollbar { display: none; }

.opt-card {
  flex-shrink: 0;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
}
.opt-swatch {
  width: 52px; height: 52px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background-size: cover;
  position: relative;
  overflow: hidden;
  transition: all .18s;
}
.opt-card.active .opt-swatch {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,92,138,.3);
}
.opt-name {
  font-size: 11px;
  color: var(--txt-dim);
  white-space: nowrap;
}
.opt-card.active .opt-name { color: var(--txt); font-weight: 600; }

/* ---------- 文字页 ---------- */
.text-page { display: flex; flex-direction: column; gap: 12px; }
.field-row { display: flex; align-items: center; gap: 10px; }
.field-label { font-size: 13px; color: var(--txt-dim); flex-shrink: 0; }
#text-input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--txt);
  font-size: 14px;
  outline: none;
}
#text-input:focus { border-color: var(--accent); }

/* 字体选项用文字预览 */
.font-swatch {
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--txt);
  background: var(--bg-2);
}

/* ---------- 导出页 ---------- */
.export-page { display: flex; flex-direction: column; gap: 14px; }
.seg-row { display: flex; gap: 8px; }
.seg {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--txt-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .18s;
}
.seg.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.export-note { font-size: 12px; color: var(--txt-dim); }
.primary-btn, .ghost-btn {
  width: 100%;
  padding: 13px 0;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  transition: all .18s;
}
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  font-weight: 600;
}
.primary-btn:disabled, .ghost-btn:disabled { opacity: .4; }
.primary-btn:active:not(:disabled) { transform: scale(.98); }
.ghost-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--txt);
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 13px;
  z-index: 99;
  transition: opacity .25s;
  max-width: 80vw;
  text-align: center;
}
/* ---------- 导出预览弹层 ---------- */
#export-modal { position: fixed; inset: 0; z-index: 50; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.72); }
.modal-body {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  width: min(86vw, 420px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#export-img {
  width: 100%;
  border-radius: 10px;
  background: repeating-conic-gradient(#3a3a3a 0 25%, #2c2c2c 0 50%) 0 0 / 20px 20px;
}
.modal-note { font-size: 12px; color: var(--txt-dim); text-align: center; }

.hidden { display: none !important; }
