:root {
  --bg: #f4f1eb;
  --surface: #ffffff;
  --text: #292b35;
  --muted: #747785;
  --accent: #6254d9;
  --accent-light: #eeeaff;
  --border: #e8e5ef;
  --page-bg: #fffefa;
  --shadow: 0 18px 50px rgba(38, 31, 70, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  line-height: 1.65;
  transition: background 0.3s, color 0.3s;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px max(5%, calc((100% - 1200px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -0.3px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: white;
  background: var(--accent);
  font-size: 1.3rem;
}

.top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
}

.text-button,
.icon-button {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.text-button:hover,
.icon-button:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

.app-shell {
  width: min(1120px, 92%);
  margin: 0 auto;
}

.intro {
  max-width: 760px;
  margin: 52px auto 34px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  padding: 5px 13px;
  border-radius: 30px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 1px;
  text-transform: uppercase;
}

h1 {
  margin: 16px 0 12px;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.15;
  letter-spacing: -1.5px;
}

.intro-copy {
  max-width: 630px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
}

.reader {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  margin-bottom: 44px;
}

.contents-panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(38, 31, 70, 0.05);
}

.contents-panel.open {
  display: block;
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  width: min(320px, 86vw);
  max-height: 80vh;
  overflow-y: auto;
}

.contents-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.contents-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.contents-close {
  display: none;
}

.contents-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.contents-item {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 0.88rem;
  line-height: 1.45;
  cursor: pointer;
}

.contents-item:hover {
  background: var(--accent-light);
}

.contents-item.current {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 750;
}

.book-stage {
  min-width: 0;
  perspective: 1800px;
}

.book {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 500px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.page {
  position: relative;
  min-width: 0;
  min-height: 500px;
  padding: clamp(22px, 4vw, 48px);
  overflow-wrap: anywhere;
  background: var(--page-bg);
}

.page-left {
  border-right: 1px solid var(--border);
  border-radius: 12px 0 0 12px;
}

.page-right {
  border-radius: 0 12px 12px 0;
}

.page-number {
  position: absolute;
  bottom: 18px;
  color: var(--muted);
  font-size: 0.78rem;
}

.page-left .page-number {
  left: 28px;
}

.page-right .page-number {
  right: 28px;
}

.chapter-label {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.page h2 {
  margin: 0 0 14px;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.25;
  letter-spacing: -0.5px;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 1rem;
}

.page-content p {
  margin: 0 0 15px;
  font-size: 0.96rem;
  line-height: 1.8;
}

.tip-box,
.prompt-box,
.closing-box {
  margin-top: 22px;
  padding: 15px 17px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.tip-box {
  border-left: 4px solid #d4a12b;
  background: #fff6dd;
  color: #59461a;
}

.prompt-box {
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
  color: var(--text);
}

.prompt-box pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  line-height: 1.7;
}

.closing-box {
  background: #e5f6ed;
  color: #215d42;
}

/* Page-turn animation fix */
.book-stage {
  position: relative;
  min-width: 0;
  perspective: 1800px;
}

/* Page-turn animation */
.book-stage {
  position: relative;
  min-width: 0;
  perspective: 1800px;
}

.book {
  isolation: isolate;
  overflow: hidden;
}

.page-flip {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  left: auto;
  width: 50%;
  height: 100%;
  display: none;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
}

.flip-front,
.flip-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  padding: clamp(22px, 4vw, 48px);
  background: var(--page-bg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-front {
  border-radius: 0 12px 12px 0;
  transform: rotateY(0deg);
}

.flip-back {
  border-radius: 12px 0 0 12px;
  transform: rotateY(180deg);
}

.page-flip.flipping-next {
  animation: flipNext 0.65s ease-in-out forwards;
}

.page-flip.flipping-prev {
  right: auto;
  left: 0;
  transform-origin: right center;
  animation: flipPrev 0.65s ease-in-out forwards;
}

@keyframes flipNext {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(-180deg);
  }
}

@keyframes flipPrev {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(180deg);
  }
}

@media (max-width: 600px) {
  .book {
    display: block;
    min-height: 440px;
  }

  .page-flip {
    width: 100%;
  }

  .flip-front,
  .flip-back {
    padding: 25px 23px 48px;
    border-radius: 12px;
  }
}

.reader-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 112px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s, background 0.2s;
}

.nav-button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.nav-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.nav-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-status {
  min-width: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.progress-track {
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 20px;
  background: var(--border);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.35s ease;
}

.keyboard-hint {
  margin: 18px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
}

.site-footer {
  padding: 25px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  font-size: 0.85rem;
}

/* Mode gelap */
body.dark {
  --bg: #171820;
  --surface: #22242f;
  --text: #f0f0f5;
  --muted: #b0b2c1;
  --accent: #a69bff;
  --accent-light: #35304f;
  --border: #393b49;
  --page-bg: #292b37;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

body.dark .tip-box {
  background: #443a24;
  color: #f6e4b0;
}

body.dark .closing-box {
  background: #203d32;
  color: #c7f1dc;
}

/* Tablet dan ponsel */
@media (max-width: 850px) {
  .reader {
    grid-template-columns: 1fr;
  }

  .contents-panel {
    display: none;
  }

  .contents-panel.open {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    display: block;
    width: min(320px, 86vw);
    overflow-y: auto;
    border-radius: 0;
    box-shadow: 12px 0 35px rgba(0, 0, 0, 0.18);
  }

  .contents-close {
    display: inline-flex;
  }

  .book {
    min-height: 450px;
  }

  .page {
    min-height: 450px;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 12px 4%;
  }

  .brand {
    gap: 8px;
    font-size: 0.85rem;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .top-actions {
    gap: 6px;
  }

  .text-button,
  .icon-button {
    padding: 8px 9px;
    font-size: 0.82rem;
  }

  .app-shell {
    width: 92%;
  }

  .intro {
    margin: 34px auto 24px;
  }

  h1 {
    letter-spacing: -0.8px;
  }

  .intro-copy {
    font-size: 0.94rem;
  }

  .book {
    display: block;
    min-height: 440px;
  }

  .page {
    min-height: 440px;
    padding: 25px 23px 48px;
  }

  .page-left {
    display: none;
  }

  .page-right {
    border-radius: 12px;
  }

  .page-flip {
    width: 100%;
  }

  .flip-front,
  .flip-back {
    padding: 25px 23px 48px;
    border-radius: 12px;
  }

  .reader-controls {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .page-status {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .nav-button {
    min-width: 0;
    padding: 10px 8px;
    font-size: 0.88rem;
  }

  .keyboard-hint {
    font-size: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.topbar .top-actions .language-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 12px;
}

.topbar .top-actions .language-switch a {
    display: inline-block;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 7px;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    background: transparent;
    transition: background-color 0.2s ease;
}

.topbar .top-actions .language-switch a:hover {
    background-color: #e8eefc;
}







