/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
  --bg-base: #060411;
  --bg-surface: rgba(14, 10, 35, 0.88);
  --bg-elevated: rgba(22, 17, 52, 0.90);
  --bg-input: rgba(28, 22, 60, 0.95);
  --bg-glass: rgba(14, 10, 35, 0.55);

  --border: rgba(90, 78, 150, 0.30);
  --border-hover: rgba(140, 120, 210, 0.52);
  --border-gold: rgba(210, 155, 20, 0.38);

  --purple: #6B21D4;
  --purple-mid: #7C3AED;
  --purple-light: #9333EA;
  --purple-bright: #C084FC;
  --gold: #C8951A;
  --gold-light: #E8BC38;
  --gold-bright: #FBBF24;
  --starlight: #EDE9FE;
  --wine: #831843;

  /* Star Color System (inspired by professional sites) */
  --star-main: #E8BC38;
  /* Gold — 主星 */
  --star-main-bg: rgba(200, 149, 26, .14);
  --star-main-bd: rgba(200, 149, 26, .42);
  --star-lucky: #34D399;
  /* Jade green — 吉星 */
  --star-lucky-bg: rgba(52, 211, 153, .12);
  --star-lucky-bd: rgba(52, 211, 153, .35);
  --star-evil: #FB7185;
  /* Rose red — 煞星 */
  --star-evil-bg: rgba(251, 113, 133, .12);
  --star-evil-bd: rgba(251, 113, 133, .35);
  --star-hua: #60A5FA;
  /* Sky blue — 四化 */
  --star-hua-bg: rgba(96, 165, 250, .12);
  --star-hua-bd: rgba(96, 165, 250, .35);
  --star-hua-lu: #34D399;
  --star-hua-quan: #F97316;
  --star-hua-ke: #60A5FA;
  --star-hua-ji: #EF4444;

  --text-1: #F5F2FF;
  --text-2: #C4B5FD;
  --text-3: #8B7EC8;
  --text-4: #4E4678;

  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;

  --font-serif: 'Noto Serif TC', 'Songti SC', 'STSong', Georgia, serif;
  --font-sans: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;

  --r-sm: 6px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 32px;
  --r-full: 9999px;

  --t-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --t-norm: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.48s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   RESET & BASE
   ============================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.7;
}

/* =============================================
   ANIMATED STAR BACKGROUND
   ============================================= */
.stars-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 12% 45%, rgba(107, 33, 212, .22) 0%, transparent 45%),
    radial-gradient(ellipse at 88% 15%, rgba(200, 149, 26, .14) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 92%, rgba(147, 51, 234, .14) 0%, transparent 48%),
    radial-gradient(ellipse at 65% 55%, rgba(107, 33, 212, .09) 0%, transparent 38%),
    radial-gradient(ellipse at 30% 80%, rgba(200, 149, 26, .07) 0%, transparent 35%);
}

.stars-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 8% 12%, rgba(255, 255, 255, .75) 0%, transparent 100%),
    radial-gradient(1px 1px at 18% 38%, rgba(255, 255, 255, .50) 0%, transparent 100%),
    radial-gradient(1px 1px at 28% 7%, rgba(255, 255, 255, .65) 0%, transparent 100%),
    radial-gradient(1px 1px at 42% 22%, rgba(255, 255, 255, .45) 0%, transparent 100%),
    radial-gradient(1px 1px at 56% 48%, rgba(255, 255, 255, .60) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 14%, rgba(255, 255, 255, .55) 0%, transparent 100%),
    radial-gradient(1px 1px at 82% 35%, rgba(255, 255, 255, .40) 0%, transparent 100%),
    radial-gradient(1px 1px at 93% 8%, rgba(255, 255, 255, .70) 0%, transparent 100%),
    radial-gradient(1px 1px at 5% 65%, rgba(255, 255, 255, .40) 0%, transparent 100%),
    radial-gradient(1px 1px at 22% 72%, rgba(255, 255, 255, .55) 0%, transparent 100%),
    radial-gradient(1px 1px at 38% 60%, rgba(255, 255, 255, .35) 0%, transparent 100%),
    radial-gradient(1px 1px at 52% 80%, rgba(255, 255, 255, .50) 0%, transparent 100%),
    radial-gradient(1px 1px at 67% 68%, rgba(255, 255, 255, .45) 0%, transparent 100%),
    radial-gradient(1px 1px at 78% 85%, rgba(255, 255, 255, .35) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 75%, rgba(255, 255, 255, .60) 0%, transparent 100%),
    radial-gradient(2px 2px at 14% 25%, rgba(255, 252, 230, .80) 0%, transparent 100%),
    radial-gradient(2px 2px at 46% 5%, rgba(255, 252, 230, .70) 0%, transparent 100%),
    radial-gradient(2px 2px at 75% 28%, rgba(255, 252, 230, .75) 0%, transparent 100%),
    radial-gradient(2px 2px at 95% 55%, rgba(255, 252, 230, .65) 0%, transparent 100%),
    radial-gradient(2px 2px at 33% 90%, rgba(255, 252, 230, .55) 0%, transparent 100%);
  animation: starTwinkleA 7s ease-in-out infinite alternate;
}

