/* ============================================
   수능 단어장 생성기 — LECTA Minimalist Design
   Inspired by: LECTA Educational Platform
   Color Palette: Blue / Cyan / Red Accent
   ============================================ */

/* Import Google Fonts for LECTA feel: Montserrat (Futura equivalent) & Lato */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800;900&family=Lato:wght@300;400;700;900&display=swap');

:root {
  /* LECTA Color Palette */
  --blue-primary: #106BD6;
  --blue-secondary: #2D8EFF;
  --cyan-light: #8FDCFF;
  --cyan-pale: #D4FAFD;
  
  --red-accent: #FF5959;
  --red-light: #FF8282;

  --navy-dark: #091528;
  --navy: #17233A;
  --slate: #374865;
  --gray: #6D7187;
  
  --border-color: #DBDCE2;
  --bg-page: #FFFFFF;
  --bg-body: #F0F0F3;

  /* Legacy re-mapping to safely migrate the existing classes without breaking them immediately */
  --purple-main: var(--blue-primary);
  --purple-dark: var(--navy-dark);
  --purple-mid: var(--blue-secondary);
  --purple-light: var(--cyan-pale);
  --purple-pale: #F8FBFF;

  --yellow-main: var(--cyan-light);
  --yellow-dark: var(--blue-primary);
  --yellow-light: var(--bg-page);

  --text-main: var(--navy);
  --text-muted: var(--gray);
  
  /* Semantic Colors for Table Cells */
  --synonym-bg: var(--cyan-pale);     
  --synonym-text: var(--navy-dark);
  --antonym-bg: #F8FBFF;      
  --antonym-text: var(--slate);
  --confusable-bg: #FFF0F0;   
  --confusable-text: var(--navy-dark);

  /* Typography */
  --font-heading: 'Montserrat', sans-serif;
  --font-main: 'Lato', sans-serif;

  /* Shadows - modern & soft */
  --shadow-book: 0 10px 40px rgba(16, 107, 214, 0.08);
  --shadow-sm: 0 4px 12px rgba(9, 21, 40, 0.05);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 50px;
}

/* ========================
   Reset & Base
   ======================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Pretendard', 'Noto Sans KR', var(--font-main);
  background: #f7f8fa;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  padding: 0;
  margin: 0;
}

.container {
  max-width: 100%;
  margin: 0;
  background: #f7f8fa;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  border: none;
}

.hidden {
  display: none !important;
}

/* ========================
   Header — Branding + Tabs (always visible, same on both pages)
   ======================== */
.header {
  text-align: center;
  padding: 15px 20px 8px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  overflow: hidden;
}

/* Branding area inside header */
.header-branding {
  position: relative;
  margin-bottom: 8px;
}

.header-logo {
  position: absolute;
  top: 15px;
  right: 170px; /* To prevent overlapping with history/settings buttons */
  height: 30px;
  z-index: 20;
}

.header-pretitle-wrapper {
  margin-bottom: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-pretitle {
  font-size: 13px;
  font-weight: 700;
  color: #79869a;
  border: 1px solid #d1d5db;
  padding: 4px 12px;
  border-radius: 4px;
}

.header-branding h1 {
  font-size: 26px;
  font-weight: 900;
  /* Gold Gradient Typography */
  background: linear-gradient(to right, #9A7B39, #E6D070, #947126);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  font-family: 'Pretendard', 'Noto Sans KR', var(--font-heading);
  letter-spacing: -0.5px;
  margin-bottom: 2px;
  position: relative;
  z-index: 2;
}

.subtitle {
  color: #17B169;
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
  margin-bottom: 0;
  z-index: 2;
  position: relative;
}

/* Module Tabs in Header */
.module-tabs {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 0;
}

.module-btn {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f8f9fa;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.module-btn.active {
  background: #D8C3A5; /* beige color */
  border-color: #C0A080;
  color: #4A3B2C;
}

.module-btn.dark {
  background: #1A2530;
  border-color: #1A2530;
  color: #fff;
}

.module-btn.disabled {
  opacity: 0.6;
}

.module-btn:hover:not(.active):not(.dark):not(.disabled) {
  background: #eaeaea;
}

/* ========================
   Content Sections
   ======================== */
.input-section,
.options-section,
.passages-section,
.progress-section,
.results-section {
  padding: 0 40px 40px;
}

/* Title bars for sections */
.options-section h3,
.passages-section h3,
.results-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--purple-main);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.options-section h3::before,
.passages-section h3::before,
.results-header h3::before {
  content: '▶';
  color: var(--yellow-main);
  font-size: 14px;
}

/* ========================
   Input Tabs
   ======================== */
.input-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.tab-btn {
  padding: 12px 24px;
  border: 2px solid var(--purple-light);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--purple-pale);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 700;
  color: var(--purple-mid);
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--purple-main);
  color: #fff;
  border-color: var(--purple-main);
}

