:root {
  color-scheme: light dark;
  --bg: #dfe4e8;
  --surface: #f7f5ef;
  --surface-strong: #fffdf8;
  --ink: #18232d;
  --muted: #60707c;
  --line: #cbd2d7;
  --accent: #b33a2f;
  --accent-strong: #8d2d25;
  --topbar: #111820;
  --topbar-ink: #f8fafb;
  --topbar-muted: #b9c4cc;
  --focus: #f0a548;
  --sidebar-width: 19rem;
  --topbar-height: 4rem;
  --shadow: 0 18px 50px rgb(20 29 36 / 0.2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
#viewerContainer:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.7rem 1rem;
  border-radius: 0.5rem;
  background: var(--surface-strong);
  color: var(--ink);
  transform: translateY(-160%);
  transition: transform 150ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: fixed;
  z-index: 40;
  inset: 0 0 auto 0;
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem max(0.65rem, env(safe-area-inset-right)) 0.55rem max(0.65rem, env(safe-area-inset-left));
  background: var(--topbar);
  color: var(--topbar-ink);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.1);
}

.identity,
.toolbar,
.tool-group,
.actions {
  display: flex;
  align-items: center;
}

.identity {
  min-width: 13rem;
  gap: 0.7rem;
}

.title-block {
  display: grid;
  line-height: 1.15;
}

.eyebrow {
  color: var(--topbar-muted);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.title-block strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
}

.federated-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.curriculum-return {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.45rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 0.55rem;
  background: rgb(255 255 255 / 0.08);
  color: var(--topbar-ink);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
  transition: background 130ms ease, border-color 130ms ease;
}

.curriculum-return:hover {
  border-color: rgb(255 255 255 / 0.38);
  background: rgb(255 255 255 / 0.15);
}

.curriculum-return-code {
  padding: 0.18rem 0.35rem;
  border-radius: 0.35rem;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.toolbar {
  justify-content: flex-end;
  gap: 0.45rem;
}

.tool-group {
  gap: 0.25rem;
}

.tool-separator {
  width: 1px;
  height: 1.65rem;
  margin: 0 0.2rem;
  background: rgb(255 255 255 / 0.16);
}

.icon-button {
  width: 2.45rem;
  height: 2.45rem;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 130ms ease, border-color 130ms ease, opacity 130ms ease;
}

.icon-button:hover:not(:disabled) {
  background: rgb(255 255 255 / 0.1);
  border-color: rgb(255 255 255 / 0.08);
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.32;
}

.icon-button svg,
.search-field svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-field input {
  width: 4rem;
  height: 2.35rem;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 0.45rem;
  background: rgb(255 255 255 / 0.08);
  color: var(--topbar-ink);
  text-align: center;
  appearance: textfield;
}

.page-field input::-webkit-outer-spin-button,
.page-field input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.page-total {
  min-width: 2.3rem;
  color: var(--topbar-muted);
  font-variant-numeric: tabular-nums;
}

#zoomSelect {
  height: 2.35rem;
  max-width: 9.8rem;
  padding: 0 1.8rem 0 0.7rem;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 0.45rem;
  background: #26313a;
  color: var(--topbar-ink);
  cursor: pointer;
}

#zoomSelect:disabled {
  opacity: 0.5;
  cursor: default;
}

.workspace {
  position: fixed;
  inset: var(--topbar-height) 0 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-width: 0;
}

.sidebar {
  position: relative;
  z-index: 30;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1.3rem 1rem max(1.3rem, env(safe-area-inset-bottom));
  border-right: 1px solid var(--line);
  background: var(--surface);
  transition: transform 180ms ease, margin 180ms ease;
}

body.sidebar-hidden .workspace {
  grid-template-columns: 0 minmax(0, 1fr);
}

body.sidebar-hidden .sidebar {
  transform: translateX(-100%);
}

.sidebar-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.sidebar-heading .eyebrow {
  color: var(--accent);
}

.sidebar h1 {
  margin: 0.25rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.05;
}

.sidebar-close {
  color: var(--ink);
}

.sidebar-close:hover:not(:disabled) {
  background: rgb(24 35 45 / 0.07);
  border-color: rgb(24 35 45 / 0.08);
}