.stars-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 42%, rgba(255, 255, 255, .50) 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 18%, rgba(255, 255, 255, .40) 0%, transparent 100%),
    radial-gradient(1px 1px at 38% 55%, rgba(255, 255, 255, .55) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 32%, rgba(255, 255, 255, .35) 0%, transparent 100%),
    radial-gradient(1px 1px at 62% 75%, rgba(255, 255, 255, .45) 0%, transparent 100%),
    radial-gradient(1px 1px at 74% 48%, rgba(255, 255, 255, .60) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 62%, rgba(255, 255, 255, .40) 0%, transparent 100%),
    radial-gradient(1px 1px at 97% 20%, rgba(255, 255, 255, .55) 0%, transparent 100%),
    radial-gradient(2px 2px at 20% 52%, rgba(255, 220, 160, .70) 0%, transparent 100%),
    radial-gradient(2px 2px at 58% 18%, rgba(200, 180, 255, .75) 0%, transparent 100%),
    radial-gradient(2px 2px at 83% 78%, rgba(255, 220, 160, .65) 0%, transparent 100%),
    radial-gradient(3px 3px at 35% 30%, rgba(255, 240, 200, .40) 0%, transparent 100%),
    radial-gradient(3px 3px at 72% 10%, rgba(210, 180, 255, .35) 0%, transparent 100%);
  animation: starTwinkleB 10s ease-in-out infinite alternate-reverse;
}

/* =============================================
   HEADER
   ============================================= */
.site-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 52px 16px 36px;
  border-bottom: 1px solid var(--border);
}

.header-deco {
  color: var(--gold);
  font-size: 14px;
  letter-spacing: .25em;
  opacity: .65;
  margin: 10px 0;
}

.site-title {
  font-family: var(--font-serif);
  font-size: clamp(32px, 7vw, 64px);
  font-weight: 900;
  letter-spacing: .12em;
  background: linear-gradient(135deg, var(--gold-light) 20%, var(--gold-bright) 50%, var(--gold-light) 80%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 32px rgba(200, 149, 26, .55));
}

.site-subtitle {
  color: var(--text-3);
  font-size: 15px;
  letter-spacing: .12em;
}

/* =============================================
   TAB NAVIGATION
   ============================================= */
.tab-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(6, 4, 17, .85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 26px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-norm);
  letter-spacing: .04em;
}

.tab-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-2);
  background: rgba(124, 58, 237, .10);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(107, 33, 212, .45), rgba(91, 33, 182, .30));
  border-color: rgba(192, 132, 252, .55);
  color: var(--text-1);
  box-shadow: 0 0 22px rgba(124, 58, 237, .30), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.tab-icon {
  font-size: 18px;
  line-height: 1;
}

.tab-label {
  line-height: 1;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn .4s ease;
}

.panel-header {
  text-align: center;
  margin-bottom: 36px;
}

.panel-header h2 {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 8px;
  text-shadow: 0 0 24px rgba(200, 149, 26, .4);
}

.panel-header p {
  color: var(--text-3);
  font-size: 15px;
}

/* =============================================
   BIRTH FORM — GLASS CARD
   ============================================= */
.birth-form {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(120, 100, 200, .30);
  border-radius: var(--r-lg);
  padding: 32px;
  margin-bottom: 36px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .40), inset 0 1px 0 rgba(255, 255, 255, .06);
}

/* Gender */
.form-gender {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.gender-label,
.cal-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .10em;
  color: var(--text-3);
  text-transform: uppercase;
  min-width: 40px;
}

.gender-btns,
.cal-btns {
  display: flex;
  gap: 10px;
}

.gender-option input,
.cal-option input {
  display: none;
}

.gender-chip,
.cal-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-3);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-norm);
  letter-spacing: .04em;
}

.gender-chip:hover,
.cal-chip:hover {
  border-color: var(--border-hover);
  color: var(--text-2);
}

.gender-icon {
  font-size: 16px;
}

.gender-option input:checked+.gender-chip,
.cal-option input:checked+.cal-chip {
  background: linear-gradient(135deg, rgba(107, 33, 212, .40), rgba(91, 33, 182, .25));
  border-color: rgba(192, 132, 252, .55);
  color: var(--text-1);
  box-shadow: 0 0 16px rgba(124, 58, 237, .22);
}

/* Calendar type */
.form-calendar-type {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.form-hint {
  width: 100%;
  font-size: 12px;
  color: var(--warning);
  margin-top: 6px;
  opacity: .85;
  letter-spacing: .02em;
}

.form-hint strong {
  color: var(--gold-bright);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .10em;
  color: var(--text-3);
  text-transform: uppercase;
}

.form-group input,
.form-group select {
  height: 48px;
  padding: 0 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 15px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
}

.form-group input::placeholder {
  color: var(--text-4);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: rgba(192, 132, 252, .65);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .15);
}

