/* ═══════════════════════════════════════════════════════
   Linguistics Revision App — Material 3 Design System
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Light Mode Colors (Material 3) */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F4F5F7;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F9FAFB;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --bg-glass-border: rgba(0, 0, 0, 0.08);
  --bg-overlay: rgba(0, 0, 0, 0.4);

  --text-primary: #1C1B1F;
  --text-secondary: #49454F;
  --text-muted: #79747E;
  --text-light: #9CA3AF;

  --accent-primary: #FFB300;
  /* Material Yellow */
  --accent-secondary: #FFC107;
  --accent-gradient: linear-gradient(135deg, #FFC107 0%, #FFB300 100%);
  --accent-glow: rgba(255, 179, 0, 0.2);

  --success: #34A853;
  --success-bg: rgba(52, 168, 83, 0.1);
  --success-border: rgba(52, 168, 83, 0.3);
  --error: #EA4335;
  --error-bg: rgba(234, 67, 53, 0.1);
  --error-border: rgba(234, 67, 53, 0.3);
  --warning: #FBBC04;

  --border: #E5E7EB;
  --border-strong: #D1D5DB;

  /* Material Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 12px var(--accent-glow);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --font: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  --header-h: 64px;
  --nav-h: 72px;
}

/* ── Dark Mode ── */
body.dark-mode {
  --bg-primary: #121212;
  --bg-secondary: #1E1E1E;
  --bg-card: #1E1E1E;
  --bg-card-hover: #2C2C2C;
  --bg-glass: rgba(30, 30, 30, 0.85);
  --bg-glass-border: rgba(255, 255, 255, 0.1);
  --bg-overlay: rgba(0, 0, 0, 0.6);

  --text-primary: #E3E3E3;
  --text-secondary: #C4C7C5;
  --text-muted: #8E918F;
  --text-light: #5F6368;

  --accent-primary: #FFCA28;
  --accent-secondary: #FFD54F;
  --accent-gradient: linear-gradient(135deg, #FFD54F 0%, #FFCA28 100%);
  --accent-glow: rgba(255, 202, 40, 0.15);

  --border: #3A3A3A;
  --border-strong: #4F4F4F;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.6);
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

/* ── App Shell ── */
#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: var(--nav-h);
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo img {
  height: 30px;
  width: auto;
  object-fit: contain;
  filter: var(--logo-filter, none);
}

body.dark-mode .header-logo img {
  filter: invert(1);
}

#theme-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition);
}

#theme-toggle:hover {
  background: var(--bg-secondary);
}

#theme-toggle .icon-sun,
#theme-toggle .icon-moon {
  position: absolute;
  width: 24px;
  height: 24px;
  transition: all var(--transition);
}

#theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

#theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

body.dark-mode #theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

body.dark-mode #theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ── Views ── */
.view {
  display: none;
  padding: 24px;
  animation: fadeSlideIn 0.3s ease-out;
}

.view.active {
  display: block;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Bottom Navigation ── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 800px;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
  transition: transform var(--transition);
}

#bottom-nav.hidden {
  transform: translateX(-50%) translateY(100%);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 24px;
  border-radius: var(--radius-full);
  transition: all var(--transition);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
}

.nav-item.active {
  color: var(--text-primary);
  background: var(--accent-glow);
}

.nav-item.active svg {
  fill: var(--accent-primary);
  stroke: var(--accent-primary);
}

/* ── Home View ── */
.welcome-section {
  margin-bottom: 32px;
}

#greeting-text {
  font-size: 2rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.countdown-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--accent-glow);
  border-radius: var(--radius-full);
  color: var(--text-primary);
}

