:root {
  --bg: #0b0b0b;
  --panel: #111111;
  --surface: #0f0f0f;
  --text: #f5f5f5;
  --muted: #b7b7b7;
  --line: #1e1e1e;
  --accent: #ffffff;
  --brand: #ffffff;
  --brand-overlay: #d1d1d1;
  --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --read-font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --reader-font-size: 17px;
  --reader-line-height: 1.6;
  --reader-page-padding: 26px;
}

body[data-theme="light"] {
  --bg: #f6f2ea;
  --panel: #f0ebe2;
  --surface: #ffffff;
  --text: #111111;
  --muted: #5b5b5b;
  --line: #d7d0c6;
  --accent: #111111;
  --brand: #111111;
  --brand-overlay: #5a4a3c;
}

body[data-theme="sepia"] {
  --bg: #f1e3c7;
  --panel: #ead7b0;
  --surface: #f7ecd3;
  --text: #2a1d10;
  --muted: #6a4c32;
  --line: #d7c3a0;
  --accent: #2a1d10;
  --brand: #ef6c21;
  --brand-overlay: #4d2a14;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui-font);
  overflow: hidden;
}

.app {
  --sidebar-width: 320px;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
}

@supports (height: 100dvh) {
  .app {
    height: 100dvh;
  }
}

.app.collapsed {
  --sidebar-width: 0px;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
  width: var(--sidebar-width);
  transition: transform 0.35s ease, opacity 0.2s ease;
  will-change: transform, opacity;
  transform: translateZ(0);
}

.app.collapsed .sidebar {
  opacity: 0;
  transform: translateX(-12px);
  pointer-events: none;
}

.brand-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
}

.brand-photo {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  position: relative;
  min-height: 38px;
  display: inline-block;
  text-align: center;
}

.brand-heart {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.brand-heart svg {
  width: 16px;
  height: 16px;
  fill: #e25a75;
}

.brand-heart:hover {
  background: var(--panel);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.brand-neville {
  display: block;
  font-family: "Arial Black", "Impact", "Haettenschweiler", sans-serif;
  font-size: 26px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 900;
  text-shadow: 0 0 0.6px var(--brand), 0 0 0.6px var(--brand);
  -webkit-text-stroke: 0.4px var(--brand);
}

.brand-codex {
  position: absolute;
  left: 58%;
  top: 18px;
  font-family: "Playball", "Brush Script MT", "Segoe Script", "Lucida Handwriting", "Apple Chancery", cursive;
  font-size: 20px;
  color: var(--brand-overlay);
  transform: translateX(-10%) rotate(-6deg);
  opacity: 0.95;
  mix-blend-mode: normal;
  text-shadow: 0 0 0.8px var(--brand-overlay), 0 0 0.8px var(--brand-overlay);
  -webkit-text-stroke: 0.2px var(--brand-overlay);
  pointer-events: none;
}

body[data-theme="sepia"] .brand-codex {
  mix-blend-mode: multiply;
}

.toggle {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.35s ease;
}

.toggle:hover {
  border-color: var(--accent);
  background: var(--panel);
}

.toggle::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
  transform: rotate(135deg);
  transition: transform 0.35s ease;
}

.app.collapsed .toggle::before {
  transform: rotate(-45deg);
}

.backdrop {
  display: none;
}

.sidebar-close {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  position: absolute;
  right: 12px;
  top: 12px;
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  z-index: 2;
}

.sidebar-close::before,
.sidebar-close::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.sidebar-close::before {
  transform: rotate(45deg);
}

.sidebar-close::after {
  transform: rotate(-45deg);
}

#search {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 6px;
  outline: none;
  width: 100%;
}

#search::placeholder {
  color: var(--muted);
}

.sorter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 2px 6px 2px 2px;
}

.search-bar #search {
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 0;
}

.search-bar .dropdown {
  position: relative;
  flex: 0 0 auto;
}

.search-bar .dropdown-toggle {
  min-width: 78px;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 24px 8px 10px;
  border-radius: 8px;
}

.search-bar .dropdown-menu {
  left: 0;
  right: auto;
  min-width: 120px;
  max-width: 160px;
  z-index: 45;
}

