:root {
  --bg: #0e0e0e;
  --surface: #1a1917;
  --surface-2: #242220;
  --border: #2e2b28;
  --text: #f0ede8;
  --secondary: #7a756f;
  --muted: #4a4540;
  --accent: #c9967a;
  --accent-light: #2a1f1a;
  --accent-text: #e0a880;
  --reader-bg: #0e0e0e;
  --reader-text: #f0ede8;
  --reader-size: 16px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  border-inline: 1px solid var(--border);
  position: relative;
}

.topbar,
.bottom-nav {
  position: sticky;
  z-index: 20;
  background: rgba(14, 14, 14, 0.96);
  border-color: var(--border);
}

.topbar {
  top: 0;
  height: 56px;
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.logo {
  width: auto;
  min-width: 0;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  border-radius: 6px;
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
}

.page {
  min-height: calc(100vh - 112px);
  padding: 24px 20px 88px;
}

.bottom-nav {
  bottom: 0;
  height: 58px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--secondary);
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 6px;
  font-size: 12px;
}

.nav-item.active {
  color: var(--accent-text);
}

.hero-title {
  font-family: "Lora", serif;
  font-size: clamp(32px, 9vw, 50px);
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  margin: 36px auto 22px;
  max-width: 430px;
}

.primary-btn,
.secondary-btn,
.quiet-btn,
.danger-btn {
  min-height: 44px;
  border-radius: 7px;
  padding: 0 16px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface-2);
}

.primary-btn {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 600;
}

.secondary-btn {
  background: var(--accent-light);
  color: var(--accent-text);
}

.quiet-btn {
  background: transparent;
}

.danger-btn {
  background: transparent;
  color: #d6a59a;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.center {
  display: grid;
  place-items: center;
}

.banner,
.empty,
.notice {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px;
  border-radius: 7px;
  color: var(--secondary);
  line-height: 1.55;
}

.notice.welcome {
  color: var(--accent-text);
  background: var(--accent-light);
}

.cover-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 108px;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0 10px;
  margin-inline: -2px;
}

.cover {
  aspect-ratio: 2 / 3;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--text);
  font-family: "Lora", serif;
  font-size: 34px;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  margin: 28px 0 12px;
}

.novel-list,
.chapter-list,
.simple-list {
  display: grid;
  gap: 10px;
}

.novel-item,
.chapter-item,
.profile-row,
.admin-row {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  padding: 12px;
}

.novel-item {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
}

.mini-cover {
  width: 54px;
  height: 78px;
  font-size: 23px;
}

.title {
  font-weight: 600;
}

.subtle {
  color: var(--secondary);
  line-height: 1.5;
}

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

.badge,
.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--secondary);
  font-size: 12px;
}

.badge.accent {
  color: var(--accent-text);
  background: var(--accent-light);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span {
  color: var(--secondary);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 7px;
  min-height: 44px;
  padding: 10px 12px;
}

textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.5;
}

.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.46);
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 45;
  width: min(82vw, 320px);
  transform: translateX(-280px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
}

.drawer a,
.drawer button {
  width: 100%;
  min-height: 42px;
  border: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  padding: 8px 0;
  text-decoration: none;
}

.modal {
  position: fixed;
  z-index: 50;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.reader {
  min-height: 100vh;
  background: var(--reader-bg);
  color: var(--reader-text);
}

.reader .page {
  padding: 0;
}

.reader-content {
  font-family: "Lora", serif;
  font-size: var(--reader-size);
  line-height: 1.95;
  padding: 28px 22px 120px;
}

.reader-content p {
  margin: 0 0 1.35em;
}

.reader-ui {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 560px);
  z-index: 35;
  background: rgba(14, 14, 14, 0.96);
  border-color: var(--border);
}

.reader-top {
  top: 0;
  min-height: 54px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
}

.reader-bottom {
  bottom: 0;
  border-top: 1px solid var(--border);
  padding: 10px;
  display: grid;
  gap: 10px;
}

.progress {
  height: 3px;
  background: var(--surface-2);
}

.progress span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--accent);
}

.tabs,
.segments {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  overflow-x: auto;
}

.tabs button,
.segments button {
  min-height: 36px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--secondary);
  padding: 0 12px;
  white-space: nowrap;
}