.tab-btn:hover:not(.active) {
  background: var(--purple-light);
}

.tab-content {
  background: #fff;
  border: 2px solid var(--purple-main);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* Textarea */
#passage-input {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 15px;
  resize: vertical;
  min-height: 220px;
  line-height: 1.8;
  color: var(--text-main);
  background: #FAFAFA;
}

#passage-input:focus {
  outline: none;
  border-color: var(--purple-main);
  background: #fff;
}

/* ========================
   Upload Area
   ======================== */
.upload-area {
  border: 2px dashed var(--purple-mid);
  border-radius: var(--radius-sm);
  padding: 50px;
  text-align: center;
  cursor: pointer;
  background: var(--purple-pale);
  transition: all 0.2s;
}

.upload-area:hover, .upload-area.dragover {
  background: var(--purple-light);
  border-color: var(--purple-main);
}

.upload-icon {
  font-size: 48px;
  color: var(--purple-main);
  margin-bottom: 10px;
}

.upload-area p {
  color: var(--purple-dark);
  font-weight: 700;
  font-size: 16px;
}

.upload-hint {
  color: var(--purple-mid) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  margin-top: 8px;
}

.file-info {
  margin-top: 20px;
  padding: 12px;
  background: var(--yellow-light);
  border-radius: var(--radius-sm);
  color: var(--antonym-text);
  font-weight: 700;
  border: 1px solid var(--yellow-main);
}

/* Text Stats Bar */
.text-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 10px 16px;
  background: #f0f4ff;
  border: 1px solid var(--blue-primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

.text-stats-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.text-stats-left span {
  font-size: 15px;
  font-weight: 800;
  color: var(--navy-dark);
}

.text-stats-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--gray);
}

.text-stats-ok {
  color: #16a34a;
  font-weight: 800;
}

.text-stats-over {
  color: #e53e3e;
  font-weight: 800;
  animation: pulse-warn 1s infinite;
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ========================
   Options Panel
   ======================== */
.options-grid {
  display: flex;
  gap: 30px;
  background: var(--purple-pale);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--purple-light);
}

/* Wide layout: 3-column grid for options above input */
.options-wide {
  max-width: 100%;
}
.options-grid-wide {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  align-items: start;
}
.options-grid-wide .option-group {
  padding: 12px 16px;
  border-right: 1px solid var(--purple-light);
}
.options-grid-wide .option-group:last-child {
  border-right: none;
}
.options-grid-wide .option-group h4 {
  margin-bottom: 8px;
}
.options-grid-wide .option-group .option-items-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
}
@media (max-width: 700px) {
  .options-grid-wide {
    grid-template-columns: 1fr;
  }
  .options-grid-wide .option-group {
    border-right: none;
    border-bottom: 1px solid var(--purple-light);
  }
}

.option-group h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--purple-dark);
  margin-bottom: 12px;
  background: var(--yellow-main);
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.option-item input[type="checkbox"],
.option-item input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--purple-main);
}

.option-sub {
  margin-left: 28px;
  display: flex;
  gap: 16px;
  padding: 2px 0 4px;
}

.option-item-sub {
  font-size: 13px !important;
  color: var(--slate) !important;
}

.option-sub.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ========================
   HERO SECTION
   ======================== */