.sidebar-summary {
  margin: 0.7rem 0 1.35rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.contents h2 {
  margin: 1.3rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.69rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.contents ol {
  display: grid;
  gap: 0.12rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contents button {
  width: 100%;
  min-height: 2.25rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.58rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.contents button:hover,
.contents button[aria-current="page"] {
  border-color: rgb(179 58 47 / 0.15);
  background: rgb(179 58 47 / 0.09);
}

.contents button[aria-current="page"] {
  color: var(--accent-strong);
  font-weight: 700;
}

.contents small {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chapters button {
  grid-template-columns: 1.7rem minmax(0, 1fr) auto;
}

.chapters b {
  display: inline-grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  border-radius: 50%;
  background: #e5e0d7;
  color: #56636d;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.resource-navigation {
  display: grid;
  gap: 0.45rem;
  margin: 0.85rem 0 1.2rem;
}

.resource-navigation a {
  display: grid;
  gap: 0.18rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--surface-strong);
  color: var(--ink);
  line-height: 1.3;
  text-decoration: none;
}

.resource-navigation a:hover {
  border-color: var(--accent);
}

.resource-navigation-course {
  border-color: rgb(179 58 47 / 0.32) !important;
  background: rgb(179 58 47 / 0.08) !important;
}

.resource-navigation strong {
  color: var(--accent-strong);
  font-size: 0.82rem;
}

.resource-navigation small {
  color: var(--muted);
  font-size: 0.7rem;
}

.contents button[aria-current="page"] b {
  background: var(--accent);
  color: white;
}

.sidebar-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.sidebar-footer a {
  color: var(--accent-strong);
  font-weight: 700;
}

.provenance {
  font-size: 0.68rem;
}

.reader {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0, rgb(255 255 255 / 0.52), transparent 45rem),
    linear-gradient(135deg, #d8dee2, #cbd2d7);
}

#viewerContainer {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

#viewer.pdfViewer {
  padding: 1.2rem 0 4rem;
}

.pdfViewer .page {
  margin: 0 auto 1.2rem;
  border: 0;
  border-radius: 0.18rem;
  box-shadow: var(--shadow);
}

.pdfViewer .page:last-child {
  margin-bottom: 4rem;
}

.loading-state,
.error-state {
  position: absolute;
  z-index: 20;
  inset: 50% auto auto 50%;
  width: min(30rem, calc(100% - 2rem));
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  padding: 1.4rem;
  border: 1px solid rgb(24 35 45 / 0.1);
  border-radius: 0.85rem;
  background: rgb(255 253 248 / 0.94);
  box-shadow: 0 18px 60px rgb(20 29 36 / 0.18);
  color: var(--ink);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}

.loading-state[hidden],
.error-state[hidden] {
  display: none;
}

#loadingDetail {
  color: var(--muted);
  font-size: 0.86rem;
}

.book-mark {
  display: flex;
  align-items: flex-end;
  gap: 0.22rem;
  height: 2rem;
  margin-bottom: 0.2rem;
}

.book-mark span {
  width: 0.28rem;
  height: 100%;
  border-radius: 1rem;
  background: var(--accent);
  animation: book-pulse 900ms ease-in-out infinite alternate;
}

.book-mark span:nth-child(2) {
  height: 68%;
  animation-delay: 170ms;
}

.book-mark span:nth-child(3) {
  height: 42%;
  animation-delay: 340ms;
}

@keyframes book-pulse {
  to { opacity: 0.28; transform: translateY(-0.2rem); }
}

.primary-link {
  display: inline-flex;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  background: var(--accent);
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.search-panel {
  position: fixed;
  z-index: 50;
  top: calc(var(--topbar-height) + 0.55rem);
  right: 0.8rem;
  width: min(37rem, calc(100% - 1.6rem));
  border: 1px solid #39434b;
  border-radius: 0.7rem;
  background: #182129;
  color: var(--topbar-ink);
  box-shadow: 0 14px 40px rgb(0 0 0 / 0.3);
}

.search-panel[hidden] {
  display: none;
}

.search-panel form {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem;
}

.search-field {
  min-width: 8rem;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.65rem;
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 0.45rem;
  background: rgb(255 255 255 / 0.08);
}

.search-field input {
  width: 100%;
  height: 2.3rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--topbar-ink);
}

.search-field input::placeholder {
  color: var(--topbar-muted);
}

.search-status {
  min-width: 5.7rem;
  color: var(--topbar-muted);
  font-size: 0.76rem;
  text-align: center;
}

.scrim {
  position: fixed;
  z-index: 25;
  inset: var(--topbar-height) 0 0;
  background: rgb(8 14 18 / 0.5);
}

.scrim[hidden] {
  display: none;
}

.noscript-message {
  position: fixed;
  z-index: 90;
  inset: auto 1rem 1rem;
  padding: 1rem;
  border-radius: 0.7rem;
  background: #fff3cd;
  color: #513d00;
  text-align: center;
}

@media (max-width: 900px) {
  :root {
    --topbar-height: 3.65rem;
  }

  .identity {
    min-width: auto;
  }

  .title-block {
    display: none;
  }

  .curriculum-return-label {
    display: none;
  }

  .zoom-controls,
  .tool-separator,
  .optional-control {
    display: none;
  }

  .workspace,
  body.sidebar-hidden .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar,
  body.sidebar-hidden .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), calc(100vw - 2.4rem));
    transform: translateX(-100%);
    box-shadow: 12px 0 40px rgb(0 0 0 / 0.24);
  }

  body.mobile-sidebar-open .sidebar {
    transform: translateX(0);
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 0.3rem;
  }

  .toolbar {
    gap: 0.08rem;
  }

  .icon-button {
    width: 2.2rem;
    height: 2.2rem;
  }

  .page-field input {
    width: 3.2rem;
    height: 2.15rem;
  }

  .page-total {
    min-width: 2rem;
    font-size: 0.82rem;
  }

  .actions .icon-button[title="Unduh PDF"] {
    display: none;
  }

  #viewer.pdfViewer {
    padding-top: 0.5rem;
  }

  .pdfViewer .page {
    margin-bottom: 0.55rem;
    border-radius: 0;
    box-shadow: 0 5px 18px rgb(20 29 36 / 0.18);
  }

  .search-panel form {
    flex-wrap: wrap;
  }

  .search-field {
    flex-basis: calc(100% - 0.8rem);
  }

  .search-status {
    flex: 1;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #20282f;
    --surface: #192127;
    --surface-strong: #242e36;
    --ink: #eef2f4;
    --muted: #a9b4bb;
    --line: #344049;
    --accent: #e36b5f;
    --accent-strong: #f18579;
    --shadow: 0 18px 55px rgb(0 0 0 / 0.45);
  }

  .reader {
    background:
      radial-gradient(circle at 50% 0, rgb(255 255 255 / 0.06), transparent 45rem),
      linear-gradient(135deg, #252f36, #1d252b);
  }

  .chapters b {
    background: #303b43;
    color: #c2ccd2;
  }

  .loading-state,
  .error-state {
    border-color: rgb(255 255 255 / 0.08);
    background: rgb(36 46 54 / 0.95);
  }

  .sidebar-close:hover:not(:disabled) {
    background: rgb(255 255 255 / 0.07);
    border-color: rgb(255 255 255 / 0.08);
  }
}
