/* ============ 全局 - 金黄传统命理主题 ============ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: linear-gradient(160deg, #2a1a00 0%, #3d2400 40%, #2a1800 100%);
  background-attachment: fixed;
  color: #ffe8a0;
  overflow: hidden;
  position: fixed;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 750px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  position: relative;
}

/* 背景装饰：八卦图纹 */
#app::before {
  content: '☯';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 320px;
  opacity: 0.03;
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }

/* ============ 顶部标题栏 ============ */
.app-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 18px;
  background: rgba(50, 30, 0, 0.9);
  border-bottom: 1px solid rgba(255, 200, 50, 0.25);
}

.app-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-main {
  font-size: 17px;
  font-weight: 600;
  color: #ffd700;
  letter-spacing: 2px;
}

.brand-sub {
  font-size: 11px;
  color: #c8a030;
  letter-spacing: 0.5px;
}

.header-btn {
  height: 32px;
  font-size: 13px;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: #d4af37;
  cursor: pointer;
  border-radius: 16px;
  padding: 0 14px;
  line-height: 30px;
  white-space: nowrap;
}

.header-btn:active { opacity: 0.7; }

/* ============ 表单区 ============ */
.form-section {
  flex: 1;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.form-area {
  background: rgba(212, 175, 55, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 16px;
  padding: 20px 18px;
}

.form-intro {
  text-align: center;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.12);
}

.intro-desc {
  font-size: 13px;
  color: #c0a060;
  line-height: 1.6;
  padding: 0 6px;
}

/* ============ 历法 Tab ============ */
.cal-tabs {
  position: relative;
  display: flex;
  background: rgba(212, 175, 55, 0.08);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
  overflow: hidden;
}

.cal-tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 13px;
  color: #a08030;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: color 0.3s;
  font-weight: 500;
}

.cal-tab.active {
  color: #fff8e0;
}

