:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #10161f;
  --panel-2: #151b24;
  --panel-3: #1b2028;
  --line: #2d3a46;
  --line-soft: rgba(142, 161, 177, 0.18);
  --text: #e7edf3;
  --muted: #9ba9b7;
  --faint: #6f7e8d;
  --amber: #f3c15f;
  --amber-2: #b98938;
  --cyan: #62c6d9;
  --green: #73b878;
  --red: #e56d64;
  --violet: #9b8ad7;
  --steel: #8ba1b4;
  --shadow: rgba(0, 0, 0, 0.48);
  --radius: 8px;
  --ui-brightness: 1;
  --font-scale: 1;
  --density-pad: 12px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  font-size: calc(16px * var(--font-scale));
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f6;
  --panel: #f8fbfd;
  --panel-2: #edf3f7;
  --panel-3: #e4edf4;
  --line: #b9c8d4;
  --line-soft: rgba(57, 76, 92, 0.18);
  --text: #17212b;
  --muted: #526476;
  --faint: #728091;
  --shadow: rgba(33, 47, 61, 0.18);
}

:root[data-theme="high-contrast"] {
  color-scheme: dark;
  --bg: #020304;
  --panel: #070b10;
  --panel-2: #0e141b;
  --panel-3: #151c25;
  --line: #617486;
  --line-soft: rgba(217, 232, 245, 0.28);
  --text: #f7fbff;
  --muted: #c2cfda;
  --faint: #9badbd;
  --amber: #ffd36b;
  --cyan: #77e4ff;
}

:root[data-density="compact"] {
  --density-pad: 9px;
}

:root[data-density="relaxed"] {
  --density-pad: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(115deg, rgba(229, 109, 100, 0.08), transparent 34%),
    linear-gradient(215deg, rgba(98, 198, 217, 0.07), transparent 38%),
    var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
  filter: brightness(var(--ui-brightness));
}

button,
textarea,
input {
  font: inherit;
}

button {
  min-height: 36px;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 318px;
  height: 100dvh;
  min-height: 620px;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 42px minmax(0, 1fr) 318px;
}

body.rail-hidden .app-shell,
body.rail-collapsed .app-shell {
  grid-template-columns: 236px minmax(0, 1fr);
}

body.sidebar-collapsed.rail-hidden .app-shell,
body.sidebar-collapsed.rail-collapsed .app-shell {
  grid-template-columns: 42px minmax(0, 1fr);
}

body.rail-hidden .right-rail,
body.rail-collapsed .right-rail {
  display: none;
}

body.runtime-focus .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.runtime-focus .sidebar,
body.runtime-focus .right-rail {
  display: none;
}

body.runtime-focus .topbar {
  padding-block: 10px;
}

body.runtime-focus .page-root {
  padding: 12px;
}

.sidebar,
.right-rail {
  min-height: 0;
  background: rgba(12, 16, 22, 0.92);
  border-color: var(--line);
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.sidebar-collapse-row {
  padding: 14px 12px 0;
}

.sidebar-collapse-row button {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.sidebar-collapse-row button:hover {
  border-color: rgba(243, 193, 95, 0.3);
  color: var(--amber);
  background: rgba(47, 34, 20, 0.34);
}

.sidebar-collapse-row span {
  font-size: 24px;
  line-height: 1;
}

.sidebar-collapse-row b {
  font-weight: 600;
}

body.sidebar-collapsed .sidebar {
  overflow: hidden;
}

body.sidebar-collapsed .brand-block,
body.sidebar-collapsed .nav-list,
body.sidebar-collapsed .sidebar-footer {
  visibility: hidden;
  pointer-events: none;
}

body.sidebar-collapsed .sidebar-collapse-row {
  padding: 14px 4px 0;
}

body.sidebar-collapsed .sidebar-collapse-row button {
  justify-content: center;
  padding: 0;
}

body.sidebar-collapsed .sidebar-collapse-row b {
  display: none;
}

body.sidebar-collapsed .sidebar-collapse-row span {
  transform: rotate(180deg);
}

.brand-block {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(243, 193, 95, 0.6);
  border-radius: 8px;
  background: #241b13;
  color: var(--amber);
  font-size: 22px;
  font-weight: 800;
}

.brand-block h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand-block p,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow: auto;
}

.nav-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  margin-bottom: 6px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #151d29;
  color: var(--text);
  border-color: var(--line);
}

.nav-item.active {
  color: var(--amber);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #1d2834;
  color: var(--cyan);
}

.nav-item small {
  color: var(--faint);
  white-space: nowrap;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--line-soft);
}

.data-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-bottom: 10px;
  padding: 0 8px;
  border: 1px solid rgba(115, 184, 120, 0.35);
  border-radius: 6px;
  background: rgba(115, 184, 120, 0.09);
  color: #a5d9a8;
  font-size: 12px;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 22, 31, 0.76);
}

.topbar h2 {
  margin: 3px 0 0;
  font-size: 21px;
  line-height: 1.25;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.primary-button {
  padding: 0 14px;
  background: #d99d3c;
  color: #111317;
  border-color: #e9bd64;
  font-weight: 700;
}

.ghost-button {
  width: 100%;
  padding: 0 10px;
  background: #121923;
  color: var(--text);
}

.icon-button {
  width: 38px;
  padding: 0;
  background: #151d29;
  color: var(--text);
  font-size: 18px;
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: var(--amber);
  filter: brightness(1.07);
}

.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  filter: none;
}

.primary-button:active,
.ghost-button:active,
.icon-button:active,
.quick-actions button:active {
  transform: translateY(1px);
}

.page-root {
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.right-rail {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  overflow: auto;
  border-left: 1px solid var(--line);
}

.right-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 10px;
  padding: 0 4px 0 8px;
  color: var(--amber);
}

.right-rail-head button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.right-rail-head button:hover {
  border-color: rgba(243, 193, 95, 0.3);
  color: var(--amber);
  background: rgba(47, 34, 20, 0.34);
}

.shell-edge-toggle {
  position: fixed;
  z-index: 45;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  min-height: 58px;
  padding: 0;
  border: 1px solid rgba(243, 193, 95, 0.3);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, rgba(243, 193, 95, 0.18), transparent 48%),
    rgba(29, 20, 12, 0.9);
  color: var(--amber);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42);
  cursor: pointer;
}

.shell-edge-toggle:hover {
  border-color: rgba(243, 193, 95, 0.72);
  background: rgba(47, 34, 20, 0.95);
}

.shell-edge-toggle::before {
  font-size: 34px;
  line-height: 1;
}

.nav-edge-toggle {
  left: 207px;
  top: 34px;
}

.nav-edge-toggle::before {
  content: "‹";
}

body.sidebar-collapsed .nav-edge-toggle {
  left: 13px;
}

body.sidebar-collapsed .nav-edge-toggle::before {
  content: "›";
}

.rail-edge-toggle {
  right: 289px;
  top: 34px;
}

.rail-edge-toggle::before {
  content: "›";
}

body.rail-collapsed .rail-edge-toggle,
body.rail-hidden .rail-edge-toggle {
  right: 12px;
}

body.rail-collapsed .rail-edge-toggle::before,
body.rail-hidden .rail-edge-toggle::before {
  content: "‹";
}

button:disabled,
button:disabled:hover {
  cursor: not-allowed;
  opacity: 0.46;
  filter: grayscale(0.35) brightness(0.78);
  transform: none;
}

.runtime-action-bar button:disabled,
.quick-actions button:disabled,
.chat-composer button:disabled {
  border-color: rgba(174, 190, 207, 0.1);
  background: rgba(12, 17, 24, 0.68);
  color: var(--faint);
  box-shadow: none;
}

body.runtime-focus .shell-edge-toggle {
  display: none;
}

.rail-panel {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(21, 27, 36, 0.82);
}

.rail-panel header,
.panel-head,
.event-head,
.task-head,
.character-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rail-panel header {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.rail-panel strong {
  color: var(--amber);
  font-size: 12px;
}

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

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

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quick-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111a25;
  color: var(--text);
  cursor: pointer;
}

.quick-actions button:hover {
  border-color: var(--cyan);
}

.dashboard-grid,
.two-column,
.protocol-grid,
.archive-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-shell {
  display: grid;
  grid-template-columns: minmax(220px, 0.28fr) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.settings-menu {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(12, 18, 26, 0.78);
}

.settings-menu-group {
  display: grid;
  gap: 6px;
}

.settings-menu-group b {
  color: var(--amber);
  font-size: 12px;
}

.settings-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.settings-menu button:hover,
.settings-menu button.active {
  border-color: rgba(243, 193, 95, 0.35);
  background: rgba(47, 34, 20, 0.56);
}

.settings-content {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.endpoint-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.34fr) minmax(0, 1fr);
  gap: 12px;
}

.endpoint-list {
  min-height: 0;
  max-height: 620px;
  overflow: auto;
}

.endpoint-simple-form {
  display: grid;
  gap: 12px;
}

.api-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: end;
}

.api-key-row .field {
  margin: 0;
}

.key-toggle {
  height: 40px;
  align-self: end;
  background: rgba(8, 13, 19, 0.6);
}

.endpoint-model-block {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.34);
}

.endpoint-model-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.endpoint-model-head b {
  display: block;
  color: var(--text);
}

.endpoint-model-head span,
.diagnostic.subtle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.endpoint-model-block .model-field {
  margin: 0;
}

.advanced-settings {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(18, 25, 35, 0.5);
}

.advanced-settings summary {
  min-height: 38px;
  padding: 9px 10px;
  color: var(--amber);
  cursor: pointer;
}

.advanced-settings .form-grid {
  padding: 0 10px 10px;
}

.image-usage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.image-usage-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
}

.image-usage-card b {
  color: var(--muted);
  font-size: 12px;
}

.image-usage-card strong {
  color: var(--text);
  font-size: 16px;
}

.image-usage-card span {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

.image-service-editor {
  margin: 12px 0;
}

.image-route-stack {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.28);
}

.preset-manager {
  margin-top: 12px;
}

.main-chat-preset-panel {
  display: grid;
  gap: 12px;
}

.main-chat-preset-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
}

.main-chat-preset-list,
.main-chat-preset-detail {
  min-width: 0;
}

.main-chat-preset-list {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: 360px;
  overflow: auto;
  padding-right: 3px;
}

.compact-head {
  margin-bottom: 2px;
}

.compact-head h4 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
}

.prompt-sections-panel {
  margin-top: 12px;
}

.prompt-section-list {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-right: 3px;
}

.prompt-section-row {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
}

.prompt-section-row.disabled {
  opacity: 0.58;
}

.prompt-section-row[open] {
  border-color: rgba(98, 198, 217, 0.32);
  background: rgba(12, 23, 31, 0.48);
}

.prompt-section-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  cursor: pointer;
  list-style: none;
}

.prompt-section-summary::-webkit-details-marker {
  display: none;
}

.prompt-section-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.prompt-section-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.prompt-section-title b {
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.prompt-section-main small {
  color: var(--faint);
  overflow-wrap: anywhere;
}

.prompt-section-main p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.prompt-section-chevron {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--muted);
  transition: transform 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.prompt-section-row[open] .prompt-section-chevron {
  color: var(--cyan);
  border-color: rgba(98, 198, 217, 0.34);
  transform: rotate(180deg);
}

.prompt-section-editor {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.prompt-section-editor textarea {
  min-height: 220px;
  resize: vertical;
  font-family: var(--mono);
  line-height: 1.55;
}

.prompt-section-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
}

.prompt-section-actions .ghost-button {
  width: auto;
  min-width: 54px;
  min-height: 34px;
  padding: 0 10px;
}

.preset-upload-field {
  min-width: 0;
}

.native-file-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 7px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(8, 13, 19, 0.48);
  font-size: 12px;
}

.file-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
}

.file-upload-row small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.preset-card {
  display: grid;
  gap: 5px;
  min-height: 88px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.38);
}

.preset-card.active {
  border-color: rgba(243, 193, 95, 0.48);
  background: rgba(55, 39, 18, 0.32);
}

.preset-card b {
  color: var(--text);
}

.preset-card span,
.preset-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.route-card,
.route-diagnostic {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
}

.route-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.route-card.bad,
.route-diagnostic.bad {
  border-color: rgba(229, 109, 100, 0.45);
  background: rgba(61, 25, 27, 0.28);
}

.route-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.route-head-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.route-card-head b {
  display: block;
  color: var(--text);
}

.route-card-head small,
.route-diagnostic small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.route-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.route-badge.ok {
  border-color: rgba(115, 184, 120, 0.48);
  color: var(--green);
}

.route-badge.bad {
  border-color: rgba(229, 109, 100, 0.55);
  color: #ff9a90;
}

.route-toggle {
  display: inline-grid;
  grid-template-columns: auto 34px;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  padding: 3px 4px 3px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(11, 15, 21, 0.78);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.route-toggle span {
  font-size: 12px;
}

.route-toggle i {
  position: relative;
  display: block;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: rgba(111, 126, 141, 0.35);
}

.route-toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.route-toggle.on {
  border-color: rgba(115, 184, 120, 0.48);
  background: rgba(21, 52, 34, 0.52);
  color: var(--green);
}

.route-toggle.on i {
  background: rgba(115, 184, 120, 0.28);
}

.route-toggle.on i::after {
  transform: translateX(14px);
  background: var(--green);
}

.route-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.route-alert,
.route-info-callout {
  display: grid;
  gap: 7px;
  padding: 10px;
  border-radius: 8px;
  line-height: 1.5;
}

.route-alert {
  border: 1px solid rgba(229, 109, 100, 0.42);
  background: rgba(83, 30, 31, 0.34);
}

.route-alert b {
  color: #ffd1cc;
}

.route-alert span {
  color: #f0aaa5;
}

.route-info-callout {
  border: 1px solid rgba(98, 198, 217, 0.26);
  background: rgba(18, 39, 48, 0.26);
}

.route-info-callout b {
  color: var(--cyan);
}

.route-info-callout span {
  color: var(--muted);
}

.route-problem {
  margin: 0;
  color: #ffafa6;
}

.workflow-preview {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(12, 16, 22, 0.38);
}

.workflow-preview.bad {
  border-color: rgba(229, 109, 100, 0.45);
}

.workflow-preview pre {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
}

.heaven-report-summary {
  display: grid;
  gap: 12px;
}

.heaven-metrics .metric-card {
  min-height: 86px;
}

.heaven-metrics .metric-card b {
  display: block;
  color: var(--text);
  font-size: 26px;
  line-height: 1.1;
}

.heaven-metrics .metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.heaven-report-grid {
  grid-column: 1 / -1;
}

.heaven-check-list,
.heaven-suggestion-grid {
  display: grid;
  gap: 8px;
}

.heaven-check-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.38);
}

.heaven-check-row.bad {
  border-color: rgba(229, 109, 100, 0.46);
  background: rgba(61, 25, 27, 0.24);
}

.heaven-check-row.warn {
  border-color: rgba(243, 193, 95, 0.38);
  background: rgba(55, 39, 18, 0.22);
}

.heaven-check-row.ok {
  border-color: rgba(115, 184, 120, 0.32);
}

.heaven-check-row b {
  display: block;
  color: var(--text);
}

.heaven-check-row p,
.heaven-check-row small {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.heaven-check-row small {
  color: var(--amber);
}

.heaven-status {
  padding: 3px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.heaven-status.ok {
  border-color: rgba(115, 184, 120, 0.46);
  color: var(--green);
}

.heaven-status.warn {
  border-color: rgba(243, 193, 95, 0.48);
  color: var(--amber);
}

.heaven-status.bad {
  border-color: rgba(229, 109, 100, 0.55);
  color: #ff9a90;
}

.heaven-action.high time {
  color: #ff9a90;
}

.heaven-action.medium time {
  color: var(--amber);
}

.heaven-action span {
  color: var(--faint);
}

.tab-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tab-strip button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--muted);
}

.tab-strip button.active {
  border-color: rgba(224, 174, 94, 0.72);
  color: var(--text);
  background: rgba(224, 174, 94, 0.12);
}

