/* ===================================================================
   TRIVIA SPARK - Modern Bright & Clean Design System
   Bright Aesthetics + Bento Grid + Vivid Accents + Mobile First
   =================================================================== */

:root {
  /* Bright Color Palette */
  --bg-main: #f8fafc;
  --bg-gradient-1: rgba(99, 102, 241, 0.08);
  --bg-gradient-2: rgba(6, 182, 212, 0.08);
  --bg-gradient-3: rgba(244, 63, 94, 0.05);

  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #ffffff;
  --bg-elevated: #f1f5f9;
  --border-glass: rgba(226, 232, 240, 0.9);
  --border-focus: rgba(99, 102, 241, 0.4);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  /* Accent Colors */
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-glow: rgba(79, 70, 229, 0.2);
  --primary-bg: #eef2ff;

  --secondary: #0284c7;
  --secondary-glow: rgba(2, 132, 199, 0.2);

  --accent-cyan: #0284c7;
  --accent-rose: #e11d48;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-purple: #7c3aed;

  /* Status Colors */
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;

  --error: #e11d48;
  --error-bg: #fff1f2;
  --error-border: #fecdd3;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 20px var(--primary-glow);

  /* Radius */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;

  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 10% 10%, var(--bg-gradient-1) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, var(--bg-gradient-2) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, var(--bg-gradient-3) 0%, transparent 60%);
  background-attachment: fixed;
}

/* Container */
.app-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 20px 100px;
  position: relative;
  z-index: 2;
}

@media (min-width: 768px) {
  .app-container {
    padding: 24px 32px 60px;
  }
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 12px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* 設問時（クイズ画面表示中）は上部ヘッダーを非表示化 */
body.in-quiz .app-header,
body:has(#view-quiz.active) .app-header {
  display: none !important;
}

body.in-quiz .quiz-arena,
body:has(#view-quiz.active) .quiz-arena {
  padding-top: 10px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.logo-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform var(--transition-bounce);
}

.logo-group:hover .logo-icon-wrap {
  transform: scale(1.08) rotate(5deg);
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #1e1b4b 20%, #4f46e5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text .logo-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
}

.header-status-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.streak-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  color: #b45309;
  box-shadow: var(--shadow-sm);
}

.streak-pill .fire-icon {
  font-size: 1.1rem;
  animation: pulse-glow 2s infinite ease-in-out;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: #ffffff;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.icon-button:hover {
  background: #f8fafc;
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

/* Navigation Bar */
.nav-bar {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  padding: 6px 8px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

/* Mobile Fixed Bottom Nav */
@media (max-width: 767px) {
  .nav-bar {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    margin-bottom: 0;
    z-index: 100;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-item.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.nav-item:hover:not(.active) {
  color: var(--primary);
  background: rgba(79, 70, 229, 0.06);
}

.nav-item-icon {
  font-size: 1.15rem;
}

/* View Section Control */
.view-section {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-section.active {
  display: block;
}

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

/* ===================================================================
   Home / Setup View (Bento Grid)
   =================================================================== */

.bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 860px) {
  .bento-grid {
    grid-template-columns: 1.25fr 0.75fr;
  }
}

.bento-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.bento-hero {
  background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.08);
}

.hero-header {
  margin-bottom: 16px;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
  margin-bottom: 12px;
}

.hero-title {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.3;
  color: #1e1b4b;
  margin-bottom: 8px;
}

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Primary Button */
.btn-primary-large {
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  border: none;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--primary-glow);
  transition: all var(--transition-fast);
  margin-top: 20px;
}

.btn-primary-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.35);
}

.btn-primary-large:active {
  transform: translateY(0);
}

/* Config Grid Selectors */
.config-group {
  margin-bottom: 20px;
}

