/* ==========================================
   今日智者 | Today's Sage v2.3.3 - 完整樣式表
   ========================================== */

:root {
  --bg-dark: #0D1019;
  --card-bg-start: #121624;
  --card-bg-end: #1A2033;
  --gold-primary: #D9A752;
  --gold-light: #F3D382;
  --gold-dim: rgba(217, 167, 82, 0.2);
  --text-white: #FFFFFF;
  --text-subdued: #9AA3B8;
  --scratch-coating: #C8CCD4;
  --font-serif: 'Playfair Display', 'Noto Serif TC', Georgia, serif;
  --font-sans: 'Noto Sans TC', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
  color: var(--text-white);
  overflow-x: hidden;
}

/* 9:16 雜誌美學主卡片 */
.card-container {
  width: 88vw;
  max-width: 420px;
  aspect-ratio: 9 / 16;
  background: linear-gradient(180deg, var(--card-bg-start) 0%, var(--card-bg-end) 100%);
  border-radius: 20px;
  border: 1px solid rgba(217, 167, 82, 0.4);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6), 0 0 20px rgba(217, 167, 82, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 28px 22px;
  position: relative;
  overflow: hidden;
}

/* 內飾雙線邊框 */
.card-inner-border {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border: 1px solid rgba(217, 167, 82, 0.2);
  border-radius: 14px;
  pointer-events: none;
}

/* 1. 頂部區域 */
.card-header-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.card-top-icon {
  color: var(--gold-primary);
  font-size: 16px;
  margin-bottom: 2px;
}

.sage-label {
  font-family: var(--font-serif);
  font-size: 11px;
  color: var(--gold-primary);
  letter-spacing: 3px;
  margin-bottom: 6px;
  text-transform: uppercase;
  opacity: 0.85;
}

.sage-name-wrapper {
  position: relative;
  display: inline-block;
  padding: 4px 12px;
  min-width: 130px;
  min-height: 44px;
  text-align: center;
}

.sage-name {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 8px;
  text-align: center;
}

/* 顯眼金光分隔線 */
.divider-gold {
  width: 50px;
  height: 3px;
  background: var(--gold-primary);
  border-radius: 2px;
  margin-top: 10px;
  box-shadow: 0 0 8px rgba(217, 167, 82, 0.6);
}

/* 2. 古文原句與出處 */
.ancient-section {
  text-align: center;
  margin: 12px 0;
  padding: 10px 14px;
  background: rgba(217, 167, 82, 0.06);
  border-radius: 10px;
  width: 100%;
  border: 1px solid rgba(217, 167, 82, 0.3);
}

