:root {
  --bg: #140f0d;
  --bg-soft: #211815;
  --card: rgba(28, 21, 18, 0.92);
  --card-strong: rgba(37, 26, 21, 0.96);
  --line: rgba(214, 183, 147, 0.18);
  --line-strong: rgba(214, 183, 147, 0.34);
  --text: #f5eee6;
  --text-soft: rgba(245, 238, 230, 0.74);
  --accent: #b25f45;
  --accent-soft: rgba(178, 95, 69, 0.16);
  --gold: #d1af77;
  --warn: #c86b56;
  --ok: #7eaf86;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius-lg: 30px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --body-font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --title-font: "Songti SC", "STSong", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(178, 95, 69, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(209, 175, 119, 0.10), transparent 26%),
    linear-gradient(180deg, #1a1311 0%, #140f0d 48%, #100c0b 100%);
  color: var(--text);
  font-family: var(--body-font);
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(209, 175, 119, 0.18);
}

button {
  font: inherit;
  touch-action: manipulation;
}

button:focus-visible,
summary:focus-visible,
.skip-link:focus-visible,
.action-card:focus-visible,
.top-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: 2px solid rgba(209, 175, 119, 0.9);
  outline-offset: 3px;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -48px;
  z-index: 40;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(11, 8, 7, 0.96);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  transition: top 0.16s ease;
}

.skip-link:focus-visible {
  top: 16px;
}

