/* ============================================================
   IELTS Academic Practice Platform — Light IELTS-style Theme
   ============================================================ */

:root {
  --bg-primary: #f5f6fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef0f5;
  --bg-card: #ffffff;
  --bg-hover: #eef1f8;
  --bg-active: #e3e8f5;

  --text-primary: #1a1a2e;
  --text-secondary: #4a4a68;
  --text-muted: #8888a0;
  --text-accent: #3b5bdb;

  --accent-primary: #3b5bdb;
  --accent-secondary: #5f3dc4;
  --accent-gradient: linear-gradient(135deg, #3b5bdb 0%, #5f3dc4 100%);
  --accent-glow: 0 0 20px rgba(59, 91, 219, 0.15);
  --accent-light: rgba(59, 91, 219, 0.08);

  --border-color: rgba(0, 0, 0, 0.08);
  --border-active: rgba(59, 91, 219, 0.35);

  --sidebar-width: 290px;
  --header-height: 54px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);

  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Merriweather', Georgia, serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* ============================================================
   TOP NAVIGATION
   ============================================================ */
#top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 32px; height: 32px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.brand-icon svg { width: 18px; height: 18px; }

.brand-text {
  font-weight: 700;
  font-size: 1rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid rgba(59,91,219,0.2);
}

.nav-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.tool-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tool-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59,91,219,0.25);
}

.tool-separator {
  width: 1px; height: 24px;
  background: var(--border-color);
  margin: 0 6px;
}

.timer-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 3px 8px 3px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.timer-display {
  font-family: 'Inter', monospace;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  min-width: 50px;
  text-align: center;
  letter-spacing: 0.05em;
}
.timer-display.warning { color: #e8590c; }
.timer-display.danger { color: #e03131; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.timer-btn { width: 28px; height: 28px; }
.timer-btn svg { width: 14px; height: 14px; }

.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.sidebar-toggle svg { width: 18px; height: 18px; }
.sidebar-toggle:hover { opacity: 0.9; transform: scale(1.03); }
.toggle-label { white-space: nowrap; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: none;
}
.sidebar.open {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}

/* Backdrop behind sidebar */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.25);
  z-index: 99;
}
.sidebar-backdrop.visible { display: block; }

.sidebar-search {
  padding: 12px;
  position: relative;
}
.sidebar-search input {
  width: 100%; height: 38px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 12px 0 36px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}
.sidebar-search input::placeholder { color: var(--text-muted); }
.sidebar-search input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-light); }
.search-icon {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}

.sidebar-filters {
  display: flex; padding: 0 12px 8px; gap: 4px;
}
.filter-btn {
  flex: 1; height: 30px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.filter-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.filter-btn.active {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 8px 20px; }

.book-group { margin-bottom: 2px; }

.book-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  user-select: none;
}
.book-header:hover { background: var(--bg-hover); }

.book-number {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-gradient);
  border-radius: 6px;
  font-weight: 800; font-size: 0.72rem; color: white;
  flex-shrink: 0;
}

.book-info { flex: 1; min-width: 0; }
.book-name { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); }
.book-year { font-size: 0.68rem; color: var(--text-muted); }

.book-chevron {
  width: 16px; height: 16px; color: var(--text-muted);
  transition: transform var(--transition-fast); flex-shrink: 0;
}
.book-group.open .book-chevron { transform: rotate(90deg); }

.book-tests { display: none; padding: 2px 0 6px 18px; }
.book-group.open .book-tests { display: block; }

.test-section-label {
  font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); padding: 8px 10px 4px;
}