.form-group select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238B7EC8'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 40px;
}

.form-actions {
  text-align: center;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 14px 40px;
  background: linear-gradient(135deg, #7C3AED 0%, #5B21B6 60%, #4C1D95 100%);
  border: 1px solid rgba(192, 132, 252, .40);
  border-radius: var(--r-md);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .06em;
  cursor: pointer;
  transition: all var(--t-norm);
  box-shadow: 0 4px 20px rgba(107, 33, 212, .40), inset 0 1px 0 rgba(255, 255, 255, .12);
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: 0;
  left: -80%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .15), transparent);
  transform: skewX(-20deg);
  transition: left 0s;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #9333EA 0%, #6D28D9 60%, #5B21B6 100%);
  box-shadow: 0 6px 28px rgba(107, 33, 212, .55), inset 0 1px 0 rgba(255, 255, 255, .15);
  transform: translateY(-2px);
}

.btn-primary:hover::after {
  animation: shimmer .55s ease forwards;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.btn-text {
  position: relative;
  z-index: 1;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 14px 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .04em;
  transition: all var(--t-norm);
  margin-left: 12px;
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text-2);
  background: rgba(255, 255, 255, .04);
}

.hidden {
  display: none !important;
}

/* =============================================
   RESULT SUMMARY CARD
   ============================================= */
.result-summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: 0 0 40px rgba(200, 149, 26, .12);
  animation: fadeIn .5s ease;
}

.summary-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.summary-avatar {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(200, 149, 26, .20), rgba(107, 33, 212, .20));
  border: 2px solid var(--border-gold);
  flex-shrink: 0;
}

.summary-title {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--gold-light);
  font-weight: 700;
  letter-spacing: .06em;
}

.summary-sub {
  color: var(--text-3);
  font-size: 13px;
  margin-top: 4px;
  letter-spacing: .04em;
}

.summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-tag {
  padding: 5px 14px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
}

.summary-tag.tag-ju {
  background: rgba(200, 149, 26, .15);
  border: 1px solid rgba(200, 149, 26, .40);
  color: var(--gold-light);
}

.summary-tag.tag-ming {
  background: rgba(107, 33, 212, .15);
  border: 1px solid rgba(192, 132, 252, .40);
  color: var(--purple-bright);
}

.summary-tag.tag-shen {
  background: rgba(52, 211, 153, .12);
  border: 1px solid rgba(52, 211, 153, .35);
  color: var(--star-lucky);
}

/* =============================================
   LEGEND BAR
   ============================================= */
.legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  padding: 12px 20px;
  margin-bottom: 16px;
  background: rgba(6, 4, 17, .60);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .04em;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.dot-main {
  background: var(--star-main);
  box-shadow: 0 0 6px var(--star-main-bg);
}

.dot-lucky {
  background: var(--star-lucky);
  box-shadow: 0 0 6px var(--star-lucky-bg);
}

.dot-evil {
  background: var(--star-evil);
  box-shadow: 0 0 6px var(--star-evil-bg);
}

.dot-hua {
  background: var(--star-hua);
  box-shadow: 0 0 6px var(--star-hua-bg);
}

/* =============================================
   PALACE GRID
   ============================================= */
.palace-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 150px);
  gap: 2px;
  background: rgba(60, 48, 110, .45);
  border: 2px solid var(--gold);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: 0 0 50px rgba(200, 149, 26, .22), 0 0 100px rgba(107, 33, 212, .12);
  margin-bottom: 24px;
}

.palace-cell {
  background: var(--bg-surface);
  padding: 10px 8px;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.palace-cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, .03) 0%, transparent 60%);
  pointer-events: none;
}

.palace-cell:hover {
  background: var(--bg-elevated);
  box-shadow: inset 0 0 20px rgba(124, 58, 237, .20);
}

.palace-cell.active-palace {
  background: rgba(30, 24, 65, 0.98);
  box-shadow: inset 0 0 24px rgba(200, 149, 26, .18), inset 0 0 1px rgba(200, 149, 26, .60);
}

.palace-cell.ming-gong {
  border: 1px solid rgba(200, 149, 26, .55);
}

.palace-center {
  grid-area: 2/2/4/4;
  background: rgba(6, 4, 17, .96);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: default;
  padding: 20px;
  border: 1px solid rgba(200, 149, 26, .25);
}

.palace-dizhi {
  font-family: var(--font-serif);
  font-size: 11px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: .12em;
  margin-bottom: 2px;
}

.palace-name {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--text-2);
  font-weight: 700;
  margin: 3px 0;
  letter-spacing: .04em;
}

.palace-tiangan {
  font-size: 10px;
  color: var(--text-4);
  letter-spacing: .06em;
}

