* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  background-color: var(--bg-app);
  background-image: var(--bg-pattern);
  background-size: auto;
  background-position: center top;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body,
[data-theme="light"] body {
  background-image: var(--bg-pattern);
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

.px-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.icon-svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* 定制流金细滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

.app-shell {
  height: 100dvh;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 18px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶部卷首题签栏（宋画绫边 / 黑漆描金） */
.top-hud {
  margin-top: 12px;
  min-height: 58px;
  padding: 6px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

[data-theme="light"] .top-hud {
  box-shadow: var(--shadow-card), inset 0 0 0 3px var(--bg-surface), inset 0 0 0 4px rgba(156, 122, 66, 0.14);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.trainer-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  padding: 4px 0;
  cursor: pointer;
  text-align: left;
  transition: opacity 150ms ease, transform 140ms var(--ease-out);
}

.trainer-chip:active {
  transform: scale(0.97);
}

.trainer-avatar-mini {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.trainer-name-row {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.1em;
  line-height: 1.2;
}

.trainer-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.currency-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.currency-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-num);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.coin-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
  font-size: 10px;
  font-weight: 700;
}

.top-nav-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  overflow-x: auto;
}

.nav-tab {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 150ms ease, background-color 150ms ease;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
  color: var(--text-main);
  background: var(--bg-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.nav-tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-vermilion);
}

.tab-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 2px;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.save-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.quiet-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.08em;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
  transition: color 140ms ease;
}

.quiet-link:hover {
  color: var(--accent-primary);
}

.theme-switch-pill {
  padding: 4px 11px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.theme-switch-pill:hover {
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
  border-color: var(--accent-primary);
}

.main-stage-wrap {
  padding-top: 0;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* 三栏视口等高卡片主布局（对齐 PokeCatch 大屏齐底结构） */
.three-col-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 316px;
  gap: 14px;
  margin-top: 12px;
  align-items: stretch;
}

.col-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 15px;
  box-shadow: var(--shadow-card);
}

.center-scroll-shell {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 13px 16px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.feed-folio {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.feed-folio .activity-feed {
  flex: 1;
  max-height: none;
  min-height: 0;
}

.col-left,
.col-right {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

#view-adventure.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.feed-card {
  margin-top: 12px;
  flex: 1;
  min-height: 140px;
  display: flex;
  flex-direction: column;
}

.feed-card .activity-feed {
  flex: 1;
  max-height: none;
  min-height: 0;
}

.dir-group-gap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}

.tab-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
}

.dir-nav-list .nav-tab.is-locked {
  opacity: 0.52;
}

.dir-chapter-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 10px 11px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.dir-chapter-box:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.dir-chapter-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dir-chapter-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dir-chapter-meta strong {
  font-family: var(--font-serif);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dir-chapter-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.dir-section-label {
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.18em;
  padding: 6px 6px 5px;
  border-bottom: 1px solid var(--hairline);
  margin: 0 0 6px;
}

.dir-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dir-nav-list .nav-tab {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 2px;
  text-align: left;
  border: none;
  border-left: 2px solid transparent;
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: 0.1em;
  transition: transform 150ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.dir-nav-list .nav-tab:hover {
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
  transform: translateX(2px);
}

.dir-nav-list .nav-tab.active {
  background: var(--bg-card);
  border-left-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: none;
}

.dir-nav-list .nav-tab.active::after {
  display: none;
}

/* 克制古风卷眉（合二为一，不再独立套白框，1280+ 保持单行利落不折行） */
.stage-meta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0 2px 9px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  box-shadow: none;
  flex-wrap: nowrap;
}

.stage-region-info {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.region-crest-box {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stage-place-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.stage-place-line strong {
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
}

.stage-sub-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.stage-step-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.step-num {
  font-size: 11px;
  color: var(--text-muted);
}

.stage-controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.loop-toggle {
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}

.loop-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.loop-switch-track {
  position: relative;
  width: 30px;
  height: 16px;
  border-radius: 999px;
  background: var(--bg-elevated);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: background-color 180ms var(--ease-out);
}

.loop-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 180ms var(--ease-out), background-color 180ms ease;
}

.loop-toggle input:checked + .loop-switch-track {
  background: var(--accent-vermilion);
}

.loop-toggle input:checked + .loop-switch-track::after {
  transform: translateX(14px);
  background: #fdf6ec;
}

/* 舞台下方双栏（独立结构化面板，与背景彻底拉开明暗层次） */
.below-stage-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.editorial-col,
.editorial-col-side {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
}

.muted-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* 二级面板沿用统一排版卡片 */
.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
}

.panel-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 16px;
}

@media (max-width: 1180px) {
  .stage-meta-strip {
    flex-wrap: wrap;
  }
}

@media (max-width: 1140px) {
  /* 定制流金细滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

.app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .three-col-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
  }
  .col-left,
  .col-right,
  .main-stage-wrap {
    height: auto;
    overflow: visible;
  }
  .col-right {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 0 8px 28px;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .top-hud {
    flex-wrap: wrap;
    height: auto;
    min-height: 0;
    padding: 8px 10px;
    gap: 8px;
    margin-top: 8px;
  }
  .hud-left {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px 10px;
    justify-content: space-between;
  }
  .currency-bar {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-content: flex-start;
  }
  .hud-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid var(--hairline);
    padding-top: 6px;
  }
  .save-hint {
    display: none;
  }
  .three-col-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-top: 10px;
  }
  .col-center {
    order: -1;
  }
  .col-left {
    padding: 10px;
  }
  .dir-chapter-box {
    margin-bottom: 8px;
    padding: 8px 10px;
  }
  .dir-section-label {
    display: none;
  }
  .dir-nav-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .dir-nav-list .nav-tab {
    width: auto;
    flex: 0 0 auto;
    padding: 6px 10px;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 4px;
    background: var(--bg-elevated);
    font-size: 12px;
    letter-spacing: 0.04em;
    gap: 5px;
  }
  .dir-nav-list .nav-tab.active {
    border-left: none;
    border-bottom-color: var(--accent-primary);
  }
  .center-scroll-shell {
    padding: 10px;
  }
  .stage-meta-strip {
    flex-wrap: wrap;
    gap: 6px;
  }
  .stage-controls-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
  }
}