.test-link {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.test-link:hover { background: var(--bg-hover); }
.test-link.active {
  background: var(--accent-light);
  border-left-color: var(--accent-primary);
}

.test-link-icon {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0;
}
.test-link-icon.reading { background: #2b8a3e; }
.test-link-icon.listening { background: #1864ab; }
.test-link-icon.writing { background: #c92a2a; }

.test-link-name {
  font-size: 0.78rem; color: var(--text-secondary);
  transition: color var(--transition-fast);
}
.test-link:hover .test-link-name { color: var(--text-primary); }
.test-link.active .test-link-name { color: var(--accent-primary); font-weight: 600; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content { flex: 1; width: 100%; overflow-y: auto; position: relative; background: var(--bg-primary); }

/* ---------- Welcome Screen ---------- */
.welcome-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100%; padding: 40px 24px;
}
.welcome-hero { text-align: center; max-width: 680px; }

.welcome-icon {
  margin: 0 auto 24px; width: 80px; height: 80px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }

.welcome-hero h1 {
  font-size: 2.2rem; font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px; letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-size: 1rem; color: var(--text-secondary);
  margin-bottom: 12px; font-weight: 500;
}
.welcome-desc {
  font-size: 0.88rem; color: var(--text-muted);
  line-height: 1.6; margin-bottom: 36px;
}

.welcome-stats { display: flex; gap: 16px; justify-content: center; margin-bottom: 40px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 28px;
  display: flex; flex-direction: column; gap: 4px;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}
.stat-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
  box-shadow: var(--accent-glow);
}

.stat-number {
  font-size: 2rem; font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-label {
  font-size: 0.72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600;
}

.welcome-features { display: flex; flex-direction: column; gap: 12px; text-align: left; }

.feature {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}
.feature:hover { border-color: var(--border-active); transform: translateX(4px); }

.feature-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.feature-icon svg { width: 20px; height: 20px; }
.feature h3 { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.feature p { font-size: 0.76rem; color: var(--text-muted); }

/* ---------- Test Container ---------- */
.test-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 32px 80px;
}
/* When reading split-pane is active, go full width */
.test-container.split-active {
  max-width: 100%;
  padding: 12px 16px 0;
}

.test-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-color);
}
.test-breadcrumb {
  font-size: 0.72rem; color: var(--text-muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.test-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }

.loading-spinner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 0; gap: 16px;
}
.loading-spinner p { color: var(--text-muted); font-size: 0.9rem; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Parsed Test Content ---------- */
.test-content {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text-primary);
}

.test-content p { margin-bottom: 14px; }
.test-content h1, .test-content h2, .test-content h3, .test-content h4 {
  font-family: var(--font-sans);
  color: var(--text-primary);
  margin: 24px 0 12px;
}
.test-content h2 { font-size: 1.3rem; }
.test-content h3 { font-size: 1.1rem; }

.test-content strong { color: var(--text-primary); }

.test-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 16px 0;
  border: 1px solid var(--border-color);
  display: block;
  background: #f0f0f0;
}

/* Tables - matching original IELTS format */
.test-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.6;
  background: var(--bg-card);
  border: 1px solid #d0d0d8;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.test-content table th,
.test-content table td {
  border: 1px solid #d0d0d8;
  padding: 10px 16px;
  text-align: left;
  vertical-align: top;
}
.test-content table th {
  background: #eef0f5;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.test-content table tr:nth-child(even) {
  background: #fafbfd;
}
.test-content table tr:hover {
  background: #f0f2f8;
}
.test-content table td:first-child {
  font-weight: 500;
}

/* Responsive tables */
.test-content .table-wrapper {
  overflow-x: auto;
  margin: 16px 0;
  -webkit-overflow-scrolling: touch;
}

/* Lists inside test content */
.test-content ul, .test-content ol {
  margin: 12px 0 12px 24px;
}
.test-content li {
  margin-bottom: 6px;
}

/* Audio player for listening tests */
.test-content audio,
.ielts-audio-player {
  width: 100%;
  margin: 16px 0;
  border-radius: var(--radius-md);
}

.audio-wrapper {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.audio-wrapper label {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   SPLIT-PANE READING LAYOUT
   ============================================================ */
.test-split {
  display: flex;
  height: calc(100vh - var(--header-height) - 70px);
  gap: 0;
  overflow: hidden;
}

.split-passage,
.split-questions {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 280px;
  overflow: hidden;
}

.split-pane-header {
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  background: var(--bg-tertiary);
  border-bottom: 2px solid var(--accent-primary);
  flex-shrink: 0;
}

.split-pane-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 60px;
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text-primary);
}
.split-pane-content p { margin-bottom: 14px; }
.split-pane-content h2, .split-pane-content h3, .split-pane-content h4 {
  font-family: var(--font-sans);
  color: var(--text-primary);
  margin: 20px 0 10px;
}
.split-pane-content strong { color: var(--text-primary); }
.split-pane-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  border: 1px solid var(--border-color);
}
.split-pane-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.6;
  background: var(--bg-card);
  border: 1px solid #d0d0d8;
}
.split-pane-content table th,
.split-pane-content table td {
  border: 1px solid #d0d0d8;
  padding: 8px 14px;
  text-align: left;
}
.split-pane-content table th {
  background: #eef0f5;
  font-weight: 700;
}

/* Divider */
.split-divider {
  width: 6px;
  background: var(--bg-tertiary);
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}
.split-divider:hover,
.split-divider.dragging {
  background: var(--accent-light);
}
.divider-grip {
  width: 3px;
  height: 36px;
  border-radius: 2px;
  background: rgba(0,0,0,0.15);
}

/* ============================================================
   INTERACTIVE ANSWER FIELDS (Questions pane)
   ============================================================ */
.question-group {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}
.question-group:last-child { border-bottom: none; }