.palace-daxian {
  font-size: 9px;
  color: var(--purple-bright);
  letter-spacing: .04em;
  opacity: .75;
  margin-top: 1px;
}

.palace-stars {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

/* Star Tags — Color Coded */
.star-tag {
  font-size: 10px;
  border-radius: 4px;
  padding: 2px 5px;
  line-height: 1.4;
  letter-spacing: .02em;
  white-space: nowrap;
}

.star-tag.main-star {
  color: var(--star-main);
  background: var(--star-main-bg);
  border: 1px solid var(--star-main-bd);
  font-weight: 700;
}

.star-tag.lucky-star {
  color: var(--star-lucky);
  background: var(--star-lucky-bg);
  border: 1px solid var(--star-lucky-bd);
}

.star-tag.evil-star {
  color: var(--star-evil);
  background: var(--star-evil-bg);
  border: 1px solid var(--star-evil-bd);
}

.star-tag.hua-star {
  color: var(--star-hua);
  background: var(--star-hua-bg);
  border: 1px solid var(--star-hua-bd);
  font-weight: 600;
}

.star-tag.hua-lu {
  color: var(--star-hua-lu);
  border-color: rgba(52, 211, 153, .40);
  background: rgba(52, 211, 153, .10);
}

.star-tag.hua-quan {
  color: var(--star-hua-quan);
  border-color: rgba(249, 115, 22, .40);
  background: rgba(249, 115, 22, .10);
}

.star-tag.hua-ke {
  color: var(--star-hua-ke);
  border-color: rgba(96, 165, 250, .40);
  background: rgba(96, 165, 250, .10);
}

.star-tag.hua-ji {
  color: var(--star-hua-ji);
  border-color: rgba(239, 68, 68, .40);
  background: rgba(239, 68, 68, .10);
}

.star-tag.minor-star {
  color: var(--text-4);
  background: rgba(50, 42, 90, .55);
  border: 1px solid rgba(80, 70, 130, .45);
}

.center-title {
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--gold-light);
  margin-bottom: 14px;
  text-shadow: 0 0 18px rgba(200, 149, 26, .55);
  letter-spacing: .12em;
}

.center-info {
  color: var(--text-3);
  font-size: 13px;
  line-height: 2.1;
}

.center-ju {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 14px;
  border: 1px solid rgba(200, 149, 26, .42);
  border-radius: var(--r-full);
  color: var(--gold-light);
  font-size: 12px;
  letter-spacing: .06em;
}

/* =============================================
   PALACE DETAIL PANEL
   ============================================= */
.palace-detail {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  min-height: 96px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .35);
}

.detail-hint {
  text-align: center;
  color: var(--text-4);
  font-size: 14px;
  padding: 16px 0;
  letter-spacing: .04em;
}

.pd-title {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--gold-light);
  margin-bottom: 10px;
  text-shadow: 0 0 12px rgba(200, 149, 26, .35);
}

.pd-stars-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.pd-stars-list .star-tag {
  font-size: 12px;
  padding: 4px 10px;
}

.pd-desc {
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.9;
  margin-bottom: 14px;
}

.pd-star-detail {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px;
  margin-top: 8px;
}

.pd-star-name {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.pd-star-desc {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.8;
}

/* =============================================
   ANALYSIS SECTION
   ============================================= */
.analysis-section {
  margin-top: 28px;
  animation: fadeIn .5s ease .2s both;
}

.analysis-title {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--gold-light);
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 0 0 14px rgba(200, 149, 26, .35);
  letter-spacing: .08em;
}

.analysis-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.analysis-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  transition: border-color var(--t-norm);
}

.analysis-card:hover {
  border-color: var(--border-hover);
}

.analysis-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.analysis-card-content {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.85;
}

.disclaimer {
  text-align: center;
  margin-top: 20px;
  color: var(--text-4);
  font-size: 12px;
  letter-spacing: .04em;
}

/* =============================================
   ZODIAC GRID
   ============================================= */
.zodiac-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.zodiac-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 12px 16px;
  cursor: pointer;
  transition: all var(--t-norm);
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.zodiac-card:hover {
  border-color: rgba(192, 132, 252, .50);
  background: rgba(107, 33, 212, .14);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(107, 33, 212, .25);
}

.zodiac-card.selected {
  border-color: var(--gold);
  background: rgba(200, 149, 26, .10);
  box-shadow: 0 0 24px rgba(200, 149, 26, .25);
}

.zc-symbol {
  font-size: 30px;
  display: block;
  margin-bottom: 8px;
}

.zc-name {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-1);
  font-weight: 700;
  display: block;
  letter-spacing: .04em;
}

.zc-dates {
  font-size: 11px;
  color: var(--text-4);
  display: block;
  margin-top: 4px;
  letter-spacing: .02em;
}

/* =============================================
   FORTUNE PANEL
   ============================================= */
.fortune-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .35);
}