.rules-table,
.realm-table {
  display: grid;
  gap: 8px;
}

.rules-row,
.realm-row {
  display: grid;
  gap: 8px;
  align-items: stretch;
}

.rules-row {
  grid-template-columns: minmax(86px, 0.8fr) minmax(110px, 1fr) minmax(104px, 0.8fr) minmax(70px, 0.6fr) minmax(70px, 0.6fr) minmax(220px, 2fr);
}

.realm-row {
  grid-template-columns: minmax(110px, 0.9fr) minmax(120px, 1fr) minmax(150px, 1.2fr) minmax(260px, 2fr);
}

.rules-row.head,
.realm-row.head {
  color: var(--muted);
  font-size: 12px;
}

.rules-row input,
.rules-row textarea,
.realm-row input,
.realm-row textarea,
.mini-fields input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.rules-row textarea,
.realm-row textarea {
  min-height: 44px;
  resize: vertical;
}

.rules-row input:disabled,
.rules-row textarea:disabled,
.realm-row input:disabled,
.realm-row textarea:disabled {
  opacity: 0.76;
}

.mini-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.message-note {
  margin-top: 8px;
  color: var(--faint);
  font-size: 12px;
}

.generated-image {
  width: min(100%, 420px);
  max-height: 420px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.route-diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.route-diagnostic {
  min-height: 74px;
  padding: 9px;
}

.route-diagnostic b {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.route-diagnostic span {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 12px;
}

.route-diagnostic.bad span {
  color: #ff9a90;
}

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

.main-story-layout,
.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 12px;
}

.creation-layout,
.manager-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(360px, 1.18fr);
  gap: 12px;
}

.creation-shell {
  display: grid;
  grid-template-columns: minmax(240px, 0.34fr) minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "sheet stage"
    "advisor stage"
    "footer footer";
  gap: 12px;
  padding-bottom: 78px;
}

.creation-top {
  grid-area: top;
  display: grid;
  grid-template-columns: minmax(240px, 0.32fr) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.creation-status-strip {
  justify-self: end;
}

.creation-top p,
.muted-line {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.creation-step-hint {
  display: inline-block;
  margin-top: 6px;
  color: var(--amber);
  font-size: 12px;
}

.creation-steps {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.creation-steps button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.creation-steps button span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(98, 198, 217, 0.12);
  color: var(--cyan);
  font-size: 12px;
}

.creation-steps button.active {
  border-color: rgba(243, 193, 95, 0.62);
  background: rgba(47, 34, 20, 0.52);
  color: var(--text);
}

.creation-steps button.done {
  border-color: rgba(115, 184, 120, 0.38);
  color: var(--text);
}

.creation-steps button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.creation-sheet {
  grid-area: sheet;
  min-width: 0;
}

.creation-stage {
  grid-area: stage;
  min-width: 0;
}

.creation-stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.primary-button.compact {
  min-height: 34px;
  padding: 8px 14px;
  white-space: nowrap;
}

.creation-advisor {
  grid-area: advisor;
  min-width: 0;
}

.creation-footer {
  position: sticky;
  bottom: 12px;
  z-index: 9;
  grid-area: footer;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 17, 24, 0.96);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.28);
}

.creation-footer div {
  display: flex;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.creation-footer b {
  color: var(--amber);
}

.creation-avatar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.creation-avatar > span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(98, 198, 217, 0.42);
  border-radius: 8px;
  background: rgba(16, 37, 47, 0.58);
  color: var(--cyan);
  font-size: 24px;
  font-weight: 800;
}

.creation-avatar h3,
.creation-avatar p {
  margin: 0;
}

.creation-avatar p {
  color: var(--muted);
  font-size: 12px;
}

.creation-budget {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(115, 184, 120, 0.34);
  border-radius: 8px;
  background: rgba(30, 52, 38, 0.24);
}

.creation-budget.bad {
  border-color: rgba(229, 109, 100, 0.46);
  background: rgba(83, 30, 31, 0.28);
}

.creation-budget span,
.creation-budget small {
  color: var(--muted);
  font-size: 12px;
}

.creation-budget b {
  grid-row: span 2;
  color: var(--text);
  font-size: 30px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

.choice-card {
  min-height: 126px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.5);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.choice-card:hover,
.choice-card.active {
  border-color: rgba(243, 193, 95, 0.64);
  background: rgba(47, 34, 20, 0.46);
}

.choice-card span {
  display: block;
  color: var(--text);
  font-weight: 700;
}

.choice-card b {
  display: block;
  margin-top: 4px;
  color: var(--amber);
  font-size: 13px;
}

.choice-card p,
.choice-card small {
  display: block;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.48;
}

.creation-custom-block {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(98, 198, 217, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(98, 198, 217, 0.055), transparent),
    rgba(8, 13, 19, 0.42);
}

.creation-custom-block summary {
  cursor: pointer;
  color: var(--cyan);
  font-weight: 700;
}

.creation-custom-block[open] summary {
  margin-bottom: 10px;
}

.creation-custom-block textarea {
  min-height: 84px;
}

.attribute-board,
.factor-board {
  display: grid;
  gap: 10px;
}

.attribute-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.38);
}

.attribute-control h4,
.attribute-control p {
  margin: 0;
}

.attribute-control p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.stepper {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 6px;
}

.stepper button,
.stepper input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  text-align: center;
}

.stepper button {
  cursor: pointer;
}

.stepper button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.section-subtitle {
  margin: 16px 0 10px;
  color: var(--amber);
  font-size: 13px;
}

.factor-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.62fr) 48px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.38);
}

.factor-control span {
  display: grid;
  gap: 4px;
}

.factor-control small {
  color: var(--muted);
  line-height: 1.45;
}

.factor-control strong {
  color: var(--cyan);
  text-align: right;
}

.creation-attr-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.creation-attr-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 8px;
  overflow: hidden;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.4);
}

.creation-attr-row b,
.creation-attr-row span,
.creation-attr-row strong {
  position: relative;
  z-index: 1;
}

.creation-attr-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.creation-attr-row strong {
  color: var(--amber);
  text-align: right;
}

.creation-attr-row i {
  position: absolute;
  inset: auto auto 0 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(98, 198, 217, 0.86), rgba(243, 193, 95, 0.82));
}

.confirm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.creation-advice {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.36);
}

.creation-advice b {
  color: var(--cyan);
}

.panel,
.event-card,
.task-card,
.character-card,
.map-detail,
.log-entry,
.code-panel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(16, 22, 31, 0.78);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
}

.panel,
.code-panel {
  padding: var(--density-pad);
}

.panel.wide,
.code-panel.wide {
  grid-column: 1 / -1;
}

.panel h3,
.code-panel h3 {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 15px;
}

.panel p {
  color: var(--muted);
  line-height: 1.65;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-height: 116px;
  padding: calc(var(--density-pad) - 2px);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #121923;
}

.metric-card h4 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.metric-desc {
  margin-top: 6px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

.gauge {
  height: 8px;
  margin-top: 8px;
  border: 1px solid #26323f;
  border-radius: 999px;
  overflow: hidden;
  background: #090d12;
}

.gauge > i {
  display: block;
  height: 100%;
  width: 50%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

.gauge.danger > i {
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.kv-grid {
  display: grid;
  gap: 8px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line-soft);
}

.kv span {
  color: var(--muted);
}

.kv b {
  min-width: 0;
  color: var(--text);
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.story-card {
  min-height: 420px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(35, 28, 20, 0.38), rgba(16, 22, 31, 0.84)),
    #10161f;
}

.runtime-console {
  position: relative;
  grid-template-columns: minmax(270px, 0.32fr) minmax(0, 1fr);
  align-items: stretch;
  min-height: calc(100dvh - 112px);
  column-gap: 18px;
}

.runtime-console.player-collapsed,
.runtime-console.focus-mode {
  grid-template-columns: minmax(0, 1fr);
  column-gap: 12px;
}

.runtime-console.focus-mode {
  min-height: calc(100dvh - 92px);
}

.runtime-console.focus-mode .story-console {
  max-width: 1280px;
  width: 100%;
  justify-self: center;
}

.player-run-panel {
  position: relative;
  min-height: 0;
  max-height: calc(100dvh - 112px);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(243, 193, 95, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(47, 34, 20, 0.28), rgba(12, 18, 26, 0.86)),
    rgba(12, 18, 26, 0.9);
}

.player-collapsed-chip {
  position: relative;
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(243, 193, 95, 0.22);
  border-radius: 8px;
  background: rgba(12, 18, 26, 0.72);
}

.runtime-panel-edge-toggle {
  position: absolute;
  z-index: 12;
  top: 18px;
  right: -30px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border: 1px solid rgba(243, 193, 95, 0.32);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, rgba(243, 193, 95, 0.16), transparent 48%),
    rgba(29, 20, 12, 0.94);
  color: var(--amber);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.36);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.runtime-panel-edge-toggle:hover {
  border-color: rgba(243, 193, 95, 0.72);
  background: rgba(47, 34, 20, 0.96);
}

.player-collapsed-chip .runtime-panel-edge-toggle {
  left: 12px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
}

.player-collapsed .player-collapsed-chip,
.focus-mode .player-collapsed-chip {
  grid-column: 1 / -1;
}

.collapsed-chip-main,
.branch-dock-collapsed button {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(21, 29, 41, 0.72);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.collapsed-chip-main:hover,
.branch-dock-collapsed button:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.collapsed-chip-main span,
.branch-dock-collapsed span {
  color: var(--muted);
  font-size: 12px;
}

.collapsed-chip-main b,
.branch-dock-collapsed b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collapsed-chip-main i,
.branch-dock-collapsed i {
  color: var(--cyan);
  font-style: normal;
  font-size: 12px;
}

.collapsed-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.collapsed-chip-grid span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(139, 161, 180, 0.08);
  font-size: 12px;
}

.player-hero {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(243, 193, 95, 0.22);
}

.player-avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(243, 193, 95, 0.58);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, rgba(243, 193, 95, 0.34), transparent 42%),
    #17120c;
  color: var(--amber);
  font-size: 24px;
  font-weight: 800;
}

.player-hero h3 {
  margin: 2px 0 3px;
  color: var(--amber);
  font-size: 20px;
  line-height: 1.2;
}

.player-hero span {
  color: var(--muted);
  font-size: 13px;
}

.side-block {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.38);
}

.side-block header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.side-block h4 {
  margin: 0;
  color: var(--amber);
  font-size: 14px;
}

.side-block header button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(21, 29, 41, 0.72);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.side-block header button:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.mini-gauge {
  display: grid;
  gap: 5px;
}

.mini-gauge .kv {
  padding-bottom: 0;
  border-bottom: 0;
  font-size: 12px;
}

.mini-gauge.cyan .gauge i {
  background: linear-gradient(90deg, var(--cyan), #8bdce9);
}

.mini-gauge.amber .gauge i {
  background: linear-gradient(90deg, var(--amber-2), var(--amber));
}

.inventory-line,
.branch-option {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(21, 29, 41, 0.72);
  color: var(--text);
  cursor: pointer;
}

.inventory-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 7px 9px;
  text-align: left;
}

.inventory-line:hover,
.branch-option:hover {
  border-color: rgba(243, 193, 95, 0.55);
  background: rgba(47, 34, 20, 0.42);
}

.inventory-line b {
  color: var(--amber);
  font-size: 12px;
}

.intel-preview,
.compact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.intel-preview span,
.compact-list span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(139, 161, 180, 0.08);
  font-size: 12px;
}

.index-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.index-grid span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  color: var(--amber);
  background: rgba(21, 29, 41, 0.56);
}

.index-grid b {
  color: var(--muted);
  font-weight: 500;
}

.story-console {
  grid-template-rows: auto auto minmax(280px, 1fr) auto auto auto;
}

.story-run-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid rgba(243, 193, 95, 0.2);
  background:
    linear-gradient(90deg, rgba(47, 34, 20, 0.5), rgba(12, 18, 26, 0.82)),
    rgba(12, 18, 26, 0.82);
}

.story-head-tools {
  min-width: 260px;
  display: grid;
  justify-items: end;
  gap: 8px;
}

.runtime-layout-controls {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.runtime-layout-controls button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(21, 29, 41, 0.82);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.runtime-layout-controls button:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(47, 34, 20, 0.42);
}

.story-run-head h3 {
  margin: 3px 0 0;
  color: var(--amber);
  font-size: 22px;
  line-height: 1.2;
}

.story-clock {
  min-width: 190px;
  display: grid;
  justify-items: end;
  gap: 2px;
  color: var(--muted);
  text-align: right;
}

.story-clock b {
  color: var(--text);
  font-size: 18px;
}

.story-clock span {
  font-size: 12px;
}

.world-strip {
  display: grid;
  grid-template-columns: minmax(160px, 0.28fr) minmax(0, 1fr) minmax(220px, 0.36fr);
  gap: 1px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--line-soft);
}

.world-strip div {
  min-width: 0;
  padding: 10px 12px;
  background: rgba(8, 13, 19, 0.54);
}

.world-strip span {
  display: block;
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 12px;
}

.world-strip b {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  max-height: calc(100dvh - 112px);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(16, 22, 31, 0.78);
  overflow: hidden;
}

.chat-panel.story-console {
  height: calc(100dvh - 112px);
  grid-template-rows: auto auto auto minmax(120px, 1fr) auto auto auto;
}

.runtime-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 13, 19, 0.56);
}

.runtime-banner span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.runtime-banner span.syncing {
  border-color: rgba(240, 197, 106, 0.42);
  color: #f2cf8a;
  background: rgba(240, 197, 106, 0.08);
}

.api-required-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(229, 109, 100, 0.36);
  background: rgba(61, 25, 27, 0.34);
}

.api-required-banner div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.api-required-banner b {
  color: #f2b2ac;
}

.api-required-banner span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.api-required-banner .primary-button {
  width: auto;
  flex: 0 0 auto;
}

.chat-log {
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 12px 28px;
  background:
    linear-gradient(90deg, rgba(243, 193, 95, 0.16) 0 1px, transparent 1px) 15px 0 / 1px 100% no-repeat;
}

.message {
  position: relative;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
}

.story-console .message::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 20px;
  width: 9px;
  height: 9px;
  border: 1px solid rgba(243, 193, 95, 0.62);
  border-radius: 50%;
  background: #0d1219;
  box-shadow: 0 0 0 3px rgba(243, 193, 95, 0.08);
}

.message.user {
  border-color: rgba(98, 198, 217, 0.32);
  background: rgba(18, 36, 45, 0.42);
}

.message.assistant {
  border-color: rgba(243, 193, 95, 0.24);
}

.message header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.message-head-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.message-menu-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(21, 29, 41, 0.88);
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}

.message-menu-button:hover,
.message-menu-button[aria-expanded="true"] {
  border-color: var(--amber);
  color: var(--amber);
}

.message-action-menu {
  position: absolute;
  z-index: 20;
  top: 32px;
  right: 0;
  display: grid;
  width: 168px;
  padding: 6px;
  border: 1px solid rgba(243, 193, 95, 0.35);
  border-radius: 8px;
  background: rgba(10, 14, 20, 0.98);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.44);
}

.message-action-menu button {
  min-height: 32px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.message-action-menu button:hover {
  background: rgba(243, 193, 95, 0.12);
  color: var(--amber);
}

.message-action-menu button.danger-text {
  color: #ff9b8f;
}

.message-action-menu button.danger-text:hover {
  background: rgba(229, 109, 100, 0.14);
  color: #ffb3aa;
}

.message-action-menu button:disabled {
  cursor: not-allowed;
  color: var(--faint);
  opacity: 0.55;
}

.message h4 {
  margin: 0 0 8px;
  color: var(--amber);
}

.message-body p {
  margin: 0 0 10px;
  color: #dce5ed;
  line-height: 1.78;
}

.update-fold {
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
  color: var(--muted);
}

.update-fold summary {
  cursor: pointer;
  color: var(--cyan);
  font-size: 12px;
}

.update-fold pre {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

.branch-dock {
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  background: rgba(12, 18, 26, 0.68);
}

.branch-dock-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 8px;
}

.branch-dock-empty div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.branch-dock-empty b {
  color: var(--amber);
  font-size: 13px;
}

.branch-dock-empty span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-dock-empty button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(21, 29, 41, 0.88);
  color: var(--text);
  cursor: pointer;
}