.count {
  font-size: 12px;
  color: var(--muted);
}

.list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 6px;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.item {
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: border 0.1s ease;
}

.item:hover {
  border: 1px solid var(--line);
}

.item.active {
  border: 1px solid var(--accent);
}

.item-title {
  font-size: 13px;
  line-height: 1.4;
}

.item-title-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.item-saved-icon {
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex: 0 0 auto;
}

.item-saved-icon svg {
  width: 12px;
  height: 12px;
  display: block;
  fill: currentColor;
}

.item-snippet {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.item-snippet .snippet-hit {
  color: var(--text);
  font-weight: 600;
}

.item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.reader {
  padding: 28px 36px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-items: center;
  transition: padding 0.35s ease;
  will-change: padding;
}

@supports (height: 100dvh) {
  .reader {
    height: 100dvh;
  }
}

.app.collapsed .reader {
  padding-left: 32px;
  padding-right: 32px;
}

.reader-header {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  column-gap: 12px;
  position: relative;
}

.header-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.icon-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(239, 108, 33, 0.18);
}

.badge-book {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: var(--ui-font);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-book .badge-asterisk {
  width: 12px;
  height: 12px;
  display: block;
}

.badge-book.small {
  font-size: 10px;
  padding: 2px 7px;
}

.badge-book.small .badge-asterisk {
  width: 11px;
  height: 11px;
}

.title {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  text-align: center;
  line-height: 1.25;
  font-size: 22px;
  font-weight: 600;
}

.mobile-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.item .badge-book {
  margin-top: 6px;
}

.page {
  width: min(720px, 92vw);
  height: calc(100vh - 56px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: var(--reader-page-padding);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px #0b0b0b inset;
}

.title {
  font-size: 22px;
  font-weight: 500;
  text-align: center;
}

.mobile-title {
  font-family: var(--read-font);
  font-size: 20px;
  line-height: 1.25;
  text-align: center;
  margin: 2px 0 16px;
  font-weight: 600;
  display: none;
}

.toggle-reader {
  position: static;
}

.theme-control {
  position: absolute;
  left: 52px;
  right: auto;
  top: 0;
  z-index: 4;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 6px 28px 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  position: relative;
  min-width: 90px;
  text-align: left;
}

.dropdown-toggle::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--text);
  transform: translateY(-30%);
  opacity: 0.7;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  padding: 6px;
  display: none;
  z-index: 40;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--panel);
}

.dropdown-item.active {
  background: #3a78d6;
  color: #fff;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.settings-overlay.open {
  display: flex;
}

.settings-modal {
  width: min(320px, 86vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.settings-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 10px;
}

.settings-section {
  margin-top: 14px;
}

.settings-subtitle {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text);
}

.slider-value {
  color: var(--muted);
}

.slider-ui {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}

.slider-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.slider-fill {
  position: absolute;
  left: 0;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.35;
}

.slider-thumb {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider-thumb:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(239, 108, 33, 0.25);
}

.settings-reset {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.settings-reset:hover {
  background: var(--panel);
}

.content {
  font-family: var(--read-font);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text);
  overflow: auto;
  padding-right: 12px;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

body[data-theme="dark"] .content {
  color: #d9d9d9;
}

body[data-theme="dark"] .content strong {
  color: #ffffff;
}

.content p {
  margin: 0 0 16px;
  text-indent: 1.4em;
}

.content .sentence.marked {
  background: var(--mark-bg, rgba(239, 108, 33, 0.18));
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--mark-border, rgba(239, 108, 33, 0.35));
  padding: 2px 4px;
}

.content .sentence.mark-start::before {
  content: "“";
  font-weight: 700;
  font-size: 22px;
  margin-right: 4px;
  line-height: 0.8;
  vertical-align: -2px;
}

.content .sentence.mark-end::after {
  content: "”";
  font-weight: 700;
  font-size: 22px;
  margin-left: 4px;
  line-height: 0.8;
  vertical-align: -2px;
}

.content .sentence.dimmed {
  filter: blur(2px);
  opacity: 0.55;
  transition: filter 0.2s ease, opacity 0.2s ease;
}

