/* =============================================================
   Qimen3AI · Executive Mode · Shared Design System
   Theme: Midnight Steel (Bloomberg-inspired)
   Mode: Auto (system) + manual toggle override
   ============================================================= */

/* ============== DARK THEME (default for OLED + CEO mode) ============== */
:root {
  /* Backgrounds */
  --bg:           #0f1419;  /* navy-black */
  --bg-elevated:  #161c23;  /* card */
  --bg-secondary: #1d242b;  /* deeper card */
  --bg-tertiary:  #0a0e12;  /* deepest */

  /* Text */
  --text-dark:      #e2e8f0;  /* primary, brightest */
  --text-muted:     #b8c0c8;  /* secondary */
  --text-tertiary:  #7c8a96;  /* tertiary */
  --text-faded:     #5a6772;  /* faded */

  /* Borders */
  --border:       #3a4148;  /* default */
  --border-light: #2a3138;  /* subtle */

  /* Accent (steel cool blue) */
  --accent-gold:       #94a3b8;  /* steel blue (was gold) */
  --accent-gold-light: #cbd5e1;  /* lighter steel */
  --gold-50:           #2a3138;  /* dark steel bg */
  --gold-100:          #3a4148;
  --gold-200:          #94a3b8;
  --gold-700:          #cbd5e1;
  --gold-900:          #e2e8f0;

  /* Semantic */
  --success:       #6b9c70;  /* sage muted */
  --success-light: #2a3a2c;
  --success-bg:    rgba(107, 156, 112, 0.12);
  --warning:       #c97961;  /* terracotta */
  --warning-bg:    rgba(201, 121, 97, 0.10);
  --danger:        #a85040;  /* rust */

  --neutral-bg: rgba(148, 163, 184, 0.08);

  /* Element colors (BaZi pillars - cool tones) */
  --el-fire-bg:   #2a221c;
  --el-fire-text: #d4a574;
  --el-water-bg:  #1c2030;
  --el-water-text: #8aa3d4;
  --el-wood-bg:   #1c2620;
  --el-wood-text: #8ab59a;
  --el-metal-bg:  #232527;
  --el-metal-text: #b8b8b8;
  --el-earth-bg:  #2a261d;
  --el-earth-text: #c9b487;

  /* Typography */
  --font-serif: 'Playfair Display', 'Noto Serif TC', Georgia, serif;
  --font-thai:  'IBM Plex Sans Thai', 'Sarabun', sans-serif;
  --font-en:    'Inter', -apple-system, sans-serif;
  --font-zh:    'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-body:  var(--font-thai), var(--font-en);

  /* Layout */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Gradients (subtle, Bloomberg-like) */
  --hero-gradient: linear-gradient(135deg, #1d242b 0%, #161c23 100%);
  --cta-gradient:  linear-gradient(135deg, #94a3b8 0%, #cbd5e1 100%);
  --gold-gradient: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);

  /* Shadows (subtle on dark) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ============== LIGHT THEME (auto if user prefers light) ============== */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:           #f5f7fa;  /* near-white cool */
    --bg-elevated:  #ffffff;
    --bg-secondary: #eaeef2;
    --bg-tertiary:  #ffffff;

    --text-dark:      #0f1419;
    --text-muted:     #3a4148;
    --text-tertiary:  #6b7a85;
    --text-faded:     #94a3b8;

    --border:       #d1d8e0;
    --border-light: #e2e8f0;

    --accent-gold:       #475569;  /* dark steel */
    --accent-gold-light: #64748b;
    --gold-50:           #eaeef2;
    --gold-100:          #d1d8e0;
    --gold-200:          #94a3b8;
    --gold-700:          #475569;
    --gold-900:          #1e293b;

    --success:       #4a7c4a;
    --success-light: #d4ead4;
    --success-bg:    rgba(74, 124, 74, 0.08);
    --warning:       #993c1d;
    --warning-bg:    rgba(184, 90, 90, 0.06);
    --danger:        #732216;

    --neutral-bg: rgba(15, 20, 25, 0.05);

    --el-fire-bg:   #fef0e2;
    --el-fire-text: #8a4d1a;
    --el-water-bg:  #e2e8f5;
    --el-water-text: #2a3d8f;
    --el-wood-bg:   #e0ecdb;
    --el-wood-text: #2a5a4d;
    --el-metal-bg:  #ebeaeb;
    --el-metal-text: #4a4a4a;
    --el-earth-bg:  #f0e9da;
    --el-earth-text: #6b5a3f;

    --hero-gradient: linear-gradient(135deg, #ffffff 0%, #eaeef2 100%);
    --cta-gradient:  linear-gradient(135deg, #1e293b 0%, #475569 100%);
    --gold-gradient: linear-gradient(135deg, #475569 0%, #1e293b 100%);

    --shadow-sm: 0 1px 2px rgba(15, 20, 25, 0.04);
    --shadow-md: 0 2px 8px rgba(15, 20, 25, 0.08);
    --shadow-lg: 0 8px 24px rgba(15, 20, 25, 0.12);
  }
}

/* ============== MANUAL OVERRIDE (data-theme attribute) ============== */
:root[data-theme="light"] {
  --bg:           #f5f7fa;
  --bg-elevated:  #ffffff;
  --bg-secondary: #eaeef2;
  --bg-tertiary:  #ffffff;
  --text-dark:      #0f1419;
  --text-muted:     #3a4148;
  --text-tertiary:  #6b7a85;
  --text-faded:     #94a3b8;
  --border:       #d1d8e0;
  --border-light: #e2e8f0;
  --accent-gold:       #475569;
  --accent-gold-light: #64748b;
  --gold-50:           #eaeef2;
  --gold-100:          #d1d8e0;
  --gold-200:          #94a3b8;
  --gold-700:          #475569;
  --gold-900:          #1e293b;
  --success:       #4a7c4a;
  --success-light: #d4ead4;
  --success-bg:    rgba(74, 124, 74, 0.08);
  --warning:       #993c1d;
  --warning-bg:    rgba(184, 90, 90, 0.06);
  --danger:        #732216;
  --neutral-bg: rgba(15, 20, 25, 0.05);
  --el-fire-bg:   #fef0e2;
  --el-fire-text: #8a4d1a;
  --el-water-bg:  #e2e8f5;
  --el-water-text: #2a3d8f;
  --el-wood-bg:   #e0ecdb;
  --el-wood-text: #2a5a4d;
  --el-metal-bg:  #ebeaeb;
  --el-metal-text: #4a4a4a;
  --el-earth-bg:  #f0e9da;
  --el-earth-text: #6b5a3f;
  --hero-gradient: linear-gradient(135deg, #ffffff 0%, #eaeef2 100%);
  --cta-gradient:  linear-gradient(135deg, #1e293b 0%, #475569 100%);
  --gold-gradient: linear-gradient(135deg, #475569 0%, #1e293b 100%);
  --shadow-sm: 0 1px 2px rgba(15, 20, 25, 0.04);
  --shadow-md: 0 2px 8px rgba(15, 20, 25, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 20, 25, 0.12);
}

/* Chinese language overrides body font */
html[lang="zh"] body,
html[lang="zh-TW"] body,
html[lang="zh-HK"] body {
  font-family: var(--font-zh), var(--font-thai), sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-dark);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 80px;
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 246, 238, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--border-light);
}
.top-bar-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-bar-left { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-tertiary); }
.top-date { font-weight: 500; }
.top-time { font-family: var(--font-serif); font-size: 13px; color: var(--text-muted); }
.top-dot { color: var(--border); }
.top-bar-right { display: flex; align-items: center; gap: 10px; }

.back-btn {
  width: 28px; height: 28px;
  font-size: 22px; line-height: 1;
  color: var(--text-muted);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease;
}
.back-btn:hover { background: var(--neutral-bg); }

.lang-switch { display: flex; gap: 2px; background: var(--neutral-bg); border-radius: var(--radius-md); padding: 2px; }
.lang-btn {
  padding: 4px 10px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.5px;
  color: var(--text-tertiary);
  border-radius: 6px;
  transition: all 0.2s ease;
}
.lang-btn.active { background: var(--bg-elevated); color: var(--text-dark); box-shadow: var(--shadow-sm); }

.theme-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-muted);
  transition: background 0.2s ease, color 0.2s ease;
  background: transparent;
  border: none;
  cursor: pointer;
}
.theme-btn:hover { background: var(--neutral-bg); color: var(--text-dark); }
.theme-btn[data-theme-mode="light"] { color: var(--accent-gold); }
.theme-btn[data-theme-mode="dark"] { color: var(--accent-gold); }

.menu-btn {
  width: 32px; height: 32px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}
.menu-btn:hover { background: var(--neutral-bg); }
.menu-btn span { display: block; width: 16px; height: 1.5px; background: var(--text-muted); border-radius: 1px; }

/* ============== AUTH BUTTON + MODAL (Midnight Steel) ============== */
.auth-btn {
  height: 32px; padding: 0 10px;
  display: flex; align-items: center; gap: 6px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}
.auth-btn:hover { background: var(--neutral-bg); color: var(--text-dark); border-color: var(--border); }
.auth-btn.signed-in { border-color: var(--accent-gold); color: var(--accent-gold); }

.auth-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
  display: none; z-index: 1000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.auth-modal-backdrop.open { display: flex; }
.auth-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 380px;
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  animation: authPopIn 0.25s ease;
}
@keyframes authPopIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.auth-modal-title { font-family: var(--font-serif); font-size: 22px; font-weight: 500; color: var(--text-dark); margin-bottom: 6px; }
.auth-modal-subtitle { font-size: 13px; color: var(--text-tertiary); margin-bottom: 20px; line-height: 1.55; }
.auth-modal-label { display: block; font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.auth-modal-input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-dark); font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.2s, background 0.2s;
}
.auth-modal-input:focus { outline: none; border-color: var(--accent-gold); background: var(--bg-secondary); }
.auth-modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.auth-modal-btn {
  flex: 1; padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary); color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; font-family: var(--font-body);
  cursor: pointer; transition: all 0.2s;
}
.auth-modal-btn:hover { background: var(--neutral-bg); color: var(--text-dark); }
.auth-modal-btn.primary {
  background: var(--cta-gradient); color: var(--bg);
  border-color: var(--accent-gold);
  font-weight: 600;
}
.auth-modal-btn.primary:hover { filter: brightness(1.08); }
.auth-modal-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-modal-msg { margin-top: 12px; font-size: 12px; line-height: 1.5; }
.auth-modal-msg.error { color: var(--danger); }
.auth-modal-msg.success { color: var(--success); }
.auth-modal-msg.info { color: var(--text-tertiary); }
.auth-modal-close { position: absolute; right: 16px; top: 14px; background: none; border: none; color: var(--text-tertiary); font-size: 22px; cursor: pointer; line-height: 1; }
.auth-modal-wrap { position: relative; }
.auth-modal-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--text-faded); font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; }
.auth-modal-divider::before, .auth-modal-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-light); }
.auth-modal-oauth { display: flex; flex-direction: column; gap: 8px; }
.auth-modal-oauth-btn {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px;
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.auth-modal-oauth-btn:hover { background: var(--neutral-bg); color: var(--text-dark); }

/* Profile Modal extends auth-modal styles */
.profile-modal { max-width: 460px; }
.profile-row { margin-top: 14px; }
.profile-row.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-row.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.profile-row.checkbox-row label { font-size: 12px; color: var(--text-tertiary); cursor: pointer; }
.profile-row .auth-modal-input { margin-top: 4px; }
.profile-radio-group { display: flex; gap: 6px; margin-top: 4px; }
.profile-radio-btn {
  flex: 1; padding: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px; font-family: var(--font-body);
  cursor: pointer; transition: all 0.2s;
}
.profile-radio-btn.active { background: var(--neutral-bg); color: var(--accent-gold); border-color: var(--accent-gold); }
.profile-coord-preview {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-tertiary);
  font-family: var(--font-en);
}
.profile-coord-preview.found { color: var(--success); border-color: var(--success); }
.profile-coord-preview.error { color: var(--danger); }
.profile-search-btn {
  margin-top: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 12px; font-family: var(--font-body);
  cursor: pointer; width: 100%;
  transition: all 0.2s;
}
.profile-search-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold); border-style: solid; }
.profile-result {
  margin-top: 14px;
  padding: 14px;
  background: var(--neutral-bg);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-dark);
  display: none;
}
.profile-result.show { display: block; }
.profile-result strong { color: var(--accent-gold); }