.fp-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.fp-emoji {
  font-size: 46px;
  line-height: 1;
}

.fp-title {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--gold-light);
  display: block;
  letter-spacing: .06em;
}

.fp-subtitle {
  color: var(--text-3);
  font-size: 13px;
  display: block;
  margin-top: 5px;
  letter-spacing: .04em;
}

/* 幸運元素區塊 */
.fp-lucky {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(168, 85, 247, .08), rgba(59, 130, 246, .08));
  border-radius: 12px;
  border: 1px solid rgba(168, 85, 247, .15);
}

.fp-lucky-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.fp-lucky-label {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

.fp-lucky-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
}

.fp-scores {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.fp-score-item {
  text-align: center;
}

.fp-score-label {
  font-size: 12px;
  color: var(--text-3);
  display: block;
  margin-bottom: 8px;
  letter-spacing: .06em;
}

.fp-stars {
  display: flex;
  justify-content: center;
  gap: 3px;
}

.fp-star {
  font-size: 16px;
}

.fp-star.on {
  color: var(--gold-light);
}

.fp-star.off {
  color: var(--border);
}

.fp-texts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.fp-text-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}

.fp-text-label {
  font-size: 11px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: .12em;
  display: block;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.fp-text-content {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.8;
}

/* =============================================
   TAROT
   ============================================= */
.tarot-question-wrap {
  max-width: 500px;
  margin: 0 auto 28px;
}

.tarot-question-wrap input {
  width: 100%;
  height: 50px;
  padding: 0 20px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 15px;
  text-align: center;
  letter-spacing: .04em;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.tarot-question-wrap input::placeholder {
  color: var(--text-4);
}

.tarot-question-wrap input:focus {
  outline: none;
  border-color: rgba(192, 132, 252, .60);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .14);
}

.tarot-spread {
  text-align: center;
}

.spread-labels {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 12px;
}

.spread-pos-label {
  font-family: var(--font-serif);
  color: var(--gold);
  font-size: 14px;
  letter-spacing: .14em;
  width: 170px;
  text-align: center;
  opacity: .80;
}

.tarot-cards-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.card-slot {
  perspective: 1000px;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, .45));
}

.tarot-card {
  width: 155px;
  height: 252px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.88s cubic-bezier(.4, 0, .2, 1);
  cursor: default;
}

.tarot-card.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--r-md);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid var(--border-gold);
  overflow: hidden;
}

.card-back {
  background: linear-gradient(150deg, #1c0a44 0%, #2e1568 60%, #1a0a38 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  background-image:
    linear-gradient(150deg, #1c0a44 0%, #2e1568 60%, #1a0a38 100%),
    repeating-linear-gradient(45deg, transparent, transparent 14px, rgba(200, 149, 26, .04) 14px, rgba(200, 149, 26, .04) 15px);
}

.card-back-glyph {
  font-size: 54px;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(200, 149, 26, .90);
  animation: pulseGlow 3s ease-in-out infinite;
}

.card-front {
  transform: rotateY(180deg);
  background: linear-gradient(165deg, #200e4c 0%, #0d0a20 100%);
  border-color: var(--gold);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px;
  box-shadow: inset 0 0 30px rgba(200, 149, 26, .20);
}

.card-front.reversed {
  border-color: var(--danger);
}

/* -- Card inner frame & decoration -- */
.card-deco {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(200, 149, 26, .28);
  border-radius: 5px;
  pointer-events: none;
}

.c-orn {
  position: absolute;
  font-size: 7px;
  color: var(--gold);
  opacity: .55;
  line-height: 1;
}

.c-orn.tl {
  top: -1px;
  left: 2px;
}

.c-orn.tr {
  top: -1px;
  right: 2px;
}

.c-orn.bl {
  bottom: -1px;
  left: 2px;
}

.c-orn.br {
  bottom: -1px;
  right: 2px;
}

.card-num {
  font-family: var(--font-serif);
  font-size: 11px;
  color: var(--gold-light);
  letter-spacing: .22em;
  opacity: .80;
  text-align: center;
  position: relative;
  z-index: 1;
}

.card-illust {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.card-illust-ring {
  position: absolute;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  opacity: .7;
  transition: box-shadow .3s;
}

.card-icon {
  font-size: 56px;
  position: relative;
  z-index: 1;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(200, 149, 26, .55));
}

.card-label {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--gold-light);
  font-weight: 700;
  text-align: center;
  letter-spacing: .08em;
  text-shadow: 0 0 10px rgba(200, 149, 26, .40);
  position: relative;
  z-index: 1;
}

.card-rev {
  position: absolute;
  bottom: 28px;
  font-size: 10px;
  color: var(--danger);
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .32);
  border-radius: 4px;
  padding: 2px 8px;
  letter-spacing: .06em;
  z-index: 2;
}

/* -- Reading aspects -- */
.reading-aspects {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reading-aspect {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.7;
  padding: 8px 12px;
  border-left: 2px solid rgba(200, 149, 26, .3);
  background: rgba(200, 149, 26, .03);
  border-radius: 0 6px 6px 0;
}

.aspect-label {
  display: inline-block;
  font-weight: 600;
  color: var(--gold-light);
  margin-right: 6px;
  font-size: 13px;
}

.tarot-actions {
  text-align: center;
  margin-bottom: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.tarot-reading-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  animation: fadeIn .5s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .35);
}

.reading-section {
  margin-bottom: 22px;
}

.reading-section:last-child {
  margin-bottom: 0;
}

.reading-section h3 {
  font-family: var(--font-serif);
  color: var(--gold-light);
  font-size: 17px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: .04em;
}

.reading-meaning {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.85;
  margin-top: 8px;
}

.reading-overall {
  color: var(--starlight);
  font-size: 15px;
  line-height: 1.9;
  font-style: italic;
  opacity: .90;
}

/* =============================================
   FOOTER
   ============================================= */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px 16px 28px;
  border-top: 1px solid var(--border);
  color: var(--text-4);
  font-size: 13px;
  letter-spacing: .06em;
}

