:root {
  --bg: #fdf6ec;
  --surface: #fff8f0;
  --text: #1a1209;
  --text2: #6b5535;
  --accent: #c5892a;
  --accent-light: #fff3dc;
  --border: #e8d5b7;
}
[data-theme="dark"] {
  --bg: #120e08;
  --surface: #1e1710;
  --text: #f0e2c8;
  --text2: #b89060;
  --accent: #d4a050;
  --accent-light: #271e10;
  --border: #3a2e1c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: Georgia, 'Times New Roman', serif; background: var(--bg); color: var(--text); min-height: 100vh; transition: background .3s, color .3s; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── SITE HEADER ── */
.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .6rem;
  padding: .9rem 1.4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}
.header-left { display: flex; align-items: center; gap: .6rem; }
.site-logo-btn { justify-self: center; text-align: center; white-space: nowrap; background: none; border: none; padding: 0; font: inherit; font-size: 1.2rem; font-weight: bold; color: var(--accent); letter-spacing: .04em; }
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .38rem .75rem;
  font-size: .95rem;
  color: var(--text);
  transition: background .15s;
}
.icon-btn:hover { background: var(--accent-light); }

/* ── HOME ── */
.home-wrap { max-width: 680px; margin: 0 auto; padding: .9rem 1.4rem 5rem; }
.series-banner {
  text-align: center;
  font-size: 1rem;
  font-style: italic;
  color: var(--text2);
  letter-spacing: .08em;
  margin-bottom: 1.8rem;
  line-height: 1.6;
}
.stories-grid { display: flex; flex-direction: column; }
.story-item {
  display: flex;
  align-items: baseline;
  gap: .65rem;
  padding: .6rem .1rem;
  border-bottom: 1px solid var(--border);
  transition: opacity .2s;
}
.story-item:last-child { border-bottom: none; }
.story-item:hover .item-title { color: var(--accent); }
.item-num { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: .66rem; font-weight: bold; color: #fff; background: var(--accent); border-radius: 999px; width: 1.45rem; height: 1.45rem; }
.item-title { font-size: .96rem; font-weight: bold; color: var(--text); line-height: 1.4; }
.story-item.is-read { opacity: .45; }

/* ── ARTICLE HEADER ── */
.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}
.reader-mid { flex: 1; display: flex; align-items: center; justify-content: center; gap: .6rem; min-width: 0; }
.reader-title { font-size: .92rem; font-weight: bold; color: var(--accent); }

/* ── NAV ARROWS (fixed in header, prev/next story) ── */
.nav-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--accent);
  background: var(--surface);
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.nav-arrow:hover { background: var(--accent-light); border-color: var(--accent); }
.nav-arrow.disabled { color: var(--border); pointer-events: none; }

/* ── ARTICLE BODY ── */
.article-wrap { max-width: 680px; margin: 0 auto; padding: 1.2rem 1.2rem 6rem; }
.article-meta { margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.article-num { float: right; display: inline-flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: bold; color: #fff; background: var(--accent); border-radius: 999px; width: 1.75rem; height: 1.75rem; margin: .35rem 0 .3rem .6rem; }
.article-cat { display: inline-block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: .15rem .6rem; }
.article-wrap h1 { display: block; font-size: 1.7rem; font-weight: bold; line-height: 1.32; margin-bottom: .5rem; color: var(--text); }
.article-teaser { font-size: .95rem; font-style: italic; color: var(--text2); margin-bottom: 2.2rem; line-height: 1.65; }
.article-wrap p { margin: 0 0 1.1em; line-height: 1.92; font-size: 1.02rem; text-align: justify; color: var(--text); text-indent: 1.4em; }
.article-wrap hr { border: none; border-top: 1px solid var(--border); margin: 2.4rem 0 1.6rem; }

/* ── SOURCES ── */
.sources-box { margin-top: 2.6rem; padding: 1.1rem 1.3rem; background: var(--accent-light); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; }
.sources-box h3 { font-size: .8rem; font-weight: bold; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); margin-bottom: .7rem; }
.sources-box ol { padding-left: 1.2rem; }
.sources-box li { font-size: .85rem; line-height: 1.6; margin-bottom: .4rem; color: var(--text2); }
.sources-box a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(197,137,42,.35); word-break: break-word; }
.sources-box a:hover { text-decoration-color: var(--accent); }

@media (max-width: 480px) {
  .article-wrap h1 { font-size: 1.4rem; }
}

/* ── BOOKS GRID ── */
.book-item { align-items: center; }
.book-item .story-link { align-items: center; }
.book-emoji { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; width: 1.9rem; }
.book-sub { display: block; font-size: .78rem; font-weight: normal; color: var(--text2); margin-top: .2rem; line-height: 1.5; }

