/* ============================================
   PAGES.CSS — Page Layouts & Page-specific Styles
   Dịch Quẻ · I Ching Oracle
============================================ */

/* ── SPLASH ── */
/* ── SPLASH SCREEN CONTAINER ── */
#splash {
  position: fixed; 
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  /* Định nghĩa màu Gold riêng cho Splash để tránh bị u tối trên Light Theme */
  --splash-gold: #a67c00; 
}

/* Cập nhật màu tươi sáng hơn cho Dark Theme */
[data-theme='dark'] #splash {
  --splash-gold: #eebd2b;
}

#splash.hidden { 
  opacity: 0; 
  pointer-events: none; 
}

/* ── BIỂU TƯỢNG (易) ── */
.splash-symbol {
  font-size: 110px; /* Tăng nhẹ kích thước tạo điểm nhấn */
  line-height: 1;
  color: var(--splash-gold);
  font-family: 'Noto Serif SC', serif;
  /* Glow nhẹ để tăng tính linh thiêng */
  filter: drop-shadow(0 0 15px rgba(166, 124, 0, 0.2));
  animation: pulseInSharp 1.2s ease forwards;
  opacity: 0;
}

[data-theme='dark'] .splash-symbol {
  filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.4));
}

/* ── TIÊU ĐỀ & SUBTITLE ── */
.splash-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: 0.12em;
  margin-top: 24px;
  color: var(--text);
  animation: fadeUp 0.8s 0.2s ease forwards;
  opacity: 0;
}

.splash-sub {
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text3);
  margin-top: 10px;
  animation: fadeUp 0.8s 0.35s ease forwards;
  opacity: 0;
}

/* ── CÂU DẪN (QUOTE) ── */
.splash-quote {
  /* Loại bỏ position relative/bottom để tránh lỗi layout trên màn hình nhỏ */
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
  font-weight: 500;
  color: var(--text2);
  text-align: center;
  max-width: 340px;
  line-height: 1.8;
  margin-top: 50px;
  padding: 0 20px;
  animation: fadeUp 1s 0.5s ease forwards;
  opacity: 0;
}

/* ── NÚT BẤM (NẾU CẦN DÙNG) ── */
.splash-btn {
  margin-top: 40px;
  padding: 13px 44px;
  background: transparent;
  color: var(--splash-gold);
  border: 1px solid var(--splash-gold);
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 40px;
  animation: fadeUp 0.8s 0.8s ease forwards;
  opacity: 0;
  transition: all 0.3s ease;
}

.splash-btn:hover {
  background: var(--splash-gold);
  color: var(--bg);
}

/* ── KEYFRAMES ĐỒNG BỘ ── */
@keyframes pulseInSharp {
  0% { transform: scale(0.9); opacity: 0; filter: blur(10px); }
  100% { transform: scale(1); opacity: 1; filter: blur(0); }
}