.countdown-wrapper svg {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

#countdown-text {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Mode Cards ── */
.modes-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.mode-card:hover {
  box-shadow: var(--shadow-md);
}

.mode-card-header {
  display: flex;
  align-items: center;
  padding: 20px;
  cursor: pointer;
  gap: 16px;
}

.mode-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

.mode-icon svg {
  width: 32px;
  height: 32px;
}

.mode-info {
  flex: 1;
}

.mode-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.mode-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.mode-stats {
  text-align: right;
}

.mode-stats .stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.mode-stats .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mode-stats .stat-time {
  font-size: 0.75rem;
  color: var(--text-light);
  min-height: 1.2em;
}

/* Practice types */
.practice-types {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition);
}

.practice-types.expanded {
  max-height: 400px;
}

.practice-types-inner {
  padding: 0 20px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.practice-type-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.practice-type-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
}

.practice-type-btn svg {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.practice-type-btn .type-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.expand-indicator {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.mode-card.expanded .expand-indicator {
  transform: rotate(180deg);
}

/* Exam Card Button */
.exam-start-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--accent-primary);
  color: #000000;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
}

.mode-card.expanded .exam-start-btn {
  opacity: 1;
  max-height: 60px;
  padding: 14px;
  margin-bottom: 20px;
  pointer-events: auto;
}

.exam-start-btn:hover {
  filter: brightness(1.05);
  box-shadow: var(--shadow-md);
}

/* ── Footer ── */
.home-footer {
  margin-top: 48px;
  padding: 24px 0;
  text-align: center;
  border-top: 1px solid var(--border);
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.footer-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.footer-link:hover {
  color: var(--text-primary);
}

.footer-divider {
  color: var(--border-strong);
}

.footer-copyright {
  font-size: 0.8rem;
  color: var(--text-light);
}

.footer-watermark {
  display: block;
  margin: 16px auto 0;
  height: 32px;
  width: auto;
  opacity: 0.15;
  filter: var(--logo-filter, none);
}

body.dark-mode .footer-watermark {
  filter: invert(1);
  opacity: 0.1;
}

/* ── Quiz View ── */
#view-quiz {
  padding: 0;
}

.quiz-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.quiz-header-left,
.quiz-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#quiz-exit-btn,
#quiz-overview-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition);
}

#quiz-exit-btn:hover,
#quiz-overview-btn:hover {
  background: var(--bg-secondary);
}

#quiz-timer,
#quiz-progress {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.quiz-progress-bar-track {
  height: 4px;
  background: var(--bg-secondary);
  position: relative;
}

#quiz-progress-bar {
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.3s ease;
  width: 0%;
}

/* Overview Panel */
#quiz-overview-panel {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right var(--transition);
  padding: 80px 24px 24px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  visibility: hidden;
  pointer-events: none;
}

#quiz-overview-panel.open {
  right: 0;
  visibility: visible;
  pointer-events: auto;
}

