/* ============================================
   CCA-F Learning Platform - Styles
   Dark theme with gold accent
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-deep: #0c0e14;
  --bg-card: #151820;
  --bg-sidebar: #111318;
  --bg-hover: #1c1f2a;
  --bg-input: #1a1d26;
  --accent: #f5b642;
  --accent-dim: rgba(245, 182, 66, 0.15);
  --accent-hover: #f7c55c;
  --text-primary: #e8e6e3;
  --text-secondary: #9ca3af;
  --text-dim: #6b7280;
  --border: #2a2d38;
  --border-light: #3a3d48;
  --success: #34d399;
  --error: #f87171;
  --info: #60a5fa;
  --warning: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --transition: 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
}

/* Claude Code mascot - CSS pixel art scattered in background */
.claude-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.claude-char {
  position: absolute;
  opacity: 0.10;
  transition: opacity 0.5s;
  --size: 1;
}
.claude-char:hover { opacity: 0.18; }

/* Body: wide terracotta block with rounded corners */
.claude-char .cc-body {
  width: calc(44px * var(--size));
  height: calc(28px * var(--size));
  background: #c87a50;
  border-radius: calc(5px * var(--size));
  position: relative;
}

/* Eyes: dark squares */
.claude-char .cc-eye {
  position: absolute;
  width: calc(5px * var(--size));
  height: calc(7px * var(--size));
  background: #1a1a1a;
  border-radius: calc(1px * var(--size));
  top: calc(8px * var(--size));
}
.claude-char .cc-eye.left { left: calc(11px * var(--size)); }
.claude-char .cc-eye.right { right: calc(11px * var(--size)); }

/* Arms: small blocks on sides */
.claude-char .cc-arm {
  position: absolute;
  width: calc(8px * var(--size));
  height: calc(12px * var(--size));
  background: #b86e45;
  border-radius: calc(2px * var(--size));
  top: calc(10px * var(--size));
}
.claude-char .cc-arm.left { left: calc(-9px * var(--size)); }
.claude-char .cc-arm.right { right: calc(-9px * var(--size)); }

/* Legs: 4 blocks underneath */
.claude-char .cc-legs {
  display: flex;
  justify-content: space-between;
  padding: 0 calc(5px * var(--size));
  margin-top: calc(-1px * var(--size));
}
.claude-char .cc-leg {
  width: calc(7px * var(--size));
  height: calc(10px * var(--size));
  background: #b86e45;
  border-radius: 0 0 calc(2px * var(--size)) calc(2px * var(--size));
}

/* Size variants */
.claude-char.sm { --size: 0.7; }
.claude-char.md { --size: 1; }
.claude-char.lg { --size: 1.4; }

/* Gentle float animation */
@keyframes ccFloat1 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}
@keyframes ccFloat2 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(-2deg); }
}
@keyframes ccFloat3 {
  0%, 100% { transform: translateY(0) rotate(1deg); }
  50% { transform: translateY(-10px) rotate(-1deg); }
}
.claude-char:nth-child(odd) { animation: ccFloat1 7s ease-in-out infinite; }
.claude-char:nth-child(even) { animation: ccFloat2 6s ease-in-out infinite; }
.claude-char:nth-child(3n) { animation: ccFloat3 8s ease-in-out infinite; }
.claude-char:nth-child(1) { animation-delay: 0s; }
.claude-char:nth-child(2) { animation-delay: -1.5s; }
.claude-char:nth-child(3) { animation-delay: -3s; }
.claude-char:nth-child(4) { animation-delay: -4.5s; }
.claude-char:nth-child(5) { animation-delay: -0.8s; }
.claude-char:nth-child(6) { animation-delay: -2.2s; }
.claude-char:nth-child(7) { animation-delay: -5s; }
.claude-char:nth-child(8) { animation-delay: -3.5s; }
.claude-char:nth-child(9) { animation-delay: -1s; }
.claude-char:nth-child(10) { animation-delay: -6s; }

/* ============================================
   Top Navigation Bar
   ============================================ */

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 1000;
  backdrop-filter: blur(12px);
}

.nav-logo {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  margin-right: 32px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-mascot {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 4px;
  transition: transform 0.3s;
}

.nav-mascot:hover {
  transform: scale(1.15) rotate(-5deg);
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.nav-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}

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

.search-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.search-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.progress-bar {
  width: 120px;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ============================================
   Main Layout
   ============================================ */

.main-container {
  margin-top: 60px;
  display: flex;
  min-height: calc(100vh - 60px);
}

/* ============================================
   Study View - Sidebar
   ============================================ */

.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  overflow-y: auto;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
}

.sidebar-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  padding: 0 20px;
  margin-bottom: 12px;
}