.footer-deco {
  color: var(--gold);
  opacity: .4;
  margin-bottom: 8px;
  font-size: 13px;
  letter-spacing: .22em;
}

.footer-counter {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-4);
  opacity: .6;
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseGlow {

  0%,
  100% {
    text-shadow: 0 0 20px rgba(200, 149, 26, .75);
  }

  50% {
    text-shadow: 0 0 44px rgba(200, 149, 26, 1), 0 0 70px rgba(200, 149, 26, .40);
  }
}

@keyframes starTwinkleA {
  0% {
    opacity: .55;
  }

  100% {
    opacity: 1;
  }
}

@keyframes starTwinkleB {
  0% {
    opacity: .40;
  }

  100% {
    opacity: .90;
  }
}

@keyframes shimmer {
  0% {
    left: -80%;
  }

  100% {
    left: 130%;
  }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .tab-btn {
    padding: 9px 16px;
    font-size: 13px;
  }

  .tab-icon {
    font-size: 16px;
  }

  .birth-form {
    padding: 24px 18px;
  }

  .palace-grid {
    grid-template-rows: repeat(4, 110px);
  }

  .palace-name {
    font-size: 12px;
  }

  .star-tag {
    font-size: 9px;
  }

  .spread-pos-label {
    width: 132px;
    font-size: 12px;
  }

  .tarot-card {
    width: 120px;
    height: 196px;
  }

  .card-icon {
    font-size: 42px;
  }

  .card-illust-ring {
    width: 68px;
    height: 68px;
  }

  .card-title {
    font-size: 13px;
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .zodiac-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .panel-header h2 {
    font-size: 23px;
  }

  .result-summary-card {
    padding: 18px 20px;
  }

  .summary-title {
    font-size: 17px;
  }

  .analysis-cards {
    grid-template-columns: 1fr;
  }

  .legend-bar {
    gap: 10px;
    font-size: 11px;
    padding: 10px 14px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 24px 14px;
  }

  .tab-btn {
    padding: 8px 12px;
    font-size: 12px;
    gap: 5px;
  }

  .palace-grid {
    grid-template-rows: repeat(4, 85px);
  }

  .palace-dizhi {
    font-size: 10px;
  }

  .palace-name {
    font-size: 11px;
  }

  .palace-daxian {
    display: none;
  }

  .star-tag {
    font-size: 8px;
    padding: 1px 4px;
  }

  .spread-pos-label {
    width: 103px;
    font-size: 11px;
  }

  .tarot-card {
    width: 98px;
    height: 160px;
  }

  .card-icon {
    font-size: 32px;
  }

  .card-illust-ring {
    width: 55px;
    height: 55px;
  }

  .card-label {
    font-size: 12px;
  }

  .card-num {
    font-size: 9px;
  }

  .card-title {
    font-size: 11px;
  }

  .card-roman {
    font-size: 9px;
  }

  .zodiac-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .fp-lucky {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .fp-scores {
    grid-template-columns: repeat(3, 1fr);
  }

  .btn-primary {
    padding: 12px 28px;
    font-size: 15px;
  }

  .gender-chip,
  .cal-chip {
    padding: 6px 14px;
    font-size: 13px;
  }

  .form-gender,
  .form-calendar-type {
    gap: 10px;
  }

  .summary-left {
    gap: 12px;
  }

  .summary-avatar {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .da-section-title {
    font-size: 16px;
  }

  .da-section-content {
    font-size: 14px;
  }
}

/* =============================================
   DETAILED ANALYSIS SECTION
   ============================================= */
.detailed-analysis {
  margin-top: 32px;
  padding: 32px;
  background: linear-gradient(135deg, rgba(26, 18, 42, 0.95), rgba(36, 25, 58, 0.9));
  border: 1px solid rgba(180, 160, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.detailed-analysis-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 24px;
  font-weight: 900;
  color: var(--gold);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.detailed-analysis-intro {
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 14px;
  margin-bottom: 28px;
  line-height: 1.6;
}

.da-section {
  margin-bottom: 24px;
  padding: 20px 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(180, 160, 255, 0.08);
  border-radius: 12px;
  transition: border-color 0.3s;
}

.da-section:hover {
  border-color: rgba(180, 160, 255, 0.2);
}

.da-section:last-of-type {
  margin-bottom: 0;
}

.da-section-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(180, 160, 255, 0.1);
}

.da-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.da-section-content {
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  line-height: 1.9;
  text-align: justify;
}

.da-section-content p {
  margin-bottom: 8px;
}

.da-section-content p:last-child {
  margin-bottom: 0;
}

/* =============================================
   2026 流年運勢
   ============================================= */
.liunian-analysis {
  margin-top: 36px;
  padding: 28px 24px 32px;
  background: linear-gradient(135deg, rgba(20, 12, 40, 0.92) 0%, rgba(40, 20, 60, 0.88) 50%, rgba(20, 15, 45, 0.92) 100%);
  border: 1px solid rgba(255, 180, 80, 0.25);
  border-radius: 18px;
  box-shadow: 0 0 40px rgba(255, 140, 50, 0.08), inset 0 0 60px rgba(255, 140, 50, 0.03);
}

.liunian-title {
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  color: #ffb347;
  margin-bottom: 14px;
  letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(255, 179, 71, 0.35);
}

.liunian-year-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 20px;
  margin: 0 auto 16px;
  max-width: 600px;
  background: linear-gradient(90deg, rgba(255, 140, 50, 0.15), rgba(255, 200, 100, 0.12), rgba(255, 140, 50, 0.15));
  border: 1px solid rgba(255, 180, 80, 0.3);
  border-radius: 30px;
  flex-wrap: wrap;
}

.lyb-icon {
  font-size: 24px;
}

.lyb-text {
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(255, 220, 160, 0.95);
  letter-spacing: 0.5px;
}

.liunian-intro {
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 28px;
  line-height: 1.7;
  max-width: 650px;
  margin-left: auto;
  margin-right: auto;
}

.ln-section {
  margin-bottom: 24px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 180, 80, 0.1);
  border-radius: 12px;
  transition: border-color 0.3s;
}

.ln-section:hover {
  border-color: rgba(255, 180, 80, 0.25);
}

.ln-section:last-child {
  margin-bottom: 0;
}

.ln-section-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffb347;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 180, 80, 0.12);
}

