:root {
  --bg: #f3f9fc;
  --bg-card: #ffffff;
  --ink: #223344;
  --ink-soft: #5c7080;
  --line: #dbeaf2;
  --brand: #2f8fd1;
  --brand-deep: #1f6ba8;
  --brand-soft: #d9edfa;
  --accent: #ef7a52;
  --accent-soft: #fde7de;
  --gold: #f4b93f;
  --danger: #d6483f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(30, 80, 110, 0.08);
  --shadow-lg: 0 8px 30px rgba(30, 80, 110, 0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Header ---- */
.site-header {
  background: linear-gradient(135deg, #164a73 0%, var(--brand) 55%, var(--gold) 100%);
  color: #ffffff;
  padding: 40px 0 34px;
}

.site-header .wrap { display: flex; flex-direction: column; gap: 6px; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  opacity: 0.92;
}

.site-header h1 {
  margin: 4px 0 2px;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

.site-header p.tagline {
  margin: 0;
  opacity: 0.94;
  font-size: 1rem;
  max-width: 60ch;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  opacity: 0.95;
  margin-bottom: 10px;
}
.back-link:hover { text-decoration: underline; }

/* ---- Intro / purpose box ---- */
.purpose-box {
  margin: -22px auto 0;
  max-width: 840px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 20px 24px;
  position: relative;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.purpose-box strong { color: var(--brand-deep); }

/* ---- Controls ---- */
.controls {
  margin: 34px 0 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.search-input {
  flex: 1 1 240px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.95rem;
  color: var(--ink);
}
.search-input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

.filter-tabs { display: flex; gap: 6px; }

.filter-tab {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.filter-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  font-weight: 600;
}

.create-link {
  margin-left: auto;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
}
.create-link:hover { background: #d1613c; }

/* ---- Lesson grid / cards ---- */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0 60px;
}

.lesson-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.lesson-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.lesson-card .badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
}
.lesson-card.old .badge { background: var(--brand-soft); color: var(--brand-deep); }

.lesson-card h3 { margin: 0 0 4px; font-size: 1.15rem; }
.lesson-card .ref { color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 8px; }
.lesson-card .summary {
  font-size: 0.88rem;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 60px 20px;
}
.empty-state p { margin: 0 0 6px; }
.empty-state-sub { font-size: 0.88rem; }
.empty-state-cta { display: inline-block; margin-top: 16px; margin-left: 0; }

/* ---- Lesson detail page ---- */
.lesson-hero {
  background: linear-gradient(135deg, #164a73 0%, var(--brand) 55%, var(--gold) 100%);
  color: #ffffff;
  padding: 26px 0 40px;
}
.lesson-hero .badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  margin-bottom: 10px;
}
.lesson-hero h1 { margin: 0 0 4px; font-size: 1.85rem; letter-spacing: -0.02em; }
.lesson-hero .ref { font-size: 1.05rem; opacity: 0.95; margin-bottom: 6px; }
.lesson-hero .subtitle { opacity: 0.92; }

.lesson-body { padding: 0 0 70px; }

.section {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-top: -18px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 2;
}
.section + .section { margin-top: 22px; box-shadow: var(--shadow); }

.section h2 {
  font-size: 1.15rem;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-deep);
}
.section h2 .icon { font-size: 1.2rem; }

.section.faq h2 { color: var(--accent); }
.section.faq { border-color: var(--accent-soft); }

.section.cross { background: linear-gradient(180deg, var(--brand-soft) 0%, var(--bg-card) 100%); border-color: var(--brand-soft); }
.section.cross h2 { color: var(--danger); }

.summary-text { font-size: 1.02rem; color: var(--ink); }

.bg-item { margin-bottom: 16px; }
.bg-item:last-child { margin-bottom: 0; }
.bg-item h4 { margin: 0 0 4px; font-size: 0.98rem; color: var(--ink); }
.bg-item p { margin: 0; color: var(--ink-soft); font-size: 0.94rem; }

.theme-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.theme-list li {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.faq-item { border-top: 1px solid var(--line); padding: 14px 0; }
.faq-item:first-child { border-top: none; padding-top: 0; }
.faq-item .q { font-weight: 700; margin: 0 0 8px; display: flex; gap: 8px; }
.faq-item .q .qmark {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
}
.faq-item .a { margin: 0; padding-left: 30px; color: var(--ink-soft); font-size: 0.94rem; }

.discuss-list { margin: 0; padding-left: 0; list-style: none; }
.discuss-list li {
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}
.discuss-list li:last-child { margin-bottom: 0; }
.discuss-list li::before { content: "💬 "; }

/* Quiz */
.quiz-item { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; }
.quiz-item:last-child { margin-bottom: 0; }
.quiz-item .q { font-weight: 700; margin: 0 0 12px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--ink);
}
.quiz-option:hover { border-color: var(--brand); }
.quiz-option.correct { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
.quiz-option.wrong { background: #fbe6df; border-color: var(--danger); }
.quiz-option[disabled] { cursor: default; }
.quiz-explain {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 8px;
  display: none;
}
.quiz-explain.show { display: block; }

.quiz-summary {
  text-align: center;
  font-weight: 700;
  padding: 14px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  margin-top: 14px;
  display: none;
}
.quiz-summary.show { display: block; }

.visual-list { display: grid; gap: 12px; }
.visual-item {
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 10px;
}
.visual-item h4 { margin: 0 0 4px; font-size: 0.95rem; }
.visual-item p { margin: 0 0 6px; color: var(--ink-soft); font-size: 0.88rem; }
.visual-item .keyword {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.cross-text { font-size: 1rem; }

.section.prayer { background: linear-gradient(180deg, #fdf1d6 0%, var(--bg-card) 100%); border-color: var(--gold); }
.section.prayer h2 { color: var(--gold); }
.prayer-text { font-size: 1rem; font-style: italic; color: var(--ink); white-space: pre-line; }

/* ---- Flow timebox ---- */
.flow-list { display: flex; flex-wrap: wrap; gap: 10px; }
.flow-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 0.92rem;
  color: var(--ink);
}
.flow-min {
  flex: none;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  background: var(--accent);
  padding: 3px 9px;
  border-radius: 999px;
}

/* ---- Age group tabs ---- */
.age-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.age-tab {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
}
.age-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Icebreaker ---- */
.icebreaker { margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px dashed var(--line); }
.icebreaker h3 {
  font-size: 1rem;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--brand-deep);
}
.icebreaker-instruction {
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 10px 14px;
  border-radius: 10px;
  margin: 0 0 14px;
}
.icebreaker-item { margin-bottom: 16px; }
.icebreaker-item:last-child { margin-bottom: 0; }
.icebreaker-item .q { font-weight: 700; margin: 0 0 10px; }
.icebreaker-options { display: flex; flex-direction: column; gap: 8px; }
.icebreaker-option {
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--ink);
}
.icebreaker-option:hover { border-color: var(--brand); }
.icebreaker-option.correct { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
.icebreaker-option.wrong { background: #fbe6df; border-color: var(--danger); }
.icebreaker-option[disabled] { cursor: default; }
.icebreaker-note {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 8px;
  display: none;
}
.icebreaker-note.show { display: block; }

/* ---- QT (관찰-해석-묵상-적용) ---- */
.qt-grid { display: grid; gap: 14px; }
.qt-step {
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--bg);
  border-left: 4px solid var(--accent);
}
.qt-step h3 {
  font-size: 0.98rem;
  margin: 0 0 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink);
}
.qt-step .qt-desc { font-size: 0.8rem; font-weight: 400; color: var(--ink-soft); }
.qt-step ul { margin: 0; padding-left: 20px; }
.qt-step li { margin-bottom: 8px; font-size: 0.94rem; }
.qt-step li:last-child { margin-bottom: 0; }
.qt-ref {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.qt-interpret { border-left-color: var(--brand); }
.qt-meditate { border-left-color: var(--gold); }
.qt-apply { border-left-color: var(--danger); }


/* ---- AI disclaimer ---- */
.ai-disclaimer {
  background: #fff3e0;
  border: 1px solid var(--gold);
  color: var(--brand-deep);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  margin: -18px 0 22px;
  position: relative;
  z-index: 2;
}

/* ---- Create form ---- */
.create-form { margin-top: 26px; }
.create-form form { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.form-row select,
.form-row input {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.98rem;
  color: var(--ink);
  background: #fff;
}
.form-row select:focus,
.form-row input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.form-row-inline { flex-direction: row; gap: 14px; }
.form-row-inline > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.field-hint { font-weight: 400; color: var(--ink-soft); font-size: 0.8rem; }

.testament-toggle { display: flex; gap: 8px; margin-bottom: 4px; }
.testament-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.testament-btn.active { background: var(--brand); border-color: var(--brand); color: #ffffff; }

.book-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 190px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.book-chip {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.book-chip:hover { border-color: var(--brand); }
.book-chip.active { background: var(--brand); border-color: var(--brand); color: #ffffff; font-weight: 600; }

.age-fieldset { border: none; padding: 0; margin: 0; }
.age-fieldset legend {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0;
  margin-bottom: 6px;
}
.age-radio-group { display: flex; flex-wrap: wrap; gap: 10px; }
.age-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
  background: #fff;
}
.age-radio:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.age-radio input { margin: 0; }

.create-submit {
  padding: 14px 20px;
  border-radius: 999px;
  border: none;
  background: var(--brand);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.create-submit:hover { background: var(--brand-deep); }
.create-submit:disabled { opacity: 0.6; cursor: default; }

.create-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 14px 0 0;
}

.create-status { margin-top: 16px; font-size: 0.92rem; }
.create-status.loading { color: var(--accent); }
.create-status.error { color: var(--danger); font-weight: 600; }

@media (max-width: 560px) {
  .form-row-inline { flex-direction: column; }
}

.print-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: var(--brand-deep);
  border: 1px solid rgba(255,255,255,0.5);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
}

.feedback-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 160px;
  padding: 10px 14px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: keep-all;
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 8px 24px rgba(239, 122, 82, 0.45);
  cursor: pointer;
  z-index: 50;
}
.feedback-bubble:hover { background: #d1613c; }

.feedback-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43, 36, 32, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.feedback-overlay.show { display: flex; }

.feedback-modal {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px 24px;
  max-width: 420px;
  width: 100%;
}
.feedback-modal h3 { margin: 0 0 10px; font-size: 1.15rem; color: var(--brand-deep); }
.feedback-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: none;
  font-size: 1.1rem;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1;
}
.feedback-desc { font-size: 0.92rem; color: var(--ink-soft); margin: 0 0 14px; }
.feedback-textarea {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.feedback-textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.feedback-submit {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
}
.feedback-submit:hover { background: var(--brand-deep); }
.feedback-submit:disabled { opacity: 0.7; cursor: default; }
.feedback-status { margin: 10px 0 0; font-size: 0.85rem; min-height: 1em; }
.feedback-status.error { color: var(--danger); }
.feedback-status.success { color: var(--accent); font-weight: 600; }

footer {
  text-align: center;
  padding: 30px 20px 50px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.print-header-banner { display: none; }

@media print {
  .site-header, .controls, .print-btn, footer, .back-link, .age-tabs, .feedback-bubble { display: none !important; }
  body { background: #fff; font-size: 0.85em; line-height: 1.45; }
  @page { size: A4 landscape; margin: 10mm; }
  .wrap { max-width: 100%; padding: 0; }

  .lesson-body {
    padding: 0;
    column-count: 2;
    column-gap: 18px;
    column-fill: auto;
  }

  .print-header-banner {
    display: block;
    break-inside: avoid;
    break-after: avoid;
    padding: 0 0 8px;
    margin: 0 0 10px;
    border-bottom: 2px solid var(--brand);
  }
  .print-header-banner .badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    margin-bottom: 4px;
  }
  .print-header-banner h1 { font-size: 1.25rem; margin: 4px 0 2px; color: var(--brand-deep); }
  .print-header-banner .ref { font-size: 0.95rem; color: var(--ink); font-weight: 700; }

  .section {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid-column;
    margin: 0 0 6px;
    padding: 10px 12px;
    display: inline-block;
    width: 100%;
  }
  .section h2 { break-after: avoid; margin-bottom: 6px; font-size: 0.98rem; }
  .age-section { display: block; break-inside: auto; }

  .bg-item, .quiz-item, .icebreaker-item, .qt-step, .visual-item, .faq-item, .flow-chip, .discuss-list li {
    break-inside: avoid;
  }
  .theme-list { break-inside: avoid; }
  .qt-grid { display: block; }
  .qt-step { padding: 8px 10px; margin-bottom: 6px; }
  .icebreaker { margin-bottom: 8px; padding-bottom: 8px; }
  .bg-item { margin-bottom: 6px; }
  .bg-item h4 { margin-bottom: 2px; }
  .icebreaker-option, .quiz-option { padding: 6px 10px; }
  .icebreaker-options, .quiz-options { gap: 4px; }
  .visual-item { padding: 8px 10px; }
  .visual-list { gap: 6px; }
}

@media (max-width: 560px) {
  .site-header { padding: 30px 0 28px; }
  .site-header h1 { font-size: 1.5rem; }
  .purpose-box { margin: -16px 16px 0; padding: 16px 18px; }
  .section { padding: 18px 18px; }
}
