:root {
  --radius: 26px;
  --border: rgba(179, 179, 179, 0.12);
  --glass: rgba(0, 0, 0, 0.09);
  --soft: rgba(255, 255, 255, 0.06);
  --muted: rgba(255, 255, 255, 0.68);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);

  --anim: 520ms;
  --ease: cubic-bezier(0.2, 0.9, 0.25, 1);
}

body {
  font-family: var(--main-font, "Nata Sans", sans-serif);
  margin: 0;
  min-height: 100vh;
  background-image: var(--site-gradient);
  color: #ddd;
  user-select: text;
  -webkit-user-select: text;
}

button {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.glass {
  background: var(--glass);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}

.glass-lite {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.page {
  width: 100%;
  max-width: 940px;
  margin: 150px auto 90px auto;
  padding: 0 16px;
  position: relative;
}

.hero {
  padding: 18px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--soft), transparent);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}

.hero-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hero-badge {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
  user-select: none;
}

.hero-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.hero-title b {
  font-size: 18px;
  font-weight: 950;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-title span {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#heroSubtitle.typing::after {
  content: "";
  width: 10px;
  height: 14px;
  margin-left: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.12);
  animation: blink 700ms step-end infinite;
  display: inline-block;
  transform: translateY(1px);
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

.hero-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.chip {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
  font-weight: 900;
  font-size: 13px;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

.chip i {
  opacity: 0.85;
  user-select: none;
}

.story-shell {
  margin-top: 14px;
  padding: 14px;
  position: relative;
}

.story-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.chapter {
  padding: 14px;
  position: relative;
  overflow: hidden;
  transform: translateY(10px);
  opacity: 0;
  transition: transform var(--anim) var(--ease), opacity var(--anim) var(--ease);
  will-change: transform;
}

.chapter.in-view {
  transform: translateY(0);
  opacity: 1;
}

.chapter-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chapter-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.chapter-ico {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
  user-select: none;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.chapter-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.chapter-meta h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 950;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.2px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 620px;
}

.chapter-meta p {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  line-height: 1.35;
}

.chapter-body {
  margin-top: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.72;
  font-size: 14.8px;
}

.chapter-body p {
  margin: 0;
}
.chapter-body p + p {
  margin-top: 10px;
}
.chapter-body ul {
  margin: 10px 0 0 18px;
  padding: 0;
}
.chapter-body li {
  margin: 8px 0;
}

.chapter.big-title .chapter-meta h2 {
  font-size: 19px;
}
.chapter.big-title .chapter-body {
  font-weight: 800;
}

.download {
  padding: 14px;
}

.download-inner {
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  display: grid;
  gap: 12px;
}

.download-inner h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 950;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.2px;
}

.download-inner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 800;
  font-size: 13px;
  line-height: 1.45;
}

.dl-btn {
  --p: 0;
  position: relative;
  justify-self: center;

  display: inline-flex;
  align-items: center;
  gap: 12px;

  height: 54px;
  padding: 0 18px;
  border-radius: 20px;

  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.03)
  );
  color: rgba(255, 255, 255, 0.92);

  font-weight: 950;
  font-size: 14px;
  cursor: pointer;

  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease,
    border-color 180ms ease;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.dl-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.dl-btn:active {
  transform: scale(0.99);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35) inset;
}

.dl-btn:disabled {
  cursor: default;
  transform: none;
  opacity: 1;
}

.dl-fill {
  position: absolute;
  inset: 0;
  width: calc(var(--p) * 1%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}
.dl-btn.is-busy .dl-fill {
  opacity: 1;
}

.dl-glow {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: calc(var(--p) * 1% - 24px);
  width: 48px;
  border-radius: 999px;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 255, 255, 0.18),
    transparent 65%
  );
  opacity: 0;
  filter: blur(8px);
  pointer-events: none;
}
.dl-btn.is-busy .dl-glow {
  opacity: 1;
}

.dl-content {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.dl-left {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  display: grid;
  place-items: center;

  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);

  flex: 0 0 auto;
}

.dl-ico {
  display: inline-block;
}

.dl-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.92);
  animation: spin 700ms linear infinite;
}

.dl-btn.is-busy .dl-ico {
  display: none;
}
.dl-btn.is-busy .dl-spinner {
  display: inline-block;
}

.dl-text {
  display: grid;
  gap: 2px;
  text-align: left;
  line-height: 1.05;
}

.dl-title {
  font-weight: 950;
  letter-spacing: 0.2px;
}

.dl-sub {
  font-size: 12px;
  font-weight: 850;
  color: rgba(255, 255, 255, 0.7);
}

.dl-pct {
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
  font-weight: 950;
  color: rgba(255, 255, 255, 0.8);
  min-width: 46px;
  text-align: right;
}

.dl-btn.is-busy .dl-pct {
  color: rgba(255, 255, 255, 0.92);
}

.updated {
  font-size: 12px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.72);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  z-index: 99999;

  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  transition: 0.25s ease;
  font-weight: 900;
  font-size: 13px;
}

.toast.show {
  transform: translateX(-50%) translateY(0px);
  opacity: 1;
}

@media (max-width: 560px) {
  .chapter-meta h2 {
    max-width: 70vw;
  }
  .hero-title b {
    max-width: 70vw;
  }
  .dl-sub {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
  #heroSubtitle.typing::after {
    animation: none !important;
  }
}
@media (max-width: 560px) {
  .page { box-sizing: border-box; }
}
