:root {
  --bg-deep: #201813;
  --bg-mid: #3c2c21;
  --paper: #f4e7ce;
  --paper-dark: #dcc8a2;
  --ink: #2f2118;
  --ink-soft: #5e4737;
  --accent: #965f33;
  --bookmark: #4e2d1b;
  --bookmark-active: #8a4f26;
  --line: #c5a77f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Nanum Myeongjo", "Song Myung", "Gungsuh", "궁서", "Batang", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #5d3f2a 0%, transparent 30%),
    radial-gradient(circle at 90% 80%, #2f1f17 0%, transparent 30%),
    linear-gradient(145deg, #2a1e17, #1b1511 70%);
}

.ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255, 235, 200, 0.06) 1px, transparent 1px),
    radial-gradient(rgba(255, 235, 200, 0.04) 1px, transparent 1px);
  background-size:
    16px 16px,
    24px 24px;
  background-position:
    0 0,
    8px 8px;
}

.cover-stage {
  position: relative;
  width: min(1140px, 94vw);
  margin: 2.4rem auto 1.3rem;
  z-index: 1;
}

.is-hidden {
  display: none !important;
}

.closed-book {
  display: grid;
  grid-template-columns: 62px 1fr 96px;
  min-height: clamp(520px, 74vh, 760px);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(228, 188, 133, 0.25);
  background:
    linear-gradient(132deg, rgba(67, 39, 24, 0.9), rgba(40, 23, 14, 0.98)),
    radial-gradient(circle at 18% 12%, rgba(255, 230, 188, 0.14), transparent 52%);
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(248, 215, 164, 0.12);
}

.closed-book-spine {
  background:
    repeating-linear-gradient(
      180deg,
      rgba(239, 200, 145, 0.24),
      rgba(239, 200, 145, 0.24) 5px,
      rgba(72, 42, 24, 0.95) 5px,
      rgba(72, 42, 24, 0.95) 12px
    );
  border-right: 1px solid rgba(243, 210, 161, 0.2);
}

.closed-book-face {
  padding: clamp(22px, 4vw, 40px);
  color: #f7e9cf;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.cover-eyebrow {
  margin: 0;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-size: 0.79rem;
  font-family: "Song Myung", "Gungsuh", "궁서", serif;
  color: rgba(254, 229, 186, 0.76);
}

.closed-book-face h1 {
  margin: 0;
  color: #fdf4e4;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.cover-lead {
  margin: 0;
  max-width: 38ch;
  color: rgba(251, 228, 194, 0.92);
  line-height: 1.65;
}

.cover-meta {
  border-top: 1px dashed rgba(248, 217, 169, 0.35);
  padding-top: 12px;
  max-width: 56ch;
}

.cover-meta p {
  margin: 0 0 8px;
  color: rgba(249, 226, 193, 0.82);
  line-height: 1.6;
}

.cover-meta-line {
  color: rgba(255, 233, 204, 0.95);
  font-size: 0.9rem;
}