.hero {
  padding: 48px 32px 36px;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 50%, #f5f0ff 100%);
  border-radius: var(--radius-lg); margin-bottom: 24px;
  border: 1px solid var(--purple-light);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -60px; right: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,0.08), transparent);
}
.hero-content-wrap {
  display: flex; align-items: center; gap: 40px;
  max-width: 1100px; margin: 0 auto;
}
.hero-text-side { flex: 1; text-align: left; }
.hero-image-side { flex: 0 0 400px; text-align: center; }
.hero-img {
  max-width: 100%; height: auto; border-radius: 16px;
  filter: drop-shadow(0 8px 24px rgba(124,58,237,0.15));
  animation: heroFloat 3s ease-in-out infinite;
}
@media (max-width: 768px) {
  .hero-content-wrap { flex-direction: column; }
  .hero-text-side { text-align: center; }
  .hero-image-side { flex: 0 0 auto; }
  .hero-img { max-width: 280px; }
}
.hero-badge {
  display: inline-block; background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f; font-size: 12px; font-weight: 800; padding: 4px 14px;
  border-radius: 20px; margin-bottom: 16px;
}
.hero-title {
  font-size: 32px; font-weight: 900; color: var(--text-main);
  line-height: 1.4; margin-bottom: 8px;
}
.hero-accent { color: #7c3aed; }
.hero-sub {
  font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6;
}

.hero-cta-group {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.hero-cta-btn {
  padding: 14px 32px; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 800; cursor: pointer;
  background: var(--purple-main);
  color: #fff; font-family: inherit; position: relative;
  box-shadow: 0 6px 24px rgba(124,58,237,0.4);
  transition: all 0.3s; display: flex; flex-direction: column; align-items: center;
}
.hero-cta-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 32px rgba(124,58,237,0.5);
}
.hero-cta-sub { font-size: 11px; font-weight: 400; opacity: 0.8; }
.hero-cta-secondary {
  background: #fff; color: var(--purple-main);
  border: 2px solid var(--purple-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.hero-cta-secondary:hover {
  background: var(--purple-pale);
  box-shadow: 0 4px 16px rgba(124,58,237,0.15);
}

.hero-features {
  display: flex; gap: 16px; flex-wrap: wrap;
  margin-bottom: 0;
}
.hero-feature {
  font-size: 13px; font-weight: 600; color: #475569;
}
@keyframes heroFloat {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ========================
   LIVE DEMO OVERLAY
   ======================== */
.demo-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.demo-panel {
  background: #fff; border-radius: 20px; max-width: 95vw; width: 100%;
  max-height: 90vh; overflow-y: auto; padding: 32px; position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}
.demo-close {
  position: absolute; top: 16px; right: 16px; background: none;
  border: none; font-size: 24px; cursor: pointer; color: #94a3b8;
}
.demo-title {
  font-size: 22px; font-weight: 900; color: var(--text-main);
  text-align: center; margin-bottom: 4px;
}
.demo-sub {
  text-align: center; color: var(--text-muted); font-size: 14px;
  margin-bottom: 20px;
}
.demo-input-area { margin-bottom: 20px; }
.demo-label {
  font-size: 13px; font-weight: 700; color: var(--purple-main); margin-bottom: 8px;
}
.demo-textarea {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 14px; min-height: 100px; font-size: 13px; line-height: 1.7;
  color: #334155; font-family: 'Lato', sans-serif;
}
.demo-progress-bar {
  height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden;
  margin-bottom: 8px;
}
.demo-progress-fill {
  height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  transition: width 0.3s;
}
.demo-progress-text {
  font-size: 13px; color: var(--purple-main); font-weight: 600;
  text-align: center;
}
.demo-results-header {
  font-size: 15px; font-weight: 700; color: #16a34a;
  margin-bottom: 16px; text-align: center;
}
.demo-results-list {
  max-height: 400px; overflow: auto; margin-bottom: 20px;
  border: 1px solid #e2e8f0; border-radius: 8px;
}
@keyframes demoSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.demo-cta-area { text-align: center; padding-top: 12px; border-top: 1px solid #e2e8f0; }
.demo-toggles {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.demo-download-btns {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 4px;
}
.demo-cta-text {
  font-size: 15px; font-weight: 700; color: var(--text-main); margin-bottom: 12px;
}

/* ========================
   GUIDE TOUR
   ======================== */
.tour-overlay { position: fixed; inset: 0; z-index: 10001; }
.tour-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  transition: clip-path 0.4s ease;
}
.tour-tooltip {
  position: fixed; background: #fff; border-radius: 14px;
  padding: 20px 24px; max-width: 360px; width: calc(100% - 32px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
  z-index: 10002; transition: all 0.4s ease;
  box-sizing: border-box;
}
.tour-step-indicator {
  font-size: 11px; font-weight: 800; color: var(--purple-main);
  margin-bottom: 8px;
}
.tour-text {
  font-size: 15px; font-weight: 600; color: var(--text-main);
  line-height: 1.6; margin-bottom: 16px;
}
.tour-btns { display: flex; gap: 8px; justify-content: flex-end; }
.tour-btn {
  padding: 10px 20px; border: 1px solid #e2e8f0; border-radius: 8px;
  background: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: inherit; color: var(--text-main); transition: all 0.2s;
}
.tour-btn:hover { border-color: var(--purple-main); }
.tour-btn-primary {
  background: var(--purple-main); color: #fff; border-color: var(--purple-main);
}
.tour-btn-primary:hover { background: #6d28d9; }

/* Mobile: fix tooltip to bottom of screen */
@media (max-width: 768px) {
  .tour-tooltip {
    bottom: 16px !important;
    top: auto !important;
    left: 50% !important;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    border-radius: 16px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
  }
  .tour-text { font-size: 14px; }
  .tour-btn { padding: 12px 20px; min-height: 44px; }
}

/* Signup */
.signup-label {
  font-size: 13px; font-weight: 700; color: var(--text-main);
  display: block; margin-bottom: 4px;
}

/* ========================
   Passages List
   ======================== */
.passages-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.passage-count {
  font-size: 14px;
  color: var(--purple-main);
  margin-left: auto;
  font-weight: 700;
  background: var(--yellow-light);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

.passages-list {
  max-height: 350px;
  overflow-y: auto;
  padding-right: 5px;
}

.passage-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px;
  border: 2px solid var(--purple-light);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: #fff;
  transition: border-color 0.2s;
}

.passage-item:hover {
  border-color: var(--purple-main);
}

.passage-item.skipped {
  opacity: 0.6;
  background: #f9f9f9;
  border-color: #eee;
}

.passage-item input[type="checkbox"] {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  accent-color: var(--purple-main);
}

.passage-title {
  font-weight: 800;
  font-size: 16px;
  color: var(--purple-dark);
  margin-bottom: 4px;
}

.passage-preview {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.passage-skip-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  background: #EEEEEE;
  color: #666;
  font-weight: 700;
}

/* ========================
   Buttons
   ======================== */
.btn {
  padding: 10px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  transition: all 0.2s;
}

.btn:hover {
  background: var(--blue-primary);
  border-color: var(--blue-primary);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.action-bar {
  text-align: center;
  padding: 0 40px 40px;
  display: flex;
  gap: 15px;
  justify-content: center;
}

.btn-primary {
  background: var(--blue-primary);
  color: #fff;
  border: 1px solid var(--blue-primary);
  padding: 14px 36px;
  font-size: 16px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 10px rgba(16, 107, 214, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: var(--blue-secondary);
  border-color: var(--blue-secondary);
  box-shadow: 0 6px 15px rgba(16, 107, 214, 0.3);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 2px 5px rgba(16, 107, 214, 0.2);
}

.btn-primary:disabled {
  background: #ccc;
  border-color: #999;
  box-shadow: 0 4px 0 #999;
  cursor: not-allowed;
  transform: none;
}

.btn-generate {
  background: var(--yellow-main);
  color: var(--purple-dark);
  border: 2px solid var(--yellow-dark);
  padding: 16px 40px;
  font-size: 16px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 0 var(--yellow-dark);
}

.btn-generate:hover {
  background: #FCE14B;
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--yellow-dark);
}

.btn-generate:active {
  transform: translateY(4px);
  box-shadow: none;
}

.btn-download {
  border-color: var(--purple-main);
  color: var(--purple-main);
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-download:hover {
  background: var(--purple-main);
  color: #fff;
}

/* ========================
   Status / Progress
   ======================== */
.progress-section {
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--purple-light);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}

.progress-fill {
  height: 100%;
  background: var(--yellow-main);
  width: 0%;
  border-radius: var(--radius-pill);
  transition: width 0.3s;
}

.progress-text {
  font-size: 15px;
  color: var(--purple-main);
  font-weight: 700;
}

/* ========================
   Results & Table — Educational Book Style
   ======================== */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
  gap: 15px;
}

.download-buttons {
  display: flex;
  gap: 15px;
}

.download-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--purple-pale);
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--purple-light);
}

/* ========================
   Toggle Switch
   ======================== */
.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--blue-primary);
  font-size: 14px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.toggle-switch input:checked + .slider {
  background-color: var(--blue-primary);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(20px);
}

.download-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--purple-main);
  padding: 0 8px;
}

.vocab-individual-download {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: -10px;
  margin-bottom: 15px;
}

/* Table Style */
.vocab-section {
  margin-bottom: 50px;
  background: #fff;
  border: 2px solid var(--purple-main);
  border-radius: var(--radius-md);
  padding: 30px;
  position: relative;
}

.vocab-question-num {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--yellow-main);
  color: var(--purple-dark);
  font-size: 18px;
  font-weight: 900;
  padding: 6px 30px;
  border-radius: var(--radius-pill);
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  letter-spacing: 1px;
}