.branch-dock-collapsed {
  padding: 8px 12px;
}

.branch-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.branch-dock-head h4 {
  margin: 2px 0 0;
  color: var(--amber);
  font-size: 14px;
}

.branch-dock-head > span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(243, 193, 95, 0.3);
  border-radius: 6px;
  color: var(--amber);
  font-size: 12px;
}

.branch-dock-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.branch-option {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  min-height: 56px;
  padding: 8px;
  text-align: left;
}

.branch-option i {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(243, 193, 95, 0.14);
  color: var(--amber);
  font-style: normal;
  font-size: 12px;
}

.branch-option b {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-option small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.runtime-action-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  background: rgba(8, 13, 19, 0.64);
}

.runtime-action-bar button,
.runtime-more-actions summary {
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(21, 29, 41, 0.88);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.runtime-action-bar button:hover,
.runtime-more-actions summary:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(47, 34, 20, 0.48);
}

.runtime-more-actions {
  position: relative;
}

.runtime-more-actions summary {
  display: grid;
  place-items: center;
  min-width: 76px;
  list-style: none;
}

.runtime-more-actions summary::-webkit-details-marker {
  display: none;
}

.runtime-more-actions div {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: 190px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 18, 26, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
}

.runtime-more-actions:not([open]) div {
  display: none;
}

.runtime-more-actions div button {
  width: 100%;
  text-align: left;
}

.composer-runtime-actions {
  flex: 0 0 auto;
}

.chat-composer {
  position: sticky;
  bottom: 0;
  z-index: 7;
  padding: 10px;
  border-top: 1px solid var(--line-soft);
  background: rgba(8, 13, 19, 0.54);
}

.chat-composer textarea {
  width: 100%;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #080d13;
  color: var(--text);
  resize: vertical;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.composer-actions .ghost-button {
  width: auto;
}

.story-card h3 {
  margin: 0 0 10px;
  color: var(--amber);
  font-size: 18px;
}

.story-card p {
  margin: 0 0 12px;
  color: #dce5ed;
  line-height: 1.82;
}

.choice-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.choice-list.compact {
  margin-top: 12px;
}

.choice-list button {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #141d27;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.choice-list button:hover {
  border-color: var(--amber);
}

.branch-card .primary-button {
  margin-top: 10px;
}

.event-card,
.task-card,
.character-card,
.log-entry {
  padding: calc(var(--density-pad) - 1px);
}

button.event-card,
button.character-card {
  width: 100%;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

button.event-card:active,
button.character-card:active,
.equipment-tile:active {
  transform: translateY(1px);
}

.event-card h4,
.task-card h4,
.character-card h4 {
  margin: 0;
  font-size: 14px;
}

.event-card p,
.task-card p,
.character-card p,
.log-entry p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.npc-index-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 178px;
  background:
    linear-gradient(135deg, rgba(243, 193, 95, 0.08), transparent 42%),
    rgba(16, 22, 31, 0.78);
}

.npc-index-card .character-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.npc-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.npc-card-meta span {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 13, 19, 0.34);
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-arrow {
  pointer-events: none;
  display: grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 50%;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(139, 161, 180, 0.09);
  color: var(--muted);
  font-size: 12px;
}

.tag.amber {
  color: var(--amber);
  border-color: rgba(243, 193, 95, 0.35);
}

.tag.green {
  color: #a9d9ab;
  border-color: rgba(115, 184, 120, 0.35);
}

.tag.red {
  color: #f0aaa5;
  border-color: rgba(229, 109, 100, 0.38);
}

.clock-track {
  height: 8px;
  margin-top: 9px;
  border-radius: 999px;
  background: #080d13;
  border: 1px solid #263240;
  overflow: hidden;
}

.clock-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 12px;
}

.city-map-shell {
  min-height: 560px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0d1219;
  overflow: hidden;
  position: relative;
}

.city-map-shell.wide {
  grid-column: span 2;
}

#city-canvas {
  width: 100%;
  height: 100%;
  min-height: 560px;
  display: block;
}

.map-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-point {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  min-width: 104px;
  max-width: 146px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid rgba(98, 198, 217, 0.35);
  border-radius: 7px;
  background: rgba(12, 18, 26, 0.84);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.map-point strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
}

.map-point small {
  color: var(--muted);
  font-size: 11px;
}

.map-point.active {
  border-color: var(--amber);
  background: rgba(47, 34, 20, 0.9);
}

.map-point.hot {
  border-color: var(--red);
}

.map-marker {
  position: absolute;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border: 1px solid rgba(243, 193, 95, 0.62);
  border-radius: 999px;
  background: rgba(34, 26, 13, 0.88);
  color: var(--amber);
  cursor: pointer;
  box-shadow: 0 0 0 6px rgba(243, 193, 95, 0.09), 0 8px 18px rgba(0, 0, 0, 0.34);
}

.map-marker span {
  max-width: 30px;
  overflow: hidden;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.map-marker.danger {
  border-color: rgba(229, 109, 100, 0.76);
  background: rgba(42, 17, 18, 0.9);
  color: #f0aaa5;
  box-shadow: 0 0 0 7px rgba(229, 109, 100, 0.10), 0 8px 18px rgba(0, 0, 0, 0.34);
}

.map-marker.ally {
  border-color: rgba(115, 184, 120, 0.72);
  background: rgba(16, 36, 24, 0.9);
  color: #a9d9ab;
  box-shadow: 0 0 0 7px rgba(115, 184, 120, 0.10), 0 8px 18px rgba(0, 0, 0, 0.34);
}

.map-marker.enemy {
  border-color: rgba(229, 109, 100, 0.72);
  background: rgba(35, 16, 25, 0.9);
}

.map-detail {
  padding: 12px;
}

.map-detail h3 {
  margin: 0 0 10px;
  color: var(--amber);
}

.map-detail h4 {
  margin: 14px 0 8px;
  color: var(--text);
  font-size: 13px;
}

.china-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 12px;
}

.china-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.52fr);
  gap: 14px;
  align-items: center;
  background:
    radial-gradient(circle at 8% 0%, rgba(243, 193, 95, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(16, 22, 31, 0.88), rgba(8, 13, 19, 0.78));
}

.china-hero h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.national-command-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.45fr);
  gap: 12px;
  align-items: stretch;
  background:
    linear-gradient(135deg, rgba(240, 197, 106, 0.11), transparent 48%),
    linear-gradient(180deg, rgba(13, 20, 29, 0.9), rgba(8, 13, 19, 0.82));
}

.national-command-panel p {
  margin: 8px 0 0;
}

.national-command-actions {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(5, 8, 12, 0.36);
}

.national-command-actions .ghost-button,
.national-command-actions .primary-button {
  width: 100%;
  min-height: 38px;
}

.national-command-actions span {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

.national-workflow-preview {
  grid-column: 1 / -1;
}

.china-summary-grid,
.province-stat-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.china-map-panel {
  min-height: 560px;
}

.china-map-board {
  position: relative;
  min-height: 510px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    radial-gradient(circle at 65% 20%, rgba(98, 198, 217, 0.12), transparent 28%),
    radial-gradient(circle at 35% 62%, rgba(243, 193, 95, 0.10), transparent 30%),
    #080d13;
}

.china-map-gridlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(139, 161, 180, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 161, 180, 0.055) 1px, transparent 1px);
  background-size: 48px 44px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

.province-node {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 2px;
  width: 108px;
  min-height: 50px;
  padding: 7px 9px;
  border: 1px solid rgba(98, 198, 217, 0.22);
  border-radius: 8px;
  background: rgba(12, 18, 26, 0.84);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.province-node b {
  font-size: 12px;
}

.province-node span {
  color: var(--muted);
  font-size: 11px;
}

.province-node.calm {
  border-color: rgba(115, 184, 120, 0.32);
}

.province-node.warn {
  border-color: rgba(243, 193, 95, 0.38);
}

.province-node.hot {
  border-color: rgba(229, 109, 100, 0.42);
  background: rgba(35, 18, 18, 0.86);
}

.province-node.danger,
.province-node.dead {
  border-color: rgba(229, 109, 100, 0.66);
  background:
    radial-gradient(circle at 18% 0%, rgba(229, 109, 100, 0.22), transparent 36%),
    rgba(36, 15, 18, 0.92);
}

.province-node.active {
  border-color: var(--amber);
  box-shadow: 0 0 0 5px rgba(243, 193, 95, 0.10), 0 18px 34px rgba(0, 0, 0, 0.34);
}

.china-province-panel {
  min-height: 560px;
}

.city-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.city-status-card {
  display: grid;
  gap: 10px;
  width: 100%;
  min-height: 154px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(98, 198, 217, 0.06), transparent 45%),
    rgba(8, 13, 19, 0.46);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.city-status-card.compact {
  min-height: 176px;
}

.city-status-card:hover {
  border-color: rgba(243, 193, 95, 0.34);
}

.city-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.city-card-head b {
  display: block;
  font-size: 15px;
}

.city-card-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.city-bars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.city-mini-bar {
  min-width: 0;
}

.city-mini-bar span,
.city-mini-bar b {
  display: inline-block;
  font-size: 11px;
}

.city-mini-bar span {
  color: var(--muted);
}

.city-mini-bar b {
  float: right;
  color: var(--text);
}

.city-mini-bar i {
  clear: both;
  display: block;
  height: 6px;
  margin-top: 4px;
  overflow: hidden;
  border: 1px solid #26323f;
  border-radius: 999px;
  background: #080d13;
}

.city-mini-bar em {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

.city-mini-bar.cyan em {
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

.city-mini-bar.danger em {
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.city-status-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.national-event-card {
  width: 100%;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.national-battle-card {
  width: 100%;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  border-color: rgba(240, 197, 106, 0.22);
  background:
    linear-gradient(135deg, rgba(240, 197, 106, 0.08), transparent 50%),
    rgba(13, 18, 26, 0.82);
}

.impact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.impact-row span {
  padding: 4px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
}

.national-detail-shell {
  display: grid;
  gap: 12px;
}

.national-city-hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(243, 193, 95, 0.22);
  border-radius: 8px;
  background:
    radial-gradient(circle at 8% 0%, rgba(243, 193, 95, 0.15), transparent 34%),
    rgba(12, 17, 24, 0.9);
}

.national-city-hero h3 {
  margin: 0;
  color: var(--amber);
  font-size: 24px;
}

.national-city-radar {
  min-width: 138px;
  padding: 10px;
  border: 1px solid rgba(229, 109, 100, 0.28);
  border-radius: 8px;
  background: rgba(38, 15, 17, 0.42);
}

.national-city-radar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.national-city-radar b {
  color: #f0aaa5;
  font-size: 28px;
}

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

.national-metric-card {
  min-height: 116px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
}

.national-metric-card span {
  color: var(--muted);
  font-size: 12px;
}

.national-metric-card b {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 26px;
}

.national-metric-card p {
  margin: 7px 0 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.42;
}

.national-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.national-rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.national-rule-card {
  min-height: 116px;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
}

.national-rule-card b {
  display: block;
  color: var(--amber);
  font-size: 13px;
}

.national-rule-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.timeline.compact .timeline-item {
  padding: 8px 0 8px 12px;
}

.code-panel pre,
.debug-json {
  max-height: 420px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #080d13;
  color: #d6e1eb;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.patch-preview,
.diagnostic {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 13, 19, 0.56);
  color: var(--muted);
}

.patch-preview b,
.diagnostic.ok {
  color: #a9d9ab;
}

.patch-preview.bad b,
.diagnostic.bad {
  color: #f0aaa5;
}

.patch-preview.ok {
  border-color: rgba(115, 184, 120, 0.38);
}

.patch-preview.bad {
  border-color: rgba(229, 109, 100, 0.42);
}

.patch-preview p {
  margin: 6px 0;
  line-height: 1.55;
}

.patch-preview ul {
  margin: 8px 0;
  padding-left: 20px;
}

.patch-preview .warn {
  color: var(--amber);
}

.patch-preview pre {
  max-height: 190px;
  margin: 8px 0 0;
  padding: 9px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #080d13;
  color: #d6e1eb;
  white-space: pre-wrap;
  word-break: break-word;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(16, 22, 31, 0.72);
}

.timeline-item time {
  color: var(--amber);
  font-size: 12px;
}

.timeline-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.app-dialog {
  width: min(760px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1219;
  color: var(--text);
  box-shadow: 0 24px 80px var(--shadow);
}

.detail-dialog.profile-detail-dialog {
  width: min(1120px, calc(100vw - 32px));
}

.detail-dialog.item-detail-dialog {
  width: min(900px, calc(100vw - 32px));
}

.detail-body {
  max-height: min(76dvh, 820px);
  overflow: auto;
  padding-right: 4px;
}

.npc-detail-shell,
.item-detail-shell {
  display: grid;
  gap: 12px;
}

.npc-hero-panel {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(243, 193, 95, 0.22);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 12%, rgba(243, 193, 95, 0.14), transparent 36%),
    linear-gradient(180deg, rgba(37, 28, 18, 0.76), rgba(12, 17, 24, 0.92));
}

.npc-avatar-large {
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  border: 1px solid rgba(243, 193, 95, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(243, 193, 95, 0.18), rgba(98, 198, 217, 0.08)),
    rgba(8, 13, 19, 0.74);
  color: var(--amber);
  font-size: 42px;
  font-weight: 800;
}

.npc-hero-main {
  min-width: 0;
}

.npc-title-row,
.item-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.npc-title-row h3,
.item-detail-head h3 {
  margin: 0;
  color: var(--amber);
  font-size: 24px;
}

.npc-hero-main > p,
.item-lead {
  margin: 10px 0 0;
  color: var(--text);
  line-height: 1.7;
}

.npc-current-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.npc-current-grid .kv,
.npc-info-card .kv {
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 13, 19, 0.36);
}

.npc-side-story-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(98, 198, 217, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(98, 198, 217, 0.1), transparent 48%),
    rgba(10, 17, 24, 0.88);
}

.npc-side-story-panel.syncing {
  border-color: rgba(98, 198, 217, 0.42);
  box-shadow: inset 0 0 0 1px rgba(98, 198, 217, 0.08);
}

.npc-side-story-panel.dead {
  border-color: rgba(229, 109, 100, 0.32);
  background:
    linear-gradient(135deg, rgba(229, 109, 100, 0.1), transparent 48%),
    rgba(15, 17, 20, 0.9);
  filter: grayscale(0.35);
}

.npc-side-story-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.npc-side-story-head h4 {
  margin: 0;
  color: var(--cyan);
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.npc-side-story-body {
  min-height: 170px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.46);
}

.npc-side-story-body p {
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.82;
}

.npc-side-story-body p:last-child {
  margin-bottom: 0;
}

.npc-side-story-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.npc-side-story-grid article {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.34);
}

.npc-side-story-grid h5 {
  margin: 0 0 9px;
  color: var(--amber);
  font-size: 13px;
}

.character-card.ai-linked {
  border-color: rgba(98, 198, 217, 0.32);
}

.character-card.dead {
  opacity: 0.62;
  filter: grayscale(0.72);
}

.character-card.dead h4 {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(229, 109, 100, 0.82);
}

.npc-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.npc-info-card,
.item-detail-block,
.equipment-art-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(16, 22, 31, 0.72);
}

.npc-info-card.wide {
  grid-column: 1 / -1;
}

.npc-info-card h4,
.item-detail-block h4,
.equipment-art-panel h4 {
  margin: 0 0 10px;
  color: var(--amber);
  font-size: 15px;
}

.npc-info-card p,
.item-detail-block p,
.equipment-art-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
}