.ancient-quote {
  font-size: 14px;
  color: #E2E7F3;
  letter-spacing: 1px;
  margin-bottom: 4px;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.origin-quote {
  font-style: italic;
  font-size: 11px;
  color: var(--gold-light);
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* 3. 白話解釋區塊 */
.meaning-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 10px;
  width: 100%;
}

.main-quote {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--text-white);
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* 4. 我講你聽 AI 回覆 */
.explain-result-box {
  width: 100%;
  margin-bottom: 10px;
  background: rgba(28, 34, 55, 0.7);
  border: 1.5px dashed var(--gold-primary);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.4s ease forwards;
}

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

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.result-author-tag {
  background: var(--gold-dim);
  color: var(--gold-light);
  font-size: 11px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(217, 167, 82, 0.4);
}

.result-badge {
  font-size: 10px;
  color: var(--gold-primary);
}

.result-content {
  color: #E2E7F3;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* 5. 頁腳區塊 */
.card-footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px dashed rgba(217, 167, 82, 0.4);
}

.footer-tip {
  font-family: var(--font-serif);
  font-size: 10px;
  color: var(--gold-primary);
  letter-spacing: 1.5px;
  opacity: 0.9;
}

.qr-placeholder {
  width: 42px;
  height: 42px;
  background-color: var(--text-white);
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 8px;
  font-weight: bold;
  color: #000;
}

/* ==========================================
   操作按鈕區 (橫排 4 按鈕統一修正)
   ========================================== */

.actions-container {
  width: 88vw;
  max-width: 420px;
  margin-top: 20px;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* 前三個文字按鈕 */
.actions-container .btn-secondary,
.actions-container .btn-primary {
  flex: 1;
  height: 44px !important;
  padding: 0 4px !important;
  font-size: 13px !important;
  font-weight: 700;
  white-space: nowrap !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 28px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary {
  background: rgba(28, 34, 55, 0.8);
  color: var(--text-white);
  border: 1px solid rgba(217, 167, 82, 0.5) !important;
}

.btn-secondary:active {
  background: rgba(217, 167, 82, 0.15);
}

.btn-primary {
  background: linear-gradient(135deg, #D9A752 0%, #C59B27 100%);
  color: #0D1019;
  box-shadow: 0 4px 15px rgba(217, 167, 82, 0.3);
}

.btn-primary:active {
  transform: scale(0.98);
}

/* 咖啡小圓按鈕 */
.btn-coffee {
  width: 44px !important;
  height: 44px !important;
  flex: 0 0 44px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: rgba(45, 30, 20, 0.85) !important;
  border: 1px solid var(--gold-primary) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-coffee:active {
  transform: scale(0.92);
  background: rgba(217, 167, 82, 0.25) !important;
}

.coffee-icon {
  width: 20px !important;
  height: 20px !important;
  stroke: var(--gold-light) !important;
  display: block !important;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.5);
}

.is-visible {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* ==========================================
   彈窗 Modal 區域
   ========================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 12, 20, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: #181E2E;
  border: 1px solid var(--gold-primary);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: transparent;
  border: none;
  color: var(--text-subdued);
  font-size: 28px;
  cursor: pointer;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  color: var(--gold-light);
  font-size: 20px;
  margin: 0;
}

.quota-badge {
  background: var(--gold-dim);
  color: var(--gold-light);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(217, 167, 82, 0.3);
}

.style-subtitle {
  color: var(--text-subdued);
  font-size: 14px;
  margin-bottom: 14px;
}

.style-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.style-item-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(217, 167, 82, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  text-align: left;
  color: #FFFFFF;
  cursor: pointer;
  transition: all 0.2s ease;
}

.style-item-btn:hover {
  background: var(--gold-dim);
  border-color: var(--gold-primary);
}

.style-item-name {
  font-weight: bold;
  font-size: 16px;
  color: var(--gold-light);
  margin-bottom: 2px;
}

.style-item-tagline {
  font-size: 12px;
  color: var(--text-subdued);
}

.explain-loading-view {
  text-align: center;
  padding: 30px 0;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gold-dim);
  border-top-color: var(--gold-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 14px auto;
}

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

.loading-text {
  color: var(--text-subdued);
  font-size: 14px;
}

/* 打賞咖啡 Modal 專用樣式 */
.coffee-modal-card {
  background: #FAF7F2 !important;
  border: 1px solid #E5D5C0 !important;
  color: #2C2C2C !important;
  padding: 24px 18px !important;
  max-width: 440px !important;
  border-radius: 20px !important;
}

.coffee-modal-close { color: #888888 !important; }

.coffee-modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.coffee-header-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.coffee-modal-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: #5A2D0C;
  margin: 0;
}

.coffee-subtitle {
  text-align: center;
  font-size: 13px;
  color: #666666;
  margin-bottom: 18px;
}

.coffee-payment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.payment-card {
  background: #FFFFFF;
  border: 1px solid #EFEAE1;
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.pay-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.payme-tag { background: #FFF0F3; color: #E60028; border: 1px solid #FFCCD5; }
.alipayhk-tag { background: #EEF6FF; color: #0080FF; border: 1px solid #CCE4FF; }
.alipay-tag { background: #EEF6FF; color: #0070E0; border: 1px solid #CCE4FF; }
.wechat-tag { background: #EAF8F0; color: #07C160; border: 1px solid #C1EED3; }

.qr-box {
  width: 100%;
  max-width: 130px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pay-hint {
  font-size: 10.5px;
  color: #888888;
  margin-top: 8px;
  text-align: center;
}