.cover-bookmarks {
  background: linear-gradient(180deg, rgba(64, 36, 22, 0.96), rgba(32, 18, 12, 0.97));
  border-left: 1px solid rgba(246, 214, 166, 0.15);
  padding: 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.cover-bookmark {
  border: none;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(140deg, #8f5226, #6a3b1d);
  color: #f7e4c5;
  font-family: "Nanum Myeongjo", "Song Myung", "Gungsuh", "궁서", serif;
  font-size: 0.88rem;
  line-height: 1.2;
  padding: 11px 8px;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.cover-bookmark:hover {
  transform: translateX(-2px);
  filter: brightness(1.08);
}

.book-shell {
  position: relative;
  width: min(1280px, 94vw);
  margin: 2rem auto;
  display: grid;
  grid-template-columns: 1fr 78px;
  border-radius: 22px;
  overflow: hidden;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 225, 185, 0.12);
}

.page-panel {
  display: none;
}

.page-panel.active {
  display: block;
  animation: page-fade 0.24s ease;
}

.bookmarks {
  background: linear-gradient(180deg, #2c1a11, #1c120d);
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  order: 2;
  border-right: none;
  border-left: 1px solid rgba(255, 220, 180, 0.15);
}

.bookmark {
  border: none;
  border-radius: 12px 0 0 12px;
  background: var(--bookmark);
  color: #f6e2c7;
  font-family: "Nanum Myeongjo", "Song Myung", "Gungsuh", "궁서", serif;
  font-size: 0.85rem;
  line-height: 1.2;
  padding: 12px 8px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.bookmark:hover {
  transform: translateX(-2px);
}

.bookmark.active {
  background: var(--bookmark-active);
}

.book-page {
  order: 1;
  background:
    linear-gradient(180deg, rgba(255, 247, 231, 0.75), rgba(240, 226, 197, 0.85)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 30px,
      rgba(139, 107, 73, 0.12) 30px,
      rgba(139, 107, 73, 0.12) 31px
    ),
    var(--paper);
  padding: 26px;
  max-height: calc(100vh - 5rem);
  min-height: min(78vh, 860px);
  overflow: auto;
}

.page-block {
  margin-bottom: 38px;
  border: 1px solid rgba(121, 83, 49, 0.25);
  border-radius: 16px;
  background: rgba(255, 250, 236, 0.56);
  padding: 20px;
  backdrop-filter: blur(1px);
}

.page-intro {
  background:
    linear-gradient(140deg, rgba(255, 243, 212, 0.95), rgba(232, 208, 164, 0.92));
}

.eyebrow {
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Song Myung", "Gungsuh", "궁서", "Nanum Myeongjo", serif;
}

h1 {
  font-size: clamp(2rem, 3.2vw, 3.15rem);
  margin-bottom: 12px;
}

h2 {
  font-size: clamp(1.65rem, 2.4vw, 2.3rem);
}

.lead {
  margin: 0 0 18px;
  color: var(--ink-soft);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.meta-card {
  border: 1px solid rgba(140, 99, 63, 0.35);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 247, 228, 0.72);
}

.meta-card p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.section-head {
  margin-bottom: 16px;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--ink-soft);
}

.composition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.composition-card {
  border: 1px solid rgba(140, 99, 63, 0.35);
  border-radius: 14px;
  background: rgba(255, 247, 228, 0.78);
  padding: 14px;
}

.composition-card h3 {
  margin-bottom: 5px;
  font-size: 1.35rem;
}

.composition-roles {
  font-size: 0.88rem;
  color: #744e31;
  margin-bottom: 10px;
}

.composition-why {
  margin: 0 0 10px;
  font-size: 0.94rem;
}

.composition-example-label {
  margin: 0 0 8px;
  color: #6f482d;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

.example-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 8px;
}

.example-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.example-names {
  font-size: 0.9rem;
  line-height: 1.35;
  color: #5d3c25;
}

.example-portrait {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #8f633f;
}

.character-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

#character-search {
  flex: 1;
  border: 1px solid rgba(140, 99, 63, 0.45);
  border-radius: 10px;
  background: rgba(255, 250, 237, 0.92);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 0.95rem;
  outline: none;
}

#character-search:focus {
  border-color: var(--accent);
}

.count-badge {
  border: 1px solid rgba(140, 99, 63, 0.45);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 243, 218, 0.88);
  color: #744e31;
  font-size: 0.84rem;
  white-space: nowrap;
}

.characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.character-card {
  border: 1px solid rgba(140, 99, 63, 0.35);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 247, 228, 0.78);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.character-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(42, 26, 16, 0.16);
}

.character-top {
  display: flex;
  gap: 10px;
  align-items: center;
}

.character-thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.character-name {
  font-weight: 700;
  font-size: 1rem;
}

.character-sub {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.role-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.role-chip {
  border: 1px solid rgba(140, 99, 63, 0.45);
  background: rgba(255, 237, 203, 0.8);
  color: #6e482b;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.76rem;
}

.principles-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.character-dialog {
  width: min(860px, 92vw);
  border: none;
  border-radius: 16px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 249, 236, 0.98), rgba(236, 217, 184, 0.98));
  color: var(--ink);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.45);
}

.character-dialog::backdrop {
  background: rgba(10, 6, 4, 0.65);
}