@keyframes fadeUp {
  0% { transform: translateY(15px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Mobile Tweak */
@media (max-width: 768px) {
  .splash-symbol { font-size: 84px; }
  .splash-title { font-size: 26px; }
  .splash-quote { font-size: 14px; margin-top: 40px; }
}

/* ── APP SHELL ── */
#app {
  display: none;
  min-height: 100vh;
}

/* ── TOP NAV ── */
.topnav {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  gap: 0;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}
.nav-brand .han { font-size: 24px; font-family: 'Noto Serif SC', serif; color: var(--gold); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 32px;
}

.nav-link {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-link:hover, .nav-link.active {
  background: var(--bg2);
  color: var(--text);
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
  border: none;
  outline: none;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: var(--shadow);
}
[data-theme="dark"] .theme-toggle { background: var(--gold); }
[data-theme="dark"] .theme-toggle::after { transform: translateX(20px); }

.theme-label {
  font-size: 28px;
  color: var(--text3);
}

/* ── MAIN CONTENT AREA ── */
.main-content {
  padding-top: 56px;
  padding-bottom: 80px;
  min-height: 100vh;
}

/* ── PAGE VISIBILITY ── */
.page { display: none !important; }
.page.active { display: block !important; }
#page-ketqua.active { display: grid !important; }

/* ── HOME PAGE ── */
#page-home {
  max-width: 860px;
  margin: 0 auto;
}

.home-hero {
  text-align: center;
  padding: 64px 32px 40px;
  border-bottom: 0.5px solid var(--border-light);
  margin-bottom: 0;
}

.home-hero-han {
  font-family: 'Noto Serif SC', serif;
  font-size: 96px;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 14px;
}

/* ── HERO COSMOS — particles + orbital rings around 易 ── */
.hero-cosmos {
  position: relative;
  width: 100%;
  height: 220px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero-cosmos #cosmos-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.cosmos-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid var(--gold);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.16;
  z-index: 1;
}

.cosmos-orbit-1 {
  width: 320px;
  height: 320px;
  transform: translate(-50%, -50%) rotate(0deg);
  animation: cosmosOrbit1 60s linear infinite;
}

.cosmos-orbit-2 {
  width: 260px;
  height: 110px;
  opacity: 0.14;
  transform: translate(-50%, -50%) rotate(-25deg);
  animation: cosmosOrbit2 45s linear infinite;
}

.cosmos-orbit-3 {
  width: 200px;
  height: 200px;
  opacity: 0.10;
  transform: translate(-50%, -50%) rotate(0deg);
  animation: cosmosOrbit3 38s linear infinite reverse;
}

[data-theme="dark"] .cosmos-orbit-1 { opacity: 0.28; }
[data-theme="dark"] .cosmos-orbit-2 { opacity: 0.22; }
[data-theme="dark"] .cosmos-orbit-3 { opacity: 0.18; }

@keyframes cosmosOrbit1 {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}
@keyframes cosmosOrbit2 {
  from { transform: translate(-50%, -50%) rotate(-25deg); }
  to   { transform: translate(-50%, -50%) rotate(335deg); }
}
@keyframes cosmosOrbit3 {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Chữ 易 trong hero-cosmos: nằm trên canvas, có glow */
.hero-cosmos .home-hero-han {
  position: relative;
  z-index: 2;
  margin-bottom: 0;
  /* Màu Gold ấm áp cho Light Theme - giúp chữ bừng sáng */
  color: #a67c00; 
  
  /* Tạo chiều sâu: 
     Lớp 1: Đổ bóng trắng mảnh để chữ sắc nét trên nền sáng
     Lớp 2: Glow vàng nhẹ tạo linh khí đồng bộ với các hạt Cosmos */
  text-shadow: 
    0px 0px 0px rgba(255, 255, 255, 0.8),
    0 0 20px rgba(166, 124, 0, 0.25);
    
  transition: color 0.5s ease, text-shadow 0.5s ease;
}

[data-theme="dark"] .hero-cosmos .home-hero-han {
  /* Vàng kim rực rỡ bắt sáng trên nền tối */
  color: #eebd2b;
  text-shadow:
    0 0 30px rgba(212, 175, 55, 0.6),
    0 0 60px rgba(212, 175, 55, 0.3);
}

.home-hero-date {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 14px;
}

.home-hero-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 28px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.65;
  margin-bottom: 28px;
}

.home-hero-btn {
  font-size: 13px;
  letter-spacing: 0.1em;
  padding: 13px 40px;
  display: inline-flex;
  width: auto;
}

.home-body {
  padding: 28px 24px 48px;
}

.home-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}

.home-stat-card {
  background: var(--surface);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 20px;
}

/* Card "Hôm nay" — teal */
.home-stat-card:first-child {
  background: linear-gradient(135deg, #b5ffc2, #72b27d);
}
.home-stat-card:first-child .home-stat-label,
.home-stat-card:first-child .home-stat-sub { color: #1a6e54; }
.home-stat-card:first-child .home-stat-val  { color: #1a6e54; }

/* Card "Tổng cộng" — amber */
.home-stat-card:last-child {
  background: linear-gradient(135deg, #f8ecc6, #eacd79);
  border-color: rgba(201, 168, 76, 0.28);
}
.home-stat-card:last-child .home-stat-label,
.home-stat-card:last-child .home-stat-sub { color: #8b6a20; }
.home-stat-card:last-child .home-stat-val  { color: #8b6a20; }

/* Dark mode overrides */
[data-theme="dark"] .home-stat-card:first-child {
  background: linear-gradient(135deg, #1a3028, #0f2018);
  border-color: rgba(80, 160, 110, 0.35);
}
[data-theme="dark"] .home-stat-card:first-child .home-stat-label,
[data-theme="dark"] .home-stat-card:first-child .home-stat-sub { color: rgba(150, 210, 170, 0.6); }
[data-theme="dark"] .home-stat-card:first-child .home-stat-val  { color: #90c8a8; }

[data-theme="dark"] .home-stat-card:last-child {
  background: linear-gradient(135deg, #2e2a1a, #221e0e);
  border-color: rgba(201, 168, 76, 0.25);
}
[data-theme="dark"] .home-stat-card:last-child .home-stat-label,
[data-theme="dark"] .home-stat-card:last-child .home-stat-sub { color: rgba(232, 200, 90, 0.55); }
[data-theme="dark"] .home-stat-card:last-child .home-stat-val  { color: #e8c85a; }

.home-stat-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

.home-stat-val {
  font-family: var(--font-serif);
  font-size: 36px;
  color: var(--gold);
  line-height: 1;
}

.home-stat-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

.home-recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.home-recent-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
}

.home-recent-link {
  font-size: 11px;
  color: var(--gold);
  cursor: pointer;
  transition: opacity var(--transition);
}
.home-recent-link:hover { opacity: 0.7; }
.mobile-br { display: none; }

/* Mobile overrides */
@media (max-width: 768px) {
  .mobile-br { display: block; }
  .home-hero { padding: 56px 35px 32px; }
  .home-hero-han { font-size: 80px; }
  .home-hero-quote { font-size: 22px; font-weight: 600}
  .home-hero-btn { padding: 12px 32px; width: auto; display: inline-flex; }
  .home-body { padding: 20px 35px 100px; }
  .home-stat-val { font-size: 28px; }
  #page-home { padding-bottom: 0; }

  .hero-cosmos { height: 200px; }
  .cosmos-orbit-1 { width: 270px; height: 270px; }
  .cosmos-orbit-2 { width: 220px; height: 95px; }
  .cosmos-orbit-3 { width: 170px; height: 170px; }
}

/* ── GIEO QUẺ PAGE ── */
#page-gieo {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.gieo-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.back-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  font-size: 20px;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.back-btn:hover { color: var(--text); }

.gieo-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
}

.question-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 12px;
  display: block;
}

.question-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 20px;
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--text);
  resize: none;
  outline: none;
  transition: border-color var(--transition);
  line-height: 1.6;
  min-height: 76px;
  height: 76px;
  margin-bottom: 16px;
}
.question-input:focus { border-color: var(--text); }
.question-input::placeholder { color: var(--text3); }

/* Hex build area — hlines panel (hào trên, text dưới, center) */
.hex-build-area {
  background: linear-gradient(160deg, #1a3028 0%, #122018 100%);
  border: 1px solid rgba(80, 160, 110, 0.35);
  box-shadow: 0 0 0 1px rgba(80, 160, 110, 0.08), inset 0 1px 0 rgba(100, 200, 140, 0.10);
  border-radius: var(--radius);
  padding: 32px 28px 24px;
  margin: 0 auto 35px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  line-height: 1.6;
}

[data-theme="dark"] .hex-build-area {
  background: linear-gradient(160deg, #1a3028 0%, #122018 100%);
  border: 1px solid rgba(80, 160, 110, 0.35);
  box-shadow: 0 0 0 1px rgba(80, 160, 110, 0.08), inset 0 1px 0 rgba(100, 200, 140, 0.10);
}

.hex-lines-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.hex-line-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Text overrides bên trong hex-build-area (nền tối luôn) */
.hex-build-area .hex-line-num {
  color: rgba(150, 210, 170, 0.4);
}

.hex-build-area .hex-preview-name {
  color: #f0f8f4;
}

.hex-build-area .hex-preview-han {
  color: #e8c85a;
}

.hex-build-area .hex-preview-meaning {
  color: rgba(200, 230, 215, 0.75);
}

/* hào line: khoét âm dùng màu nền forest green (chỉ áp cho sm/md/lg, không áp gieo) */
.hex-build-area .hao-line:not(.gieo).yin::after,
.hex-build-area .hao-line:not(.gieo).moving.yin::after {
  background: #162a20;
}
.hex-build-area .hao-line.empty {
  background: rgba(255, 255, 255, 0.10);
}
.hex-build-area .hao-line:not(.gieo):not(.empty):not(.moving) {
  background: rgba(240, 248, 244, 0.88);
}

.hex-line-num {
  font-size: 11px;
  color: var(--text3);
  width: 16px;
  text-align: right;
}

.hex-line {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 200px;
}

.hex-preview-info {
  width: 100%;
  text-align: center;
  min-width: 0;
}

.hex-preview-name {
  font-family: var(--font-serif);
  font-size: 28px;
  margin-bottom: 4px;
}

.hex-preview-han {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 8px;
}

.hex-preview-meaning {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

.gieo-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0 0 20px;
}

.pip-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  transition: background var(--transition), transform var(--transition);
  display: inline-block;
}

.pip.filled {
  background: var(--gold);
}

.step-indicator {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
}

.gieo-action {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 0;
}

/* ── KẾT QUẢ PAGE ── */
#page-ketqua {
  display: grid;
  grid-template-columns: 1fr 2fr;
  min-height: calc(100vh - 56px);
}

.ketqua-left {
  border-right: 1px solid var(--border-light);
  padding: 28px;
  padding-bottom: 48px;
  overflow-y: auto;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
}

.ketqua-right {
  padding: 28px;
  padding-bottom: 48px;
  overflow-y: auto;
}

.kq-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text3);
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 20px;
  width: fit-content;
  transition: color var(--transition);
}
.kq-back:hover { color: var(--text); }

.kq-number {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 4px;
}

.kq-name {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 300;
  line-height: 1.2;
  margin-bottom: 2px;
}

.kq-han {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 4px;
}

.kq-meaning {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 16px;
}

.kq-question {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--text2);
  margin-bottom: 16px;
  padding: 12px 14px;
  border-left: 2px solid var(--gold);
  background: var(--bg2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.6;
}

.big-hex {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  margin: 32px 0;
}

.big-hex-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.big-hex-nums {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-left: 12px;
}
.big-hex-num { height: 6px; display: flex; align-items: center; }

.moving-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
}

/* Biến quẻ */
.bien-que-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

.section-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 16px;
}

.bien-que-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bien-hex-small {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.arrow-icon { color: var(--text3); font-size: 16px; }

.bien-info h4 { font-family: var(--font-serif); font-size: 18px; margin-bottom: 2px; }
.bien-info p  { font-size: 12px; color: var(--text2); }

/* Kết quả right side */
.kq-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-light);
}
.kq-section:last-child { border-bottom: none; }

.kq-section-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 16px;
}

