/* ===== 기본 리셋 & 변수 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #E85D2C;
  --primary-light: #F09070;
  --primary-dark: #C44A1E;
  --secondary: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --bg: #FFF8F5;
  --card: #FFFFFF;
  --text: #1E293B;
  --text-light: #64748B;
  --border: #E2E8F0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px 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);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== 헤더 ===== */
.header {
  text-align: center;
  padding: 40px 20px 30px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  color: white;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.header .subtitle {
  font-size: 15px;
  opacity: 0.85;
  font-weight: 400;
}

/* ===== 섹션 공통 ===== */
section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* ===== 강 필터 ===== */
.chapter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chapter-btn {
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.2s;
}

.chapter-btn:hover {
  border-color: var(--primary-light);
  background: #FFF0EB;
}

.chapter-btn.active {
  border-color: var(--primary);
  background: #FFF0EB;
  color: var(--primary);
}

/* ===== 뱃지 & 태그 ===== */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--primary);
  color: white;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.tag.source {
  background: #FFF0EB;
  color: var(--primary);
}

.tag.original-type {
  background: #FEF3C7;
  color: #92400E;
}

.type-badge {
  font-size: 14px;
}

/* ===== 지문 목록 ===== */
.passage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.passage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 12px;
}

.passage-item:hover {
  border-color: var(--primary-light);
  background: #FFF0EB;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.passage-item.active {
  border-color: var(--primary);
  background: #FFF0EB;
}

.passage-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.passage-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.passage-item-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.passage-item-info p {
  font-size: 13px;
  color: var(--text-light);
}

.passage-item-right {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== 선택된 지문 ===== */
.passage-text {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  font-size: 14.5px;
  line-height: 1.8;
  color: #334155;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-line;
}

.passage-meta {
  display: flex;
  gap: 6px;
}

/* ===== 어법 포인트 ===== */
.grammar-toggle {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.grammar-toggle:hover {
  border-color: var(--primary-light);
  background: #FFF0EB;
}

.grammar-points {
  margin-top: 12px;
  overflow-x: auto;
}

.grammar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.grammar-table th {
  background: var(--primary);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.grammar-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.grammar-table tr:nth-child(even) {
  background: #F8FAFC;
}

.grammar-table tr:hover {
  background: #FFF0EB;
}

/* ===== 유형 버튼 ===== */
.type-section .type-notice {
  font-size: 13px;
  color: var(--danger);
  font-weight: 600;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: #FEF2F2;
  border-radius: var(--radius-sm);
}

.type-group {
  margin-bottom: 20px;
}

.type-group:last-child {
  margin-bottom: 0;
}

.type-group h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.type-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.type-btn {
  position: relative;
  padding: 14px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  min-width: 120px;
  text-align: center;
}

.type-btn:hover:not(.disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: #FFF0EB;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.type-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  text-decoration: line-through;
  background: #F1F5F9;
}

.type-btn .stars {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  color: var(--warning);
}

.type-btn.essay-btn {
  border-color: #D1FAE5;
  background: #ECFDF5;
}

.type-btn.essay-btn:hover:not(.disabled) {
  border-color: var(--secondary);
  color: #065F46;
  background: #D1FAE5;
}

/* ===== 문제 카드 ===== */
.question-card {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  margin-bottom: 20px;
}

.question-card .q-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.question-card .q-points {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.question-card .q-direction {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  line-height: 1.5;
}

.question-card .q-text {
  font-size: 14.5px;
  line-height: 1.8;
  color: #334155;
  margin-bottom: 16px;
  padding: 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: pre-line;
}

.question-card .q-text u {
  text-decoration-color: var(--danger);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.question-card .q-summary {
  font-size: 14px;
  line-height: 1.7;
  padding: 12px 16px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.question-card .q-condition {
  font-size: 13px;
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  color: #991B1B;
  font-weight: 500;
}

.question-card .q-given-words {
  display: inline-block;
  padding: 8px 16px;
  background: white;
  border: 2px solid var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 16px;
}

/* 선택지 */
.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14.5px;
  line-height: 1.6;
}

.choice-item:hover {
  border-color: var(--primary-light);
  background: #FFF0EB;
}

.choice-item.selected {
  border-color: var(--primary);
  background: #FFF0EB;
}

.choice-item.correct {
  border-color: var(--secondary);
  background: #ECFDF5;
}

.choice-item.wrong {
  border-color: var(--danger);
  background: #FEF2F2;
}

.choice-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
  flex-shrink: 0;
}

.choice-item.selected .choice-number {
  background: var(--primary);
  color: white;
}

.choice-item.correct .choice-number {
  background: var(--secondary);
  color: white;
}

.choice-item.wrong .choice-number {
  background: var(--danger);
  color: white;
}

/* 순서배열 파트 */
.order-parts {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.order-part {
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.7;
}

.order-part-label {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  text-align: center;
  line-height: 28px;
  font-weight: 700;
  font-size: 14px;
  margin-right: 8px;
}

/* 서술형 답안 입력 */
.essay-input {
  width: 100%;
  min-height: 80px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s;
}

.essay-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== 정답 & 해설 ===== */
.answer-area {
  margin-bottom: 20px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.answer-box, .explanation-box {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.answer-box {
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
}

.answer-box h4 {
  color: #065F46;
  font-size: 14px;
  margin-bottom: 6px;
}

.answer-box p {
  color: #047857;
  font-size: 15px;
  font-weight: 600;
}

.explanation-box {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
}

.explanation-box h4 {
  color: #1E40AF;
  font-size: 14px;
  margin-bottom: 6px;
}

.explanation-box p {
  color: #1D4ED8;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== 버튼 ===== */
.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-answer {
  background: var(--primary);
  color: white;
}

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

.btn-back {
  background: white;
  color: var(--text-light);
  border: 2px solid var(--border);
}

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

/* ===== 푸터 ===== */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-light);
  font-size: 13px;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* ===== 반응형 ===== */
@media (max-width: 640px) {
  .container {
    padding: 12px;
  }

  .header {
    padding: 28px 16px 24px;
  }

  .header h1 {
    font-size: 22px;
  }

  section {
    padding: 16px;
  }

  .type-btn {
    min-width: 100px;
    padding: 12px 16px;
    font-size: 14px;
  }

  .passage-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .passage-item-right {
    margin-top: 8px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chapter-buttons {
    gap: 6px;
  }

  .chapter-btn {
    padding: 8px 14px;
    font-size: 13px;
  }
}
