.screen {
  min-height: 100%;
  padding: 0 18px 112px;
  animation: page-in 220ms ease-out;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  margin: 0 -18px 14px;
  padding: 13px 18px 8px;
  background: linear-gradient(to bottom, rgba(248, 244, 232, 0.98) 74%, rgba(248, 244, 232, 0));
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--leaf-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

h3 {
  margin-bottom: 7px;
  font-size: 16px;
}

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

.tiny {
  font-size: 12px;
}

.body-copy {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

.stack {
  display: grid;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 24px 2px 11px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.section-head p {
  margin: 0;
  font-size: 12px;
}

.card {
  padding: 16px;
  border: 1px solid rgba(60, 84, 63, 0.09);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 247, 0.88);
  box-shadow: var(--shadow-sm);
}

.card--leaf { background: linear-gradient(145deg, #f5f7ea, var(--leaf-pale)); }
.card--clay { background: linear-gradient(145deg, #fff8ef, var(--clay-pale)); }
.card--sun { background: linear-gradient(145deg, #fffaf0, var(--sun-pale)); }
.card--mist { background: linear-gradient(145deg, #f7fbf8, var(--mist-pale)); }
.card--ink { color: #f8f4e8; background: #354b3c; }

.card-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grow {
  flex: 1;
  min-width: 0;
}

.character {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 45% 55% 50% 46%;
  color: var(--ink);
  background: var(--character-color, var(--sprout));
  box-shadow: inset -4px -5px 0 rgba(45, 64, 49, 0.08);
  font-size: 13px;
  font-weight: 900;
}

.character--small {
  width: 38px;
  height: 38px;
  font-size: 11px;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-round);
  white-space: nowrap;
}

.pill {
  padding: 7px 10px;
  color: var(--leaf-deep);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.tag {
  padding: 4px 8px;
  color: var(--ink-soft);
  background: rgba(77, 100, 78, 0.08);
  font-size: 11px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 17px;
  border: 0;
  border-radius: var(--radius-round);
  color: #fff;
  background: var(--leaf-deep);
  box-shadow: 0 7px 16px rgba(55, 91, 66, 0.2);
  font-weight: 800;
  cursor: pointer;
}

.button:active {
  transform: translateY(1px);
}

.button--secondary {
  color: var(--leaf-deep);
  background: var(--white);
  box-shadow: none;
  border: 1px solid var(--line);
}

.button--soft {
  color: var(--ink);
  background: var(--leaf-pale);
  box-shadow: none;
}

.button--wide {
  width: 100%;
}

.icon-button,
.text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.64);
  font-size: 20px;
}

.text-button {
  padding: 5px 0;
  color: var(--leaf-deep);
  font-size: 12px;
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.choice {
  min-width: 0;
  padding: 10px 3px 8px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  cursor: pointer;
}

.choice span {
  display: block;
  margin-top: 4px;
  font-size: 10px;
}

.choice.is-active {
  border-color: var(--leaf);
  background: var(--white);
  box-shadow: 0 5px 12px rgba(55, 91, 66, 0.12);
}

.progress {
  overflow: hidden;
  height: 8px;
  border-radius: var(--radius-round);
  background: rgba(58, 75, 61, 0.1);
}

.progress > span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sprout), var(--leaf));
  transition: width 420ms ease;
}

.bottom-nav {
  position: fixed;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 20;
  width: calc(min(430px, 100vw) - 20px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px 10px;
  border: 1px solid rgba(55, 75, 58, 0.1);
  border-radius: 28px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 14px 35px rgba(53, 68, 55, 0.18);
  backdrop-filter: blur(16px);
  /* 不支持 backdrop-filter 的纯色后备 */
  -webkit-backdrop-filter: blur(16px);
  transform: translateX(-50%);
  transition: transform 180ms ease;
}

/* 纯色后备：不支持 backdrop-filter 时 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bottom-nav { background: rgba(255, 253, 247, 0.98); }
}

.nav-item {
  display: grid;
  gap: 4px;
  min-height: 54px;
  place-items: center;
  border: 0;
  border-radius: 18px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: background 200ms ease;
}
.nav-item:focus-visible {
  outline: 2px solid rgba(83, 105, 78, 0.5);
  outline-offset: 2px;
}

/* 图标叠放容器 */
.nav-item__icon {
  position: relative;
  width: 38px;
  height: 38px;
  transition: transform 280ms cubic-bezier(.2, .8, .2, 1);
}

/* 无素材时的字符图标兜底（如听风树） */
.nav-item__glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
  color: var(--ink-soft);
  transition: color 220ms ease, transform 280ms cubic-bezier(.2, .8, .2, 1);
}
.nav-item.is-active .nav-item__glyph {
  color: var(--leaf-deep);
  transform: scale(1.12) translateY(-1px);
  text-shadow: 0 2px 8px rgba(62, 104, 75, 0.35);
}

.nav-item__icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition:
    opacity 220ms ease,
    transform 280ms cubic-bezier(.2, .8, .2, 1);
}

/* 默认：显示 idle，隐藏 active */
.nav-item__icon .icon-active {
  opacity: 0;
  transform: scale(.88) translateY(2px);
}

/* 激活：交叉淡入到 active */
.nav-item.is-active .icon-idle {
  opacity: 0;
  transform: scale(.92);
}
.nav-item.is-active .icon-active {
  opacity: 1;
  transform: scale(1.06) translateY(-3px);
}

.nav-item:active .nav-item__icon {
  transform: scale(.9);
}

.nav-item__label {
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.nav-item.is-active {
  color: var(--leaf-deep);
  background: var(--leaf-pale);
  font-weight: 800;
}

/* reduced-motion 支持 */
@media (prefers-reduced-motion: reduce) {
  .nav-item__icon,
  .nav-item__icon img,
  .nav-item {
    animation: none;
    transition: none;
  }
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.input {
  min-height: 46px;
  padding: 0 13px;
}

.textarea {
  min-height: 92px;
  padding: 13px;
  resize: vertical;
}

.input:focus,
.textarea:focus {
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(102, 136, 94, 0.12);
}

.toast {
  position: absolute;
  z-index: 50;
  right: 24px;
  bottom: 92px;
  left: 24px;
  padding: 12px 16px;
  border-radius: 14px;
  color: #fff;
  background: rgba(36, 50, 42, 0.94);
  box-shadow: var(--shadow-md);
  text-align: center;
  font-size: 13px;
  animation: toast-in 200ms ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.empty-state {
  padding: 26px 18px;
  border: 1px dashed rgba(55, 91, 66, 0.25);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.38);
  text-align: center;
}

.chat-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 440px;
  overflow-y: auto;
  padding: 4px 4px 8px;
  scroll-behavior: smooth;
}

.chat-bubble {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-bubble--user {
  flex-direction: row-reverse;
}

.chat-text {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 18px 18px 18px 4px;
  background: rgba(255, 253, 247, 0.95);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(60, 84, 63, 0.08);
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink);
}

.chat-bubble--user .chat-text {
  border-radius: 18px 18px 4px 18px;
  background: var(--leaf-deep);
  color: #f8f4e8;
  border: 0;
}

.chat-bubble--user .chat-text::after {
  content: "（你的提问）";
  font-size: 11px;
  opacity: 0.7;
  display: block;
  margin-top: 4px;
}

.chat-chapter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
}

.chat-chapter-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(60, 84, 63, 0.2), transparent);
}

.chat-chapter-card {
  text-align: center;
  padding: 12px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(232, 185, 86, 0.12), rgba(185, 209, 124, 0.12));
  border: 1px solid rgba(60, 84, 63, 0.1);
  max-width: 260px;
}

.chat-chapter-card h3 {
  margin: 2px 0;
  font-size: 14px;
  color: var(--leaf-deep);
}

.chat-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-bottom: 4px;
}

.source-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(60, 84, 63, 0.06);
}

/* 书架 */
.book-card {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.book-card:active {
  transform: translateY(1px);
}

.book-cover {
  display: grid;
  place-items: center;
  width: 58px;
  height: 74px;
  border-radius: 10px;
  color: #fff;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.08);
  font-size: 22px;
}

.book-arrow {
  color: var(--ink-soft);
  font-size: 20px;
  opacity: 0.5;
}

.category-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
}

.category-pill.is-active {
  background: var(--leaf-deep);
  color: #fff;
  border-color: var(--leaf-deep);
  font-weight: 800;
}

/* 互动叙事 */
.story-choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.story-choice:active {
  transform: translateY(1px);
}

.story-choice:hover {
  box-shadow: 0 5px 14px rgba(67, 76, 57, 0.1);
}

.choice-text {
  font-weight: 700;
  color: var(--ink);
  font-size: 14px;
}

.choice-flavor {
  font-size: 12px;
  color: var(--ink-soft);
}

.affinity-tip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 6px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.7);
  border: 1px dashed rgba(60, 84, 63, 0.14);
  color: var(--ink-soft);
}