.kq-text {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.8;
}

.kq-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--text);
  line-height: 1.7;
  padding: 20px 24px;
  border-left: 3px solid var(--gold);
  background: var(--bg2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 16px 0;
}

.hao-list { display: flex; flex-direction: column; gap: 12px; }

.hao-item {
  padding: 16px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.hao-name { font-size: 12px; font-weight: 500; color: var(--gold); margin-bottom: 6px; }
.hao-text { font-size: 13px; color: var(--text2); line-height: 1.7; }

.topic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.topic-item {
  padding: 12px 14px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.topic-name { font-size: 11px; color: var(--text3); margin-bottom: 4px; }
.topic-val  { font-size: 13px; color: var(--text); line-height: 1.5; }

/* ── KHO 64 QUẺ PAGE ── */
#page-kho {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 24px;
}

.kho-search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  margin-bottom: 24px;
  transition: border-color var(--transition);
}
.kho-search:focus { border-color: var(--text); }
.kho-search::placeholder { color: var(--text3); }

.trigram-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
}

.trigram-tab {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text2);
}
.trigram-tab:hover, .trigram-tab.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.que-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.que-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.que-card:hover { box-shadow: var(--shadow-md); border-color: var(--border); transform: translateY(-1px); }

.que-card-num    { font-size: 10px; color: var(--text3); margin-bottom: 6px; letter-spacing: 0.08em; }
.que-card-han    { font-family: 'Noto Serif SC', serif; font-size: 20px; color: var(--gold); margin-bottom: 2px; }
.que-card-name   { font-size: 12px; font-weight: 500; margin-bottom: 2px; }
.que-card-meaning{ font-size: 10px; color: var(--text3); line-height: 1.4; }