body.no-blur .content .sentence.dimmed {
  filter: none;
  opacity: 0.7;
}

body.mark-mode .content .sentence {
  cursor: pointer;
}

.mark-tooltip {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 4px 0 12px;
  text-align: center;
}

.mark-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin: 0 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  touch-action: none;
}

.mark-actions {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  position: relative;
  margin-left: 6px;
}

.mark-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mark-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  padding: 8px;
  display: none;
  z-index: 50;
  min-width: 180px;
  max-width: 280px;
  width: auto;
  box-sizing: border-box;
  gap: 4px;
  flex-direction: column;
  align-items: stretch;
}

.mark-menu.open {
  display: flex;
}

.mark-menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mark-menu-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.25;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.mark-menu-item:hover {
  background: var(--panel);
}

.mark-menu-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
}

.mark-menu-divider {
  height: 1px;
  background: var(--line);
  opacity: 0.7;
  margin: 2px 4px;
}

.mark-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 4px;
}

.mark-color-btn {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  background: transparent;
}

.mark-color-btn.active {
  box-shadow: 0 0 0 2px var(--accent);
}

.mark-color-btn.color-pink { background: #e75ea4; }
.mark-color-btn.color-orange { background: #ef6c21; }
.mark-color-btn.color-blue { background: #2f7edb; }
.mark-color-btn.color-green { background: #2d9b61; }
.mark-color-btn.color-purple { background: #8a5adf; }
.mark-color-btn.color-red { background: #d84a4a; }

body[data-mark-color="pink"] {
  --mark-bg: rgba(231, 94, 164, 0.2);
  --mark-border: rgba(231, 94, 164, 0.38);
}

body[data-mark-color="orange"] {
  --mark-bg: rgba(239, 108, 33, 0.18);
  --mark-border: rgba(239, 108, 33, 0.35);
}

body[data-mark-color="blue"] {
  --mark-bg: rgba(47, 126, 219, 0.18);
  --mark-border: rgba(47, 126, 219, 0.35);
}

body[data-mark-color="green"] {
  --mark-bg: rgba(45, 155, 97, 0.18);
  --mark-border: rgba(45, 155, 97, 0.35);
}

body[data-mark-color="purple"] {
  --mark-bg: rgba(138, 90, 223, 0.2);
  --mark-border: rgba(138, 90, 223, 0.4);
}

body[data-mark-color="red"] {
  --mark-bg: rgba(216, 74, 74, 0.18);
  --mark-border: rgba(216, 74, 74, 0.35);
}

body[data-theme="dark"] .mark-handle {
  border-color: #3a3a3a;
  background: #141414;
  color: #f2f2f2;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.qa-section {
  margin-top: 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-overlay);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line) inset;
}

.qa-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 12px;
}

.qa-item {
  position: relative;
  padding-left: 0;
  margin-bottom: 14px;
  line-height: 1.6;
}

.qa-label {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.qa-q {
  font-weight: 700;
}

.qa-divider {
  height: 1px;
  background: var(--line);
  opacity: 0.6;
  margin: -2px 0 12px;
}

.donation-block {
  margin: 26px 0 12px;
  padding: 22px 22px 18px;
  background: var(--donation-bg, var(--surface));
  border-radius: 14px;
  font-family: var(--read-font);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

body[data-theme="dark"] .donation-block {
  background: #141210;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

body[data-theme="sepia"] .donation-block {
  background: #f3e7cd;
}

body[data-theme="light"] .donation-block {
  background: #f9f3e8;
}

.donation-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}

.donation-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 14px;
}

.donation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.kofi-widget-placeholder {
  display: inline-flex;
  align-items: center;
}

.kofi-widget-placeholder .kofi-button,
.kofi-widget-placeholder .kofiwidget2 {
  margin: 0;
}

.kofi-widget-frame {
  display: inline-flex;
  align-items: center;
}

.kofi-iframe {
  width: 190px;
  height: 40px;
  border: none;
  background: transparent;
}

.donation-btn {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-family: var(--read-font);
}

.donation-btn:hover {
  background: var(--surface);
}

.donation-btn-20 {
  background: #e2a074;
  border-color: #d08a5d;
  color: #2a1d10;
}

.donation-btn-20:hover {
  background: #e8b08a;
}

body[data-theme="dark"] .donation-btn-20 {
  background: #9a5b3d;
  border-color: #7f462c;
  color: #f6e7d0;
}

body[data-theme="dark"] .donation-btn-20:hover {
  background: #a86848;
}

.donation-exit {
  border: none;
  background: #f08bbb;
  font-size: 13px;
  color: #2a1d10;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 999px;
  margin: 2px 0 10px;
  font-family: var(--read-font);
}

.donation-exit:hover {
  background: #f4a2c9;
}

.donation-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  margin-left: 2px;
  cursor: pointer;
  touch-action: manipulation;
}

.donation-opt input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.notfound-block {
  margin: 32px 0 16px;
  padding: 24px 24px 20px;
  background: var(--surface);
  border-radius: 14px;
  font-family: var(--read-font);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  opacity: 0;
  transform: translateY(6px);
  animation: notfoundFade 0.5s ease forwards;
}

body[data-theme="dark"] .notfound-block {
  background: #141210;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.notfound-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.notfound-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 14px;
}

.notfound-inner {
  display: flex;
  align-items: center;
  gap: 18px;
}

.notfound-copy {
  flex: 1;
  min-width: 0;
}

.notfound-code {
  font-family: "Playball", "Brush Script MT", "Segoe Script", "Lucida Handwriting", "Apple Chancery", cursive;
  font-size: 36px;
  color: var(--brand);
  margin-bottom: 6px;
  line-height: 1;
}

.notfound-butterfly {
  width: 120px;
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.12));
}

.notfound-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: var(--read-font);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.notfound-btn:hover {
  background: var(--panel);
}

.searchinfo-block {
  margin: 32px 0 16px;
  padding: 24px 24px 20px;
  background: var(--surface);
  border-radius: 14px;
  font-family: var(--read-font);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  opacity: 0;
  transform: translateY(6px);
  animation: notfoundFade 0.5s ease forwards;
}

body[data-theme="dark"] .searchinfo-block {
  background: #141210;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.membership-block {
  background: #dbe9f7;
  box-shadow: inset 0 0 0 1px rgba(20, 40, 70, 0.08);
}

body[data-theme="dark"] .membership-block {
  background: #1e2b3a;
  box-shadow: inset 0 0 0 1px rgba(120, 160, 210, 0.18);
}

.searchinfo-inner {
  display: flex;
  align-items: center;
  gap: 18px;
}

.searchinfo-copy {
  flex: 1;
  min-width: 0;
}

.searchinfo-code {
  font-family: "Playball", "Brush Script MT", "Segoe Script", "Lucida Handwriting", "Apple Chancery", cursive;
  font-size: 30px;
  color: var(--brand);
  margin-bottom: 6px;
  line-height: 1;
}

.searchinfo-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.searchinfo-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 14px;
}