.vocab-title {
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  color: var(--purple-main);
  margin-top: 15px;
  margin-bottom: 5px;
}

.vocab-subtitle {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 25px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.vocab-subtitle span {
  background: var(--purple-pale);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  color: var(--purple-main);
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: auto;
}

.vocab-table th, .vocab-table td {
  border: 1px solid var(--border-color);
}

.vocab-table th {
  background: var(--purple-main);
  color: #fff;
  padding: 14px 10px;
  text-align: center;
  font-weight: 800;
  font-size: 14px;
}

.vocab-table td {
  padding: 14px 12px;
  vertical-align: top;
  line-height: 1.6;
}

.vocab-table tr:nth-child(even) td {
  background: var(--purple-pale);
}

/* Base formatting inside cells */
.col-no { width: 50px; text-align: center; font-weight: 900; color: var(--purple-mid); }
.col-word { width: 110px; }
.col-pos, .col-meaning { width: 140px; }
.col-def-en { width: 220px; }
.col-example { width: 300px; }
.col-synonym { width: 150px; }
.col-antonym { width: 150px; }
.col-confusable { width: 150px; }

.word-cell {
  font-weight: 900;
  font-size: 16px;
  color: var(--purple-dark);
}

.pos-cell {
  font-weight: 600;
  color: var(--text-main);
}

.def-en-cell {
  font-size: 13px;
  font-style: italic;
  color: #555;
  line-height: 1.5;
}

.example-cell .example-en {
  font-size: 14px;
  font-weight: 500;
  color: var(--purple-dark);
}

.example-cell .example-kr {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

/* Distinctive Columns */
.synonym-cell {
  background: var(--synonym-bg) !important;
  color: var(--synonym-text);
  font-weight: 600;
}

.antonym-cell {
  background: var(--antonym-bg) !important;
  color: var(--antonym-text);
  font-weight: 600;
}

.confusable-cell {
  background: var(--confusable-bg) !important;
  color: var(--confusable-text);
  font-weight: 600;
}

/* ========================
   Loading Spinner
   ======================== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================
   Test Sheet
   ======================== */
.btn-test {
  background: linear-gradient(135deg, #FF6B35, #FF8C42) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 700;
}
.btn-test:hover { opacity: 0.9; }

.test-panel {
  margin-top: 12px;
  padding: 14px 18px;
  background: #fdf8f3;
  border: 1px solid #ffd6b3;
  border-radius: var(--radius-md);
}
.test-options {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.test-options label {
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.test-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--purple-dark);
}

.test-sheet {
  margin-top: 16px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.test-header { text-align: center; margin-bottom: 16px; }
.test-question-num {
  display: inline-block;
  padding: 4px 20px;
  border: 2px solid #FF5959;
  border-radius: var(--radius-pill);
  color: #FF5959;
  font-weight: 900;
  font-size: 14px;
  margin-bottom: 6px;
}
.test-title { font-size: 22px; font-weight: 900; color: var(--text-main); }
.test-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.test-info { font-size: 13px; color: #666; margin-top: 8px; }

.test-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: #f0f2f5;
  border-radius: var(--radius-md);
  flex-wrap: wrap;
  gap: 8px;
}
.test-toolbar-left, .test-toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.test-toggle-label { font-size: 13px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.test-part-select {
  padding: 4px 8px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; background: #fff; cursor: pointer;
}
.test-ans {
  color: #EF4444;
  font-weight: 700;
  font-size: 12px;
}
.test-choices { text-align: left !important; font-size: 12px; line-height: 1.8; }
.choice-item { display: inline-block; min-width: 120px; margin-right: 8px; font-weight: 500; }
.test-table th.test-choices { text-align: center !important; }
.test-part {
  margin-bottom: 24px;
}
.test-part-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--purple-dark);
  margin-bottom: 10px;
  padding: 6px 12px;
  background: var(--purple-pale);
  border-left: 4px solid var(--purple-main);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.test-hint {
  font-size: 11px;
  color: #888;
  font-weight: 400;
}
.test-table-full {
  width: 100%;
}

.test-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.test-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.test-table th {
  background: var(--purple-main);
  color: #fff;
  font-weight: 700;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  font-size: 12px;
}
.test-table td {
  border: 1px solid var(--border-color);
  padding: 6px 8px;
  height: 28px;
}
.test-table td.test-no { width: 35px; text-align: center; font-weight: 700; color: var(--purple-mid); }
.test-table td.test-word { font-weight: 800; font-size: 14px; }
.test-table td.test-meaning { min-width: 120px; }
.test-table tbody tr:nth-child(even) { background: #f7f8fa; }
.test-table tbody tr:nth-child(odd) { background: #fff; }

.test-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  color: #fff;
}
.badge-syn { background: #3B82F6; }
.badge-ant { background: #EF4444; }
.badge-conf { background: #F59E0B; }

/* ========================
   Responsive
   ======================== */
@media (max-width: 768px) {
  body { padding: 10px; }
  .container { border-left-width: 10px; }
  
  .input-section, .options-section, .passages-section, .results-section, .action-bar {
    padding: 0 15px 25px;
  }
  
  .header h1 { font-size: 28px; }
  .vocab-table { display: block; overflow-x: auto; }
  .download-buttons { flex-direction: column; }
  .download-group { justify-content: space-between; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--purple-mid); border-radius: 10px; }


/* ========================
   Top Navigation & Logo
   ======================== */
.top-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 15px;
  z-index: 100;
}

.header-large-logo {
  position: absolute;
  top: 0px;
  right: 40px;
  height: 90px;
  width: auto;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 10;
}

.icon-btn {
  background: #E0F2F1;
  border: 1px solid #B2DFDB;
  color: #00695C;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn:hover {
  background: #B2DFDB;
  color: #004D40;
  border-color: #80CBC4;
}

/* ========================
   Modals & Panels
   ======================== */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  width: 90%;
  max-width: 400px;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-book);
  border: 2px solid var(--purple-main);
}

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

.modal-header h3 {
  color: var(--purple-dark);
  font-size: 18px;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

.close-btn:hover {
  color: var(--purple-main);
}

.settings-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-body);
}

.settings-input:focus {
  outline: none;
  border-color: var(--purple-main);
  background: white;
}

/* History Panel */
.history-panel {
  position: fixed;
  top: 0; right: 0; width: 320px; height: 100vh;
  background: white;
  border-left: 2px solid var(--purple-main);
  box-shadow: -5px 0 20px rgba(0,0,0,0.1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-panel.hidden {
  display: flex !important;
  transform: translateX(110%);
}

.history-header {
  padding: 20px;
  background: var(--purple-pale);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-header h3 {
  color: var(--purple-dark);
  font-size: 18px;
}

.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
}

.history-item {
  border: 1px solid var(--purple-light);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  border-color: var(--purple-main);
  background: var(--purple-pale);
}

.history-item-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.history-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--purple-main);
}

.history-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* =====================
   Failed Passage & Retry Button
   ===================== */
.vocab-failed {
  text-align: center;
  padding: 30px 20px;
  background: linear-gradient(135deg, #fff5f5 0%, #fff0f0 100%);
  border: 2px dashed var(--red-accent);
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.failed-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.failed-msg {
  font-size: 13px;
  color: var(--red-accent);
  margin-bottom: 16px;
  word-break: break-all;
}

.btn-retry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: var(--red-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-retry:hover {
  background: #e04545;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 89, 89, 0.3);
}

.btn-retry-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  padding: 4px 12px;
  background: transparent;
  color: var(--blue-primary);
  border: 1px solid var(--blue-primary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  vertical-align: middle;
}

.btn-retry-inline:hover {
  background: var(--blue-primary);
  color: #fff;
}

/* ========================
   PDF 변환 모듈
   ======================== */
.pdf-convert-section {
  padding: 0 40px 40px;
}

.pdf-convert-panel {
  background: #fff;
  border: 2px solid var(--blue-primary);
  border-radius: var(--radius-md);
  padding: 30px;
}

.pdf-convert-panel h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--blue-primary);
  margin-bottom: 8px;
}

.pdf-convert-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.pdf-convert-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.btn-pdf-convert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border: 2px solid var(--blue-primary);
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--blue-primary);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-pdf-convert:hover {
  background: var(--blue-primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(16, 107, 214, 0.25);
}

.btn-pdf-convert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-pdf-convert .btn-icon {
  font-size: 20px;
}

.pdf-progress {
  margin-top: 24px;
  text-align: center;
}

/* ========================
   Processing Overlay (Battery Charge Style)
   ======================== */
.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: overlayFadeIn 0.3s ease;
}

.processing-overlay.hidden {
  display: none;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.processing-card {
  background: rgba(255, 255, 255, 0.97);
  border-radius: 20px;
  padding: 44px 48px 36px;
  text-align: center;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  max-width: 340px;
  width: 88%;
  animation: cardSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Circular Ring Progress */
.ring-container {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
}

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

.ring-track {
  fill: none;
  stroke: #eee;
  stroke-width: 5;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGrad);
  stroke: var(--purple-main, #6a5acd);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.4s ease;
  filter: drop-shadow(0 0 6px rgba(106, 90, 205, 0.4));
}

.ring-percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 800;
  color: #222;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.5px;
}

.ring-unit {
  font-size: 18px;
  font-weight: 600;
  color: #999;
  margin-left: 1px;
}

.processing-title {
  font-size: 17px;
  font-weight: 700;
  color: #222;
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.processing-status {
  font-size: 13px;
  font-weight: 500;
  color: #888;
  animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.processing-detail {
  font-size: 12px;
  color: #aaa;
  margin-top: 4px;
  min-height: 16px;
}

/* ============================================================
   COMPREHENSIVE RESPONSIVE LAYOUT
   Breakpoints: 1024px (laptop), 768px (tablet), 480px (mobile)
   ============================================================ */

/* ─── Tablet & smaller laptop (≤1024px) ─── */
@media (max-width: 1024px) {
  .header-branding h1 { font-size: 24px; }
  .header-large-logo { height: 80px; right: 20px; top: 0; }
  .hero-content-wrap { gap: 30px; }
  .hero-title { font-size: 36px; }
  .module-tabs { flex-wrap: wrap; gap: 8px; }
  .module-btn { font-size: 13px; padding: 8px 14px; }
}

/* ─── Tablet (≤768px) ─── */
@media (max-width: 768px) {
  /* Top nav & logo: stack and shrink */
  .top-nav { position: relative; top: auto; right: auto; padding: 8px; justify-content: flex-end; }
  .icon-btn { font-size: 12px; padding: 6px 12px; }

  /* Header compact */
  .header { padding: 8px 12px 6px; }
  .header-branding { margin-bottom: 4px; }
  .header-branding h1 { font-size: 20px; margin-bottom: 0; }
  .subtitle { font-size: 12px; margin-top: 0; }
  .header-pretitle { font-size: 10px; padding: 2px 8px; }
  .header-pretitle-wrapper { margin-bottom: 2px; }
  .header-large-logo {
    position: relative;
    top: auto; right: auto;
    height: 50px;
    margin: 0 auto 4px;
    display: block;
  }

  /* Module tabs: single row, horizontal scroll */
  .module-tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .module-btn {
    font-size: 11px;
    padding: 6px 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Hero: stack vertically */
  .hero { padding: 20px 16px; }
  .hero-content-wrap {
    flex-direction: column;
    gap: 24px;
  }
  .hero-text-side { width: 100%; text-align: center; }
  .hero-image-side { width: 100%; max-width: 400px; margin: 0 auto; }
  .hero-img { width: 100%; height: auto; }
  .hero-badge { font-size: 12px; padding: 6px 14px; }
  .hero-title { font-size: 26px; line-height: 1.3; }
  .hero-sub { font-size: 14px; }
  .hero-cta-group { flex-direction: column; gap: 10px; align-items: stretch; }
  .hero-cta-btn { font-size: 15px; padding: 14px 20px; width: 100%; }
  .hero-features { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hero-feature { font-size: 12px; }

  /* Demo overlay */
  .demo-panel {
    width: 95%;
    max-width: 95%;
    padding: 20px 16px;
    max-height: 90vh;
    overflow-y: auto;
  }
  .demo-title { font-size: 22px; }
  .demo-sub { font-size: 13px; }
  .demo-textarea { font-size: 13px; padding: 12px; min-height: 120px; }
  .demo-toggles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .demo-download-btns { flex-direction: column; gap: 8px; }
  .demo-download-btns .btn { width: 100%; font-size: 14px; }

  /* Modals */
  .modal-content { width: 95%; max-width: 95%; padding: 20px 16px; }

  /* Tables: scroll horizontally */
  .vocab-table { display: block; overflow-x: auto; white-space: nowrap; }
  .vocab-table th, .vocab-table td { font-size: 12px; padding: 8px 10px; }

  /* Inputs & buttons */
  .input-section, .options-section, .passages-section, .results-section, .action-bar {
    padding: 0 12px 20px;
  }
  textarea, input[type="text"], input[type="password"] { font-size: 14px; }
}

/* ─── Mobile (≤480px) ─── */
@media (max-width: 480px) {
  /* Ultra-compact header for game visibility */
  .header { padding: 6px 8px 4px; }
  .header-branding { margin-bottom: 2px; }
  .header-branding h1 { font-size: 16px; }
  .subtitle { font-size: 11px; }
  .header-pretitle { font-size: 9px; padding: 2px 6px; }
  .header-large-logo { height: 40px; margin: 0 auto 2px; }

  .module-tabs { gap: 4px; }
  .module-btn { font-size: 10px; padding: 5px 10px; }

  .hero { padding: 16px 12px; }
  .hero-title { font-size: 22px; }
  .hero-sub { font-size: 13px; }
  .hero-cta-btn { font-size: 14px; padding: 12px 16px; }
  .hero-features { grid-template-columns: 1fr; }

  .demo-panel { padding: 16px 12px; }
  .demo-title { font-size: 18px; }
  .demo-textarea { font-size: 12px; }

  .vocab-table th, .vocab-table td { font-size: 11px; padding: 6px 8px; }

  .ring-percent { font-size: 28px; }
  .ring-unit { font-size: 14px; }
}

/* ─── Touch devices: larger tap targets ─── */
@media (hover: none) and (pointer: coarse) {
  button, .btn, .icon-btn, .module-btn, .hero-cta-btn {
    min-height: 44px;
  }
  input[type="checkbox"], input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
  }
}