.attribute-matrix {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.attribute-row {
  position: relative;
  min-height: 58px;
  overflow: hidden;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 13, 19, 0.42);
}

.attribute-row span,
.item-bonus-grid span,
.item-rarity-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.attribute-row b,
.item-bonus-grid b,
.item-rarity-box b {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 16px;
}

.attribute-row i {
  position: absolute;
  inset: auto auto 0 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--amber));
}

.npc-memory-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.npc-memory-list div {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 13, 19, 0.32);
}

.npc-memory-list time {
  color: var(--amber);
  font-size: 12px;
}

.npc-memory-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.equipment-tile {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 10px;
  border: 1px solid rgba(243, 193, 95, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(243, 193, 95, 0.1), transparent 48%),
    rgba(8, 13, 19, 0.5);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.equipment-tile:hover {
  border-color: rgba(243, 193, 95, 0.42);
}

.equipment-tile span {
  color: var(--amber);
  font-size: 12px;
}

.equipment-tile b {
  font-size: 15px;
}

.equipment-tile small {
  color: var(--muted);
  line-height: 1.45;
}

.item-detail-head {
  padding: 14px;
  border: 1px solid rgba(243, 193, 95, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(243, 193, 95, 0.13), transparent 42%),
    rgba(12, 17, 24, 0.9);
}

.item-rarity-box {
  min-width: 140px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
}

.item-bonus-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.item-bonus-grid div {
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 13, 19, 0.36);
}

.equipment-art-panel {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.equipment-art-frame {
  min-height: 220px;
  overflow: hidden;
  border: 1px solid rgba(243, 193, 95, 0.18);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.45);
}

.equipment-art-frame img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
  display: block;
}

.equipment-art-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 220px;
  color: var(--muted);
}

.equipment-art-empty span {
  color: rgba(243, 193, 95, 0.42);
  font-size: 42px;
}

.inline-image-prompt {
  width: 100%;
  min-height: 86px;
  margin: 12px 0 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #080d13;
  color: var(--text);
  resize: vertical;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select,
.field textarea,
.dialog-title-input,
.app-dialog > form > textarea,
.io-textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #080d13;
  color: var(--text);
}

.field textarea,
.app-dialog > form > textarea,
.io-textarea {
  min-height: 150px;
  resize: vertical;
}

.dialog-title-input {
  margin-bottom: 10px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.toggle-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  min-height: 96px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.42);
  cursor: pointer;
}

.toggle-card input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  accent-color: var(--amber);
}

.toggle-card b {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 14px;
}

.toggle-card small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.toggle-card:has(input:checked) {
  border-color: rgba(115, 184, 120, 0.38);
  background: rgba(24, 48, 38, 0.38);
}

.snapshot-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  margin-top: 10px;
}

.snapshot-item .archive-item {
  margin-bottom: 0;
}

.inline-actions {
  margin-top: 0;
}

.inline-actions .ghost-button,
.inline-actions .primary-button {
  width: auto;
}

.preset-list,
.backend-diagnostics {
  max-height: 280px;
  overflow: auto;
}

.ghost-button.full {
  width: 100%;
}

.primary-button.full {
  width: 100%;
  margin-top: 6px;
}

.manager-list {
  min-height: 0;
}

.manager-list-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 8px;
}

.manager-list-item-row .manager-list-item {
  margin-bottom: 0;
}

.manager-list-item-row.active .manager-list-item {
  border-color: rgba(243, 193, 95, 0.45);
  background: rgba(47, 34, 20, 0.6);
}

.mini-toggle {
  min-width: 54px;
  min-height: 52px;
  padding: 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 13, 19, 0.42);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.mini-toggle.on {
  border-color: rgba(115, 184, 120, 0.45);
  background: rgba(27, 55, 39, 0.48);
  color: #9ad6a1;
}

.mini-toggle:hover {
  border-color: rgba(243, 193, 95, 0.46);
  color: var(--amber);
}

.manager-list-item,
.archive-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 52px;
  margin-bottom: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(8, 13, 19, 0.42);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.manager-list-item span,
.archive-item span {
  color: var(--muted);
  font-size: 12px;
}

.manager-list-item.active,
.archive-item.active {
  border-color: rgba(243, 193, 95, 0.45);
  background: rgba(47, 34, 20, 0.6);
}

.archive-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.archive-list {
  max-height: 420px;
  overflow: auto;
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

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

.dialog-head h3 {
  margin: 2px 0 0;
}

#patch-input {
  width: 100%;
  min-height: 300px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #080d13;
  color: #dce5ee;
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.dialog-actions .ghost-button {
  width: auto;
}

.detail-body {
  display: grid;
  gap: 8px;
}

.mobile-nav {
  display: none;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(16, 22, 31, 0.46);
}

.empty-state b {
  color: var(--amber);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 218px minmax(0, 1fr);
  }

  body.sidebar-collapsed .app-shell {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .right-rail {
    display: none;
  }

  .rail-edge-toggle {
    display: none;
  }

  .nav-edge-toggle {
    left: 189px;
  }

  body.sidebar-collapsed .nav-edge-toggle {
    left: 13px;
  }

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

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
    height: auto;
    padding-bottom: 92px;
  }

  .sidebar {
    display: none;
  }

  .shell-edge-toggle {
    display: none;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px;
  }

  .topbar h2 {
    font-size: 18px;
  }

  .page-root {
    overflow: visible;
    padding: 12px 12px 92px;
  }

  .main-chat-preset-layout,
  .prompt-section-summary {
    grid-template-columns: 1fr;
  }

  .main-chat-preset-list,
  .prompt-section-list {
    max-height: none;
  }

  .prompt-section-actions {
    justify-content: flex-start;
  }

  .dashboard-grid,
  .two-column,
  .three-column,
  .china-layout,
  .china-hero,
  .national-command-panel,
  .china-summary-grid,
  .province-stat-strip,
  .city-bars,
  .national-metric-grid,
  .national-detail-grid,
  .national-rule-grid,
  .settings-grid,
  .settings-shell,
  .endpoint-layout,
  .main-story-layout,
  .chat-layout,
  .creation-shell,
  .creation-top,
  .creation-layout,
  .manager-layout,
  .map-layout,
  .protocol-grid,
  .archive-grid {
    grid-template-columns: 1fr;
  }

  .creation-shell {
    grid-template-areas:
      "top"
      "sheet"
      "stage"
      "advisor"
      "footer";
    padding-bottom: 106px;
  }

  .creation-steps,
  .choice-grid,
  .choice-grid.slim,
  .confirm-grid {
    grid-template-columns: 1fr;
  }

  .creation-footer {
    bottom: 96px;
    grid-template-columns: 1fr;
  }

  .creation-footer div {
    display: grid;
    justify-items: center;
  }

  .attribute-control,
  .factor-control {
    grid-template-columns: 1fr;
  }

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

  .settings-menu {
    max-height: none;
  }

  .form-grid.compact,
  .route-diagnostic-grid {
    grid-template-columns: 1fr;
  }

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

  .runtime-console {
    min-height: 0;
    column-gap: 12px;
  }

  .player-run-panel {
    max-height: none;
  }

  .runtime-panel-edge-toggle {
    right: 10px;
    top: 10px;
    width: 38px;
    height: 38px;
    min-height: 38px;
    font-size: 24px;
  }

  .story-run-head {
    display: grid;
    align-items: start;
  }

  .story-head-tools {
    min-width: 0;
    justify-items: start;
    width: 100%;
  }

  .runtime-layout-controls {
    justify-content: flex-start;
    width: 100%;
  }

  .runtime-layout-controls button {
    flex: 1 1 96px;
  }

  .story-clock {
    min-width: 0;
    justify-items: start;
    text-align: left;
  }

  .world-strip,
  .branch-dock-grid {
    grid-template-columns: 1fr;
  }

  .runtime-action-bar {
    grid-template-columns: 1fr 1fr;
  }

  .chat-panel {
    max-height: none;
    grid-template-rows: auto minmax(180px, 1fr) auto;
  }

  .chat-panel.story-console {
    height: auto;
    min-height: calc(100dvh - 154px);
    grid-template-rows: auto auto auto minmax(180px, 1fr) auto auto auto;
  }

  .composer-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .composer-actions .ghost-button,
  .composer-actions .primary-button {
    width: 100%;
  }

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

  .detail-dialog.profile-detail-dialog,
  .detail-dialog.item-detail-dialog {
    width: min(100vw - 18px, 760px);
  }

  .npc-hero-panel,
  .npc-current-grid,
  .npc-side-story-head,
  .npc-side-story-grid,
  .npc-detail-grid,
  .attribute-matrix,
  .equipment-grid,
  .equipment-art-panel,
  .item-bonus-grid {
    grid-template-columns: 1fr;
  }

  .npc-avatar-large {
    width: 86px;
    height: 86px;
    font-size: 32px;
  }

  .npc-title-row,
  .item-detail-head {
    display: grid;
  }

  .item-rarity-box {
    min-width: 0;
  }

  .city-map-shell,
  #city-canvas {
    min-height: 460px;
  }

  .china-map-panel,
  .china-province-panel {
    min-height: 0;
  }

  .china-map-board {
    min-height: 620px;
  }

  .province-node {
    width: 96px;
    min-width: 0;
    padding: 7px 8px;
  }

  .national-command-actions {
    align-content: start;
  }

  .national-city-hero {
    display: grid;
  }

  .city-map-shell.wide {
    grid-column: span 1;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    overflow-x: auto;
    scrollbar-width: thin;
    border-top: 1px solid var(--line);
    background: rgba(10, 14, 20, 0.95);
    box-shadow: 0 -14px 32px rgba(0, 0, 0, 0.36);
  }

  .mobile-nav button {
    flex: 0 0 76px;
    min-height: 58px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
  }

  body[data-mobile-nav="compact"] .mobile-nav button {
    flex-basis: 64px;
    min-height: 52px;
    font-size: 11px;
  }

  .mobile-nav button.active {
    color: var(--amber);
  }

  .panel .kv {
    align-items: flex-start;
  }

  .panel .kv span {
    flex: 0 0 86px;
  }

  .panel .kv b {
    text-align: right;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 520px) {
  .top-actions {
    gap: 5px;
  }

  .runtime-action-bar {
    grid-template-columns: 1fr;
  }

  .branch-option {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .primary-button {
    padding: 0 10px;
  }

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

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

  .metric-card {
    min-height: 96px;
  }

  .map-point {
    min-width: 92px;
    max-width: 116px;
    padding: 5px 6px;
  }

  .china-map-board {
    min-height: 720px;
  }

  .province-node {
    width: 62px;
    min-height: 36px;
    padding: 4px;
    gap: 1px;
  }

  .province-node b {
    font-size: 10px;
  }

  .province-node span {
    max-width: 100%;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .national-rule-card {
    min-height: 0;
  }
}

/* Experience polish inspired by the reference app: darker ink, warmer hierarchy, cleaner runtime flow. */
:root {
  --bg: #05070b;
  --panel: #0d1219;
  --panel-2: #121924;
  --panel-3: #182130;
  --line: #354252;
  --line-soft: rgba(174, 190, 207, 0.16);
  --text: #eef4f8;
  --muted: #a7b3bf;
  --faint: #6f7d8b;
  --amber: #f0c56a;
  --amber-2: #9d6d2b;
  --cyan: #71c9dc;
  --green: #85c58b;
  --red: #e77b70;
  --violet: #9386d8;
  --shadow: rgba(0, 0, 0, 0.56);
}

:root[data-theme="light"] {
  --bg: #edf2f5;
  --panel: #f8fbfd;
  --panel-2: #edf3f7;
  --panel-3: #e3edf4;
  --line: #b7c7d4;
  --line-soft: rgba(50, 72, 91, 0.16);
  --text: #17212b;
  --muted: #516475;
  --faint: #728292;
  --shadow: rgba(34, 48, 62, 0.18);
}

html,
body {
  background:
    linear-gradient(150deg, rgba(109, 75, 35, 0.2), transparent 28%),
    linear-gradient(220deg, rgba(44, 97, 121, 0.16), transparent 36%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 26px),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.62;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.025)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 7px);
  mix-blend-mode: screen;
}

* {
  scrollbar-color: rgba(240, 197, 106, 0.42) rgba(8, 12, 17, 0.46);
  scrollbar-width: thin;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(240, 197, 106, 0.78);
  outline-offset: 2px;
}

.app-shell {
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(3, 6, 10, 0.7), transparent 18%, transparent 82%, rgba(3, 6, 10, 0.55));
}

.sidebar,
.right-rail,
.topbar {
  backdrop-filter: blur(18px) saturate(125%);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
}

.sidebar,
.right-rail {
  background:
    linear-gradient(180deg, rgba(16, 20, 26, 0.96), rgba(7, 10, 15, 0.94)),
    var(--panel);
}

.sidebar {
  box-shadow: inset -1px 0 0 rgba(240, 197, 106, 0.08), 18px 0 56px rgba(0, 0, 0, 0.26);
}

.brand-block {
  position: relative;
  padding-block: 16px;
  background:
    linear-gradient(135deg, rgba(240, 197, 106, 0.1), transparent 46%),
    rgba(255, 255, 255, 0.015);
}

.brand-block::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240, 197, 106, 0.48), transparent);
}

.brand-mark {
  border-color: rgba(240, 197, 106, 0.68);
  background:
    linear-gradient(145deg, rgba(240, 197, 106, 0.18), rgba(20, 13, 7, 0.92)),
    #17110a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 28px rgba(0, 0, 0, 0.34);
}

.nav-list {
  padding: 10px 8px 12px;
}

.nav-item {
  min-height: 42px;
  margin-bottom: 5px;
  border-color: rgba(255, 255, 255, 0.02);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(240, 197, 106, 0.28);
  background:
    linear-gradient(90deg, rgba(240, 197, 106, 0.13), rgba(18, 25, 35, 0.68)),
    rgba(18, 25, 35, 0.92);
  transform: translateX(2px);
}

.nav-item.active {
  box-shadow: inset 2px 0 0 var(--amber);
}

.nav-icon {
  background:
    linear-gradient(145deg, rgba(113, 201, 220, 0.16), rgba(18, 32, 43, 0.9));
  color: #9bdce9;
}

.nav-item.active .nav-icon {
  background:
    linear-gradient(145deg, rgba(240, 197, 106, 0.22), rgba(45, 30, 15, 0.95));
  color: var(--amber);
}

.nav-advanced-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(174, 190, 207, 0.12);
}

.nav-advanced-toggle {
  opacity: 0.82;
}

.nav-advanced-toggle.active-soft {
  border-color: rgba(113, 201, 220, 0.2);
  background: rgba(15, 24, 33, 0.68);
}

.nav-advanced-list {
  display: none;
  gap: 2px;
}

.nav-advanced-block.open .nav-advanced-list {
  display: grid;
}

.nav-item-advanced {
  min-height: 36px;
  opacity: 0.74;
}

.nav-item-advanced:hover,
.nav-item-advanced.active {
  opacity: 1;
}

.nav-item-advanced .nav-icon {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

.sidebar-footer {
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.22));
}

.topbar {
  position: relative;
  background:
    linear-gradient(90deg, rgba(15, 21, 30, 0.92), rgba(10, 14, 20, 0.78)),
    rgba(16, 22, 31, 0.82);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, rgba(240, 197, 106, 0.52), transparent 58%);
}

.eyebrow {
  color: var(--faint);
}

.topbar h2,
.story-run-head h3,
.player-hero h3,
.panel h3,
.code-panel h3 {
  letter-spacing: 0;
}

.primary-button {
  background:
    linear-gradient(180deg, #f1ca72, #c9882e);
  border-color: rgba(255, 224, 145, 0.72);
  color: #151007;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), 0 10px 24px rgba(184, 118, 37, 0.18);
}

.ghost-button,
.icon-button,
.runtime-layout-controls button,
.side-block header button {
  background:
    linear-gradient(180deg, rgba(27, 36, 49, 0.9), rgba(13, 18, 26, 0.92));
}

.primary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.runtime-layout-controls button:hover,
.side-block header button:hover {
  transform: translateY(-1px);
}

.page-root {
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 24%),
    transparent;
}