.chapter-list {
  list-style: none;
}

.chapter-item {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chapter-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chapter-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
}

.chapter-item .ch-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  min-width: 28px;
  text-align: center;
}

.chapter-item.active .ch-num {
  background: var(--accent);
  color: var(--bg-deep);
}

/* ============================================
   Study View - Content
   ============================================ */

.content-area {
  flex: 1;
  padding: 40px;
  max-width: 900px;
  margin: 0 auto;
  overflow-y: auto;
}

.content-area h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 24px;
  line-height: 1.3;
}

.content-area h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 40px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.content-area h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 28px;
  margin-bottom: 12px;
}

.content-area h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 20px;
  margin-bottom: 8px;
}

.content-area p {
  margin-bottom: 16px;
  color: var(--text-primary);
}

.content-area ul, .content-area ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.content-area li {
  margin-bottom: 6px;
  color: var(--text-primary);
}

.content-area code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  color: var(--accent);
}

.content-area pre {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  margin-bottom: 16px;
  overflow-x: auto;
  line-height: 1.6;
  font-variant-ligatures: none;
}

.content-area pre code {
  background: transparent;
  padding: 0;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.82rem;
  color: var(--text-primary);
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
}

.content-area blockquote {
  border-left: 3px solid var(--accent);
  padding: 14px 22px;
  margin-bottom: 16px;
  background: rgba(245, 182, 66, 0.04);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-primary);
}

.content-area table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.015);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.content-area th {
  background: rgba(245, 182, 66, 0.07);
  font-weight: 600;
  text-align: left;
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--accent);
  font-size: 0.85rem;
}

.content-area td {
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.01);
}

.content-area tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.content-area strong {
  color: var(--text-primary);
  font-weight: 600;
}

.content-area img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

.content-area hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* ============================================
   Practice View
   ============================================ */

.practice-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px;
  width: 100%;
}

.scenario-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.scenario-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.scenario-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.scenario-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.scenario-card .scenario-jp {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.scenario-card .scenario-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.scenario-card .scenario-progress {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Question Area */

.question-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}

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

.question-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--accent);
}

.question-chapter-link {
  font-size: 0.8rem;
  color: var(--info);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.question-chapter-link:hover {
  color: var(--accent);
}

/* Question List Grid */
.question-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.qlist-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.qlist-item:hover {
  border-color: var(--accent);
  background: rgba(245, 182, 66, 0.04);
  transform: translateY(-1px);
}

.qlist-item.mastered {
  border-color: rgba(52, 211, 153, 0.2);
  background: rgba(52, 211, 153, 0.02);
}

.qlist-item.dimmed {
  opacity: 0.4;
}

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

.qlist-num {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
}

.qlist-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 100px;
}