/* ============== BaZi meta row (Executive) + pillar-color (Master) ============== */
.bazi-meta-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; border-top: 1px solid var(--border-light); }
.bazi-meta-row:first-of-type { border-top: none; padding-top: 12px; margin-top: 8px; }
.bazi-meta-key { color: var(--text-tertiary); }
.bazi-meta-val { color: var(--text-dark); font-weight: 500; }
.bazi-master-link {
  display: block; margin-top: 12px; padding: 10px 12px;
  text-align: center; font-size: 12px;
  background: var(--neutral-bg); border-radius: var(--radius-sm);
  color: var(--accent-gold); text-decoration: none;
  transition: all 0.2s;
}
.bazi-master-link:hover { background: var(--bg-tertiary); color: var(--accent-gold-light); }

/* BaZi Energy Hero (ตัวเลขใหญ่) */
.bazi-energy-hero {
  text-align: center;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 12px;
}
.bazi-energy-label {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.bazi-energy-score-row {
  display: flex; align-items: baseline; justify-content: center; gap: 4px;
  font-family: var(--font-serif);
}
.bazi-energy-score {
  font-size: 64px;
  font-weight: 500;
  color: var(--accent-gold);
  line-height: 1;
  letter-spacing: -2px;
}
.bazi-energy-suffix {
  font-size: 18px;
  color: var(--text-tertiary);
  font-weight: 400;
}
.bazi-energy-tier {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0.4px;
}
.bazi-energy-hero.tier-good .bazi-energy-score { color: var(--success); }
.bazi-energy-hero.tier-warn .bazi-energy-score { color: var(--warning); }
.bazi-energy-hero.tier-danger .bazi-energy-score { color: var(--danger); }

/* ============== Hourly Energy Strip ============== */
.hourly-section { margin-top: 18px; padding: 16px; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-lg); }
.hourly-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.hourly-title { font-family: var(--font-serif); font-size: 16px; color: var(--text-dark); font-weight: 500; }
.hourly-now-marker { font-size: 11px; color: var(--text-tertiary); }
.hourly-strip-wrap { position: relative; }
.hourly-strip {
  display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 4px 2px 8px; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.hourly-strip::-webkit-scrollbar { height: 6px; }
.hourly-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.hour-card {
  flex: 0 0 90px; min-height: 110px; padding: 10px 8px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  scroll-snap-align: start;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  text-align: center;
}
.hour-card:hover { background: var(--neutral-bg); transform: translateY(-2px); }
.hour-card.is-current { border-color: var(--accent-gold); box-shadow: 0 0 0 1px var(--accent-gold); }
.hour-card.is-best::before {
  content: '⭐'; position: absolute; top: -8px; right: -4px;
  font-size: 14px; line-height: 1;
}
.hour-card.is-selected { background: var(--neutral-bg); border-color: var(--accent-gold); }
.hour-time { font-size: 11px; color: var(--text-tertiary); letter-spacing: 0.3px; }
.hour-score { font-family: var(--font-serif); font-size: 24px; font-weight: 500; line-height: 1.1; margin-top: 6px; }
.hour-tier { font-size: 11px; margin-top: 4px; letter-spacing: 0.3px; }
.hour-element-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-left: 4px; vertical-align: middle; }
.hour-element-dot.el-wood   { background: #8ab59a; }
.hour-element-dot.el-fire   { background: #d4a574; }
.hour-element-dot.el-earth  { background: #c9b487; }
.hour-element-dot.el-metal  { background: #b8b8b8; }
.hour-element-dot.el-water  { background: #8aa3d4; }
/* score tier color (main) — apply to score + tier */
.hour-card.tier-da_ji   .hour-score, .hour-card.tier-da_ji   .hour-tier { color: var(--success); }
.hour-card.tier-ji      .hour-score, .hour-card.tier-ji      .hour-tier { color: var(--accent-gold); }
.hour-card.tier-ping    .hour-score, .hour-card.tier-ping    .hour-tier { color: var(--text-muted); }
.hour-card.tier-xiong   .hour-score, .hour-card.tier-xiong   .hour-tier { color: var(--warning); }
.hour-card.tier-da_xiong .hour-score, .hour-card.tier-da_xiong .hour-tier { color: var(--danger); }

.hourly-expand-btn {
  display: block; margin: 12px auto 0; padding: 8px 16px;
  background: transparent; border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); color: var(--text-tertiary);
  font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.hourly-expand-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

.hour-detail-panel {
  margin-top: 14px; padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  display: none;
}
.hour-detail-panel.show { display: block; }
.hour-detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.hour-detail-title { font-family: var(--font-serif); font-size: 15px; color: var(--text-dark); }
.hour-detail-pillar { font-size: 12px; color: var(--text-tertiary); }
.hour-detail-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; border-top: 1px solid var(--border-light); }
.hour-detail-row:first-of-type { border-top: none; }
.hour-detail-label { color: var(--text-tertiary); }
.hour-detail-value { color: var(--text-dark); text-align: right; max-width: 65%; }
.hour-detail-action { margin-top: 10px; padding: 8px 10px; background: var(--neutral-bg); border-radius: var(--radius-sm); font-size: 13px; color: var(--accent-gold); text-align: center; }

/* Pillar by element color (ใช้ใน Master Mode 4-pillar grid) */
.pillar-el-wood   { background: var(--el-wood-bg);   color: var(--el-wood-text);   border: 1px solid var(--el-wood-text); }
.pillar-el-fire   { background: var(--el-fire-bg);   color: var(--el-fire-text);   border: 1px solid var(--el-fire-text); }
.pillar-el-earth  { background: var(--el-earth-bg);  color: var(--el-earth-text);  border: 1px solid var(--el-earth-text); }
.pillar-el-metal  { background: var(--el-metal-bg);  color: var(--el-metal-text);  border: 1px solid var(--el-metal-text); }
.pillar-el-water  { background: var(--el-water-bg);  color: var(--el-water-text);  border: 1px solid var(--el-water-text); }
.pillar-el-wood .master-pillar-stem,
.pillar-el-fire .master-pillar-stem,
.pillar-el-earth .master-pillar-stem,
.pillar-el-metal .master-pillar-stem,
.pillar-el-water .master-pillar-stem { color: inherit; }

/* Main Container */
.main { max-width: 600px; margin: 0 auto; padding: 24px 20px 32px; }

/* Page Title */
.page-title-block { margin-bottom: 20px; }
.page-meta { font-size: 10px; letter-spacing: 3px; color: var(--text-tertiary); text-transform: uppercase; margin-bottom: 4px; }
.page-title { font-family: var(--font-serif); font-size: 24px; font-weight: 500; color: var(--text-dark); line-height: 1.2; }
.page-subtitle { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

/* Section Label */
.section-label {
  font-size: 10px; letter-spacing: 2.5px;
  color: var(--text-tertiary); text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 12px;
  padding-left: 4px;
}

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

/* Buttons */
.btn-primary {
  background: var(--cta-gradient);
  color: var(--gold-50);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  text-align: center;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-dark);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s ease;
}
.btn-secondary:hover { border-color: var(--accent-gold); }

/* Inputs */
.input {
  width: 100%;
  background: var(--bg-elevated);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text-dark);
  transition: border-color 0.2s ease;
}
.input:focus {
  outline: none;
  border-color: var(--accent-gold);
}

/* Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 0.5px solid var(--border-light);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0));
  z-index: 40;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  color: var(--text-tertiary);
  transition: color 0.2s ease;
}
.tab.tab-active { color: var(--accent-gold); }
.tab:hover { color: var(--text-muted); }
.tab-label { font-size: 11px; font-weight: 500; }

/* Menu Drawer */
.menu-drawer { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.menu-drawer.open { pointer-events: auto; }
.menu-backdrop {
  position: absolute; inset: 0;
  background: rgba(74, 54, 20, 0.4);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.menu-drawer.open .menu-backdrop { opacity: 1; }
.menu-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 280px; max-width: 80vw;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
  padding: 20px;
}
.menu-drawer.open .menu-panel { transform: translateX(0); }
.menu-close { font-size: 24px; color: var(--text-tertiary); align-self: flex-end; margin-bottom: 16px; line-height: 1; }
.menu-header { padding-bottom: 16px; border-bottom: 0.5px solid var(--border-light); }
.menu-title { font-family: var(--font-serif); font-size: 18px; font-weight: 500; color: var(--text-dark); }
.menu-nav { padding-top: 16px; flex: 1; }
.menu-item {
  display: block;
  padding: 12px 0;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 0.5px solid var(--border-light);
  transition: color 0.2s ease;
}
.menu-item:hover { color: var(--text-dark); }
.menu-item-master { color: var(--accent-gold); border-bottom: none; margin-top: 8px; }
.menu-footer { padding-top: 16px; border-top: 0.5px solid var(--border-light); }
.menu-version { font-size: 10px; color: var(--text-tertiary); }

/* Skeleton Loading */
.skeleton {
  display: block;
  background: linear-gradient(90deg, rgba(212, 197, 163, 0.2) 25%, rgba(212, 197, 163, 0.4) 50%, rgba(212, 197, 163, 0.2) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.6s ease-in-out infinite;
  border-radius: 4px;
}
.skeleton-line { height: 12px; }
.skeleton-circle { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.skeleton-content { flex: 1; }
.action-skeleton { display: flex; gap: 12px; padding: 12px; background: var(--bg-elevated); border-radius: var(--radius-md); border: 0.5px solid var(--border-light); }
.w-40 { width: 40%; } .w-60 { width: 60%; } .w-80 { width: 80%; } .w-90 { width: 90%; }
.mt-6 { margin-top: 6px; } .mt-12 { margin-top: 12px; }

@keyframes skeleton-wave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Fade in */
.fade-in { animation: fadeIn 0.5s ease-out backwards; }
.fade-in:nth-child(1) { animation-delay: 0s; }
.fade-in:nth-child(2) { animation-delay: 0.05s; }
.fade-in:nth-child(3) { animation-delay: 0.1s; }
.fade-in:nth-child(4) { animation-delay: 0.15s; }
.fade-in:nth-child(5) { animation-delay: 0.2s; }
.fade-in:nth-child(6) { animation-delay: 0.25s; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile responsive */
@media (max-width: 480px) {
  .main { padding: 20px 16px 32px; }
  .page-title { font-size: 22px; }
}
@media (min-width: 768px) {
  .page-title { font-size: 28px; }
}