.panel,
.event-card,
.task-card,
.character-card,
.map-detail,
.log-entry,
.code-panel,
.rail-panel,
.route-card,
.route-diagnostic,
.choice-card,
.toggle-card,
.side-block,
.message,
.branch-option,
.manager-list-item,
.archive-item {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
    rgba(13, 18, 26, 0.82);
  border-color: rgba(174, 190, 207, 0.15);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 40px rgba(0, 0, 0, 0.22);
}

.panel:hover,
.event-card:hover,
.task-card:hover,
.character-card:hover,
.route-card:hover,
.choice-card:hover,
.toggle-card:hover {
  border-color: rgba(240, 197, 106, 0.28);
}

.panel h3,
.code-panel h3 {
  color: var(--amber);
}

.rail-panel {
  margin-bottom: 10px;
}

.data-pill,
.tag {
  border-radius: 7px;
}

.tag {
  background: rgba(255, 255, 255, 0.045);
}

.tag.amber {
  background: rgba(240, 197, 106, 0.1);
}

.tag.green {
  background: rgba(133, 197, 139, 0.1);
}

.tag.red {
  background: rgba(231, 123, 112, 0.1);
}

.runtime-console {
  grid-template-columns: minmax(248px, 0.31fr) minmax(0, 1fr);
  gap: 16px;
}

.player-run-panel {
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(54, 37, 19, 0.5), rgba(8, 12, 17, 0.92)),
    rgba(9, 13, 19, 0.94);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 22px 50px rgba(0, 0, 0, 0.3);
}

.player-avatar {
  border-color: rgba(240, 197, 106, 0.72);
  background:
    linear-gradient(145deg, rgba(240, 197, 106, 0.23), rgba(28, 17, 9, 0.95)),
    #17110c;
  box-shadow: 0 0 0 5px rgba(240, 197, 106, 0.08);
}

.chat-panel.story-console {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 112px);
  min-height: 0;
  max-height: calc(100dvh - 112px);
}

.chat-panel.story-console .chat-log {
  flex: 1 1 auto;
  min-height: 96px;
  overflow: auto;
}

.story-run-head {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(168px, auto);
  align-items: start;
  background:
    linear-gradient(135deg, rgba(57, 38, 19, 0.72), rgba(9, 13, 19, 0.88) 58%),
    rgba(12, 18, 26, 0.9);
}

.story-run-head h3 {
  max-width: 22rem;
  font-size: 21px;
}

.story-head-tools {
  min-width: 0;
}

body.chat-runtime-shell .page-chat-runtime .story-head-tools,
body.runtime-focus .page-chat-runtime .story-head-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

body.chat-runtime-shell .page-chat-runtime .story-clock,
body.runtime-focus .page-chat-runtime .story-clock {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-align: right;
}

body.chat-runtime-shell .page-chat-runtime .story-clock span,
body.runtime-focus .page-chat-runtime .story-clock span {
  display: none;
}

.story-clock b {
  color: var(--amber);
}

.world-strip {
  flex: 0 0 auto;
  grid-template-columns: minmax(116px, 0.8fr) minmax(0, 1.25fr) minmax(142px, 1fr);
  background: rgba(240, 197, 106, 0.16);
}

.world-strip div {
  background: rgba(7, 11, 16, 0.68);
}

.runtime-banner {
  flex: 0 0 auto;
  background:
    linear-gradient(90deg, rgba(113, 201, 220, 0.08), transparent),
    rgba(8, 13, 19, 0.6);
}

.api-required-banner {
  flex: 0 0 auto;
  align-items: center;
  padding: 12px 14px;
  border-color: rgba(231, 123, 112, 0.3);
  background:
    linear-gradient(90deg, rgba(231, 123, 112, 0.16), rgba(45, 21, 18, 0.48)),
    rgba(16, 13, 14, 0.76);
}

.api-required-banner b {
  color: #ffc1ba;
}

.chat-log {
  flex: 1 1 160px;
  min-height: 120px;
  overflow: auto;
  padding: 16px 18px 14px 30px;
  background:
    linear-gradient(90deg, rgba(240, 197, 106, 0.2) 0 1px, transparent 1px) 16px 0 / 1px 100% no-repeat,
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 45%),
    rgba(5, 8, 12, 0.45);
}

.message {
  padding: 13px 14px;
}

.message.assistant {
  background:
    linear-gradient(180deg, rgba(240, 197, 106, 0.07), rgba(8, 13, 19, 0.72)),
    rgba(8, 13, 19, 0.72);
}

.message.user {
  background:
    linear-gradient(180deg, rgba(113, 201, 220, 0.08), rgba(8, 13, 19, 0.72)),
    rgba(9, 18, 24, 0.72);
}

.message-body p {
  color: #e4edf3;
}

.branch-dock,
.runtime-action-bar,
.chat-composer {
  flex: 0 0 auto;
}

.branch-dock {
  background:
    linear-gradient(180deg, rgba(240, 197, 106, 0.055), rgba(8, 13, 19, 0.82));
}

.branch-option {
  min-height: 64px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    rgba(14, 20, 29, 0.88);
}

.branch-option:hover {
  transform: translateY(-1px);
}

.branch-option i {
  background:
    linear-gradient(145deg, rgba(240, 197, 106, 0.22), rgba(55, 36, 17, 0.82));
}

.runtime-action-bar {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  background:
    linear-gradient(180deg, rgba(7, 11, 16, 0.8), rgba(7, 11, 16, 0.96));
}

.runtime-action-bar button {
  min-height: 42px;
  white-space: normal;
  line-height: 1.2;
}

.chat-composer {
  background:
    linear-gradient(180deg, rgba(8, 13, 19, 0.72), rgba(5, 8, 12, 0.96));
}

.chat-composer textarea,
.field input,
.field select,
.field textarea,
.dialog-title-input,
.app-dialog > form > textarea,
.io-textarea,
#patch-input,
.code-panel pre,
.debug-json {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent),
    #060a0f;
  border-color: rgba(174, 190, 207, 0.2);
}

.chat-composer textarea:focus {
  border-color: rgba(240, 197, 106, 0.58);
  box-shadow: 0 0 0 3px rgba(240, 197, 106, 0.09);
}

.empty-state {
  background:
    linear-gradient(135deg, rgba(240, 197, 106, 0.07), rgba(13, 18, 26, 0.62)),
    rgba(13, 18, 26, 0.7);
}

.app-dialog {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 24%),
    #0b1017;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.66);
}

.app-dialog::backdrop {
  background: rgba(1, 3, 6, 0.74);
  backdrop-filter: blur(10px);
}

.startup-gate {
  min-height: calc(100dvh - 112px);
  display: grid;
  gap: 14px;
}

.startup-gate-hero,
.startup-readiness,
.startup-flow button {
  border: 1px solid rgba(174, 190, 207, 0.16);
  border-radius: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 22px 52px rgba(0, 0, 0, 0.24);
}

.startup-gate-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(300px, 0.62fr);
  overflow: hidden;
  background:
    linear-gradient(130deg, rgba(56, 37, 17, 0.86), rgba(8, 12, 18, 0.92) 56%),
    rgba(10, 14, 20, 0.94);
}

.startup-gate-copy {
  min-width: 0;
  padding: 24px;
}

.startup-gate-copy h3 {
  max-width: 680px;
  margin: 6px 0 10px;
  color: var(--amber);
  font-size: 30px;
  line-height: 1.15;
}

.startup-gate-copy p:not(.eyebrow) {
  max-width: 720px;
  margin: 0;
  color: #dce7ee;
  line-height: 1.72;
}

.startup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.startup-actions button {
  min-width: 116px;
}

.startup-world-card {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 20px;
  border-left: 1px solid rgba(240, 197, 106, 0.18);
  background:
    linear-gradient(180deg, rgba(113, 201, 220, 0.08), transparent),
    rgba(7, 11, 16, 0.54);
}

.startup-world-card > span {
  color: var(--faint);
  font-size: 12px;
}

.startup-world-card > b {
  color: var(--text);
  font-size: 20px;
}

.startup-world-grid {
  display: grid;
  gap: 8px;
}

.startup-world-grid .kv {
  padding: 8px 0 0;
}

.startup-readiness {
  display: grid;
  gap: 12px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.026), rgba(255, 255, 255, 0.01)),
    rgba(11, 16, 23, 0.84);
}

.startup-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.startup-section-head h4 {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 18px;
}

.startup-route-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.startup-route-card {
  min-width: 0;
  min-height: 132px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(174, 190, 207, 0.14);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.58);
}

.startup-route-card.ok {
  border-color: rgba(133, 197, 139, 0.22);
}

.startup-route-card.bad {
  border-color: rgba(231, 123, 112, 0.24);
  background:
    linear-gradient(180deg, rgba(231, 123, 112, 0.06), transparent),
    rgba(12, 13, 17, 0.62);
}

.startup-route-card b,
.startup-flow b {
  display: block;
  color: var(--text);
}

.startup-route-card small,
.startup-flow small {
  grid-column: 2;
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

.startup-route-card p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

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

.startup-flow button {
  min-width: 0;
  min-height: 92px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012)),
    rgba(13, 18, 26, 0.82);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.startup-flow button:hover {
  border-color: rgba(240, 197, 106, 0.32);
  transform: translateY(-1px);
}