/* Detail overlay */
.detail-overlay {
  position: fixed; inset: 0;
  background: rgba(26,24,20,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.detail-overlay.open { opacity: 1; pointer-events: all; }

.detail-panel {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 40px;
  transform: translateY(20px);
  transition: transform 0.2s;
  box-shadow: var(--shadow-lg);
}
.detail-overlay.open .detail-panel { transform: translateY(0); }

.detail-close {
  float: right;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text3);
  padding: 4px;
}

/* ── HISTORY PAGE ── */
#page-history {
  max-width: 700px;
  margin: 0 auto;
  padding: 48px 24px;
}

.history-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.htab {
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.htab:hover { color: var(--text); }
.htab.active { color: var(--text); border-bottom-color: var(--text); }

/* ── FOOTER ── */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  padding: 8px 20px;
  display: flex;
  height: 48px;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 99;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-han {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--gold);
}

.footer-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  display: block;
}

.footer-by {
  font-size: 10px;
  color: var(--text3);
  display: block;
white-space: nowrap;
}

.footer-link {
  font-size: 11px;
  color: var(--gold);
  text-decoration: none;
  border: 0.5px solid var(--gold-light);
  padding: 4px 10px;
  border-radius: 20px;
  transition: all 0.2s;
}

.footer-link:hover {
  background: var(--bg2);
}

