:root {
  --bg: #f7f1e3;
  --surface: rgba(255, 252, 245, 0.92);
  --surface-strong: #fffdf7;
  --text: #2a241d;
  --muted: #7a6f62;
  --border: rgba(86, 67, 47, 0.12);
  --accent: #8a5a34;
  --accent-soft: rgba(138, 90, 52, 0.12);
  --shadow: 0 18px 40px rgba(78, 58, 39, 0.08);
  --radius: 18px;
  --page-width: 720px;
  --read-width: 920px;
  --gutter: 16px;
  --font-ui: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-reading: "Source Han Serif SC", "Noto Serif SC", "Songti SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.45), transparent 32%),
    linear-gradient(180deg, #fbf7ed 0%, #f4ecdb 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-ui);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 20px var(--gutter) calc(28px + env(safe-area-inset-bottom));
}

.page {
  width: min(100%, var(--page-width));
  margin: 0 auto;
}

.page-header {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.page-title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.stack-list {
  display: grid;
  gap: 10px;
}

.stack-item {
  display: block;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--surface-strong);
  color: inherit;
  text-align: left;
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.stack-item:active {
  transform: scale(0.99);
}

.stack-item:hover,
.stack-item:focus-visible {
  border-color: rgba(138, 90, 52, 0.28);
  background: #fff8ef;
  outline: none;
}

.stack-item-title {
  display: block;
  font-size: 1.02rem;
  line-height: 1.45;
  word-break: break-word;
}

.page-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.96rem;
}

.page-link:hover,
.page-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.status-card {
  padding: 22px 18px;
}

.status-title {
  margin: 0;
  font-size: 1rem;
}

.status-text {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.status-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.status-button,
.pager-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid rgba(138, 90, 52, 0.16);
  background: var(--surface-strong);
  color: var(--text);
  text-decoration: none;
}

.status-button:hover,
.pager-button:hover,
.status-button:focus-visible,
.pager-button:focus-visible {
  border-color: rgba(138, 90, 52, 0.32);
  background: #fff8ef;
  outline: none;
}

.reading-page {
  width: min(100%, var(--read-width));
}

.reading-shell {
  padding: 18px 16px 0;
  background: rgba(255, 252, 246, 0.82);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.reading-header {
  padding: 6px 6px 20px;
}

.reading-title {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  line-height: 1.2;
  word-break: break-word;
}

.reading-content {
  padding: 0 6px 28px;
  font-family: var(--font-reading);
  font-size: clamp(1.05rem, 2.4vw, 1.18rem);
  line-height: 1.95;
  letter-spacing: 0.01em;
}

.reading-paragraph {
  margin: 0;
  text-indent: 2em;
  white-space: pre-wrap;
  word-break: break-word;
}

.reading-paragraph + .reading-paragraph {
  margin-top: 0.8em;
}

.reading-footer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 0 calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(247, 241, 227, 0) 0%, rgba(247, 241, 227, 0.9) 28%, rgba(247, 241, 227, 1) 100%);
}

.pager-button {
  width: 100%;
}

.pager-button[disabled] {
  color: #ab9d8c;
  border-color: rgba(120, 96, 74, 0.12);
  background: rgba(255, 252, 246, 0.72);
  cursor: not-allowed;
}

.loading-dots::after {
  content: "...";
  display: inline-block;
  width: 1.2em;
  overflow: hidden;
  vertical-align: bottom;
  animation: dots 1.1s steps(4, end) infinite;
}

@keyframes dots {
  from {
    width: 0;
  }

  to {
    width: 1.2em;
  }
}

@media (min-width: 768px) {
  .app-shell {
    padding-top: 32px;
    padding-bottom: 36px;
  }

  .reading-shell {
    padding: 28px 30px 0;
  }

  .reading-content {
    padding: 0 8px 34px;
  }
}

@media (min-width: 1080px) {
  .page {
    width: min(100%, calc(var(--page-width) + 80px));
  }

  .reading-page {
    width: min(100%, var(--read-width));
  }

  .reading-content {
    font-size: 1.2rem;
    line-height: 2;
  }
}