.question-group-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 6px;
}
.question-group-instruction {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-primary);
}
.question-group-instruction.embedded-notes {
  font-size: 0.9rem;
  color: var(--text-primary);
  padding: 14px 18px;
}
.question-group-instruction.embedded-notes p {
  margin: 0 0 10px 0;
}
.question-group-instruction.embedded-notes p:last-child { margin-bottom: 0; }
.question-group-instruction.embedded-notes table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}
.question-group-instruction.embedded-notes td,
.question-group-instruction.embedded-notes th {
  border: 1px solid var(--border-color, #ddd);
  padding: 6px 10px;
  font-size: 0.85rem;
}

.matching-list {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color, #e1e4e8);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 0 0 16px 0;
}
.matching-list-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.matching-list-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 16px;
}
.matching-list-items li {
  font-size: 0.88rem;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
}
.matching-list-items .ml-letter {
  font-weight: 700;
  color: var(--accent-primary);
  min-width: 18px;
}

/* Images that belong to the question side (diagrams, charts, tables-as-images) */
.question-group-images {
  margin: 0 0 16px 0;
}
.q-images {
  margin: 8px 0 10px;
}
.question-group-images img,
.q-images img,
.question-group-instruction.embedded-notes img {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--border-color, #e1e4e8);
  border-radius: var(--radius-sm);
  margin: 8px 0;
}
.question-group-instruction.embedded-notes .table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Original question prompts shown inline within the passage panel
   (so the user can verify questions against passage text) */
.passage-question-block {
  background: #fff8e7;
  border-left: 3px solid #f3b73c;
  border-radius: 4px;
  padding: 8px 14px;
  margin: 12px 0;
  font-size: 0.92rem;
}
.passage-question-block p {
  margin: 4px 0;
}
.passage-question-block strong {
  color: #8a5a00;
}

.question-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.question-item:hover {
  background: var(--bg-hover);
}

.question-number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  color: white;
  border-radius: 50%;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
}

.question-text {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.q-statement {
  margin-bottom: 10px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Fill-in-the-blank input */
.answer-input {
  display: inline-block;
  width: 180px;
  height: 32px;
  border: 2px solid #d0d0d8;
  border-radius: 4px;
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: white;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  vertical-align: middle;
}
.answer-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.answer-input.correct {
  border-color: #2b8a3e;
  background: #ebfbee;
  color: #2b8a3e;
}
.answer-input.incorrect {
  border-color: #e03131;
  background: #fff5f5;
  color: #e03131;
}

/* Multiple choice radio/select */
.answer-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.answer-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: background var(--transition-fast);
  border: 1px solid transparent;
}
.answer-option:hover {
  background: var(--bg-hover);
}
.answer-option input[type="radio"] {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.answer-option.selected {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--text-primary);
  font-weight: 600;
}
.answer-option.correct-option {
  background: #ebfbee;
  border-color: #2b8a3e;
  color: #2b8a3e;
}
.answer-option.incorrect-option {
  background: #fff5f5;
  border-color: #e03131;
  color: #e03131;
}
/* Revealed (via Show Answers) — correct option, dashed to distinguish from a
   graded result. */
.answer-option.reveal-correct {
  background: #ebfbee;
  border: 2px dashed #2b8a3e;
  color: #2b8a3e;
  font-weight: 600;
}
/* Inline pill showing the exact official answer next to each question. */
.answer-reveal {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  background: #ebfbee;
  border: 1px solid #2b8a3e;
  border-radius: 999px;
  color: #1f6b30;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
}

/* Select dropdown */
.answer-select {
  height: 32px;
  border: 2px solid #d0d0d8;
  border-radius: 4px;
  padding: 0 8px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: white;
  outline: none;
  cursor: pointer;
  min-width: 120px;
}
.answer-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Check Answers button */
.check-answers-bar {
  position: sticky;
  bottom: 0;
  padding: 12px 20px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 5;
}
.btn-check-answers {
  padding: 8px 22px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(59,91,219,0.25);
}
.btn-check-answers:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59,91,219,0.35);
}
.btn-show-answers {
  padding: 8px 18px;
  background: transparent;
  color: #2b8a3e;
  border: 1px solid #2b8a3e;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-show-answers:hover {
  background: #ebfbee;
}
.btn-show-answers.active {
  background: #2b8a3e;
  color: white;
}
.btn-reset-answers {
  padding: 8px 18px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.score-display {
  margin-left: auto;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-primary);
}

/* ---- Listening: Check Answers toggle + official answer key ---- */
.listening-check-btn {
  display: inline-block;
  margin: 22px 0 4px;
}
.listening-answer-key {
  display: none;
  margin: 10px 0 24px;
  padding: 16px 20px;
  background: #ebfbee;
  border: 1px solid #2b8a3e;
  border-radius: var(--radius-md, 12px);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--text-primary);
}
.listening-answer-key.visible { display: block; }
.listening-answer-key p { margin: 0; }
.listening-answer-key ol { margin: 0; padding-left: 22px; }

