:root {
  --theory-gold: #efb701;
  --theory-gold-dark: #7b5e00;
  --theory-cream: #fff8dc;
  --theory-ink: #262216;
  --theory-muted: #696253;
  --theory-line: #e8dfc5;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.kdl-theory-body { margin: 0; background: #f7f5ef; color: var(--theory-ink); }
.kdl-theory-page { min-height: 70vh; }
.kdl-theory-hero {
  height: 8px;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  color: transparent;
  scroll-margin-top: 0;
}
.kdl-theory-hero-inner {
  height: 8px;
  min-height: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  overflow: hidden;
  color: transparent;
  font-size: 1px;
  line-height: 1;
}
.kdl-theory-hero span,
.kdl-theory-hero h1,
.kdl-theory-hero p {
  margin: 0;
  padding: 0;
  color: transparent;
  font-size: 1px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: 0;
}
.kdl-theory-hero p { max-width: none; word-break: normal; }
.kdl-theory-shell { padding-top: 26px; padding-bottom: 64px; }
.kdl-theory-resume { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 20px; border: 1px solid var(--theory-line); border-radius: 18px; background: #fff; }
.kdl-theory-resume div { min-width: 0; }
.kdl-theory-resume span { display: block; margin-bottom: 4px; color: var(--theory-gold-dark); font-size: 13px; font-weight: 900; }
.kdl-theory-resume strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.kdl-theory-resume button { min-height: 42px; padding: 0 16px; border: 1px solid #d6c994; border-radius: 12px; background: #fffdf5; color: #5c4700; font: inherit; font-weight: 800; cursor: pointer; }
.kdl-theory-tabs { position: sticky; top: var(--kdl-theory-tabs-top, 0px); scroll-margin-top: var(--kdl-theory-tabs-top, 0px); z-index: 4; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 18px 0; padding: 8px; border: 1px solid var(--theory-line); border-radius: 18px; background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.kdl-theory-tabs button { min-height: 50px; padding: 8px 10px; border: 0; border-radius: 12px; background: transparent; color: #575040; font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; }
.kdl-theory-tabs button[aria-selected="true"] { background: var(--theory-gold); color: #2f2500; box-shadow: 0 7px 18px rgba(142,103,0,.18); }
.kdl-theory-progress { margin-bottom: 16px; padding: 0 2px; }
.kdl-theory-progress > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.kdl-theory-progress span { color: var(--theory-muted); font-size: 14px; font-weight: 800; }
.kdl-theory-progress strong { color: var(--theory-gold-dark); font-size: 15px; }
.kdl-theory-progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #e8e2d2; }
.kdl-theory-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--theory-gold); transition: width .22s ease; }
.kdl-theory-stage { min-height: 440px; }
.kdl-theory-card { min-height: 430px; padding: clamp(24px, 4vw, 42px); border: 1px solid var(--theory-line); border-radius: 26px; background: #fff; box-shadow: 0 16px 45px rgba(58,49,23,.08); }
.kdl-theory-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.kdl-theory-card-meta span { color: var(--theory-gold-dark); font-size: 14px; font-weight: 900; }
.kdl-theory-card-meta strong { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 32px; padding: 0 10px; border-radius: 999px; background: var(--theory-gold); color: #302600; font-size: 14px; }
.kdl-theory-card h2 { margin: 0 0 24px; font-size: 27px; line-height: 1.38; letter-spacing: -0.03em; word-break: keep-all; }
.kdl-theory-card-content { color: #413c31; }
.kdl-theory-card-content ul,
.kdl-theory-card-content ol { margin: 0; padding-left: 25px; }
.kdl-theory-card-content li { margin: 11px 0; font-size: 20px; line-height: 1.72; font-weight: 400; word-break: break-all; text-align: justify; text-justify: inter-character; }
.kdl-theory-card-content li::marker { color: var(--theory-gold-dark); font-weight: 900; }
.kdl-theory-card-image { margin: 0 0 24px; overflow: hidden; border: 1px solid var(--theory-line); border-radius: 18px; background: var(--theory-cream); }
.kdl-theory-card-image img { display: block; width: 100%; max-height: 430px; object-fit: contain; background: #fff; }
.kdl-theory-card-image figcaption { padding: 14px 16px; color: #625b4d; font-size: 15px; line-height: 1.65; }
.kdl-theory-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.kdl-theory-controls button { min-height: 54px; border: 0; border-radius: 15px; font: inherit; font-size: 17px; font-weight: 900; cursor: pointer; }
.kdl-theory-controls button:first-child { background: #e9e4d8; color: #443e32; }
.kdl-theory-controls #theoryNextButton { background: var(--theory-gold); color: #302600; }
.kdl-theory-controls button:disabled { opacity: .4; cursor: not-allowed; }
.kdl-theory-controls .kdl-theory-subject-start {
  grid-column: 1 / -1;
  width: 100%;
  background: #000;
  color: #fff;
}
.kdl-theory-controls .kdl-theory-subject-start:hover { filter: brightness(.97); }

.kdl-theory-live { position: fixed; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 820px) {
  .kdl-theory-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kdl-theory-card-content li { font-size: 19px; }
}
@media (max-width: 560px) {
  .kdl-theory-shell { padding-top: 20px; padding-bottom: 48px; }
  .kdl-theory-resume { align-items: stretch; flex-direction: column; }
  .kdl-theory-resume strong { white-space: normal; }
  .kdl-theory-resume button { width: 100%; }
  .kdl-theory-tabs { position: relative; grid-template-columns: 1fr; }
  .kdl-theory-tabs button { min-height: 46px; }
  .kdl-theory-stage { min-height: 390px; }
  .kdl-theory-card { min-height: 380px; padding: 24px 20px; border-radius: 21px; }
  .kdl-theory-card h2 { margin-bottom: 20px; font-size: 24px; }
  .kdl-theory-card-content li { font-size: 18px; line-height: 1.7; }
  .kdl-theory-controls button { min-height: 52px; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .kdl-theory-progress-track span { transition: none; }
}
.kdl-theory-card-subheading {
  margin: 26px 0 10px;
  color: #6b5200;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.kdl-theory-card-content > .kdl-theory-card-subheading:first-child { margin-top: 0; }
@media (max-width: 560px) {
  .kdl-theory-card-subheading { margin-top: 22px; font-size: 17px; }
}

/* 이론 총정리 전용: 카드의 세로 길이를 줄이고, 필요한 교재 이미지는 설명 옆에 배치 */
.kdl-theory-complete-body .kdl-theory-shell {
  padding-top: 18px;
  padding-bottom: 48px;
}
.kdl-theory-complete-body .kdl-theory-resume {
  padding: 13px 16px;
  border-radius: 15px;
}
.kdl-theory-complete-body .kdl-theory-resume span { margin-bottom: 2px; }
.kdl-theory-complete-body .kdl-theory-resume button { min-height: 38px; }
.kdl-theory-complete-body .kdl-theory-tabs {
  margin: 12px 0;
  padding: 6px;
  border-radius: 15px;
}
.kdl-theory-complete-body .kdl-theory-tabs button { min-height: 42px; }
.kdl-theory-complete-body .kdl-theory-progress { margin-bottom: 10px; }
.kdl-theory-complete-body .kdl-theory-progress > div:first-child { margin-bottom: 6px; }
.kdl-theory-complete-body .kdl-theory-stage { min-height: 0; }
.kdl-theory-complete-body .kdl-theory-card {
  min-height: 0;
  padding: 24px 28px;
  border-radius: 21px;
}
.kdl-theory-complete-body .kdl-theory-card-meta { margin-bottom: 8px; }
.kdl-theory-complete-body .kdl-theory-card h2 {
  margin-bottom: 14px;
  font-size: 24px;
  line-height: 1.32;
}
.kdl-theory-complete-body .kdl-theory-card-body { min-width: 0; }
.kdl-theory-complete-body .kdl-theory-card.has-image .kdl-theory-card-body {
  display: grid;
  grid-template-columns: minmax(250px, .82fr) minmax(0, 1.18fr);
  align-items: start;
  gap: 22px;
}
.kdl-theory-complete-body .kdl-theory-card-image {
  margin: 0;
  border-radius: 14px;
}
.kdl-theory-complete-body .kdl-theory-card-image img {
  width: 100%;
  max-height: 330px;
  object-fit: contain;
}
.kdl-theory-complete-body .kdl-theory-card-image figcaption {
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.45;
}
.kdl-theory-complete-body .kdl-theory-card-content {
  max-height: none;
  overflow: visible;
  overscroll-behavior: auto;
  padding-right: 0;
  scrollbar-gutter: auto;
}
.kdl-theory-complete-body .kdl-theory-card-content li {
  margin: 5px 0;
  font-size: 17px;
  line-height: 1.56;
  text-align: left;
  word-break: keep-all;
}
.kdl-theory-complete-body .kdl-theory-card-subheading {
  margin: 15px 0 6px;
  font-size: 16px;
  line-height: 1.4;
}
.kdl-theory-complete-body .kdl-theory-controls {
  margin-top: 12px;
  gap: 10px;
}
.kdl-theory-complete-body .kdl-theory-controls button { min-height: 48px; }

@media (max-width: 820px) {
  .kdl-theory-complete-body .kdl-theory-card.has-image .kdl-theory-card-body {
    grid-template-columns: minmax(210px, .72fr) minmax(0, 1.28fr);
    gap: 16px;
  }
  .kdl-theory-complete-body .kdl-theory-card-content { max-height: none; overflow: visible; }
}

@media (max-width: 640px) {
  .kdl-theory-complete-body .kdl-theory-shell { padding-top: 14px; }
  .kdl-theory-complete-body .kdl-theory-card { padding: 20px 17px; }
  .kdl-theory-complete-body .kdl-theory-card h2 { font-size: 21px; }
  .kdl-theory-complete-body .kdl-theory-card.has-image .kdl-theory-card-body {
    display: block;
  }
  .kdl-theory-complete-body .kdl-theory-card-image { margin-bottom: 13px; }
  .kdl-theory-complete-body .kdl-theory-card-image img { max-height: 280px; }
  .kdl-theory-complete-body .kdl-theory-card-content {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .kdl-theory-complete-body .kdl-theory-card-content li {
    font-size: 16px;
    line-height: 1.55;
  }
}

/* 이론 총정리 v3: 쪽수 대신 카드 번호를 명확히 표시하고, 내용을 주제별 상자로 나눔 */
.kdl-theory-complete-body .kdl-theory-card-meta strong {
  min-width: 74px;
  padding: 0 12px;
  white-space: nowrap;
}
.kdl-theory-complete-body .kdl-theory-card-image figcaption { display: none; }
.kdl-theory-complete-body .kdl-theory-card-content {
  display: grid;
  gap: 11px;
}
.kdl-theory-complete-body .kdl-theory-topic-group {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid #eee7d5;
  border-radius: 14px;
  background: #fbfaf6;
}
.kdl-theory-complete-body .kdl-theory-topic-group.is-goal {
  border-color: #d9e7ef;
  background: #f3f8fb;
}
.kdl-theory-complete-body .kdl-theory-topic-group.is-note {
  border-color: #eadfab;
  background: #fffbed;
}
.kdl-theory-complete-body .kdl-theory-topic-group.is-warning {
  border-color: #edcfc6;
  background: #fff6f3;
}
.kdl-theory-complete-body .kdl-theory-topic-group.is-table {
  border-color: #d9e1d4;
  background: #f7faf5;
}
.kdl-theory-complete-body .kdl-theory-topic-group ul,
.kdl-theory-complete-body .kdl-theory-topic-group ol {
  margin: 0;
  padding-left: 23px;
}
.kdl-theory-complete-body .kdl-theory-topic-group li {
  margin: 5px 0;
  overflow-wrap: anywhere;
}
.kdl-theory-complete-body .kdl-theory-topic-group li.is-emphasis {
  font-weight: 700;
}
.kdl-theory-complete-body .kdl-theory-topic-group .kdl-theory-card-subheading {
  margin: 0 0 8px;
  color: #5f4a08;
}
@media (max-width: 640px) {
  .kdl-theory-complete-body .kdl-theory-topic-group {
    padding: 12px 13px;
    border-radius: 12px;
  }
}

/* 이론 총정리 v4 */
.kdl-theory-complete-body .kdl-theory-card {
  padding: 30px 34px;
}
.kdl-theory-complete-body .kdl-theory-card h2 {
  margin-bottom: 20px;
  font-size: 29px;
  line-height: 1.42;
}
.kdl-theory-complete-body .kdl-theory-card-body,
.kdl-theory-complete-body .kdl-theory-card.has-image .kdl-theory-card-body {
  display: block;
  min-width: 0;
}
.kdl-theory-complete-body .kdl-theory-card-image {
  width: 100%;
  margin: 0 0 24px;
  border-radius: 16px;
}
.kdl-theory-complete-body .kdl-theory-card-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}
.kdl-theory-complete-body .kdl-theory-card-content {
  display: grid;
  gap: 15px;
  max-height: none;
  overflow: visible;
  overscroll-behavior: auto;
  padding-right: 0;
  scrollbar-gutter: auto;
}
.kdl-theory-complete-body .kdl-theory-topic-group {
  padding: 18px 20px;
}
.kdl-theory-complete-body .kdl-theory-card-content li {
  margin: 8px 0;
  font-size: 20px;
  line-height: 1.72;
  letter-spacing: -0.015em;
  overflow-wrap: break-word;
  word-break: keep-all;
}
.kdl-theory-complete-body .kdl-theory-card-subheading,
.kdl-theory-complete-body .kdl-theory-topic-group .kdl-theory-card-subheading {
  margin: 0 0 11px;
  font-size: 20px;
  line-height: 1.5;
}
.kdl-theory-complete-body .kdl-theory-table-block {
  padding: 20px;
  border-color: #d7dfd1;
  background: #f8fbf6;
}
.kdl-theory-complete-body .kdl-theory-table-wrap {
  width: 100%;
}
.kdl-theory-complete-body .kdl-theory-html-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: #34362f;
  background: #fff;
}
.kdl-theory-complete-body .kdl-theory-html-table th,
.kdl-theory-complete-body .kdl-theory-html-table td {
  padding: 14px 13px;
  border-right: 1px solid #d9dfd5;
  border-bottom: 1px solid #d9dfd5;
  font-size: 17px;
  line-height: 1.6;
  vertical-align: top;
  text-align: left;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.kdl-theory-complete-body .kdl-theory-html-table th {
  color: #463a16;
  background: #eee7cf;
  font-weight: 900;
  text-align: center;
}
.kdl-theory-complete-body .kdl-theory-html-table tr > :first-child {
  border-left: 1px solid #d9dfd5;
}
.kdl-theory-complete-body .kdl-theory-html-table thead tr:first-child > * {
  border-top: 1px solid #d9dfd5;
}
.kdl-theory-complete-body .kdl-theory-html-table thead tr:first-child > :first-child {
  border-top-left-radius: 11px;
}
.kdl-theory-complete-body .kdl-theory-html-table thead tr:first-child > :last-child {
  border-top-right-radius: 11px;
}
.kdl-theory-complete-body .kdl-theory-html-table tbody tr:last-child > :first-child {
  border-bottom-left-radius: 11px;
}
.kdl-theory-complete-body .kdl-theory-html-table tbody tr:last-child > :last-child {
  border-bottom-right-radius: 11px;
}
.kdl-theory-complete-body .kdl-theory-html-table .is-empty {
  color: #a39d8d;
  text-align: center;
}
.kdl-theory-complete-body .kdl-theory-table-cards {
  display: none;
  gap: 13px;
}
.kdl-theory-complete-body .kdl-theory-table-card {
  padding: 17px;
  border: 1px solid #d8dfd3;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(61, 72, 54, .06);
}
.kdl-theory-complete-body .kdl-theory-table-card-label {
  display: block;
  margin-bottom: 4px;
  color: #7a6727;
  font-size: 14px;
  font-weight: 900;
}
.kdl-theory-complete-body .kdl-theory-table-card h4 {
  margin: 0 0 13px;
  color: #292c26;
  font-size: 20px;
  line-height: 1.45;
  word-break: keep-all;
}
.kdl-theory-complete-body .kdl-theory-table-card dl {
  margin: 0;
}
.kdl-theory-complete-body .kdl-theory-table-card dl > div {
  display: grid;
  grid-template-columns: minmax(88px, .42fr) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #ecefe9;
}
.kdl-theory-complete-body .kdl-theory-table-card dt,
.kdl-theory-complete-body .kdl-theory-table-card dd {
  margin: 0;
  font-size: 17px;
  line-height: 1.58;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.kdl-theory-complete-body .kdl-theory-table-card dt {
  color: #6a5a25;
  font-weight: 900;
}
.kdl-theory-complete-body .kdl-theory-table-card dd {
  color: #393a35;
}

@media (max-width: 1100px) {
  .kdl-theory-complete-body .kdl-theory-table-block.is-wide-table .kdl-theory-table-wrap { display: none; }
  .kdl-theory-complete-body .kdl-theory-table-block.is-wide-table .kdl-theory-table-cards { display: grid; }
}

@media (max-width: 760px) {
  .kdl-theory-complete-body .kdl-theory-card {
    padding: 24px 19px;
  }
  .kdl-theory-complete-body .kdl-theory-card h2 {
    margin-bottom: 18px;
    font-size: 25px;
    line-height: 1.45;
  }
  .kdl-theory-complete-body .kdl-theory-card-image {
    margin-bottom: 19px;
  }
  .kdl-theory-complete-body .kdl-theory-card-content {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .kdl-theory-complete-body .kdl-theory-topic-group,
  .kdl-theory-complete-body .kdl-theory-table-block {
    padding: 15px;
    border-radius: 13px;
  }
  .kdl-theory-complete-body .kdl-theory-card-content li {
    margin: 7px 0;
    font-size: 19px;
    line-height: 1.7;
  }
  .kdl-theory-complete-body .kdl-theory-card-subheading,
  .kdl-theory-complete-body .kdl-theory-topic-group .kdl-theory-card-subheading {
    font-size: 19px;
  }
  .kdl-theory-complete-body .kdl-theory-table-block.is-card-mobile .kdl-theory-table-wrap { display: none; }
  .kdl-theory-complete-body .kdl-theory-table-block.is-card-mobile .kdl-theory-table-cards { display: grid; }
  .kdl-theory-complete-body .kdl-theory-table-card {
    padding: 16px;
  }
  .kdl-theory-complete-body .kdl-theory-table-card h4 {
    font-size: 20px;
  }
  .kdl-theory-complete-body .kdl-theory-table-card dt,
  .kdl-theory-complete-body .kdl-theory-table-card dd {
    font-size: 18px;
  }
}

@media (max-width: 430px) {
  .kdl-theory-complete-body .kdl-theory-card {
    padding: 22px 15px;
  }
  .kdl-theory-complete-body .kdl-theory-table-card dl > div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