.overview-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.overview-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.overview-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.question-num {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.question-num:hover {
  background: var(--bg-secondary);
}

.question-num.current {
  border-color: var(--accent-primary);
  border-width: 2px;
  color: var(--text-primary);
}

.question-num.answered {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.question-num.wrong {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

/* Question Area */
.question-area {
  padding: 32px 24px;
  min-height: calc(100vh - var(--header-h) - 120px);
}

.question-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 20px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

#question-text {
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 32px;
}

/* Options */
#options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text-primary);
  text-align: left;
  line-height: 1.5;
}

.option-btn:hover:not(.disabled) {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.option-key {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

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

.option-btn.wrong {
  border-color: var(--error);
  background: var(--error-bg);
  animation: shake 0.4s ease;
}

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

.option-btn.disabled {
  cursor: default;
  opacity: 0.6;
  pointer-events: none;
}

/* Fill-in */
#fill-container {
  display: none;
}

#fill-container.active {
  display: block;
}

.fill-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fill-input {
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: all var(--transition);
}

.fill-input:focus {
  border-color: var(--accent-primary);
  border-width: 2px;
  padding: 15px 19px;
}

.fill-input.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.fill-input.wrong {
  border-color: var(--error);
  animation: shake 0.4s ease;
}

.fill-attempts {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

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

.attempt-dot.used {
  background: var(--error);
}

/* Exam Nav */
.exam-nav {
  display: none;
  padding: 16px 24px;
  gap: 16px;
  position: sticky;
  bottom: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

.exam-nav.active {
  display: flex;
}

.exam-nav-btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}

.exam-nav-btn:hover {
  background: var(--bg-secondary);
}

.exam-nav-btn.primary {
  background: var(--accent-primary);
  color: #000;
  border: none;
}

.exam-nav-btn.primary:hover {
  filter: brightness(1.05);
}

.exam-nav-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

/* ── Results View ── */
.results-header {
  text-align: center;
  padding: 24px 0 32px;
}

.results-title {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.results-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

.score-circle-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

.score-circle {
  position: relative;
  width: 180px;
  height: 180px;
}

.score-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-circle .track {
  fill: none;
  stroke: var(--bg-secondary);
  stroke-width: 10;
}

.score-circle .progress {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 440;
  stroke-dashoffset: 440;
  transition: stroke-dashoffset 1s ease-out;
}

.score-circle .score-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-value {
  font-size: 2.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.score-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  text-align: center;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.stat-card .stat-num {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.stat-card .stat-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-card.correct-stat .stat-num {
  color: var(--success);
}

.stat-card.wrong-stat .stat-num {
  color: var(--error);
}

.stat-card.time-stat .stat-num {
  color: var(--accent-primary);
}

.results-wrong-title {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.wrong-count {
  background: var(--error-bg);
  color: var(--error);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
}

.wrong-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.wrong-item-question {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.wrong-item-answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wrong-answer-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.9rem;
}

.wrong-answer-row .label {
  font-weight: 500;
  min-width: 64px;
}

.wrong-answer-row.user .label {
  color: var(--error);
}

.wrong-answer-row.correct .label {
  color: var(--success);
}

.wrong-answer-row .value {
  color: var(--text-secondary);
  flex: 1;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
}

.results-btn {
  padding: 16px;
  border-radius: var(--radius-full);
  border: none;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}

.results-btn.primary {
  background: var(--accent-primary);
  color: #000;
}

.results-btn.primary:hover {
  filter: brightness(1.05);
}

.results-btn.secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.results-btn.secondary:hover {
  background: var(--border);
}

/* ── Error Book View ── */
.errorbook-header {
  margin-bottom: 24px;
}

.errorbook-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.errorbook-title {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0;
  min-width: 0;
}

.errorbook-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-group {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  padding: 4px;
}

.filter-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.filter-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.errorbook-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.errorbook-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
}

.error-date-group {
  margin-bottom: 32px;
}

.error-date-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.error-source-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  background: var(--bg-secondary);
}

#clear-errorbook-btn {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: auto;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--error);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  margin: 0;
  white-space: nowrap;
  line-height: 1.2;
}

#clear-errorbook-btn:hover {
  background: var(--error-bg);
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-spring);
}

.modal-overlay.open .modal-content {
  transform: scale(1);
}

.modal-content.modal-large {
  max-width: 500px;
}

.scrollable-message {
  max-height: 50vh;
  overflow-y: auto;
  text-align: left;
  margin-bottom: 24px;
  padding-right: 8px;
}

.scrollable-message h3 {
  font-size: 1rem;
  color: var(--text-primary);
  margin: 16px 0 8px;
}

.scrollable-message p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  color: var(--accent-primary);
}

.modal-icon.warning {
  color: var(--warning);
}

.modal-icon.error {
  color: var(--error);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.modal-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  padding: 10px 24px;
  border-radius: var(--radius-full);
  border: none;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--accent-primary);
}

.modal-btn:hover {
  background: var(--accent-glow);
}

.modal-btn.danger {
  color: var(--error);
}

.modal-btn.danger:hover {
  background: var(--error-bg);
}

.modal-btn.confirm {
  background: var(--accent-primary);
  color: #000;
}

.modal-btn.confirm:hover {
  filter: brightness(1.05);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition);
  z-index: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Hidden helper ── */
.hidden {
  display: none !important;
}