.config-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip-btn:hover {
  background: #ffffff;
  color: var(--text-main);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.chip-btn.selected {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}

/* Category Grid */
.category-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.category-card-select {
  padding: 12px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-glass);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.category-card-select:hover {
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: #cbd5e1;
}

.category-card-select.selected {
  background: var(--primary-bg);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.category-card-select .cat-icon {
  font-size: 1.6rem;
}

.category-card-select .cat-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Mini Stats Aside */
.side-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-box {
  background: #f8fafc;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  transition: transform var(--transition-fast);
}

.metric-box:hover {
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.metric-box .metric-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: #1e1b4b;
}

.metric-box .metric-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===================================================================
   Quiz Arena View (Live Quiz)
   =================================================================== */

.quiz-arena {
  max-width: 680px;
  margin: 0 auto;
}

/* Progress and Status Bar */
.quiz-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.question-counter {
  font-size: 1.05rem;
  font-weight: 800;
  color: #1e1b4b;
}

.question-counter span {
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
}

.combo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 800;
  color: #b45309;
  box-shadow: var(--shadow-sm);
}

.quiz-quit-btn {
  padding: 4px 12px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quiz-quit-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  border-radius: var(--radius-pill);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(79, 70, 229, 0.4);
}

/* Main Quiz Card (Clean & Focused without unnecessary images) */
.quiz-question-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  position: relative;
}

.quiz-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.quiz-category-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.difficulty-stars {
  font-size: 0.95rem;
  color: #f59e0b;
  letter-spacing: 2px;
}

.question-text {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.55;
  color: #0f172a;
  letter-spacing: -0.01em;
}

/* 4-Option Buttons Area */
.options-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .options-list {
    grid-template-columns: 1fr 1fr;
  }
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  color: #1e293b;
  font-size: 1.02rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.option-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.option-btn:active:not(:disabled) {
  transform: translateY(0);
}

.option-key {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
  border: 1px solid #cbd5e1;
}

.option-text {
  flex-grow: 1;
}

/* Answer State Classes */
.option-btn.correct {
  background: var(--success-bg) !important;
  border-color: var(--success) !important;
  color: #065f46 !important;
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.2) !important;
}

.option-btn.correct .option-key {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.option-btn.wrong {
  background: var(--error-bg) !important;
  border-color: var(--error) !important;
  color: #9f1239 !important;
  box-shadow: 0 4px 16px rgba(225, 29, 72, 0.2) !important;
}

.option-btn.wrong .option-key {
  background: var(--error);
  color: #ffffff;
  border-color: var(--error);
}

.option-btn:disabled {
  cursor: default;
}

/* Feedback & Explanation Card */
.feedback-box {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 16px;
  display: none;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.feedback-box.show {
  display: block;
}

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

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

.feedback-status-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.feedback-header.is-correct .feedback-status-title {
  color: var(--success);
}

.feedback-header.is-wrong .feedback-status-title {
  color: var(--error);
}

.feedback-explanation {
  font-size: 0.98rem;
  color: #334155;
  line-height: 1.75;
  margin-bottom: 16px;
}

.feedback-tip-box {
  background: #f5f3ff;
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  color: #4338ca;
  margin-bottom: 18px;
}

.btn-next-action {
  width: 100%;
  padding: 16px 20px;
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-next-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.3);
}

/* ===================================================================
   Quiz Results View
   =================================================================== */

.result-container {
  max-width: 680px;
  margin: 0 auto;
}

.result-hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 100%);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.result-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #ffffff;
  font-size: 2.5rem;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35);
  margin-bottom: 16px;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  0% { transform: scale(0.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: #1e1b4b;
  margin-bottom: 6px;
}

.result-subtext {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.result-score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 480px;
  margin: 0 auto 24px;
}

.result-score-item {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.result-score-val {
  font-size: 1.45rem;
  font-weight: 800;
  color: #1e1b4b;
}

.result-score-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-secondary {
  padding: 14px 22px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

/* ===================================================================
   Stats & Analytics View (Dashboard)
   =================================================================== */

.stats-dashboard {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.period-filter-bar {
  display: flex;
  gap: 8px;
  background: #ffffff;
  padding: 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-glass);
  width: fit-content;
  margin: 0 auto 12px;
  box-shadow: var(--shadow-sm);
}

.period-tab {
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.period-tab.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

/* Analytics Bento Cards */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .analytics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.summary-stat-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.summary-stat-val {
  font-size: 2.2rem;
  font-weight: 800;
  color: #1e1b4b;
}

.summary-stat-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Strengths & Weaknesses Section */
.insight-bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 800px) {
  .insight-bento-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.insight-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

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

.insight-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1e1b4b;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Category Progress Bars */
.cat-progress-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cat-progress-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
}

.cat-progress-track {
  height: 9px;
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.cat-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.5s ease-out;
}

/* AI Coaching Advice Box */
.ai-coach-card {
  background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.ai-coach-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.ai-coach-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #a855f7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.3);
}

.ai-coach-title h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1e1b4b;
}

.ai-coach-title span {
  font-size: 0.8rem;
  color: #7c3aed;
  font-weight: 600;
}

.ai-advice-content {
  font-size: 0.98rem;
  color: #334155;
  line-height: 1.75;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 18px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
}

.ai-advice-content ul {
  margin-top: 10px;
  padding-left: 20px;
}

.ai-advice-content li {
  margin-bottom: 6px;
}

/* Habit Calendar / Heatmap */
.calendar-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.calendar-day-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  position: relative;
  transition: all var(--transition-fast);
}

.calendar-day-cell.active-level-1 {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.calendar-day-cell.active-level-2 {
  background: #818cf8;
  border-color: #6366f1;
  color: #ffffff;
}

.calendar-day-cell.active-level-3 {
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  border-color: #4338ca;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.calendar-day-cell.today {
  outline: 2px solid #4f46e5;
  outline-offset: 1px;
}

/* Encyclopedia View Styles */
.encyclopedia-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 4px 12px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all var(--transition-fast);
}

.encyclopedia-search-wrapper:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.encyclopedia-search-icon {
  font-size: 1.1rem;
  color: #94a3b8;
  margin-right: 8px;
  user-select: none;
}

.encyclopedia-search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  padding: 10px 0;
  color: #1e293b;
  background: transparent;
}

