:root {
  --bg: #fbf8f1;
  --bg-soft: #f7f2e9;
  --panel: rgba(255, 251, 244, 0.72);
  --ink: #2f2a24;
  --muted: rgba(47, 42, 36, 0.56);
  --line: rgba(78, 62, 42, 0.14);
  --accent: #8a5f3c;
  --accent-weak: rgba(138, 95, 60, 0.12);
  --shadow: 0 22px 54px rgba(72, 52, 32, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 252, 244, 0.96), transparent 24%),
    radial-gradient(circle at 82% 16%, rgba(230, 214, 189, 0.28), transparent 22%),
    radial-gradient(circle at 50% 70%, rgba(238, 227, 209, 0.36), transparent 26%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif SC", serif;
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background:
    radial-gradient(circle at 25% 30%, rgba(171, 140, 97, 0.14), transparent 0 17%, transparent 19%),
    radial-gradient(circle at 72% 22%, rgba(205, 188, 162, 0.12), transparent 0 15%, transparent 18%),
    radial-gradient(circle at 40% 78%, rgba(190, 170, 140, 0.1), transparent 0 16%, transparent 19%),
    radial-gradient(circle at 78% 74%, rgba(166, 145, 116, 0.09), transparent 0 14%, transparent 18%);
  opacity: 0.55;
  filter: blur(6px);
}

body::after {
  background:
    linear-gradient(120deg, transparent 0 44%, rgba(255, 255, 255, 0.06) 48%, transparent 52%),
    linear-gradient(65deg, transparent 0 62%, rgba(169, 146, 116, 0.05) 66%, transparent 72%);
  opacity: 0.8;
}

button,
input,
select {
  font: inherit;
}

.shell {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  z-index: 1;
}

.frame {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.card {
  position: relative;
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 252, 0.45), rgba(255, 251, 244, 0.88)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.03) 0%, rgba(255, 252, 246, 0.01) 42%, rgba(255, 248, 239, 0.12) 100%),
    url("./images/reading-bg.jpg") center bottom / cover no-repeat;
  opacity: 0.38;
  filter: saturate(0.62) contrast(1.08) blur(0px);
  pointer-events: none;
  z-index: 0;
}

.reader {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  gap: 12px;
  padding: clamp(12px, 1.8vw, 22px);
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.source {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.status {
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-weak);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

.content {
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 18px;
  border: 1px solid rgba(78, 62, 42, 0.08);
  border-radius: 22px;
  background: rgba(255, 251, 244, 0.08);
  backdrop-filter: blur(2px);
}

.stage {
  white-space: pre-wrap;
  word-break: break-word;
}

.original {
  font-size: clamp(28px, 5vw, 34px);
  line-height: 1.9;
  letter-spacing: 0.01em;
}

.light {
  margin-top: 22px;
  font-size: clamp(18px, 3vw, 22px);
  line-height: 1.8;
  color: rgba(47, 42, 36, 0.6);
}

.deep {
  margin-top: 22px;
  font-size: clamp(20px, 3vw, 24px);
  line-height: 1.9;
  color: rgba(47, 42, 36, 0.76);
}

.chunk {
  display: inline;
}

.reveal {
  opacity: 0;
  transform: translateY(8px);
  filter: blur(1px);
  animation: fadeUp var(--reveal-duration, 1000ms) cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: opacity, transform, filter;
}

.tail-punctuation,
.chunk.punctuation.blink {
  display: inline-block;
  transform-origin: center;
}

.tail-punctuation.blink,
.chunk.punctuation.blink {
  animation: punctuationBlink 125ms linear infinite;
}

.footer {
  flex-shrink: 0;
  padding-top: 2px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  margin-top: 0;
  border-top: 1px solid rgba(78, 62, 42, 0.1);
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.3), rgba(255, 251, 244, 0.68));
  backdrop-filter: blur(10px);
}

.progress {
  height: 1px;
  border-radius: 999px;
  background: rgba(78, 62, 42, 0.12);
  overflow: hidden;
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(138, 95, 60, 0.35), rgba(138, 95, 60, 0.85));
  transition: width 220ms ease;
}

.meta-line {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group.center {
  justify-content: center;
}

.control-group.right {
  justify-content: flex-end;
}

.nav-btn,
.mode-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 16px;
}

.nav-btn.active {
  background: var(--accent-weak);
  color: var(--accent);
}

.nav-btn {
  font-size: 23px;
  line-height: 1;
  padding: 10px 12px;
}

.mode-btn {
  font-size: 13px;
  min-width: 44px;
  padding: 10px 12px;
}

.mode-btn.active {
  background: var(--accent-weak);
  color: var(--accent);
}

.nav-btn:disabled {
  opacity: 0.25;
}

@keyframes fadeUp {
  0% {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(1px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes punctuationBlink {
  0%,
  79.999% {
    opacity: 1;
  }

  80%,
  100% {
    opacity: 0.32;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 0;
  }

  .reader {
    padding: 12px 12px 10px;
    border-radius: 0;
    gap: 12px;
  }

  .topbar {
    display: none;
  }

  .source {
    font-size: 13px;
  }

  .status {
    font-size: 12px;
    padding: 7px 10px;
    align-self: flex-start;
  }

  .content {
    padding: 12px 10px 14px;
    border-radius: 18px;
  }

  .reveal {
    transform: translateY(10px);
    filter: blur(1.1px);
  }

  .original {
    font-size: clamp(24px, 6.4vw, 30px);
    line-height: 1.85;
  }

  .light {
    font-size: clamp(16px, 4.2vw, 20px);
    line-height: 1.75;
    margin-top: 18px;
  }

  .deep {
    font-size: clamp(18px, 4.6vw, 22px);
    line-height: 1.85;
    margin-top: 18px;
  }

  .topbar,
  .meta-line {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    justify-items: stretch;
    gap: 8px;
  }

  .control-group,
  .control-group.right {
    justify-content: center;
  }

  .nav-btn {
    font-size: 19px;
    padding: 10px 10px;
  }

  .mode-btn {
    font-size: 12px;
    padding: 9px 10px;
  }
}