.tabs button.active,
.segments button.active {
  color: var(--accent-text);
  background: var(--accent-light);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  width: min(92vw, 500px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
}

.hidden {
  display: none;
}

@media (min-width: 700px) {
  body {
    padding: 24px 0;
  }

  .app-shell {
    min-height: calc(100vh - 48px);
  }

  .drawer {
    left: calc(50% - 280px);
    transform: none;
  }
}

/* Visual overhaul: app-first layout, site theme toggle, reader-only background controls. */
body[data-theme="light"] {
  --bg: #f7f4ef;
  --surface: #eee8df;
  --surface-2: #e4ddd3;
  --border: #d4cabd;
  --text: #25211d;
  --secondary: #716960;
  --muted: #9a9086;
  --accent-light: #ead8cc;
  --accent-text: #8a563d;
  color-scheme: light;
}

body,
.app-shell,
.page {
  background: var(--bg);
}

.topbar,
.bottom-nav,
.reader-ui {
  background: var(--bg);
}

.page {
  padding: 16px 16px 88px;
}

button,
.primary-btn,
.secondary-btn,
.quiet-btn,
.danger-btn,
.nav-item,
.chapter-item,
.novel-item,
.drawer-link,
.drawer-chip,
.drawer-segments button,
.reader-save,
.pill-btn,
.boba-line button {
  border-radius: 8px;
  text-align: left;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.hero-title {
  margin: 24px auto 16px;
}

.section-title {
  margin: 24px 0 12px;
}

.banner,
.empty,
.notice,
.novel-item,
.chapter-item,
.profile-row,
.admin-row {
  padding: 16px;
}

.novel-item,
.chapter-item {
  width: 100%;
  color: var(--text);
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chapter-item .title {
  min-width: 0;
  flex: 1;
}

.badge {
  flex: 0 0 auto;
  min-height: 22px;
  border: 0;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.badge.free {
  background: #2f6f4e;
  color: #fff;
}

.badge.locked {
  background: var(--surface-2);
  color: var(--secondary);
}

.drawer {
  display: grid;
  align-content: start;
  gap: 0;
  padding: 20px 18px;
}

.drawer-title {
  font-weight: 600;
  margin-bottom: 16px;
}

.drawer-section {
  display: grid;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.drawer-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.drawer-link,
.drawer-details summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0 12px;
  border-radius: 8px;
}

.drawer-details summary {
  cursor: pointer;
}

.drawer-chips,
.drawer-segments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}

.drawer-chip,
.drawer-segments button {
  min-height: 32px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--secondary);
  padding: 0 10px;
}

.drawer-segments button.active {
  background: var(--accent-light);
  color: var(--accent-text);
}

.drawer-section-title {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drawer-section-title.small {
  margin-top: 2px;
}

.toggle-row,
.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  color: var(--text);
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-row i {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  flex: 0 0 auto;
}

.toggle-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--secondary);
  transition: transform 180ms ease, background 180ms ease;
}

.toggle-row input:checked + i {
  background: var(--accent-light);
}

.toggle-row input:checked + i::after {
  transform: translateX(20px);
  background: var(--accent);
}

.slider-row input {
  width: 140px;
  accent-color: var(--accent);
}

.drawer-about span {
  display: block;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
}

.drawer-about p {
  margin: 0;
  color: var(--secondary);
  line-height: 1.5;
}

.reader,
.reader .page {
  background: var(--reader-bg);
  color: var(--reader-text);
}

.reader-content {
  width: 100%;
  max-width: none;
  background: var(--reader-bg);
  color: var(--reader-text);
  padding: 28px 22px 112px;
}

.reader-bottom {
  padding: 10px 12px 12px;
  gap: 10px;
}

.reader-tools {
  display: grid;
  gap: 8px;
}

.segments.compact {
  margin: 0;
  gap: 6px;
}

.segments.compact button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.reader-nav {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  align-items: center;
  gap: 10px;
}

.pill-btn,
.reader-save {
  min-height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.primary-pill {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  font-weight: 600;
}

.reader-save {
  width: 40px;
  padding: 0;
  color: var(--accent-text);
  background: var(--accent-light);
}

.boba-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 16px;
  padding-top: 14px;
  border-top: 1px solid color-mix(in srgb, var(--reader-text) 18%, transparent);
  color: color-mix(in srgb, var(--reader-text) 68%, transparent);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 13px;
}

.boba-line button {
  min-height: 32px;
  border: 1px solid color-mix(in srgb, var(--reader-text) 18%, transparent);
  background: transparent;
  color: inherit;
  padding: 0 10px;
}

@media (min-width: 700px) {
  .page {
    padding-inline: 18px;
  }
}