.qlist-badge.mastered-badge {
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.qlist-badge.wrong-badge {
  background: rgba(248, 113, 113, 0.12);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.qlist-badge.bookmark-badge {
  background: rgba(96, 165, 250, 0.12);
  color: var(--info);
  border: 1px solid rgba(96, 165, 250, 0.25);
}

/* Bookmark button on question screen */
.bookmark-btn {
  padding: 5px 10px;
  font-size: 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}

.bookmark-btn:hover {
  border-color: var(--info);
  background: rgba(96, 165, 250, 0.08);
}

.bookmark-btn.is-bookmarked {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.4);
}

.qlist-preview {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.qlist-chapter {
  font-size: 0.75rem;
  color: var(--text-dim);
}

@media (max-width: 768px) {
  .question-list-grid {
    grid-template-columns: 1fr;
  }
}

/* Mastered button */
.mastered-btn {
  padding: 5px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.mastered-btn:hover {
  border-color: var(--success);
  color: var(--success);
}

.mastered-btn.is-mastered {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--success);
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 24px;
  color: var(--text-primary);
}

/* Removed: question-text-jp is now shown via hover tooltip, not inline */
.question-text-jp {
  display: none;
}

.answer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-item {
  padding: 14px 18px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.answer-item:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.answer-item.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.answer-item.correct {
  border-color: var(--success);
  background: rgba(52, 211, 153, 0.1);
}

.answer-item.incorrect {
  border-color: var(--error);
  background: rgba(248, 113, 113, 0.1);
}

.answer-item.show-correct {
  border-color: var(--success);
  background: rgba(52, 211, 153, 0.08);
}

.answer-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
}

.answer-item.selected .answer-label,
.answer-item.correct .answer-label {
  background: var(--accent);
  color: var(--bg-deep);
}

.answer-item.incorrect .answer-label {
  background: var(--error);
  color: white;
}

.answer-text {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Explanation */

.explanation-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  display: none;
}

.explanation-box.visible {
  display: block;
}

.explanation-box h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.explanation-box .exp-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.explanation-box .exp-text-jp {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-secondary);
  padding: 14px 18px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  font-family: 'DM Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

/* Study Tip Box */
.study-tip {
  margin-top: 16px;
  padding: 16px 20px;
  background: rgba(245, 182, 66, 0.06);
  border: 1px solid rgba(245, 182, 66, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--text-secondary);
  font-family: 'DM Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

.explanation-box .question-chapter-link {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 16px;
  background: rgba(245, 182, 66, 0.08);
  border: 1px solid rgba(245, 182, 66, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: all var(--transition);
}

.explanation-box .question-chapter-link:hover {
  background: rgba(245, 182, 66, 0.15);
  border-color: var(--accent);
}

/* Navigation buttons */

.question-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-deep);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
}

.btn-back {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-back:hover {
  border-color: var(--text-secondary);
}

/* Score display */

.score-display {
  text-align: center;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.score-display h2 {
  font-family: 'Outfit', sans-serif;
  color: var(--accent);
  margin-bottom: 16px;
  border: none;
  padding: 0;
}

.score-number {
  font-family: 'Outfit', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
}

.score-detail {
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ============================================
   Vocabulary Tooltip
   ============================================ */

.vocab {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  position: relative;
}

.vocab:hover {
  color: var(--accent);
}

#tooltip {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--text-primary);
  max-width: 320px;
  z-index: 9999;
  pointer-events: none;
  display: none;
  box-shadow: var(--shadow-lg);
  line-height: 1.5;
}

#tooltip .tooltip-word {
  color: var(--accent);
  font-weight: 600;
  margin-right: 6px;
}

#tooltip .tooltip-meaning {
  color: var(--text-secondary);
}

/* Japanese translation tooltip (larger) */
#tooltip.tooltip-jp {
  font-size: 0.95rem;
  max-width: 520px;
  min-width: 200px;
  padding: 14px 18px;
  line-height: 1.8;
  border-color: rgba(245, 182, 66, 0.4);
  background: #1a1d2e;
  font-family: 'DM Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

#tooltip .tooltip-flag {
  font-size: 0.8rem;
  margin-right: 4px;
}

/* Hover indicator for Japanese-translatable elements */
.has-jp {
  cursor: help;
}

.jp-hint {
  font-size: 0.7rem;
  opacity: 0.4;
  margin-left: 8px;
  vertical-align: middle;
  transition: opacity 0.2s;
}

.has-jp:hover .jp-hint {
  opacity: 1;
}

/* Chapter link in quiz (styled as link, not button) */
.question-chapter-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  transition: opacity 0.2s;
}

.question-chapter-link:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
  .top-nav {
    padding: 0 12px;
  }

  .nav-logo {
    font-size: 1rem;
    margin-right: 16px;
  }

  .nav-tab {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .nav-progress {
    display: none;
  }

  .main-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: 200px;
    position: relative;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .chapter-list {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 0 12px;
  }

  .chapter-item {
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .chapter-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .content-area {
    padding: 20px 16px;
  }

  .content-area h1 {
    font-size: 1.5rem;
  }

  .content-area h2 {
    font-size: 1.25rem;
  }

  .practice-container {
    padding: 20px 16px;
  }

  .scenario-selector {
    grid-template-columns: 1fr;
  }

  .question-area {
    padding: 20px;
  }

  .question-text {
    font-size: 0.95rem;
  }
}

/* ============================================
   Utility
   ============================================ */

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

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

/* Scrollbar styling */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ============================================
   Auth Screen
   ============================================ */

.auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-screen.hidden {
  display: none;
}

.auth-box {
  text-align: center;
  max-width: 360px;
  width: 100%;
  padding: 48px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}

.auth-box input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input, #1a1e28);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}

.auth-box input[type="password"]:focus {
  border-color: var(--accent);
}

.auth-box button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), #fcd34d);
  border: none;
  border-radius: var(--radius-sm);
  color: #1a1a2e;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-box button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(245,182,66,0.25);
}

/* ============================================
   Mark Popup (text selection)
   ============================================ */

.mark-popup {
  position: absolute;
  z-index: 1500;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
}

.mark-popup.hidden {
  display: none;
}

.mark-popup button {
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}

.mark-popup button:hover {
  background: var(--accent-dim);
}

/* ============================================
   Notes View
   ============================================ */

.notes-chapter-group {
  margin-bottom: 28px;
}

.notes-chapter-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(245, 182, 66, 0.15);
}

.notes-chapter-title:hover {
  text-decoration: underline;
}