.dialog-close {
  border: 1px solid rgba(140, 99, 63, 0.5);
  border-radius: 9px;
  background: rgba(255, 239, 209, 0.9);
  color: #6e482b;
  font-family: "Nanum Myeongjo", "Song Myung", "Gungsuh", "궁서", serif;
  padding: 6px 10px;
  cursor: pointer;
}

.dialog-layout {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 14px;
  margin-top: 10px;
}

.dialog-thumb {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.dialog-section {
  margin-top: 12px;
  border-top: 1px dashed rgba(121, 83, 49, 0.35);
  padding-top: 10px;
}

.weapon-tabs {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.weapon-tab {
  border: 1px solid rgba(121, 83, 49, 0.45);
  border-radius: 999px;
  background: rgba(255, 241, 213, 0.85);
  color: #6f4629;
  padding: 5px 12px;
  font-family: "Nanum Myeongjo", "Song Myung", "Gungsuh", "궁서", serif;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.weapon-tab:hover {
  transform: translateY(-1px);
}

.weapon-tab.active {
  background: #7a4825;
  color: #f7e7cc;
}

.weapon-pages {
  margin-top: 6px;
}

.weapon-page {
  display: none;
}

.weapon-page.active {
  display: block;
}

.combo-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 8px;
}

.combo-line.mini {
  margin-top: 3px;
  margin-bottom: 8px;
}

.combo-line.mini .skill-icon {
  width: 22px;
  height: 22px;
}

.skill-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(121, 83, 49, 0.35);
  object-fit: cover;
  background: #f7ead1;
}

.skill-icon-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #6e482b;
}

.arrow {
  font-size: 0.85rem;
  color: #845533;
}

.skill-order-weapon {
  border: 1px solid rgba(121, 83, 49, 0.25);
  border-radius: 10px;
  background: rgba(255, 248, 231, 0.72);
  padding: 10px;
  margin-bottom: 10px;
}

.skill-order-weapon h4 {
  margin: 0 0 8px;
  font-family: "Song Myung", "Gungsuh", "궁서", serif;
  font-size: 0.95rem;
  color: #6d452a;
}

.skill-order-build {
  border-top: 1px dashed rgba(121, 83, 49, 0.24);
  padding-top: 8px;
  margin-top: 8px;
}

.skill-order-build:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.skill-order-label {
  font-size: 0.76rem;
  color: #6c472d;
  margin-bottom: 3px;
}

@keyframes page-fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .cover-stage {
    width: min(560px, 94vw);
    margin-top: 1rem;
    margin-bottom: 0.9rem;
  }

  .closed-book {
    grid-template-columns: 18px 1fr 68px;
    min-height: min(78vh, 820px);
  }

  .closed-book-face {
    padding: 20px 16px;
  }

  .closed-book-face h1 {
    font-size: clamp(1.9rem, 8vw, 2.6rem);
  }

  .cover-bookmarks {
    grid-column: auto;
    flex-direction: column;
    justify-content: center;
    overflow: visible;
    border-left: 1px solid rgba(246, 214, 166, 0.15);
    border-top: none;
    padding: 12px 6px;
  }

  .cover-bookmark {
    border-radius: 8px 0 0 8px;
    white-space: normal;
    padding: 10px 6px;
    font-size: 0.8rem;
  }

  .book-shell {
    width: min(560px, 94vw);
    margin: 1.1rem auto 1.4rem;
    grid-template-columns: 1fr 62px;
  }

  .bookmarks {
    order: 2;
    flex-direction: column;
    overflow: visible;
    border-right: none;
    border-left: 1px solid rgba(255, 220, 180, 0.15);
    border-bottom: none;
    padding: 12px 6px;
    gap: 8px;
  }

  .bookmark {
    border-radius: 8px 0 0 8px;
    white-space: normal;
    padding: 10px 6px;
    font-size: 0.78rem;
  }

  .book-page {
    order: 1;
    max-height: min(78vh, 900px);
    min-height: min(78vh, 900px);
    padding: 18px 14px;
  }

  .page-block {
    margin-bottom: 16px;
    padding: 14px;
  }

  .dialog-layout {
    grid-template-columns: 1fr;
  }
}