/* ── Chat page: ẩn footer để không che input bar (desktop) ── */
body:has(#page-chat.active) .app-footer {
  display: none;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  #page-ketqua { grid-template-columns: 1fr; }

  .ketqua-left {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }

  .home-grid { grid-template-columns: 1fr; }
  .card-action { flex-direction: column; align-items: flex-start; }
  .nav-links { display: none; }
  .que-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 640px) {
  .hex-build-area {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
  }
  .hex-preview-info {
    text-align: center;
    width: 100%;
    min-width: unset;
  }
}

.nav-brand-by {
  display: none;
  font-family: var(--font-sans);
  font-size: 9px;
  color: var(--text3);
white-space: nowrap;
}

/* ── BOTTOM NAV (mobile only) ── */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-brand-by { display: block; }
  .nav-username { display: none; }
  .nav-user span { display: none; }
  .main-content { padding-bottom: 120px; }
  .app-footer { display: none; }
  .bottom-nav {

    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 50px;
    background: var(--surface);
    border-top: 1px solid var(--border-light);
    z-index: 100;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--text3);
    transition: color 0.2s;
    font-size: 9px;
    border: none;
    background: none;
    font-family: var(--font-sans);
  }

  .bottom-nav-item.active {
    color: var(--text);
    border-top: 2px solid var(--gold);
  }

  .bottom-nav-item svg {
    width: 17px;
    height: 17px;
  }
}

/* ── AI BUBBLE ── */
.ai-bubble-wrap {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 150;
  display: none;
}

.ai-bubble {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0f5c4a;
  outline: 2px solid #7a5c1e;
  outline-offset: 3px;
  border: 1.5px solid #2a9478;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.2s;
}
.ai-bubble:hover { opacity: 0.85; }

.ai-bubble-han {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px;
  line-height: 1;
  color: #e0f5ef;
}
.ai-bubble-sub {
  font-size: 6.5px;
  letter-spacing: .04em;
  color: #9fe1cb;
  white-space: nowrap;
  font-family: var(--font-sans);
}

/* ── AI CTA CARD ── */
.ai-cta-card {
  position: fixed;
  top: 136px;
  right: 24px;
  width: 260px;
  background: var(--surface);
  border: 1px solid #c9a45a;
  border-radius: var(--radius);
  padding: 18px;
  z-index: 149;
  display: none;
}
.ai-cta-card.open { display: block; }

.ai-cta-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.ai-cta-card-han {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  color: var(--gold);
}
.ai-cta-card-close {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 16px;
  cursor: pointer;
  padding: 2px;
  line-height: 1;
}
.ai-cta-card-label {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 4px;
}
.ai-cta-card-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 400;
  margin-bottom: 12px;
  line-height: 1.4;
  color: var(--text);
}
.ai-cta-features {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}
.ai-cta-feat {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}
.ai-cta-feat-icon {
  color: var(--gold);
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 1px;
  font-family: 'Noto Serif SC', serif;
}
.ai-cta-start {
  width: 100%;
  padding: 10px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.2s;
}
.ai-cta-start:hover { opacity: 0.85; }
.ai-cta-start .btn-han {
  font-family: 'Noto Serif SC', serif;
  color: var(--gold);
}

@media (max-width: 768px) {
  .ai-bubble-wrap { top: 110px; right: 16px; }
  .ai-cta-card { right: 16px; left: 16px; width: auto; top: 166px; }
}