.startup-flow span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(240, 197, 106, 0.28);
  border-radius: 8px;
  color: var(--amber);
  background: rgba(55, 36, 17, 0.42);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1500px) {
  .china-layout {
    grid-template-columns: 1fr;
  }

  .china-map-panel,
  .china-province-panel {
    min-height: 0;
  }

  .china-map-board {
    min-height: 560px;
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 224px minmax(0, 1fr);
  }

  body.sidebar-collapsed .app-shell {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .nav-edge-toggle {
    left: 195px;
  }

  .runtime-console {
    grid-template-columns: minmax(236px, 0.31fr) minmax(0, 1fr);
  }

  .china-layout {
    grid-template-columns: 1fr;
  }

  .china-map-panel,
  .china-province-panel {
    min-height: 0;
  }

  .china-map-board {
    min-height: 560px;
  }
}

@media (max-width: 980px) {
  .startup-gate-hero,
  .startup-route-grid,
  .startup-flow {
    grid-template-columns: 1fr;
  }

  .startup-world-card {
    border-left: 0;
    border-top: 1px solid rgba(240, 197, 106, 0.16);
  }

  .runtime-console {
    grid-template-columns: 1fr;
  }

  .player-run-panel {
    max-height: 320px;
  }

  .runtime-panel-edge-toggle {
    right: 10px;
  }

  .story-run-head {
    grid-template-columns: 1fr;
  }

  .story-head-tools {
    justify-items: start;
  }
}

@media (max-width: 860px) {
  body {
    filter: none;
  }

  body::before {
    opacity: 0.45;
  }

  .app-shell,
  body.sidebar-collapsed .app-shell,
  body.rail-hidden .app-shell,
  body.rail-collapsed .app-shell,
  body.sidebar-collapsed.rail-hidden .app-shell,
  body.sidebar-collapsed.rail-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace {
    width: 100%;
  }

  .topbar {
    background: rgba(10, 14, 20, 0.92);
  }

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .page-root {
    padding: 12px 12px 96px;
  }

  .chat-panel.story-console {
    min-height: auto;
  }

  .runtime-console {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .runtime-console .story-console {
    order: 1;
  }

  .runtime-console .player-run-panel,
  .runtime-console .player-collapsed-chip {
    order: 2;
  }

  .world-strip,
  .branch-dock-grid {
    grid-template-columns: 1fr;
  }

  .player-run-panel {
    max-height: none;
  }

  .startup-gate {
    min-height: auto;
  }

  .startup-gate-copy,
  .startup-world-card {
    padding: 16px;
  }

  .startup-gate-copy h3 {
    font-size: 24px;
  }

  .startup-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .startup-actions button {
    width: 100%;
  }

  .api-required-banner {
    display: grid;
  }

  .api-required-banner .primary-button {
    width: 100%;
  }

  .mobile-nav {
    background:
      linear-gradient(180deg, rgba(17, 23, 32, 0.82), rgba(5, 8, 12, 0.98));
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
  }

  .mobile-nav button.active {
    background: rgba(240, 197, 106, 0.1);
    box-shadow: inset 0 2px 0 var(--amber);
  }

  .mobile-more-toggle[aria-expanded="false"] ~ .mobile-nav-extra {
    display: none;
  }

  .mobile-more-toggle[aria-expanded="true"] ~ .mobile-nav-extra {
    display: block;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar h2 {
    font-size: 17px;
  }

  .world-strip div {
    padding: 9px 10px;
  }

  .runtime-action-bar {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Keep shell collapse affordances available without competing with the runtime start panel. */
.shell-edge-toggle {
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-color: rgba(240, 197, 106, 0.24);
  background:
    radial-gradient(circle at 50% 35%, rgba(240, 197, 106, 0.12), transparent 48%),
    rgba(16, 14, 12, 0.82);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.32);
}

.shell-edge-toggle::before {
  font-size: 22px;
}

.nav-edge-toggle {
  left: 218px;
  top: 46px;
}

.nav-edge-toggle::before {
  content: "‹";
}

body.sidebar-collapsed .nav-edge-toggle {
  left: 13px;
}

body.sidebar-collapsed .nav-edge-toggle::before {
  content: "›";
}

.rail-edge-toggle {
  right: 300px;
  top: 46px;
}

.rail-edge-toggle::before {
  content: "›";
}

body.rail-collapsed .rail-edge-toggle,
body.rail-hidden .rail-edge-toggle {
  right: 12px;
}

body.rail-collapsed .rail-edge-toggle::before,
body.rail-hidden .rail-edge-toggle::before {
  content: "‹";
}

.page-root.page-chat-runtime {
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 12px;
}

.page-chat-runtime .runtime-console {
  flex: 1 1 auto;
  min-height: 0;
}

.page-chat-runtime .player-run-panel {
  max-height: none;
}

.page-chat-runtime .chat-panel.story-console {
  height: auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.page-chat-runtime .chat-panel.story-console,
.page-chat-runtime .player-run-panel {
  align-self: stretch;
}

.page-chat-runtime .chat-panel.story-console .chat-log {
  flex: 1 1 auto;
  min-height: 0;
}

.page-chat-runtime .chat-composer {
  position: static;
  flex: 0 0 auto;
}

.page-chat-runtime .chat-composer textarea {
  min-height: 72px;
  max-height: 150px;
}

@media (max-width: 980px) {
  .app-shell {
    height: 100dvh;
    overflow: hidden;
  }

  .workspace {
    height: 100dvh;
    overflow: hidden;
  }

  .page-root.page-chat-runtime {
    height: auto;
    overflow-y: auto;
    padding-bottom: 96px;
  }

  .page-chat-runtime .runtime-console {
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
  }

  .page-chat-runtime .chat-panel.story-console {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 8px;
  }

  .page-chat-runtime .player-run-panel,
  .page-chat-runtime .player-collapsed-chip {
    display: none;
  }

  .page-chat-runtime .story-run-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 10px;
  }

  .page-chat-runtime .story-run-head h3 {
    margin-top: 2px;
    font-size: 18px;
  }

  .page-chat-runtime .story-run-head .tag-row,
  .page-chat-runtime .story-clock {
    display: none;
  }

  .page-chat-runtime .story-head-tools {
    min-width: 0;
    justify-items: end;
  }

  .page-chat-runtime .runtime-layout-controls {
    width: auto;
    justify-content: flex-end;
  }

  .page-chat-runtime .runtime-layout-controls button {
    flex: 0 0 30px;
    width: 30px;
    min-height: 30px;
    padding: 0;
    overflow: hidden;
  }

  .page-chat-runtime .world-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page-chat-runtime .world-strip div,
  .page-chat-runtime .runtime-banner,
  .page-chat-runtime .branch-dock,
  .page-chat-runtime .runtime-action-bar,
  .page-chat-runtime .chat-composer {
    padding: 6px 8px;
  }

  .page-chat-runtime .world-strip span {
    margin-bottom: 2px;
  }

  .page-chat-runtime .world-strip b {
    font-size: 12px;
  }

  .page-chat-runtime .runtime-banner {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .page-chat-runtime .runtime-banner span {
    min-width: 0;
    min-height: 22px;
    padding: 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-chat-runtime .branch-dock-head {
    display: none;
  }

  .page-chat-runtime .branch-dock-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .page-chat-runtime .branch-option {
    min-height: 42px;
    padding: 6px;
  }

  .page-chat-runtime .branch-option small {
    display: none;
  }

  .page-chat-runtime .runtime-action-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 6px;
  }

  .page-chat-runtime .runtime-action-bar button {
    min-height: 36px;
    padding: 0 6px;
    font-size: 12px;
  }

  .page-chat-runtime .composer-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .page-chat-runtime .composer-actions .primary-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .page-chat-runtime .runtime-action-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  }
}

@media (min-width: 981px) {
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed):not(.rail-hidden):not(.rail-collapsed) .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  body.chat-runtime-shell.sidebar-collapsed:not(.rail-hidden):not(.rail-collapsed) .app-shell {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed).rail-hidden .app-shell,
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed).rail-collapsed .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  body.chat-runtime-shell:not(.runtime-focus) .topbar {
    padding: 10px 14px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .topbar h2 {
    font-size: 18px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .top-actions button {
    min-height: 34px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .sidebar {
    overflow: hidden;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .sidebar-collapse-row {
    padding: 12px 8px 0;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .sidebar-collapse-row button {
    justify-content: center;
    padding: 0;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .sidebar-collapse-row b,
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .brand-block > div:not(.brand-mark),
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .nav-item > span:not(.nav-icon),
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .nav-item small,
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .sidebar-footer {
    display: none;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .brand-block {
    justify-content: center;
    padding: 12px 8px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .brand-block::after {
    left: 12px;
    right: 12px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .nav-list {
    padding: 10px 8px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 48px;
    padding: 7px 0;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .nav-icon {
    width: 34px;
    height: 34px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed) .nav-edge-toggle {
    left: 66px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.rail-hidden):not(.rail-collapsed) .rail-edge-toggle {
    right: 12px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.rail-hidden):not(.rail-collapsed) .right-rail {
    position: fixed;
    top: 78px;
    right: 12px;
    bottom: 12px;
    z-index: 38;
    width: min(300px, calc(100vw - 118px));
    min-height: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.rail-hidden):not(.rail-collapsed) .right-rail-head {
    min-height: 34px;
    margin-bottom: 8px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.rail-hidden):not(.rail-collapsed) .rail-panel {
    margin-bottom: 8px;
    padding: 8px;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.rail-hidden):not(.rail-collapsed) .rail-list,
  body.chat-runtime-shell:not(.runtime-focus):not(.rail-hidden):not(.rail-collapsed) .rail-pressure {
    max-height: 150px;
    overflow: auto;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.rail-hidden):not(.rail-collapsed) .quick-actions {
    grid-template-columns: 1fr;
  }

  body.chat-runtime-shell:not(.runtime-focus):not(.rail-hidden):not(.rail-collapsed) .quick-actions button {
    min-height: 34px;
    padding: 0 6px;
    font-size: 12px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-root.page-chat-runtime {
    padding: 10px 12px 12px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console {
    grid-template-columns: minmax(200px, 0.18fr) minmax(0, 1fr);
    gap: 12px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip,
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .story-console {
    grid-column: 1 / -1;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip,
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-dock-collapsed {
    display: none;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .player-run-panel {
    padding: 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-run-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 6px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-run-head h3 {
    max-width: none;
    margin: 0;
    font-size: 17px;
    line-height: 1.2;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-run-head .eyebrow {
    margin: 0 0 2px;
    font-size: 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-run-head .tag-row {
    display: none;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-head-tools {
    gap: 4px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-clock b {
    font-size: 14px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-clock span {
    display: none;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .world-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .world-strip div,
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-banner,
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-dock,
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-action-bar,
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-composer {
    padding: 6px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .world-strip div {
    min-height: 40px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .world-strip span {
    margin-bottom: 2px;
    font-size: 11px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .world-strip b {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-banner {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-banner span {
    min-width: 0;
    min-height: 22px;
    padding: 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-banner span:nth-child(3) {
    display: none;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .api-required-banner {
    gap: 10px;
    padding: 7px 10px;
    border-bottom-color: rgba(231, 123, 112, 0.22);
    background: rgba(61, 25, 27, 0.28);
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .api-required-banner div {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .api-required-banner b {
    flex: 0 0 auto;
    font-size: 13px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .api-required-banner span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .api-required-banner .primary-button {
    min-height: 32px;
    padding: 0 14px;
    font-size: 13px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-log {
    padding: 22px 42px 18px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .message {
    max-width: 1180px;
    margin-right: auto;
    margin-left: auto;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-dock-head {
    display: none;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-dock-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-option {
    min-height: 48px;
    padding: 7px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-option small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-action-bar {
    display: none;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-composer {
    padding: 8px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-composer textarea {
    min-height: 62px;
    max-height: 128px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-actions {
    display: grid;
    grid-template-columns: auto minmax(220px, 0.22fr);
    justify-content: end;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-actions .primary-button {
    width: 100%;
    min-height: 36px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-runtime-actions summary {
    min-height: 36px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .mobile-nav {
    display: none;
  }
}

/* ZhanShen design-system pass: midnight blueprint console. */
:root {
  --font-ui: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Segoe UI", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --zs-void: #00030a;
  --zs-canvas: #05060f;
  --zs-canvas-grid: rgba(186, 215, 247, 0.045);
  --zs-panel: #0d131d;
  --zs-panel-2: #121a26;
  --zs-panel-3: #182230;
  --zs-plate: #202b39;
  --zs-raised: #263342;
  --zs-line: #334052;
  --zs-line-soft: rgba(186, 215, 247, 0.12);
  --zs-line-faint: rgba(186, 215, 247, 0.06);
  --zs-text: #e7edf7;
  --zs-heading: #d8ecf8;
  --zs-strong: #ffffff;
  --zs-muted: #9da7ba;
  --zs-faint: #6f7d91;
  --zs-action: #8052ff;
  --zs-action-2: #663af3;
  --zs-info: #b6d9fc;
  --zs-cyan: #62c6d9;
  --zs-amber: #ffb829;
  --zs-green: #269684;
  --zs-red: #e46d4c;
  --zs-glow-blue: rgba(186, 207, 247, 0.3);
  --zs-glow-violet: rgba(128, 82, 255, 0.34);
  --zs-glow-danger: rgba(228, 109, 76, 0.28);
  --zs-inset: inset 0 0 0 1px var(--zs-line-soft);
  --zs-inset-faint: inset 0 0 0 1px var(--zs-line-faint);

  --bg: var(--zs-canvas);
  --panel: var(--zs-panel);
  --panel-2: var(--zs-panel-2);
  --panel-3: var(--zs-panel-3);
  --line: var(--zs-line);
  --line-soft: var(--zs-line-soft);
  --text: var(--zs-text);
  --muted: var(--zs-muted);
  --faint: var(--zs-faint);
  --amber: var(--zs-amber);
  --amber-2: #a86f16;
  --cyan: var(--zs-cyan);
  --green: var(--zs-green);
  --red: var(--zs-red);
  --violet: var(--zs-action);
  --steel: #8ea4b9;
  --shadow: rgba(0, 0, 0, 0.58);
  --radius: 8px;
  font-family: var(--font-ui);
}

:root[data-theme="light"] {
  --zs-void: #eaf1f7;
  --zs-canvas: #edf3f8;
  --zs-canvas-grid: rgba(30, 55, 83, 0.055);
  --zs-panel: #f8fbfd;
  --zs-panel-2: #edf3f7;
  --zs-panel-3: #e2ebf3;
  --zs-plate: #d8e3ec;
  --zs-raised: #cbd9e5;
  --zs-line: #b3c3d1;
  --zs-line-soft: rgba(50, 72, 91, 0.16);
  --zs-line-faint: rgba(50, 72, 91, 0.08);
  --zs-text: #16212c;
  --zs-heading: #102235;
  --zs-strong: #07111d;
  --zs-muted: #516475;
  --zs-faint: #738394;
  --zs-glow-blue: rgba(78, 118, 160, 0.18);
  --zs-glow-violet: rgba(102, 58, 243, 0.18);
}

:root[data-theme="high-contrast"] {
  --zs-canvas: #020304;
  --zs-panel: #070b10;
  --zs-panel-2: #0e141b;
  --zs-panel-3: #151c25;
  --zs-line: #617486;
  --zs-line-soft: rgba(217, 232, 245, 0.28);
  --zs-line-faint: rgba(217, 232, 245, 0.16);
  --zs-text: #f7fbff;
  --zs-heading: #ffffff;
  --zs-muted: #c2cfda;
  --zs-faint: #9badbd;
}

html,
body {
  background:
    radial-gradient(circle at 20% -10%, rgba(98, 198, 217, 0.1), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(128, 82, 255, 0.08), transparent 34%),
    linear-gradient(180deg, var(--zs-void), var(--zs-canvas) 42%, #03050b);
  color: var(--zs-text);
  font-family: var(--font-ui);
  letter-spacing: 0;
}

body {
  position: relative;
  font-size: 14px;
}

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

body::before {
  opacity: 0.8;
  background-image:
    linear-gradient(var(--zs-canvas-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--zs-canvas-grid) 1px, transparent 1px),
    linear-gradient(115deg, rgba(186, 215, 247, 0.035) 0 1px, transparent 1px 32px);
  background-size: 40px 40px, 40px 40px, 100% 100%;
  mix-blend-mode: screen;
}

body::after {
  opacity: 0.22;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045), transparent 10%, transparent 90%, rgba(255, 255, 255, 0.03)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 8px);
}

* {
  scrollbar-color: rgba(182, 217, 252, 0.34) rgba(3, 6, 12, 0.62);
  scrollbar-width: thin;
}

.app-shell {
  position: relative;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(0, 3, 10, 0.72), transparent 18%, transparent 82%, rgba(0, 3, 10, 0.68));
  isolation: isolate;
}

.workspace {
  min-width: 0;
}

.sidebar,
.right-rail,
.topbar,
.mobile-nav {
  border-color: var(--zs-line-soft);
  background:
    linear-gradient(180deg, rgba(18, 26, 38, 0.94), rgba(7, 11, 18, 0.94)),
    var(--zs-panel);
  backdrop-filter: blur(18px) saturate(118%);
  -webkit-backdrop-filter: blur(18px) saturate(118%);
}

.sidebar {
  box-shadow:
    inset -1px 0 0 var(--zs-line-faint),
    18px 0 56px rgba(0, 0, 0, 0.22);
}

.right-rail {
  box-shadow:
    inset 1px 0 0 var(--zs-line-faint),
    -18px 0 56px rgba(0, 0, 0, 0.18);
}

.brand-block {
  background:
    radial-gradient(circle at 20% 0%, rgba(98, 198, 217, 0.12), transparent 42%),
    rgba(186, 215, 247, 0.018);
}

.brand-block::after {
  background: linear-gradient(90deg, transparent, rgba(182, 217, 252, 0.42), transparent);
}

.brand-mark,
.player-avatar,
.npc-avatar-large {
  border-color: rgba(182, 217, 252, 0.42);
  background:
    radial-gradient(circle at 50% 25%, rgba(182, 217, 252, 0.18), transparent 48%),
    linear-gradient(145deg, rgba(18, 34, 48, 0.95), rgba(5, 8, 14, 0.95));
  color: var(--zs-heading);
  box-shadow: var(--zs-inset), 0 0 0 4px rgba(98, 198, 217, 0.045);
}

.nav-list {
  padding: 10px 8px 12px;
}

.nav-item {
  min-height: 42px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--zs-muted);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 120ms ease;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(182, 217, 252, 0.2);
  background:
    linear-gradient(90deg, rgba(98, 198, 217, 0.1), rgba(18, 26, 38, 0.72)),
    rgba(18, 26, 38, 0.72);
  color: var(--zs-heading);
  transform: translateX(2px);
}

.nav-item.active {
  border-color: rgba(128, 82, 255, 0.36);
  box-shadow: inset 2px 0 0 var(--zs-action), 0 0 22px rgba(128, 82, 255, 0.08);
}

.nav-icon,
.nav-item.active .nav-icon {
  border: 1px solid var(--zs-line-faint);
  background:
    linear-gradient(145deg, rgba(98, 198, 217, 0.12), rgba(12, 19, 28, 0.9));
  color: var(--zs-info);
}

.nav-item.active .nav-icon {
  border-color: rgba(128, 82, 255, 0.34);
  color: #c8bbff;
  box-shadow: 0 0 20px rgba(128, 82, 255, 0.16);
}

.nav-advanced-block {
  border-top-color: var(--zs-line-faint);
}

.topbar {
  min-height: 58px;
  padding: 9px 14px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.2);
}

.topbar::after {
  left: 14px;
  right: 14px;
  background: linear-gradient(90deg, rgba(182, 217, 252, 0.38), transparent 62%);
}

.topbar h2,
.story-run-head h3,
.player-hero h3,
.panel h3,
.code-panel h3,
.npc-title-row h3,
.item-detail-head h3,
.national-city-hero h3 {
  color: var(--zs-heading);
  font-weight: 650;
  letter-spacing: 0;
}

.eyebrow,
.panel p,
.metric-desc,
.muted-line,
.message header,
.world-strip span,
.runtime-banner span,
.tag,
.data-pill {
  color: var(--zs-muted);
}

.data-pill,
.tag,
.runtime-banner span,
.collapsed-chip-grid span,
.compact-list span,
.intel-preview span,
.impact-row span {
  border-color: var(--zs-line-soft);
  border-radius: 999px;
  background: rgba(186, 215, 247, 0.045);
  box-shadow: var(--zs-inset-faint);
}

.tag.amber {
  border-color: rgba(255, 184, 41, 0.34);
  color: #ffd680;
  background: rgba(255, 184, 41, 0.07);
}

.tag.green {
  border-color: rgba(38, 150, 132, 0.42);
  color: #87dacb;
  background: rgba(38, 150, 132, 0.08);
}

.tag.red {
  border-color: rgba(228, 109, 76, 0.42);
  color: #ffb39e;
  background: rgba(228, 109, 76, 0.08);
}

button,
summary {
  letter-spacing: 0;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid rgba(128, 82, 255, 0.82);
  outline-offset: 2px;
}

.primary-button {
  border-color: rgba(161, 137, 255, 0.64);
  background:
    linear-gradient(180deg, #8f68ff, var(--zs-action-2));
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(128, 82, 255, 0.16),
    0 12px 28px rgba(128, 82, 255, 0.18);
}

.primary-button:hover:not(:disabled) {
  border-color: rgba(200, 187, 255, 0.8);
  background:
    linear-gradient(180deg, #9b78ff, #7044ff);
  transform: translateY(-1px);
}

.primary-button:disabled {
  border-color: var(--zs-line-soft);
  background:
    linear-gradient(180deg, rgba(32, 43, 57, 0.92), rgba(13, 19, 29, 0.92));
  color: var(--zs-faint);
  box-shadow: var(--zs-inset-faint);
}

.ghost-button,
.icon-button,
.sidebar-collapse-row button,
.right-rail-head button,
.runtime-layout-controls button,
.side-block header button,
.runtime-action-bar button,
.runtime-more-actions summary,
.runtime-more-actions div button,
.branch-dock-empty button,
.choice-list button,
.quick-actions button,
.message-menu-button,
.message-action-menu button {
  border-color: var(--zs-line-soft);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(32, 43, 57, 0.72), rgba(13, 19, 29, 0.88));
  color: var(--zs-muted);
  box-shadow: var(--zs-inset-faint);
}

.ghost-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.sidebar-collapse-row button:hover,
.right-rail-head button:hover,
.runtime-layout-controls button:hover,
.side-block header button:hover,
.runtime-action-bar button:hover:not(:disabled),
.runtime-more-actions summary:hover,
.runtime-more-actions div button:hover:not(:disabled),
.branch-dock-empty button:hover:not(:disabled),
.choice-list button:hover:not(:disabled),
.quick-actions button:hover:not(:disabled),
.message-menu-button:hover,
.message-menu-button[aria-expanded="true"] {
  border-color: rgba(182, 217, 252, 0.36);
  background:
    linear-gradient(180deg, rgba(38, 51, 66, 0.92), rgba(18, 26, 38, 0.92));
  color: var(--zs-heading);
  transform: translateY(-1px);
}

.icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
}

.panel,
.event-card,
.task-card,
.character-card,
.map-detail,
.log-entry,
.code-panel,
.rail-panel,
.route-card,
.route-diagnostic,
.choice-card,
.toggle-card,
.side-block,
.message,
.branch-option,
.manager-list-item,
.archive-item,
.metric-card,
.story-card,
.startup-gate-hero,
.startup-readiness,
.startup-flow button,
.startup-route-card,
.npc-info-card,
.item-detail-block,
.equipment-art-panel {
  border-color: var(--zs-line-soft);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.026), rgba(255, 255, 255, 0.006)),
    rgba(13, 19, 29, 0.82);
  box-shadow:
    var(--zs-inset-faint),
    0 18px 40px rgba(0, 0, 0, 0.2);
}

.panel:hover,
.event-card:hover,
.task-card:hover,
.character-card:hover,
.route-card:hover,
.choice-card:hover,
.toggle-card:hover,
.city-status-card:hover,
.equipment-tile:hover {
  border-color: rgba(182, 217, 252, 0.28);
  box-shadow:
    var(--zs-inset),
    0 18px 44px rgba(0, 0, 0, 0.22);
}

.panel h3,
.code-panel h3,
.side-block h4,
.branch-dock-head h4,
.branch-dock-empty b,
.story-card h3,
.event-card h4,
.task-card h4,
.character-card h4,
.map-detail h3,
.npc-info-card h4,
.item-detail-block h4,
.equipment-art-panel h4 {
  color: var(--zs-heading);
}

.field input,
.field select,
.field textarea,
.dialog-title-input,
.app-dialog > form > textarea,
.io-textarea,
#patch-input,
.code-panel pre,
.debug-json,
.inline-image-prompt,
.chat-composer textarea {
  border-color: var(--zs-line-soft);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.022), transparent),
    #050a12;
  color: var(--zs-text);
  box-shadow: var(--zs-inset-faint);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.dialog-title-input:focus,
.app-dialog > form > textarea:focus,
.io-textarea:focus,
#patch-input:focus,
.inline-image-prompt:focus,
.chat-composer textarea:focus {
  border-color: rgba(128, 82, 255, 0.62);
  box-shadow:
    0 0 0 3px rgba(128, 82, 255, 0.12),
    var(--zs-inset);
}

.rail-panel,
.right-rail-head {
  background: rgba(8, 13, 20, 0.58);
}

.rail-panel header strong,
.story-clock b,
.kv b,
.metric-value {
  color: var(--zs-strong);
}

.gauge,
.clock-track,
.city-mini-bar i {
  border-color: rgba(186, 215, 247, 0.1);
  background: #040810;
}

.gauge > i {
  background: linear-gradient(90deg, var(--zs-green), var(--zs-info));
}

.gauge.danger > i,
.city-mini-bar.danger em {
  background: linear-gradient(90deg, var(--zs-amber), var(--zs-red));
}

.mini-gauge.cyan .gauge i,
.city-mini-bar.cyan em {
  background: linear-gradient(90deg, var(--zs-cyan), var(--zs-info));
}

.mini-gauge.amber .gauge i,
.city-mini-bar em {
  background: linear-gradient(90deg, var(--zs-green), var(--zs-amber));
}

.page-root {
  background: transparent;
}

.runtime-console {
  gap: 12px;
}

body.runtime-focus .page-root.page-chat-runtime {
  padding: 10px 12px 12px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100dvh - 88px);
  gap: 0;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .player-run-panel,
body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .player-collapsed-chip {
  display: none !important;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-console {
  grid-column: 1 / -1;
  width: min(1360px, 100%);
  max-width: 1360px;
  min-height: calc(100dvh - 88px);
  justify-self: center;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-run-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 50px;
  padding: 7px 10px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-run-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-run-head .eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-run-head .tag-row,
body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-clock span {
  display: none;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-head-tools {
  min-width: 0;
  gap: 4px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-clock {
  min-width: 0;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-clock b {
  font-size: 14px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .world-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .world-strip div {
  min-height: 36px;
  padding: 6px 10px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .runtime-banner {
  min-height: 30px;
  padding: 5px 10px;
  flex-wrap: nowrap;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .runtime-banner span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .api-required-banner {
  min-height: 38px;
  padding: 6px 10px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .chat-log {
  padding: 22px clamp(24px, 5vw, 72px) 18px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .branch-dock-collapsed {
  display: none !important;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .chat-composer {
  padding: 8px 10px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .chat-composer textarea {
  height: 58px;
  min-height: 58px;
  max-height: 132px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .composer-actions {
  display: grid;
  grid-template-columns: auto minmax(176px, 220px);
  justify-content: end;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .composer-runtime-actions summary,
body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .composer-actions .primary-button {
  min-height: 34px;
}

.player-run-panel {
  border-color: var(--zs-line-soft);
  background:
    radial-gradient(circle at 18% 0%, rgba(98, 198, 217, 0.1), transparent 38%),
    linear-gradient(180deg, rgba(13, 19, 29, 0.9), rgba(6, 10, 17, 0.94));
  box-shadow:
    var(--zs-inset),
    0 22px 52px rgba(0, 0, 0, 0.28);
}

.runtime-panel-edge-toggle {
  width: 34px;
  height: 50px;
  min-height: 50px;
  right: -18px;
  border-color: rgba(182, 217, 252, 0.2);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(32, 43, 57, 0.92), rgba(8, 13, 20, 0.96));
  color: var(--zs-info);
  box-shadow:
    var(--zs-inset),
    0 12px 30px rgba(0, 0, 0, 0.32);
  font-size: 24px;
}

.runtime-panel-edge-toggle:hover {
  border-color: rgba(128, 82, 255, 0.48);
  background:
    linear-gradient(180deg, rgba(38, 51, 66, 0.94), rgba(13, 19, 29, 0.96));
  color: #c8bbff;
}

.player-collapsed-chip {
  padding: 8px 10px;
  border-color: var(--zs-line-soft);
  background:
    linear-gradient(90deg, rgba(98, 198, 217, 0.07), rgba(13, 19, 29, 0.86));
}

.collapsed-chip-main,
.branch-dock-collapsed button {
  min-height: 34px;
  border-color: var(--zs-line-soft);
  border-radius: 6px;
  background: rgba(18, 26, 38, 0.72);
}

.collapsed-chip-main:hover,
.branch-dock-collapsed button:hover {
  border-color: rgba(128, 82, 255, 0.42);
  color: #c8bbff;
}

.player-hero {
  grid-template-columns: 48px minmax(0, 1fr);
  padding-bottom: 10px;
  border-bottom-color: var(--zs-line-soft);
}

.player-avatar {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

.player-hero h3 {
  font-size: 18px;
}

.side-block {
  gap: 8px;
  padding: 9px;
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.018), transparent),
    rgba(6, 10, 17, 0.46);
}

.side-block header button {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.kv {
  border-bottom-color: var(--zs-line-faint);
}

.inventory-line,
.branch-option,
.city-status-card,
.equipment-tile {
  border-color: var(--zs-line-soft);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.02), transparent),
    rgba(18, 26, 38, 0.68);
  box-shadow: var(--zs-inset-faint);
}

.inventory-line:hover,
.branch-option:hover {
  border-color: rgba(128, 82, 255, 0.42);
  background:
    linear-gradient(180deg, rgba(128, 82, 255, 0.09), transparent),
    rgba(18, 26, 38, 0.78);
}

.inventory-line b,
.branch-option i,
.collapsed-chip-main i,
.branch-dock-collapsed i {
  color: var(--zs-info);
}

.chat-panel.story-console {
  border-color: rgba(186, 215, 247, 0.16);
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.026), rgba(186, 215, 247, 0.006)),
    rgba(9, 14, 22, 0.88);
  box-shadow:
    var(--zs-inset),
    0 24px 70px rgba(0, 0, 0, 0.34);
}

.story-run-head {
  border-bottom-color: var(--zs-line-soft);
  background:
    linear-gradient(90deg, rgba(98, 198, 217, 0.08), rgba(13, 19, 29, 0.86)),
    rgba(13, 19, 29, 0.92);
}

.story-run-head h3 {
  max-width: none;
}

.story-head-tools {
  min-width: 0;
}

.runtime-layout-controls {
  gap: 6px;
}

.runtime-layout-controls button {
  min-width: 30px;
  min-height: 30px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
}

.world-strip {
  border-bottom-color: var(--zs-line-soft);
  background: var(--zs-line-faint);
}

.world-strip div {
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.018), transparent),
    rgba(5, 10, 18, 0.68);
}

.world-strip b {
  color: var(--zs-text);
}

.runtime-banner {
  border-bottom-color: var(--zs-line-soft);
  background:
    linear-gradient(90deg, rgba(98, 198, 217, 0.06), transparent),
    rgba(5, 10, 18, 0.62);
}

.runtime-banner span.syncing {
  position: relative;
  overflow: hidden;
  border-color: rgba(128, 82, 255, 0.44);
  color: #d3c9ff;
  background: rgba(128, 82, 255, 0.1);
  box-shadow:
    var(--zs-inset),
    0 0 22px rgba(128, 82, 255, 0.12);
}

.runtime-banner span.syncing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
  transform: translateX(-120%);
  animation: zs-sync-sweep 1.4s linear infinite;
}

.api-required-banner {
  border-bottom-color: rgba(228, 109, 76, 0.26);
  background:
    linear-gradient(90deg, rgba(228, 109, 76, 0.14), rgba(13, 19, 29, 0.74));
}

.api-required-banner b {
  color: #ffc0ae;
}

.chat-log {
  background:
    linear-gradient(90deg, rgba(98, 198, 217, 0.18) 0 1px, transparent 1px) 21px 0 / 1px 100% no-repeat,
    linear-gradient(180deg, rgba(186, 215, 247, 0.022), transparent 36%),
    rgba(2, 6, 12, 0.34);
}

.message {
  border-color: rgba(186, 215, 247, 0.1);
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.024), rgba(186, 215, 247, 0.006)),
    rgba(8, 13, 20, 0.62);
}

.story-console .message::before {
  border-color: rgba(98, 198, 217, 0.58);
  background: #07101a;
  box-shadow:
    0 0 0 3px rgba(98, 198, 217, 0.08),
    0 0 18px rgba(98, 198, 217, 0.12);
}

.message.assistant {
  border-color: rgba(186, 215, 247, 0.14);
  background:
    linear-gradient(180deg, rgba(182, 217, 252, 0.04), rgba(8, 13, 20, 0.7)),
    rgba(8, 13, 20, 0.72);
}

.message.user {
  border-color: rgba(98, 198, 217, 0.26);
  background:
    linear-gradient(180deg, rgba(98, 198, 217, 0.075), rgba(8, 13, 20, 0.68)),
    rgba(8, 17, 24, 0.72);
}

.message.system {
  border-color: rgba(128, 82, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(128, 82, 255, 0.055), rgba(8, 13, 20, 0.68)),
    rgba(8, 13, 20, 0.72);
}

.message header {
  border-bottom: 1px solid var(--zs-line-faint);
  padding-bottom: 7px;
}

.message h4 {
  color: var(--zs-heading);
}

.message-body {
  color: var(--zs-text);
}

.message-body p {
  color: #eaf1fb;
  font-size: 16.5px;
  line-height: 1.86;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.update-fold {
  border-top-color: var(--zs-line-faint);
}

.update-fold summary {
  color: var(--zs-info);
}

.branch-dock {
  border-top-color: var(--zs-line-soft);
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.014), transparent),
    rgba(6, 10, 17, 0.74);
}

.branch-option i {
  border-radius: 6px;
  background:
    linear-gradient(145deg, rgba(128, 82, 255, 0.16), rgba(18, 26, 38, 0.88));
}

.branch-option small {
  color: var(--zs-muted);
}

.runtime-action-bar,
.chat-composer {
  border-top-color: var(--zs-line-soft);
  background:
    linear-gradient(180deg, rgba(8, 13, 20, 0.78), rgba(2, 6, 12, 0.96));
}

.chat-composer textarea {
  resize: vertical;
  line-height: 1.65;
}

.composer-actions {
  gap: 8px;
}

.runtime-more-actions {
  position: relative;
}

.runtime-more-actions summary {
  min-width: 72px;
}

.runtime-more-actions div,
.message-action-menu {
  border-color: rgba(186, 215, 247, 0.2);
  background:
    linear-gradient(180deg, rgba(18, 26, 38, 0.98), rgba(6, 10, 17, 0.98));
  box-shadow:
    var(--zs-inset),
    0 18px 46px rgba(0, 0, 0, 0.48);
}

.runtime-more-actions div button,
.message-action-menu button {
  min-height: 32px;
  box-shadow: none;
}

.startup-gate-hero {
  background:
    radial-gradient(circle at 14% 0%, rgba(98, 198, 217, 0.12), transparent 38%),
    radial-gradient(circle at 86% 18%, rgba(128, 82, 255, 0.1), transparent 32%),
    linear-gradient(180deg, rgba(13, 19, 29, 0.92), rgba(5, 10, 18, 0.9));
}

.startup-gate-copy h3 {
  color: var(--zs-heading);
}

.startup-world-card {
  border-left-color: var(--zs-line-soft);
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.026), transparent),
    rgba(5, 10, 18, 0.5);
}

.startup-flow span {
  border-color: rgba(128, 82, 255, 0.3);
  color: #c8bbff;
  background: rgba(128, 82, 255, 0.1);
}

.china-hero,
.national-command-panel {
  background:
    radial-gradient(circle at 10% 0%, rgba(98, 198, 217, 0.1), transparent 34%),
    linear-gradient(180deg, rgba(13, 19, 29, 0.9), rgba(5, 10, 18, 0.82));
}

.china-map-board,
.city-map-shell {
  border-color: rgba(186, 215, 247, 0.14);
  background:
    radial-gradient(circle at 66% 22%, rgba(98, 198, 217, 0.12), transparent 28%),
    radial-gradient(circle at 38% 64%, rgba(128, 82, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(5, 10, 18, 0.94), rgba(2, 6, 12, 0.96));
}

.china-map-gridlines {
  background-image:
    linear-gradient(rgba(186, 215, 247, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(186, 215, 247, 0.06) 1px, transparent 1px);
}

.province-node {
  border-color: rgba(98, 198, 217, 0.24);
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.028), transparent),
    rgba(8, 13, 20, 0.86);
  box-shadow:
    var(--zs-inset-faint),
    0 12px 30px rgba(0, 0, 0, 0.28);
}

.province-node:hover,
.province-node.active {
  border-color: rgba(128, 82, 255, 0.55);
  box-shadow:
    0 0 0 5px rgba(128, 82, 255, 0.1),
    0 18px 36px rgba(0, 0, 0, 0.36);
}

.province-node.calm {
  border-color: rgba(38, 150, 132, 0.36);
}

.province-node.warn {
  border-color: rgba(255, 184, 41, 0.42);
}

.province-node.hot,
.province-node.danger,
.province-node.dead {
  border-color: rgba(228, 109, 76, 0.62);
  background:
    radial-gradient(circle at 18% 0%, rgba(228, 109, 76, 0.18), transparent 36%),
    rgba(28, 13, 17, 0.92);
}

.city-status-card {
  background:
    linear-gradient(135deg, rgba(98, 198, 217, 0.055), transparent 45%),
    rgba(8, 13, 20, 0.58);
}

.national-battle-card {
  border-color: rgba(128, 82, 255, 0.28);
  background:
    linear-gradient(135deg, rgba(128, 82, 255, 0.08), transparent 50%),
    rgba(13, 19, 29, 0.82);
}

.national-city-hero,
.item-detail-head,
.npc-hero-panel {
  border-color: rgba(186, 215, 247, 0.16);
  background:
    radial-gradient(circle at 10% 0%, rgba(98, 198, 217, 0.1), transparent 34%),
    linear-gradient(180deg, rgba(13, 19, 29, 0.92), rgba(5, 10, 18, 0.88));
}

.npc-side-story-panel {
  position: relative;
  overflow: hidden;
  border-color: rgba(128, 82, 255, 0.24);
  background:
    radial-gradient(circle at 12% 0%, rgba(128, 82, 255, 0.14), transparent 36%),
    linear-gradient(180deg, rgba(13, 19, 29, 0.94), rgba(5, 10, 18, 0.9));
}

.npc-side-story-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background:
    radial-gradient(circle at 18% 18%, rgba(128, 82, 255, 0.42) 0 1px, transparent 1.5px),
    radial-gradient(circle at 64% 28%, rgba(182, 217, 252, 0.35) 0 1px, transparent 1.5px),
    radial-gradient(circle at 86% 72%, rgba(98, 198, 217, 0.3) 0 1px, transparent 1.5px);
  background-size: 150px 110px, 180px 140px, 220px 170px;
}

.npc-side-story-panel.syncing {
  border-color: rgba(128, 82, 255, 0.55);
  box-shadow:
    var(--zs-inset),
    0 0 32px rgba(128, 82, 255, 0.16);
}

.npc-side-story-panel.dead {
  border-color: rgba(228, 109, 76, 0.42);
  background:
    linear-gradient(135deg, rgba(228, 109, 76, 0.12), transparent 48%),
    rgba(11, 13, 17, 0.92);
  filter: grayscale(0.82);
  opacity: 0.72;
}

.npc-side-story-head,
.npc-side-story-body,
.npc-side-story-grid,
.npc-side-story-panel > * {
  position: relative;
  z-index: 1;
}

.npc-side-story-head h4 {
  color: #d3c9ff;
}

.npc-side-story-body {
  min-height: 220px;
  max-height: min(46dvh, 460px);
  border-color: rgba(186, 215, 247, 0.12);
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.022), transparent),
    rgba(3, 7, 13, 0.58);
}

.npc-side-story-body p {
  color: #eaf1fb;
  font-size: 15.5px;
  line-height: 1.86;
}

.npc-side-story-grid article,
.npc-current-grid .kv,
.npc-info-card .kv,
.attribute-row,
.item-bonus-grid div,
.item-rarity-box {
  border-color: var(--zs-line-soft);
  background: rgba(5, 10, 18, 0.44);
  box-shadow: var(--zs-inset-faint);
}

.npc-side-story-grid h5,
.npc-memory-list time,
.equipment-tile span {
  color: var(--zs-info);
}

.character-card.ai-linked {
  border-color: rgba(128, 82, 255, 0.38);
  background:
    radial-gradient(circle at 12% 0%, rgba(128, 82, 255, 0.12), transparent 36%),
    linear-gradient(180deg, rgba(186, 215, 247, 0.026), rgba(255, 255, 255, 0.006)),
    rgba(13, 19, 29, 0.82);
  box-shadow:
    var(--zs-inset),
    0 0 28px rgba(128, 82, 255, 0.1);
}

.character-card.dead {
  opacity: 0.58;
  filter: grayscale(0.9);
  border-color: rgba(228, 109, 76, 0.32);
}

.equipment-tile {
  border-color: rgba(128, 82, 255, 0.2);
  background:
    linear-gradient(135deg, rgba(128, 82, 255, 0.075), transparent 48%),
    rgba(8, 13, 20, 0.58);
}

.equipment-art-frame {
  border-color: rgba(186, 215, 247, 0.14);
  background:
    linear-gradient(135deg, rgba(98, 198, 217, 0.07), transparent 48%),
    rgba(5, 10, 18, 0.64);
}

.equipment-art-empty span {
  color: rgba(128, 82, 255, 0.42);
}

.app-dialog {
  border-color: rgba(186, 215, 247, 0.18);
  background:
    radial-gradient(circle at 12% 0%, rgba(98, 198, 217, 0.1), transparent 32%),
    linear-gradient(180deg, rgba(13, 19, 29, 0.98), rgba(5, 10, 18, 0.98));
  box-shadow:
    var(--zs-inset),
    0 30px 96px rgba(0, 0, 0, 0.68);
}

.app-dialog::backdrop {
  background: rgba(0, 3, 10, 0.78);
  backdrop-filter: blur(10px);
}

.shell-edge-toggle {
  border-color: rgba(186, 215, 247, 0.22);
  background:
    linear-gradient(180deg, rgba(32, 43, 57, 0.9), rgba(8, 13, 20, 0.94));
  color: var(--zs-info);
  box-shadow:
    var(--zs-inset),
    0 10px 26px rgba(0, 0, 0, 0.34);
}

.shell-edge-toggle:hover {
  border-color: rgba(128, 82, 255, 0.48);
  color: #c8bbff;
}

@keyframes zs-sync-sweep {
  to {
    transform: translateX(120%);
  }
}

@media (min-width: 981px) {
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed):not(.rail-hidden):not(.rail-collapsed) .app-shell,
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed).rail-hidden .app-shell,
  body.chat-runtime-shell:not(.runtime-focus):not(.sidebar-collapsed).rail-collapsed .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  body.chat-runtime-shell.sidebar-collapsed:not(.rail-hidden):not(.rail-collapsed) .app-shell,
  body.chat-runtime-shell.sidebar-collapsed.rail-hidden .app-shell,
  body.chat-runtime-shell.sidebar-collapsed.rail-collapsed .app-shell {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  body.chat-runtime-shell:not(.runtime-focus) .topbar {
    min-height: 54px;
    padding: 8px 12px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .topbar h2 {
    font-size: 17px;
    line-height: 1.2;
  }

  body.chat-runtime-shell:not(.runtime-focus) .top-actions {
    gap: 6px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .top-actions button {
    min-height: 32px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .top-actions .icon-button {
    width: 32px;
    min-width: 32px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .top-actions .primary-button {
    min-width: 112px;
    padding: 0 12px;
    font-size: 13px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-root.page-chat-runtime {
    padding: 8px 10px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console {
    grid-template-columns: minmax(230px, 0.2fr) minmax(0, 1fr);
    gap: 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .player-run-panel {
    padding: 9px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-run-head {
    min-height: 48px;
    padding: 7px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-run-head .eyebrow {
    font-size: 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-head-tools {
    gap: 4px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .story-clock {
    min-width: 120px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .world-strip div {
    min-height: 36px;
    padding: 6px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-banner {
    min-height: 30px;
    padding: 5px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .api-required-banner {
    min-height: 38px;
    padding: 6px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-log {
    padding: 18px clamp(24px, 4vw, 58px) 16px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .message {
    max-width: min(1120px, calc(100% - 48px));
    padding: 13px 15px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .message-body p {
    font-size: 16.8px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-dock {
    padding: 7px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-dock-grid {
    gap: 7px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .branch-option {
    min-height: 46px;
    padding: 7px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-composer {
    padding: 8px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-composer textarea {
    height: 58px;
    min-height: 58px;
    max-height: 132px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-actions {
    grid-template-columns: auto minmax(176px, 220px);
    margin-top: 6px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-runtime-actions summary,
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-actions .primary-button {
    min-height: 34px;
  }
}

@media (min-width: 1280px) {
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console {
    grid-template-columns: minmax(242px, 0.19fr) minmax(0, 1fr);
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .topbar {
    min-height: 56px;
  }

  .page-chat-runtime .branch-dock-collapsed {
    display: none !important;
  }

  .page-chat-runtime .story-run-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: 48px;
    padding: 8px;
  }

  .page-chat-runtime .story-run-head h3 {
    margin: 0;
    font-size: 17px;
    line-height: 1.2;
  }

  .page-chat-runtime .story-run-head .eyebrow {
    margin: 0 0 2px;
    font-size: 10px;
  }

  .page-chat-runtime .story-clock {
    display: none !important;
  }

  .page-chat-runtime .runtime-layout-controls button {
    width: 30px;
    min-width: 30px;
  }

  .page-chat-runtime .api-required-banner {
    display: flex;
    min-height: 38px;
    padding: 6px 8px;
  }

  .page-chat-runtime .api-required-banner div {
    display: block;
  }

  .page-chat-runtime .api-required-banner b {
    font-size: 13px;
    white-space: nowrap;
  }

  .page-chat-runtime .api-required-banner span {
    display: none;
  }

  .page-chat-runtime .api-required-banner .primary-button {
    width: auto;
    min-height: 30px;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .page-chat-runtime .chat-log {
    padding: 16px 16px 14px 28px;
  }

  .page-chat-runtime .message {
    padding: 12px;
  }

  .page-chat-runtime .message-body p {
    font-size: 16px;
    line-height: 1.78;
  }

  .page-chat-runtime .chat-composer {
    padding: 7px 8px;
  }

  .page-chat-runtime .chat-composer textarea {
    height: 60px;
    min-height: 60px;
    max-height: 118px;
  }

  .page-chat-runtime .composer-actions {
    gap: 6px;
    margin-top: 6px;
  }

  .page-chat-runtime .composer-runtime-actions summary,
  .page-chat-runtime .composer-actions .primary-button {
    min-height: 34px;
  }

  .npc-current-grid,
  .npc-detail-grid,
  .npc-side-story-grid,
  .attribute-matrix,
  .equipment-grid,
  .equipment-art-panel,
  .item-bonus-grid,
  .national-command-panel,
  .china-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .top-actions .icon-button {
    display: none;
  }

  .top-actions .primary-button {
    min-width: 0;
    padding-inline: 10px;
  }

  .world-strip {
    grid-template-columns: 1fr;
  }

  .runtime-banner {
    grid-template-columns: 1fr;
  }

  .message-body p {
    font-size: 15.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .runtime-banner span.syncing::after {
    animation: none;
  }
}

/* Keep the player overview restore action visible without reserving a layout row. */
body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip {
  position: absolute;
  z-index: 36;
  top: 10px;
  left: 0;
  display: block !important;
  width: auto;
  max-width: min(236px, calc(100vw - 36px));
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .runtime-panel-edge-toggle,
body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .collapsed-chip-grid {
  display: none;
}

body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .collapsed-chip-main {
  pointer-events: auto;
  width: auto;
  min-width: 136px;
  min-height: 34px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 0 10px 0 12px;
  border-color: rgba(128, 82, 255, 0.42);
  border-left: 0;
  border-radius: 0 7px 7px 0;
  background:
    linear-gradient(90deg, rgba(128, 82, 255, 0.24), rgba(18, 26, 38, 0.94));
  color: var(--zs-heading);
  box-shadow:
    var(--zs-inset),
    0 14px 30px rgba(0, 0, 0, 0.34),
    0 0 24px rgba(128, 82, 255, 0.13);
}

body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .collapsed-chip-main:hover {
  border-color: rgba(200, 187, 255, 0.68);
  background:
    linear-gradient(90deg, rgba(128, 82, 255, 0.32), rgba(24, 34, 48, 0.96));
}

body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .collapsed-chip-main span {
  color: #d3c9ff;
  font-size: 12px;
}

body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .collapsed-chip-main b {
  display: none;
}

body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .collapsed-chip-main i {
  color: var(--zs-info);
}

.runtime-console.player-collapsed .runtime-layout-controls button[data-runtime-layout="toggle-player"] {
  min-width: 58px;
  padding: 0 9px;
  border-color: rgba(128, 82, 255, 0.44);
  color: #d3c9ff;
  background:
    linear-gradient(180deg, rgba(128, 82, 255, 0.2), rgba(18, 26, 38, 0.94));
  font-size: 0;
}

.runtime-console.player-collapsed .runtime-layout-controls button[data-runtime-layout="toggle-player"]::before {
  content: "›";
  margin-right: 5px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.runtime-console.player-collapsed .runtime-layout-controls button[data-runtime-layout="toggle-player"]::after {
  content: "玩家";
  font-size: 12px;
}

@media (max-width: 980px) {
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip {
    top: 52px;
    max-width: 160px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .collapsed-chip-main {
    min-width: 104px;
    min-height: 30px;
    padding-inline: 9px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console.player-collapsed .player-collapsed-chip .collapsed-chip-main span {
    font-size: 11px;
  }
}

/* Desktop runtime composer: keep input and submit controls on one row. */
@media (min-width: 981px) {
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-composer,
  body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .chat-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 310px);
    gap: 8px;
    align-items: stretch;
    padding: 8px 10px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-composer textarea,
  body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .chat-composer textarea {
    grid-column: 1;
    height: 54px;
    min-height: 54px;
    max-height: 112px;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-actions,
  body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .composer-actions {
    grid-column: 2;
    align-self: stretch;
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px;
    margin-top: 0;
    min-width: 0;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-runtime-actions,
  body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .composer-runtime-actions {
    height: 100%;
  }

  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-runtime-actions summary,
  body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .composer-runtime-actions summary,
  body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .composer-actions .primary-button,
  body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .composer-actions .primary-button {
    width: 100%;
    height: 100%;
    min-height: 54px;
  }
}

/* Runtime chat is the primary screen; hide the global page bar there. */
body.chat-runtime-shell:not(.runtime-focus) .workspace,
body.runtime-focus .workspace {
  grid-template-rows: minmax(0, 1fr);
}

body.chat-runtime-shell:not(.runtime-focus) .topbar,
body.runtime-focus .topbar {
  display: none;
}

body.chat-runtime-shell:not(.runtime-focus) .page-root.page-chat-runtime,
body.runtime-focus .page-root.page-chat-runtime {
  grid-row: 1;
}

body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .runtime-console,
body.runtime-focus .page-chat-runtime .runtime-console.focus-mode {
  min-height: calc(100dvh - 20px);
}

body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .chat-panel.story-console,
body.runtime-focus .page-chat-runtime .runtime-console.focus-mode .story-console,
body.chat-runtime-shell:not(.runtime-focus) .page-chat-runtime .player-run-panel {
  min-height: calc(100dvh - 20px);
}

.player-attribute-panel {
  align-content: start;
}

.player-attribute-matrix {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.player-attribute-row {
  position: relative;
  min-width: 0;
  min-height: 118px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--zs-line-soft);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(186, 215, 247, 0.024), rgba(255, 255, 255, 0.006)),
    rgba(8, 13, 20, 0.58);
  box-shadow: var(--zs-inset-faint);
}

.player-attribute-row span {
  display: block;
  color: var(--zs-heading);
  font-size: 16px;
  font-weight: 700;
}

.player-attribute-row p {
  margin: 6px 0 0;
  color: var(--zs-muted);
  font-size: 12px;
  line-height: 1.5;
}

.player-attribute-row b {
  position: relative;
  z-index: 1;
  color: var(--zs-amber);
  font-family: var(--font-mono);
  font-size: 26px;
  line-height: 1;
}

.player-attribute-row i {
  position: absolute;
  inset: auto auto 0 0;
  height: 4px;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, var(--zs-cyan), var(--zs-amber));
}

@media (max-width: 1180px) {
  .player-attribute-matrix {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .player-attribute-matrix {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-attribute-row {
    min-height: 128px;
    padding: 10px;
  }

  .player-attribute-row span {
    font-size: 14px;
  }

  .player-attribute-row p {
    font-size: 11px;
    line-height: 1.45;
  }

  .player-attribute-row b {
    font-size: 22px;
  }
}

@media (max-width: 340px) {
  .player-attribute-matrix {
    grid-template-columns: 1fr;
  }
}
