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

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --max-width: 1200px;
}

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

[id] { scroll-margin-top: 4rem; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; }
img { max-width: 100%; display: block; }

/* ===== Header ===== */
.header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
  text-decoration: none;
}

.header-nav {
  display: flex;
  gap: 0.25rem;
}

.header-nav-item {
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
  transition: all 0.15s;
}

.header-nav-item:hover { color: var(--primary); background: var(--primary-light); }
.header-nav-item.active { color: var(--primary); background: var(--primary-light); }

.search-bar {
  position: relative;
}

.search-bar-main {
  max-width: var(--max-width);
  margin: 1rem auto 0;
  padding: 0 1rem;
}

.search-bar input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: var(--primary);
}

.search-bar-main::before {
  content: "\1F50D";
  position: absolute;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
}

/* ===== Banner ===== */
.banner {
  background: var(--primary);
  padding: 1.25rem 1rem;
}

.banner-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.banner-text {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
}

/* ===== Category Filter ===== */
.category-bar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.category-bar::-webkit-scrollbar { display: none; }

.category-btn {
  padding: 0.375rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: #fff;
  font-size: 0.8125rem;
  white-space: nowrap;
  color: var(--gray-600);
  transition: all 0.2s;
}

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

/* ===== Exam Card Grid ===== */
.card-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem 2rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.exam-card {
  display: block;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}

.exam-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.exam-card .badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.exam-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.exam-card .desc {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
}

.exam-card .session-count {
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* ===== Exam Page: Layout ===== */
.exam-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.exam-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.exam-title {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-home {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.8125rem;
  color: var(--gray-600);
  white-space: nowrap;
}

.btn-home:hover { background: var(--gray-100); }

/* ===== Question Card ===== */
.question-area {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
}

.subject-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  display: inline-block;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.question-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.question-number {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.question-text {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.7;
  margin-bottom: 1.25rem;
  word-break: keep-all;
}

/* ===== Options ===== */
.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 48px;
}

.option-item:hover { border-color: var(--primary-light); background: var(--gray-50); }

.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-number {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--gray-500);
  transition: all 0.15s;
}

.option-item.selected .option-number {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.option-text {
  font-size: 0.9375rem;
  line-height: 1.5;
  padding-top: 0.0625rem;
}

.option-item.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.option-item.correct .option-number {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.option-item.wrong {
  border-color: var(--danger);
  background: var(--danger-light);
}

.option-item.wrong .option-number {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* ===== Explanation ===== */
.explanation {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--gray-50);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.875rem;
  color: var(--gray-700);
  line-height: 1.7;
  display: none;
}

.explanation.show { display: block; }

.explanation-label {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

/* ===== Practice Mode ===== */
.btn-check-answer {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-check-answer:hover { background: var(--primary-dark); }

.btn-next-random {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

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

.practice-hint {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--gray-400);
}

.practice-result {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.practice-result.correct {
  background: var(--success-light);
  color: var(--success);
}

.practice-result.wrong {
  background: var(--danger-light);
  color: var(--danger);
}

/* ===== Report ===== */
.btn-report {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.75rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
  background: transparent;
  color: var(--gray-400);
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.15s;
}

.btn-report svg { flex-shrink: 0; }
.btn-report:hover { border-color: var(--danger); color: var(--danger); }
.btn-report:disabled { opacity: 0.5; cursor: default; }

.report-form {
  margin-top: 0.75rem;
}

.report-input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.875rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.report-input:focus { border-color: var(--primary); }

.btn-report-submit {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.625rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  transition: background 0.15s;
}

.btn-report-submit:hover { background: #b91c1c; }
.btn-report-submit:disabled { opacity: 0.5; cursor: default; }

.report-success {
  text-align: center;
  padding: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--success);
}

/* ===== Notice ===== */
.notice {
  max-width: var(--max-width);
  margin: 2rem auto;
  padding: 0 1rem 2rem;
}

.notice-inner {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.notice-title {
  font-size: 1.125rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--gray-800);
}

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

.notice-item {
  display: flex;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--gray-200);
  align-items: baseline;
}

.notice-item:last-child { border-bottom: none; }

.notice-date {
  font-size: 0.8125rem;
  color: var(--gray-400);
  white-space: nowrap;
}

.notice-text {
  font-size: 0.9375rem;
  color: var(--gray-700);
  text-decoration: none;
}

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

.notice-empty {
  padding: 2rem 0;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.9375rem;
}

/* ===== Notice Detail ===== */
.notice-detail {
  max-width: var(--max-width);
  margin: 2rem auto;
  padding: 0 1rem 2rem;
}

.notice-detail-inner {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem;
}

.notice-detail-date {
  display: block;
  font-size: 0.8125rem;
  color: var(--gray-400);
  margin-bottom: 0.5rem;
}

.notice-detail-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gray-800);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.notice-detail-content {
  font-size: 0.9375rem;
  color: var(--gray-600);
  line-height: 1.8;
}

.notice-detail-content p + p {
  margin-top: 1rem;
}

.notice-detail-back {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-500);
  text-decoration: none;
  transition: all 0.15s;
}

.notice-detail-back:hover { color: var(--primary); border-color: var(--primary); }

/* ===== FAQ ===== */
.faq {
  max-width: var(--max-width);
  margin: 2rem auto;
  padding: 0 1rem 2rem;
}

.faq-inner {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.faq-title {
  font-size: 1.125rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--gray-800);
}

.faq-item {
  border-bottom: 1px solid var(--gray-200);
}

.faq-item:last-child { border-bottom: none; }

.faq-question {
  padding: 1rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  list-style: none;
}

.faq-question::before {
  content: "Q. ";
  color: var(--primary);
  font-weight: 800;
}

.faq-question::-webkit-details-marker { display: none; }

.faq-answer {
  padding: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--gray-600);
  line-height: 1.7;
}

/* ===== Ad ===== */
.ad-container {
  margin-top: 1.25rem;
  text-align: center;
  min-height: 100px;
  overflow: hidden;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}

.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9375rem; }

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Responsive: Tablet ===== */
@media (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .question-area {
    padding: 1.5rem;
  }

  .question-card {
    padding: 2rem;
  }
}

/* ===== Responsive: Desktop ===== */
@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .question-card {
    padding: 2.5rem;
  }

  .options-list {
    gap: 0.625rem;
  }

  .option-item {
    padding: 1rem 1.25rem;
  }
}