.notes-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  transition: all var(--transition);
}

.notes-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(245, 182, 66, 0.3);
}

.notes-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.notes-delete {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 8px;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.notes-delete:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ============================================
   Vocab View
   ============================================ */

.vocab-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.vocab-filter-btn {
  padding: 6px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.vocab-filter-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.vocab-filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.vocab-category {
  margin-bottom: 28px;
}

.vocab-cat-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(245, 182, 66, 0.15);
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

.vocab-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: all var(--transition);
}

.vocab-card:hover {
  border-color: rgba(245, 182, 66, 0.3);
  background: rgba(255, 255, 255, 0.04);
}

.vocab-card-en {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.vocab-card-jp {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-family: 'DM Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

.vocab-card.starred {
  border-color: rgba(245, 182, 66, 0.35);
  background: rgba(245, 182, 66, 0.05);
}

.vocab-star {
  color: var(--accent);
  font-size: 0.85em;
}

.vocab-card {
  cursor: pointer;
  user-select: none;
}

@media (max-width: 768px) {
  .vocab-grid {
    grid-template-columns: 1fr;
  }
  .vocab-filter {
    gap: 4px;
  }
  .vocab-filter-btn {
    font-size: 0.75rem;
    padding: 5px 10px;
  }
}

/* ============================================
   Search Modal
   ============================================ */

.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: flex;
  justify-content: center;
  padding-top: 80px;
  backdrop-filter: blur(4px);
}

.search-modal.hidden {
  display: none !important;
}

.search-modal-inner {
  width: 700px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.search-header input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

.search-header input:focus {
  border-color: var(--accent);
}

.search-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}

.search-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.search-results {
  overflow-y: auto;
  padding: 16px 20px;
  flex: 1;
}

.search-placeholder {
  color: var(--text-dim);
  text-align: center;
  padding: 32px;
  font-size: 0.9rem;
}

.search-result-card {
  padding: 14px 18px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition);
}

.search-result-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.search-result-chapter {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.search-result-snippet {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.search-result-snippet mark {
  background: rgba(245, 182, 66, 0.3);
  color: var(--text-primary);
  padding: 1px 3px;
  border-radius: 2px;
}

.search-no-results {
  color: var(--text-dim);
  text-align: center;
  padding: 32px;
  font-size: 0.9rem;
}

/* ============================================
   Exam Mode
   ============================================ */

.exam-start {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
  padding: 60px 24px;
}

.exam-start h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 16px;
}

.exam-start p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.7;
}

.exam-time-selector {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.exam-time-option {
  padding: 10px 24px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
}

.exam-time-option:hover {
  border-color: var(--accent);
}

.exam-time-option.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.exam-timer-bar {
  position: sticky;
  top: 60px;
  z-index: 500;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exam-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 80px;
}

.exam-timer.timer-low {
  color: var(--error);
  animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.exam-timer-progress {
  flex: 1;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  margin: 0 16px;
  overflow: hidden;
}

.exam-timer-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 1s linear;
}

.exam-timer-fill.timer-low {
  background: var(--error);
}

.exam-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  max-width: 100%;
}

.exam-nav-cell {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-dim);
}

.exam-nav-cell:hover {
  border-color: var(--accent);
}

.exam-nav-cell.current {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.exam-nav-cell.answered {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.exam-nav-cell.flagged {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--warning);
}

.exam-nav-cell.flagged.answered {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--warning);
}

.exam-flag-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.exam-flag-btn:hover {
  border-color: var(--warning);
  color: var(--warning);
}

.exam-flag-btn.flagged {
  border-color: var(--warning);
  background: rgba(251, 191, 36, 0.1);
  color: var(--warning);
}

.exam-scenario-label {
  font-size: 0.8rem;
  color: var(--info);
  margin-bottom: 8px;
  font-weight: 500;
}

.exam-results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.exam-result-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.exam-result-card h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.exam-result-card .result-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.exam-pass {
  color: var(--success) !important;
}

.exam-fail {
  color: var(--error) !important;
}

/* ============================================
   Practice Question Source Tabs
   ============================================ */

.practice-source-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.practice-source-tab {
  padding: 8px 18px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.practice-source-tab:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.practice-source-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 768px) {
  .nav-right {
    gap: 8px;
  }

  .search-btn {
    width: 32px;
    height: 32px;
  }

  .exam-time-selector {
    flex-direction: column;
    align-items: center;
  }

  .exam-results-grid {
    grid-template-columns: 1fr;
  }

  .exam-nav-cell {
    width: 28px;
    height: 28px;
    font-size: 0.65rem;
  }

  .practice-source-tabs {
    flex-direction: column;
  }
}