.affinity-face {
  font-size: 22px;
}

/* 属性面板 */
.stats-panel {
  display: grid;
  gap: 10px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-label {
  width: 42px;
  font-size: 13px;
  color: var(--ink-soft);
}

.stat-value {
  width: 24px;
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  color: var(--leaf-deep);
}

.stat-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(58, 75, 61, 0.1);
  overflow: hidden;
}

.stat-track span {
  display: block;
  height: 100%;
  width: var(--stat-progress, 0%);
  border-radius: inherit;
  transition: width 420ms ease;
}

.affinity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--ink-soft);
}

.affinity-value {
  position: relative;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(232, 185, 86, 0.2) var(--affinity, 0%), rgba(232, 185, 86, 0.05) var(--affinity, 0%));
  color: var(--leaf-deep);
  font-weight: 800;
}

/* 存档 */
.archive-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.archive-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  padding: 10px;
  border: 1px dashed rgba(60, 84, 63, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink-soft);
  cursor: pointer;
}

.archive-slot.has-save {
  background: var(--leaf-pale);
  border-style: solid;
  border-color: var(--leaf);
  color: var(--leaf-deep);
}

.archive-slot b {
  font-size: 13px;
}

.archive-slot small {
  font-size: 11px;
}

/* 结局卡片 */
.ending-card {
  text-align: center;
  padding: 26px 20px;
}

.ending-card .tag {
  margin-bottom: 8px;
}