.ln-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.ln-section-content {
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  line-height: 1.9;
  text-align: justify;
}

.ln-section-content p {
  margin-bottom: 8px;
}

.ln-section-content p:last-child {
  margin-bottom: 0;
}

/* =============================================
   HISTORY PANEL & STORAGE MANAGER UI
   ============================================= */

/* 浮動紀錄按鈕 */
.history-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(107, 33, 212, 0.85), rgba(124, 58, 237, 0.9));
  border: 1px solid rgba(192, 132, 252, 0.3);
  border-radius: 50px;
  color: #F5F2FF;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(107, 33, 212, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(107, 33, 212, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.9), rgba(147, 51, 234, 0.95));
}

.htb-icon {
  font-size: 18px;
}

.htb-label {
  letter-spacing: 0.5px;
}

.htb-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--gold-bright);
  color: #1a1a2e;
  font-size: 11px;
  font-weight: 800;
  border-radius: 10px;
}

/* 遮罩 */
.history-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity 0.3s;
}

.history-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* 側滑面板 */
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1000;
  width: min(420px, 92vw);
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(180deg, #0e0a23 0%, #0a0718 100%);
  border-left: 1px solid rgba(107, 33, 212, 0.3);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.history-panel.hidden {
  transform: translateX(100%);
}

/* 面板頭 */
.hp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  background: rgba(107, 33, 212, 0.12);
  border-bottom: 1px solid rgba(107, 33, 212, 0.2);
  flex-shrink: 0;
  flex-direction: row;
}

.hp-title {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--purple-bright);
  flex-shrink: 0;
}

.hp-privacy-badge {
  font-size: 11px;
  color: rgba(16, 185, 129, 0.9);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  margin-left: auto;
}

/* 左側關閉按鈕（面板內左側） */
.hp-side-close {
  order: -1;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(192, 132, 252, 0.25);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: all 0.25s ease;
  padding: 0;
  letter-spacing: 0;
}

.hp-side-close:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #EF4444;
}

/* 面板內容區 — 可滾動的中間區域 */
.hp-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}

/* 底部操作按鈕固定在面板底部 */
.hp-footer {
  flex-shrink: 0;
}

/* 容量條 */
.storage-usage {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.su-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.su-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--purple-bright));
  border-radius: 3px;
  transition: width 0.5s;
}