.encyclopedia-search-clear {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  display: none;
  transition: color 0.15s;
}

.encyclopedia-search-clear:hover {
  color: #334155;
}

.encyclopedia-search-clear.visible {
  display: block;
}

/* Category Tabs */
.encyclopedia-cat-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}

.encyclopedia-cat-tabs::-webkit-scrollbar {
  height: 4px;
}

.encyclopedia-cat-tabs::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.ency-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.ency-tab-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.ency-tab-btn.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.tab-count-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
}

.ency-tab-btn.active .tab-count-badge {
  background: rgba(255, 255, 255, 0.25);
}

/* Filter Sub-bar */
.encyclopedia-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.ency-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ency-filter-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ency-filter-select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 0.82rem;
  color: #334155;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.ency-filter-select:focus {
  border-color: #6366f1;
}

/* Card Grid */
.encyclopedia-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .encyclopedia-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.encyclopedia-item {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.encyclopedia-item:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.encyclopedia-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 6px;
}

.encyclopedia-item-title {
  font-size: 1.02rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: #0f172a;
  line-height: 1.5;
}

.ency-answer-box {
  background: #f0fdf4;
  border-left: 4px solid #10b981;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #065f46;
}

.encyclopedia-item-exp {
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.65;
  margin-bottom: 12px;
  flex: 1;
}

.ency-tip-box {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #92400e;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

/* Empty State */
.encyclopedia-empty {
  text-align: center;
  padding: 48px 20px;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px dashed #cbd5e1;
  grid-column: 1 / -1;
}

.encyclopedia-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.encyclopedia-empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.encyclopedia-empty-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Load More Button */
.encyclopedia-pagination {
  margin-top: 24px;
  text-align: center;
}

.btn-load-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 9999px;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.btn-load-more:hover {
  background: #f8fafc;
  border-color: #6366f1;
  color: #4f46e5;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Keyboard hint chips */
.keyboard-hint {
  display: none;
}

@media (min-width: 768px) {
  .keyboard-hint {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-left: 6px;
  }
}

/* Animations */
@keyframes pulse-glow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Utility */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* Sync Modal */
.sync-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out forwards;
}

.sync-modal-backdrop.show {
  display: flex;
}

.sync-modal-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 26px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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