.topbar,
.action-rail,
.scene-panel,
.feed-panel,
.side-panel,
.command-panel,
.status-card,
.overlay-card,
.location-card,
.action-card,
.timeline-step,
.log-item {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.topbar,
.action-rail,
.scene-panel,
.feed-panel,
.side-panel,
.command-panel,
.status-card,
.overlay-card {
  border-radius: var(--radius-lg);
}

.topbar {
  padding: 20px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto;
  gap: 18px;
  align-items: start;
}

.action-rail {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  position: sticky;
  top: 12px;
  z-index: 12;
  background:
    linear-gradient(180deg, rgba(178, 95, 69, 0.18), rgba(30, 22, 18, 0.96)),
    var(--card-strong);
}

.action-rail-copy {
  display: grid;
  gap: 8px;
}

.action-rail-note {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.action-rail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.brand-block,
.panel-title-row > div:first-child,
.scene-copy {
  display: grid;
  gap: 8px;
}

.brand-kicker,
.panel-kicker,
.scene-kicker,
.meter-name,
.location-meta,
.action-meta,
.overlay-head .panel-kicker {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.brand-title,
.scene-title,
.panel-title,
.ending-title {
  margin: 0;
  font-family: var(--title-font);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-title {
  font-size: clamp(28px, 5vw, 42px);
}

.brand-copy,
.scene-objective,
.panel-note,
.fold-body,
.action-copy,
.location-copy,
.reading-copy,
.ending-copy,
.overlay-card p {
  color: var(--text-soft);
  line-height: 1.7;
}

.top-meta,
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.top-meta {
  align-items: center;
  color: var(--text-soft);
}

.top-button {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.top-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(214, 183, 147, 0.48);
}

.top-button.danger {
  border-color: rgba(200, 107, 86, 0.46);
  color: #ffd7cf;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.scene-panel,
.feed-panel {
  grid-column: 1;
}

.side-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 126px;
}

.scene-panel {
  overflow: hidden;
  min-height: 480px;
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto;
}

.scene-image {
  min-height: 360px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.10), rgba(0, 0, 0, 0.55)),
    center / cover no-repeat;
}

.scene-copy {
  padding: 22px;
  background: linear-gradient(180deg, rgba(27, 18, 15, 0.56), rgba(21, 15, 13, 0.96));
  border-top: 1px solid var(--line);
}

.scene-title {
  font-size: clamp(28px, 4vw, 40px);
}

.feed-panel,
.command-panel,
.side-panel {
  padding: 20px;
}

.feed-panel {
  display: grid;
  gap: 16px;
}

.story-feed {
  display: grid;
  gap: 12px;
  align-content: start;
  max-height: 420px;
  overflow: auto;
  padding-right: 6px;
}

.story-feed::-webkit-scrollbar {
  width: 8px;
}

.story-feed::-webkit-scrollbar-thumb {
  background: rgba(209, 175, 119, 0.18);
  border-radius: 999px;
}

.log-item {
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--card-strong);
  display: grid;
  gap: 8px;
}

.log-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.log-title {
  font-size: 18px;
  font-weight: 600;
}

.log-turn {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.status-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.meter-list {
  display: grid;
  gap: 12px;
}

.meter-row {
  display: grid;
  gap: 8px;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.meter-value {
  color: var(--text);
  font-weight: 600;
}

.meter-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #d18a67);
}

.meter-fill.warn {
  background: linear-gradient(90deg, #9f5164, #dc7c64);
}

.meter-fill.ok {
  background: linear-gradient(90deg, #6c9d76, #91c58d);
}

.fold-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(23, 17, 15, 0.88);
  overflow: hidden;
}

.fold-card summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 600;
  position: relative;
}

.fold-card summary::-webkit-details-marker {
  display: none;
}

.fold-card summary::after {
  content: "展开";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  font-size: 12px;
}

.fold-card[open] summary::after {
  content: "收起";
}

.fold-body {
  border-top: 1px solid var(--line);
  padding: 0 18px 18px;
}

.fold-body > :first-child {
  margin-top: 16px;
}

.fold-list {
  display: grid;
  gap: 12px;
}

.fold-item {
  border: 1px solid rgba(214, 183, 147, 0.12);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.fold-item-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.command-panel {
  display: grid;
  gap: 18px;
  scroll-margin-top: 108px;
  background:
    linear-gradient(180deg, rgba(209, 175, 119, 0.08), rgba(37, 26, 21, 0.96)),
    var(--card-strong);
}

.timeline-strip {
  display: grid;
  grid-template-columns: repeat(12, minmax(80px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.timeline-step {
  border-radius: var(--radius-md);
  padding: 12px 10px;
  min-width: 88px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 4px;
  text-align: center;
}

.timeline-step.current {
  border-color: rgba(209, 175, 119, 0.5);
  background: linear-gradient(180deg, rgba(178, 95, 69, 0.18), rgba(255, 255, 255, 0.03));
}

.timeline-step.done {
  opacity: 0.6;
}

.timeline-step-day {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.timeline-step-slot {
  font-weight: 600;
}

.action-hint {
  border: 1px dashed rgba(209, 175, 119, 0.24);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  padding: 16px 18px;
  color: var(--text);
  font-weight: 600;
}

.location-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.location-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--card-strong);
  display: grid;
  grid-template-rows: 140px auto;
}

.location-image {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.48)),
    center / cover no-repeat;
}

.location-body {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.location-title {
  font-family: var(--title-font);
  font-size: 24px;
}

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

.action-card {
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 10px;
  border: 1px solid rgba(214, 183, 147, 0.16);
  background: rgba(255, 255, 255, 0.03);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.action-card:hover {
  transform: translateY(-2px);
  border-color: rgba(209, 175, 119, 0.44);
  background: rgba(255, 255, 255, 0.05);
}

.action-card:disabled,
.top-button:disabled,
.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

.action-card:disabled:hover,
.top-button:disabled:hover,
.primary-button:disabled:hover,
.secondary-button:disabled:hover {
  transform: none;
  border-color: rgba(214, 183, 147, 0.16);
  background: rgba(255, 255, 255, 0.03);
}

.action-card.primary {
  border-color: rgba(178, 95, 69, 0.42);
  background: linear-gradient(180deg, rgba(178, 95, 69, 0.18), rgba(255, 255, 255, 0.04));
}

.action-title {
  font-size: 18px;
  font-weight: 600;
}

.action-kicker {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.action-meta-list {
  display: grid;
  gap: 4px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.action-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 128px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(209, 175, 119, 0.14);
  color: var(--text);
  font-weight: 700;
}

.action-card:disabled .action-cta {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-soft);
}

.empty-state {
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
}

.cover-block,
.ending-block {
  grid-column: 1 / -1;
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--card-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.cover-grid,
.ending-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.cover-card,
.ending-summary-card {
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid rgba(214, 183, 147, 0.14);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 8px;
}

.cover-card-title,
.ending-summary-label {
  font-weight: 600;
}

.cover-actions,
.ending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-button {
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  background: linear-gradient(90deg, #b25f45, #d18766);
  color: #fff8f5;
  cursor: pointer;
  font-weight: 600;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.overlay.hidden {
  display: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 5, 0.72);
  backdrop-filter: blur(6px);
}

.overlay-card {
  position: relative;
  width: min(920px, calc(100vw - 24px));
  margin: 32px auto;
  padding: 22px;
  display: grid;
  gap: 14px;
}

.overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

@media (max-width: 1180px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-column: 1;
    grid-row: auto;
    position: static;
  }

  .location-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-panel,
  .feed-panel {
    min-height: auto;
  }
}

@media (max-width: 860px) {
  body {
    padding: 12px;
  }

  .topbar,
  .action-rail {
    grid-template-columns: 1fr;
  }

  .top-meta,
  .top-actions,
  .action-rail-actions {
    justify-content: flex-start;
  }

  .location-grid,
  .cover-grid,
  .ending-summary {
    grid-template-columns: 1fr;
  }

  .scene-panel {
    grid-template-rows: 260px auto;
  }
}

@media (max-width: 560px) {
  .topbar,
  .action-rail,
  .feed-panel,
  .side-panel,
  .command-panel,
  .scene-copy,
  .overlay-card {
    padding: 16px;
  }

  .top-actions,
  .action-rail-actions,
  .cover-actions,
  .ending-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .top-button,
  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .location-grid {
    grid-template-columns: 1fr;
  }
}