.su-label {
  font-size: 11px;
  color: var(--text-3);
}

/* 篩選 */
.history-filters {
  display: flex;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  overflow-x: auto;
}

.hf-btn {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-3);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.hf-btn:hover {
  border-color: rgba(192, 132, 252, 0.3);
  color: var(--text-2);
}

.hf-btn.active {
  background: rgba(107, 33, 212, 0.2);
  border-color: rgba(192, 132, 252, 0.4);
  color: var(--purple-bright);
}

/* 紀錄列表 */
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.history-item:hover {
  background: rgba(107, 33, 212, 0.08);
}

.history-item:last-child {
  border-bottom: none;
}

.hi-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

.hi-content {
  flex: 1;
  min-width: 0;
}

.hi-type {
  font-size: 11px;
  color: var(--purple-bright);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.hi-summary {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.hi-time {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 3px;
}

.hi-delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-4);
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
}

.history-item:hover .hi-delete {
  opacity: 1;
}

.hi-delete:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: #EF4444;
}

/* 操作按鈕組 */
.history-actions {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.ha-btn {
  flex: 1;
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-3);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.ha-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-2);
}

.ha-export:hover {
  border-color: rgba(96, 165, 250, 0.3);
  color: #60A5FA;
}

.ha-import:hover {
  border-color: rgba(52, 211, 153, 0.3);
  color: #34D399;
}

.ha-clear:hover {
  border-color: rgba(239, 68, 68, 0.3);
  color: #EF4444;
}

/* 空狀態 */
.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.history-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.history-empty p {
  color: var(--text-3);
  font-size: 15px;
}

.history-empty-hint {
  font-size: 13px !important;
  color: var(--text-4) !important;
  margin-top: 8px;
}

/* 手機適配 */
@media (max-width: 480px) {
  .history-toggle-btn {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
    font-size: 13px;
  }

  .history-panel {
    width: 100vw;
  }

  .history-actions {
    flex-wrap: wrap;
  }

  .ha-btn {
    flex: 1 1 calc(50% - 4px);
  }
}

/* =============================================
   CONTENT BLUR MASK & AD MODAL
   ============================================= */

/* 模糊遮罩 — 套用在 #detailed-analysis 和 #liunian-analysis */
.content-blurred {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
  transition: filter 0.6s ease;
  position: relative;
}

/* 內嵌廣告解鎖卡片 */
.ad-inline-card {
  margin-top: 32px;
  padding: 36px 28px;
  background: linear-gradient(135deg, rgba(26, 18, 55, 0.97) 0%, rgba(50, 25, 80, 0.92) 50%, rgba(26, 18, 55, 0.97) 100%);
  border: 1.5px solid rgba(192, 132, 252, 0.35);
  border-radius: 18px;
  text-align: center;
  box-shadow:
    0 8px 40px rgba(107, 33, 212, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: adCardGlow 3s ease-in-out infinite alternate;
}

.ad-inline-card.hidden {
  display: none;
}

@keyframes adCardGlow {
  from {
    box-shadow: 0 8px 40px rgba(107, 33, 212, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  to {
    box-shadow: 0 8px 50px rgba(107, 33, 212, 0.35), 0 0 30px rgba(192, 132, 252, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }
}

.ad-inline-inner {
  max-width: 480px;
  margin: 0 auto;
}

.ad-inline-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

.ad-inline-card h3 {
  font-family: 'Noto Serif TC', serif;
  font-size: 22px;
  font-weight: 900;
  color: var(--gold, #FFD700);
  margin-bottom: 10px;
  letter-spacing: 1.5px;
}

.ad-inline-card p {
  color: rgba(255, 255, 255, 0.65);
  font-size: 14.5px;
  line-height: 1.7;
  margin-bottom: 22px;
}

/* 廣告連結按鈕 */
.ad-link-btn {
  display: inline-block;
  padding: 14px 40px;
  background: linear-gradient(135deg, #FF6B35, #FF8C42, #FFB347);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 50px;
  letter-spacing: 1px;
  box-shadow:
    0 4px 20px rgba(255, 107, 53, 0.4),
    0 0 40px rgba(255, 140, 66, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: adBtnPulse 2s ease-in-out infinite;
}

.ad-link-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 8px 32px rgba(255, 107, 53, 0.55),
    0 0 60px rgba(255, 140, 66, 0.2);
}

@keyframes adBtnPulse {

  0%,
  100% {
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4), 0 0 40px rgba(255, 140, 66, 0.15);
  }

  50% {
    box-shadow: 0 4px 28px rgba(255, 107, 53, 0.6), 0 0 60px rgba(255, 140, 66, 0.25);
  }
}

/* 手機適配 */
@media (max-width: 480px) {
  .ad-inline-card {
    padding: 28px 16px;
  }

  .ad-inline-card h3 {
    font-size: 19px;
  }

  .ad-link-btn {
    padding: 12px 32px;
    font-size: 15px;
  }
}