/* ============================================================
   HIGHLIGHTING & MARKING
   ============================================================ */
.ielts-highlight {
  border-radius: 2px; padding: 1px 0;
  transition: background var(--transition-fast);
  cursor: pointer;
}
.ielts-highlight:hover { filter: brightness(0.95); }

.ielts-underline {
  text-decoration: underline;
  text-decoration-color: var(--accent-primary);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.ielts-strikethrough {
  text-decoration: line-through;
  text-decoration-color: #e03131;
  text-decoration-thickness: 2px;
  opacity: 0.45;
  cursor: pointer;
}

/* ============================================================
   CONTEXT MENU
   ============================================================ */
.context-menu {
  position: fixed; z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  display: flex; gap: 2px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:translateY(0)} }

.context-menu button {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  border-radius: 4px; cursor: pointer;
  transition: background var(--transition-fast);
  color: var(--text-secondary);
}
.context-menu button:hover { background: var(--bg-hover); }

.cm-swatch {
  display: block; width: 18px; height: 18px;
  border-radius: 4px; border: 1px solid rgba(0,0,0,0.15);
}

/* ============================================================
   DRAWING CANVAS OVERLAY — fixed viewport overlay
   ============================================================ */
#draw-canvas { display: none; } /* legacy fixed overlay — replaced by per-pane canvases */

/* Per-pane drawing canvas: lives INSIDE each scrolling pane so strokes
   scroll with the text (like highlights), instead of floating on a fixed
   viewport overlay. */
.split-pane-content { position: relative; }
.pane-draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  pointer-events: none;
  touch-action: none;
}
.pane-draw-canvas.active {
  pointer-events: auto;
  cursor: crosshair;
}
.pane-draw-canvas.eraser-active {
  pointer-events: auto;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='white' stroke='%23333' stroke-width='1.5'%3E%3Crect x='4' y='4' width='16' height='16' rx='3'/%3E%3C/svg%3E") 12 12, auto;
}

/* ============================================================
   INTERACTIVE WRITING TEST
   ============================================================ */
.writing-test { max-width: 1400px; margin: 0 auto; padding: 8px 4px 40px; }

.writing-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0;
}
.writing-tab {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 22px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.writing-tab:hover { color: var(--text-primary); }
.writing-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.writing-instruction {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 20px;
  margin-bottom: 14px;
}
.writing-instruction h3 {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px;
}
.writing-instruction p {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0;
}

.writing-split {
  display: flex;
  gap: 18px;
  align-items: stretch;
  min-height: 60vh;
}
.writing-prompt,
.writing-answer { flex: 1; min-width: 0; }

.writing-prompt {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 22px 24px;
  overflow-y: auto;
  max-height: 72vh;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text-primary);
}
.writing-prompt p { margin: 0 0 14px; font-weight: 600; }
.writing-prompt p:last-child { margin-bottom: 0; }
.writing-figure { margin: 16px 0 4px; text-align: center; }
.writing-figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #fff;
  padding: 8px;
}

.writing-answer { display: flex; flex-direction: column; }
.writing-textarea {
  flex: 1;
  width: 100%;
  min-height: 60vh;
  resize: vertical;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px 18px;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-secondary);
  outline: none;
  box-sizing: border-box;
}
.writing-textarea:focus { border-color: var(--accent-primary); }

.writing-wordcount {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 10px 4px 0;
}
.writing-wordcount .wc-num { color: var(--text-primary); }
.writing-wordcount .wc-num.wc-met { color: #1a9e54; }
.writing-wordcount .wc-target { color: var(--text-muted); font-weight: 600; }

@media (max-width: 880px) {
  .writing-split { flex-direction: column; min-height: 0; }
  .writing-prompt { max-height: none; }
  .writing-textarea { min-height: 40vh; }
}

/* Drawing tool inputs in toolbar */
.draw-color-input {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
}
.draw-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.draw-color-input::-webkit-color-swatch { border: none; border-radius: 2px; }

.draw-size-select {
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0 4px;
  cursor: pointer;
  outline: none;
}
.draw-size-select:focus { border-color: var(--accent-primary); }

/* Active draw mode indicator on body */
body.draw-mode .main-content { user-select: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: var(--header-height); left: 0; bottom: 0;
    z-index: 90; box-shadow: var(--shadow-lg);
  }
  .sidebar.collapsed { transform: translateX(-100%); }
  .brand-badge { display: none; }
  .test-container { padding: 16px 16px 60px; }
  .welcome-hero h1 { font-size: 1.6rem; }
  .welcome-stats { flex-direction: column; align-items: center; }
  .draw-size-select { display: none; }
}
@media (max-width: 480px) {
  .timer-group { display: none; }
  .draw-color-input { display: none; }
}
