@import url("./tokens.css");

.reader-page {
  --reader-bg: #f3f0e8;
  --reader-surface: #fffdf8;
  --reader-ink: #27231f;
  --reader-page-bg: #f6f2e9;
  --reader-surface: #fffdf8;
  --reader-text: #27231f;
  --reader-muted: #6c675f;
  --reader-font: var(--font-reading);
  --reader-font-size: 18px;
  --reader-line-height: 2.05;
  --reader-letter-spacing: 0;
  background: var(--reader-bg);
  color: var(--reader-ink);
}

.reader-settings-panel {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 42;
  width: min(390px,calc(100vw - 40px));
  max-height: calc(100vh - 94px);
  overflow-y: auto;
  padding: 0 18px 18px;
  background: var(--reader-surface);
  border: 1px solid var(--color-line);
  box-shadow: var(--shadow-high);
  transform: translateX(calc(100% + 32px));
  visibility: hidden;
  transition: transform .2s ease,visibility .2s ease;
}
.reader-settings-panel.is-open { transform: translateX(0); visibility: visible; }
.reader-settings-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--color-line); }
.reader-settings-head strong { display: inline-flex; align-items: center; gap: 8px; }
.reader-settings-head button { width: 34px; height: 34px; display: grid; place-items: center; color: inherit; background: transparent; border: 0; cursor: pointer; }
.reader-setting-group { display: grid; gap: 9px; padding: 14px 0; border-bottom: 1px solid var(--color-line); }
.reader-setting-group > span { color: var(--reader-muted); font-size: 12px; font-weight: 700; }
.reader-segmented { display: grid; grid-template-columns: repeat(3,1fr); border: 1px solid var(--color-line); }
.reader-segmented button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; color: inherit; background: transparent; border: 0; border-right: 1px solid var(--color-line); cursor: pointer; }
.reader-segmented button:last-child { border-right: 0; }
.reader-segmented button.is-active { color: #fff; background: var(--color-emerald); }
.reader-backgrounds { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; }
.reader-backgrounds button { min-height: 54px; display: grid; place-items: center; gap: 4px; color: inherit; background: transparent; border: 1px solid var(--color-line); cursor: pointer; font-size: 11px; }
.reader-backgrounds button i { width: 22px; height: 22px; display: block; border: 1px solid #d5d5d5; border-radius: 50%; }
.reader-backgrounds [data-reader-background="warm"] i { background: #f6f2e9; }
.reader-backgrounds [data-reader-background="white"] i { background: #fff; }
.reader-backgrounds [data-reader-background="green"] i { background: #e7f0df; }
.reader-backgrounds [data-reader-background="gray"] i { background: #eceff0; }
.reader-backgrounds button.is-active { color: var(--color-emerald); border-color: var(--color-emerald); }
.reader-size-setting > div { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; border: 1px solid var(--color-line); }
.reader-size-setting button { height: 38px; display: grid; place-items: center; color: inherit; background: transparent; border: 0; cursor: pointer; }
.reader-size-setting output { text-align: center; font-weight: 700; }
.reader-settings-reset { width: 100%; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; color: var(--color-emerald); background: transparent; border: 1px solid var(--color-emerald); cursor: pointer; }
.reader-settings-panel svg { width: 17px; height: 17px; }

.reader-header {
  position: sticky;
  top: 0;
  z-index: 30;
  color: var(--color-ink);
  background: rgba(255, 253, 248, 0.96);
  border-bottom: 3px solid var(--color-emerald);
  box-shadow: 0 3px 14px rgba(25, 36, 32, 0.08);
}

.reader-header-inner {
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
}

.reader-book-link {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-header-title {
  max-width: 520px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.reader-icon-button {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  color: var(--color-emerald-strong);
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.reader-icon-button:has([data-lucide]) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.reader-main {
  width: min(calc(100% - 40px), 900px);
  margin: 32px auto 0;
}

.reader-article {
  padding: 42px 70px 28px;
}

.reader-title {
  margin: 0;
  text-align: center;
  font-size: 32px;
  line-height: 1.35;
}

.reader-byline {
  margin: 10px 0 42px;
  color: #7b746c;
  text-align: center;
  font-size: 14px;
}

.reader-content {
  font-family: var(--font-reading);
  font-size: 20px;
  line-height: 2;
  letter-spacing: 0;
}

.reader-content p {
  margin: 0 0 1.25em;
  text-indent: 2em;
}

.reader-end {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-top: 52px;
  color: var(--color-ink-soft);
  text-align: center;
}

.reader-end::before,
.reader-end::after {
  content: "";
  height: 1px;
  background: #d9d5c9;
}

.reader-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  margin-top: 24px;
}

.reader-nav a,
.reader-nav button {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  background: #fff;
  border: 1px solid #ccd5cf;
  border-radius: var(--radius-sm);
  cursor: pointer;
  gap: 8px;
}

.reader-nav a:last-child {
  color: #fff;
  background: var(--color-emerald);
  border-color: var(--color-emerald);
}

.reader-recent {
  margin-top: 20px;
  padding: 22px;
  background: rgba(255, 253, 248, 0.62);
  border-top: 1px solid #d9d5c9;
  border-bottom: 1px solid #d9d5c9;
}

.reader-recent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 32px;
}

.reader-recent-grid a {
  padding: 10px 4px;
  overflow: hidden;
  border-bottom: 1px solid #e0dccf;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-recent-grid a::before {
  content: "";
  width: 0;
  height: 0;
  display: inline-block;
  margin: 0 9px 1px 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--color-emerald);
}

.reader-drawer {
  position: fixed;
  top: 74px;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  width: min(420px, calc(100vw - 40px));
  display: none;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-high);
}

.reader-drawer.is-open {
  display: flex;
}

.reader-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-line);
}

.reader-drawer-head strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.reader-drawer-list {
  overflow-y: auto;
  padding: 10px;
}

.reader-drawer-list a {
  display: block;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
}

.reader-drawer-list a:hover,
.reader-drawer-list a.is-current {
  color: var(--color-emerald);
  background: var(--color-emerald-soft);
}

.reader-footer {
  margin-top: 52px;
  padding: 28px 0;
  color: rgba(255, 255, 255, 0.72);
  background: var(--color-emerald-strong);
  text-align: center;
  font-size: 13px;
}

@media (max-width: 760px) {
  .reader-header-inner {
    grid-template-columns: 1fr auto;
  }

  .reader-header-title {
    display: none;
  }

  .reader-article {
    padding: 36px 24px 48px;
  }

  .reader-title {
    font-size: 26px;
  }

  .reader-content {
    font-size: 18px;
  }

  .reader-recent-grid {
    grid-template-columns: 1fr;
  }

  .reader-settings-panel { top: 64px; right: 10px; width: calc(100vw - 20px); max-height: calc(100vh - 74px); }
}