.cal-indicator {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: linear-gradient(135deg, #b8860b, #d4af37);
  border-radius: 8px;
  transition: transform 0.3s ease;
  z-index: 1;
}

.cal-indicator.right {
  transform: translateX(100%);
}

/* ============ 滚轮选择器 ============ */
.picker-container {
  position: relative;
  height: 140px;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(212, 175, 55, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.12);
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.picker-columns {
  display: flex;
  height: 100%;
  touch-action: pan-y;
  overflow: hidden;
}

.picker-column {
  flex: 1;
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: y mandatory;
  padding: 50px 0;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.picker-column::-webkit-scrollbar { display: none; }

.picker-item {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: rgba(212, 175, 55, 0.2);
  scroll-snap-align: center;
  transition: color 0.15s, transform 0.15s;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.picker-item.selected {
  color: #ffd700;
  font-weight: 600;
  font-size: 17px;
  transform: scale(1.05);
}

.picker-item.near {
  color: rgba(255, 215, 0, 0.5);
  font-size: 14px;
}

.picker-highlight {
  position: absolute;
  top: 50%;
  left: 10px;
  right: 10px;
  height: 36px;
  transform: translateY(-50%);
  border-top: 1px solid rgba(212, 175, 55, 0.3);
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  pointer-events: none;
  z-index: 3;
}

.picker-mask-top,
.picker-mask-bottom {
  position: absolute;
  left: 0;
  right: 0;
  height: 50px;
  pointer-events: none;
  z-index: 3;
}

.picker-mask-top {
  top: 0;
  background: linear-gradient(to bottom, rgba(42, 26, 0, 0.95) 0%, rgba(42, 26, 0, 0) 100%);
}

.picker-mask-bottom {
  bottom: 0;
  background: linear-gradient(to top, rgba(42, 26, 0, 0.95) 0%, rgba(42, 26, 0, 0) 100%);
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  color: #c0a060;
  margin-bottom: 8px;
  font-weight: 500;
}

.gender-selector {
  display: flex;
  gap: 12px;
}

.gender-option {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  background: rgba(212, 175, 55, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 10px;
  font-size: 15px;
  color: #a08030;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1;
}

.gender-option.active {
  background: rgba(212, 175, 55, 0.2);
  border-color: rgba(212, 175, 55, 0.6);
  color: #d4af37;
}

/* ============ 按钮 ============ */
.primary-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 14px 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 3px;
  color: #2a1000;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(135deg, #ffd700, #ffb800, #e6a800);
  box-shadow: 0 4px 20px rgba(255, 200, 0, 0.35);
}

.primary-btn:active { opacity: 0.85; }

.primary-btn:disabled {
  background: rgba(212, 175, 55, 0.15);
  color: #665520;
  cursor: not-allowed;
  box-shadow: none;
}

/* ============ 占卜 Loading ============ */
.fortune-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 10, 0, 0.95);
}

.bagua-spinner {
  width: 100px;
  height: 100px;
  font-size: 90px;
  line-height: 100px;
  text-align: center;
  animation: baguaSpin 3s linear infinite;
  color: #ffd700;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.3);
}

@keyframes baguaSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.fortune-loading-text {
  margin-top: 24px;
  font-size: 16px;
  color: #ffd700;
  letter-spacing: 4px;
  animation: textPulse 1.5s ease-in-out infinite;
}

.fortune-loading-sub {
  margin-top: 10px;
  font-size: 12px;
  color: #c8a030;
  letter-spacing: 2px;
}

@keyframes textPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============ 对话区域 ============ */
.chat-section {
  flex: 1;
  padding: 12px 16px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.user-info-card {
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #c0a060;
  text-align: center;
  flex-shrink: 0;
}

.user-info-card .info-label { color: #a08030; margin-right: 4px; }
.user-info-card .info-sep { margin: 0 8px; color: rgba(212,175,55,0.2); }

.message-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

.message-list::-webkit-scrollbar { width: 3px; }
.message-list::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.2); border-radius: 3px; }

.message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: msgIn 0.3s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.75;
  word-break: break-word;
  white-space: pre-wrap;
}

.message.user .msg-bubble {
  background: linear-gradient(135deg, #b8860b, #d4af37);
  color: #1a0f00;
  border-bottom-right-radius: 4px;
}

.message.assistant .msg-bubble {
  background: rgba(212, 175, 55, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.15);
  color: #e8d5a0;
  border-bottom-left-radius: 4px;
}

/* 加载中（三个点） */
.message.loading .msg-bubble {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d4af37;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.message.error .msg-bubble {
  background: rgba(180, 60, 60, 0.12);
  border: 1px solid rgba(180, 60, 60, 0.3);
  color: #ffb0b0;
}

/* ============ 推荐问题 ============ */
.suggestions {
  margin-top: 12px;
  flex-shrink: 0;
}

.suggestions-title {
  font-size: 11px;
  color: #806020;
  margin-bottom: 8px;
  padding-left: 4px;
}

.suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-item {
  padding: 7px 13px;
  background: rgba(212, 175, 55, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 16px;
  font-size: 12px;
  color: #c0a060;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion-item:active {
  background: rgba(212, 175, 55, 0.2);
  border-color: rgba(212, 175, 55, 0.5);
}

/* ============ 输入框 ============ */
.input-area {
  flex-shrink: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(20, 12, 0, 0.95);
  border-top: 1px solid rgba(212, 175, 55, 0.1);
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 750px;
  margin: 0 auto;
}

.chat-input {
  flex: 1;
  background: rgba(212, 175, 55, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  color: #f5e6c8;
  outline: none;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
}

.chat-input:focus { border-color: rgba(212, 175, 55, 0.5); }
.chat-input::placeholder { color: #665520; }

/* ============ 分享/发送文字按钮 ============ */
.action-text-btn {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  color: #c0a060;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 18px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  white-space: nowrap;
}

.action-text-btn:active { opacity: 0.7; }

.action-text-btn.primary-text-btn {
  background: linear-gradient(135deg, #b8860b, #d4af37);
  border: none;
  color: #1a0f00;
  font-weight: 600;
}

.action-text-btn.primary-text-btn:disabled {
  background: rgba(212, 175, 55, 0.15);
  color: #665520;
  cursor: not-allowed;
}

/* ============ 海报弹层 ============ */
.poster-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}

.poster-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 90vh;
  padding: 16px;
  -webkit-user-select: none;
  user-select: none;
}

.poster-tip {
  font-size: 13px;
  color: #c0a060;
  margin-bottom: 12px;
}

.poster-image {
  max-width: 90vw;
  max-height: 70vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  -webkit-touch-callout: default;
  -webkit-user-select: none;
  user-select: none;
}

.poster-canvas { display: none; }

.poster-close-btn {
  margin-top: 16px;
  padding: 10px 36px;
  font-size: 15px;
  color: #d4af37;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 24px;
  cursor: pointer;
  font-family: inherit;
}

.poster-close-btn:active { opacity: 0.7; }

/* ============ 大屏适配 ============ */
@media (min-width: 768px) {
  #app {
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.1);
  }
}