/* ── BOOK CHAPTER CONTENT BLOCKS ── */
.article-wrap h3 { font-size: 1.05rem; font-weight: bold; margin: 1.7rem 0 .6rem; color: var(--text); }
.block-bullets { margin: 0 0 1.2em 1.4em; }
.block-bullets li { margin-bottom: .55rem; line-height: 1.75; }

.callout { margin: 1.3rem 0; padding: .9rem 1.15rem; border-radius: 0 10px 10px 0; border-left: 4px solid; line-height: 1.75; font-size: .95rem; }
.callout-label { display: block; font-size: .72rem; font-weight: bold; letter-spacing: .07em; text-transform: uppercase; margin-bottom: .35rem; }
.callout-bad { background: rgba(192, 57, 43, .09); border-color: #c0392b; }
.callout-bad .callout-label { color: #c0392b; }
.callout-good { background: rgba(46, 125, 50, .09); border-color: #2e7d32; }
.callout-good .callout-label { color: #2e7d32; }
.callout-tip { background: var(--accent-light); border-color: var(--accent); }
.callout-tip .callout-label { color: var(--accent); }
.callout-exercise { background: var(--accent-light); border-color: var(--text2); }
.callout-exercise .callout-label { color: var(--text2); }
.callout-parentnote { background: var(--surface); border-color: var(--text2); border-left-style: dashed; }
.callout-parentnote .callout-label { color: var(--text2); }

.dialogue-line { margin: 0 0 .85em; padding: .55rem .95rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font-size: .96rem; line-height: 1.65; }
.dialogue-line b { color: var(--accent); }

.checklist-box { margin: 1.3rem 0; }
.checklist-box .checklist-title { font-size: .85rem; font-weight: bold; color: var(--text2); margin-bottom: .5rem; }
.checklist-box ul { list-style: none; }
.checklist-box li { padding: .35rem 0 .35rem 1.7rem; position: relative; line-height: 1.65; }
.checklist-box li::before { content: '☐'; position: absolute; left: 0; color: var(--accent); }

.content-table-wrap { overflow-x: auto; margin: 1.3rem 0; -webkit-overflow-scrolling: touch; }
.content-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.content-table th, .content-table td { border: 1px solid var(--border); padding: .5rem .65rem; text-align: left; vertical-align: top; }
.content-table th { background: var(--accent-light); color: var(--text2); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }

@media (max-width: 480px) {
  .content-table { font-size: .78rem; }
}

/* ── BOOK: continuous flow + inline table of contents ── */
.book-toc { margin: 0 0 2.6rem; padding: 1.1rem 1.3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.book-toc-title { font-size: .78rem; font-weight: bold; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); margin-bottom: .8rem; }
.book-toc ol { list-style: decimal; padding-left: 1.3rem; }
.book-toc li { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .5rem; line-height: 1.55; }
.book-toc a { color: var(--text); font-size: .92rem; }
.book-toc a:hover { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(197,137,42,.35); }

.book-chapter { scroll-margin-top: 4.6rem; padding-top: .5rem; }
.chapter-part { display: inline-block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: .15rem .6rem; margin-bottom: .7rem; }
.chapter-title { font-size: 1.25rem; font-weight: bold; line-height: 1.35; margin: 0 0 1rem; color: var(--text); }
.chapter-divider { border: none; border-top: 1px dashed var(--border); margin: 2.6rem 0; }

@media (max-width: 480px) {
  .chapter-title { font-size: 1.12rem; }
}

/* ── USER PROFILE ── */
.header-right { display: flex; align-items: center; gap: .6rem; justify-self: end; }
#profile-btn { font-weight: bold; transition: color .15s, border-color .15s; }
.profile-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 1rem;
}
.profile-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.4rem; max-width: 320px; width: 100%;
}
.profile-modal-title { font-weight: bold; text-align: center; margin-bottom: 1rem; font-size: 1.05rem; }
.profile-grid { display: flex; flex-direction: column; gap: .55rem; }
.profile-pick-btn {
  display: flex; align-items: center; gap: .65rem;
  background: none; border: 1px solid var(--border); border-radius: 10px;
  padding: .6rem .8rem; font: inherit; font-size: .95rem; color: var(--text);
  transition: background .15s;
}
.profile-pick-btn:hover { background: var(--accent-light); }
.profile-pick-dot { width: .85rem; height: .85rem; border-radius: 50%; flex-shrink: 0; }

/* ── READ CHECKBOXES ── */
.story-check { accent-color: var(--accent); width: 1.05em; height: 1.05em; cursor: pointer; flex-shrink: 0; }
.story-link { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: .65rem; }
.read-check-label { display: inline-flex; align-items: center; gap: .4em; font-size: .78rem; color: var(--text2); font-family: -apple-system, sans-serif; float: right; cursor: pointer; }
.read-check-end { float: none; display: flex; justify-content: flex-end; margin-top: 1.8rem; }
