:root {
  --bg-dark: #060d1f;
  --bg-mid: #0d1c3d;
  --bg-panel: #0e1b38;
  --ink: #2f2417;
  --paper: #f5e8c9;
  --paper-edge: #d2b277;
  --gold: #f3cf8a;
  --gold-soft: #b99656;
  --gold-deep: #8c6a2f;
  --accent: #294a8c;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(243, 207, 138, 0.9) rgba(10, 22, 46, 0.9);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: #f6efe3;
  background:
    radial-gradient(circle at 15% 5%, rgba(243, 207, 138, 0.14) 0%, rgba(243, 207, 138, 0) 28%),
    radial-gradient(circle at 85% 10%, rgba(71, 114, 196, 0.18) 0%, rgba(71, 114, 196, 0) 35%),
    linear-gradient(180deg, #102754 0%, var(--bg-mid) 35%, var(--bg-dark) 100%);
}

*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

*::-webkit-scrollbar-track {
  background: linear-gradient(180deg, rgba(10, 22, 46, 0.9) 0%, rgba(7, 16, 33, 0.95) 100%);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(245, 216, 149, 0.9) 0%, rgba(185, 150, 86, 0.95) 100%);
  border: 2px solid rgba(10, 22, 46, 0.95);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(255, 229, 166, 0.95) 0%, rgba(211, 171, 100, 0.98) 100%);
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(243, 207, 138, 0.2);
  letter-spacing: 0.5px;
}

.topbar p {
  margin: 6px 0 0;
  color: #d9e4ff;
}

.search-wrap {
  width: min(460px, 100%);
  position: relative;
}

#searchInput {
  width: 100%;
  border: 1px solid rgba(243, 207, 138, 0.4);
  background: linear-gradient(180deg, rgba(14, 27, 56, 0.94) 0%, rgba(9, 19, 40, 0.95) 100%);
  color: #f8f2e8;
  font-size: 16px;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 238, 197, 0.15);
}

#searchInput:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(243, 207, 138, 0.22), 0 0 18px rgba(243, 207, 138, 0.18);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(14, 27, 56, 0.98) 0%, rgba(10, 21, 45, 0.98) 100%);
  border: 1px solid rgba(243, 207, 138, 0.35);
  border-radius: 12px;
  overflow: hidden;
  display: none;
  max-height: 300px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 18px 28px rgba(2, 8, 20, 0.45);
  scroll-behavior: smooth;
}

.search-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: #f3ead8;
  padding: 10px 12px;
  cursor: pointer;
}

.search-item:hover,
.search-item:focus {
  background: rgba(243, 207, 138, 0.14);
}

.search-item small {
  display: block;
  opacity: 0.8;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
}

.sidebar {
  background: linear-gradient(165deg, rgba(16, 34, 70, 0.95) 0%, rgba(9, 20, 42, 0.98) 100%);
  border: 1px solid rgba(243, 207, 138, 0.32);
  border-radius: 14px;
  padding: 14px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  scroll-behavior: smooth;
  box-shadow: inset 0 1px 0 rgba(255, 238, 197, 0.12), 0 12px 24px rgba(3, 9, 23, 0.45);
}

.sidebar h2 {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 19px;
}

.category {
  margin-bottom: 12px;
}

.category-title {
  margin: 0 0 8px;
  font-size: 15px;
  color: #d6e4ff;
  border-bottom: 1px solid rgba(243, 207, 138, 0.2);
  padding-bottom: 6px;
}

.course-link {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(243, 207, 138, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.03);
  color: #f7f3e8;
  cursor: pointer;
  font-family: inherit;
  transition: all 140ms ease;
}

.course-link:hover,
.course-link:focus {
  background: rgba(243, 207, 138, 0.15);
  border-color: rgba(243, 207, 138, 0.28);
  transform: translateX(2px);
}

.course-link.active {
  background: linear-gradient(90deg, rgba(243, 207, 138, 0.26) 0%, rgba(243, 207, 138, 0.12) 100%);
  color: #ffe9bb;
  border: 1px solid rgba(243, 207, 138, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 232, 180, 0.1);
}

.book-panel {
  background:
    linear-gradient(180deg, rgba(243, 207, 138, 0.2) 0%, rgba(243, 207, 138, 0.06) 14%, rgba(243, 207, 138, 0) 30%),
    linear-gradient(150deg, rgba(16, 34, 70, 0.92) 0%, rgba(8, 18, 38, 0.95) 100%);
  border: 1px solid rgba(243, 207, 138, 0.36);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 24px 34px rgba(0, 0, 0, 0.42);
}

.book-page {
  background:
    radial-gradient(circle at 100% 0, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0) 22%),
    linear-gradient(180deg, #f7ebcd 0%, #f1ddb4 100%);
  border: 1px solid #d4b57a;
  border-radius: 10px;
  color: var(--ink);
  min-height: calc(100vh - 170px);
  padding: 26px;
  overflow: auto;
  scroll-behavior: smooth;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 0 rgba(165, 128, 67, 0.14);
}

.book-page h1,
.book-page h2,
.book-page h3 {
  color: #3a2a14;
  border-bottom: 1px solid rgba(177, 132, 60, 0.2);
  padding-bottom: 4px;
}

.book-page pre {
  background: #efddba;
  border: 1px solid #d2b27a;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
}

.book-page code {
  background: rgba(80, 57, 30, 0.12);
  padding: 2px 4px;
  border-radius: 4px;
}

.book-page mark.search-highlight {
  background: linear-gradient(180deg, rgba(255, 229, 166, 0.95) 0%, rgba(243, 207, 138, 0.95) 100%);
  color: #2f2417;
  padding: 0 3px;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(162, 122, 54, 0.24);
}

.status {
  margin-top: 8px;
  color: #e8d9bf;
  font-size: 13px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .book-page {
    min-height: 50vh;
  }
}