.searchinfo-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.searchinfo-unlock {
  margin-bottom: 14px;
}

.searchinfo-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.searchinfo-input {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.searchinfo-input input {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-family: var(--ui-font);
  font-size: 13px;
}

.searchinfo-input button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-family: var(--read-font);
  font-size: 13px;
  cursor: pointer;
}

.searchinfo-input button:hover {
  background: var(--surface);
}

.searchinfo-status {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.searchinfo-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: var(--read-font);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
}

.searchinfo-btn.kofi {
  background: #cfe6ff;
  border-color: #b4d2f3;
  color: #1b2a3b;
}

body[data-theme="dark"] .searchinfo-btn.kofi {
  background: #3a5f85;
  border-color: #6b8db3;
  color: #f1f6ff;
}

.searchinfo-btn:hover {
  background: var(--surface);
}

.searchinfo-btn.ghost {
  background: transparent;
}

.searchinfo-cat {
  width: 120px;
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.12));
}

.membership-perks {
  margin: 0 0 14px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.membership-perks li {
  margin-bottom: 6px;
}

.membership-canvas {
  width: min(560px, 92vw);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  margin: 18px auto 0;
  box-sizing: border-box;
}

.membership-canvas .membership-block {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 22px 22px 20px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

body.banner-mode .sidebar {
  display: none;
}

body.banner-mode .app {
  --sidebar-width: 0px;
  grid-template-columns: 1fr;
}

body.banner-mode .reader {
  padding: 0;
  align-items: stretch;
}

body.banner-mode .reader {
  width: 100%;
}

body.banner-mode .reader-header {
  display: none;
}

body.banner-mode .page {
  width: 100%;
  min-height: 100dvh;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.banner-mode .page,
body.banner-mode .content {
  margin: 0 auto;
}

body.banner-mode .content {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 24px 0;
  flex: none;
  text-align: center;
}

body.banner-mode .membership-canvas {
  margin: 0 auto;
  position: relative;
  left: 0;
}

@keyframes notfoundFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }
  .app {
    display: block;
    height: 100dvh;
    min-height: 100dvh;
    padding-bottom: 0;
  }
  .backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    display: none;
    z-index: 20;
  }
  .app:not(.collapsed) .backdrop {
    display: block;
  }
  .sidebar {
    border-right: 1px solid var(--line);
    border-bottom: none;
    height: 100dvh;
    width: min(86vw, 360px);
    padding: 18px 16px 16px;
    border-radius: 0 18px 18px 0;
    margin: 0;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(0);
    transition: transform 0.35s ease, opacity 0.2s ease;
  }
  .sidebar-close {
    display: inline-flex;
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }
  .app.collapsed .sidebar {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
  }
  .brand-wrap {
    justify-content: flex-start;
  }
  .brand {
    text-align: left;
  }
  .reader {
    height: 100dvh;
    padding: 0;
    align-items: stretch;
  }
  .app.collapsed .reader {
    padding-left: 0;
    padding-right: 0;
  }
  .page {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    padding: calc(var(--reader-page-padding) + env(safe-area-inset-top))
      calc(var(--reader-page-padding) + env(safe-area-inset-right))
      calc(var(--reader-page-padding) + env(safe-area-inset-bottom))
      calc(var(--reader-page-padding) + env(safe-area-inset-left));
    border-radius: 0;
    box-shadow: none;
  }
  .list {
    max-height: calc(100dvh - 190px);
    padding-right: 2px;
  }
  .reader-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }
  .reader-header .title {
    display: none;
  }
  .mobile-title {
    display: block;
  }
  .toggle-reader,
  .theme-control {
    position: static;
  }
  .title {
    font-size: 18px;
    line-height: 1.3;
  }
  .content {
    font-size: var(--reader-font-size);
    line-height: var(--reader-line-height);
    padding-right: 6px;
  }
  .item {
    padding: 12px 12px;
    border-radius: 10px;
  }
  .item-title {
    font-size: 14px;
  }
  .item-meta {
    font-size: 11px;
  }
  .donation-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .donation-butterfly {
    width: 92px;
    align-self: flex-end;
  }
  .notfound-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .notfound-butterfly {
    width: 96px;
    align-self: flex-end;
  }
  .searchinfo-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .searchinfo-cat {
    width: 96px;
    align-self: flex-end;
  }
  #search {
    border-radius: 10px;
  }
  #sort {
    border-radius: 10px;
  }
}
.donation-inner {
  display: flex;
  align-items: center;
  gap: 18px;
}

.donation-copy {
  flex: 1;
  min-width: 0;
}

.donation-heading {
  font-family: var(--read-font);
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--brand);
}

.donation-butterfly {
  width: 110px;
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.12));
}

.theme-control .dropdown-menu {
  left: 0;
  right: auto;
}

.reader-header .theme-control {
  grid-column: 2;
  justify-self: center;
}

.reader-header .header-tools {
  grid-column: 3;
  justify-self: end;
}

.reader-header .toggle-reader {
  grid-column: 1;
  justify-self: start;
}

.reader-header.desktop-header {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-rows: auto auto;
  row-gap: 8px;
  align-items: center;
  column-gap: 12px;
}

.reader-header.desktop-header .toggle-reader {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.reader-header.desktop-header .theme-control {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.reader-header.desktop-header .header-tools {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.reader-header.desktop-header .title {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: center;
  width: 100%;
  text-align: center;
}
