@font-face {
  font-family: "Fusion Pixel SC";
  src: url("/fonts/fusion-pixel-12px-proportional-sc.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* 像素小镇 · 日间 */
  --bg: #78bce4;
  --panel: #f7e4b5;
  --panel-soft: #f0d69e;
  --line: #c08a4e;
  --line-strong: #59371b;
  --text: #4c2b12;
  --muted: #8a6842;
  --soft-text: #6b4a28;
  --green: #2f7a24;
  --green-dark: #245d1b;
  --green-soft: #e3efc0;
  --blue: #2b6ea8;
  --blue-soft: #d9e9f4;
  --amber: #9a5b16;
  --rose: #b8394a;
  --code: #241a38;
  --bubble: #fcf0d2;
  --shadow: 0 4px 0 rgba(89, 55, 27, 0.28);
  --shadow-soft: 0 3px 0 rgba(89, 55, 27, 0.22);
  /* 星露谷 UI 材质 token */
  --sky-hi: #4ea3dc;
  --sky-lo: #a9dcef;
  --parchment: #f7e4b5;
  --parchment-deep: #efd59b;
  --parchment-hi: #fcf0d2;
  --wood: #b4713d;
  --wood-hi: #dfa76a;
  --wood-lo: #8a5326;
  --wood-dark: #59371b;
  --ink: #4c2b12;
  --grass: #47a335;
  --grass-dark: #2f7a24;
  --gold: #ffc93c;
  --gold-hi: #ffe08a;
  --gold-lo: #d9a018;
  --berry: #b8394a;
  --water: #2b6ea8;
  font-family:
    "Fusion Pixel SC", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button,
.secondary-link {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

button:hover,
.secondary-link:hover {
  background: var(--green-dark);
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(15, 123, 108, 0.24);
  outline-offset: 2px;
}

.secondary-button,
.secondary-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.secondary-button:hover,
.secondary-link:hover {
  background: #f1f4f6;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

textarea::placeholder,
input::placeholder {
  color: #5f6b74;
}

textarea {
  resize: vertical;
  min-height: 104px;
  max-height: 210px;
  line-height: 1.5;
}

label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  width: min(1160px, calc(100vw - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-content: start;
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  position: sticky;
  top: 10px;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.brand-block {
  min-width: 180px;
  color: inherit;
  text-decoration: none;
}

.brand-kicker,
.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
}

.topbar h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.site-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid #eef1f3;
  border-radius: 10px;
  background: #f7f9fa;
}

.site-nav a {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.site-nav a:hover {
  background: #edf2f4;
  color: var(--text);
}

.site-nav a.active {
  background: var(--green-soft);
  color: var(--green-dark);
}

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

.header-actions > span,
.chat-card-header > span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 10px;
  background: #eef2f4;
  color: var(--muted);
  font-size: 13px;
}

.account-menu {
  position: relative;
}

.account-menu summary {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-menu summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 9px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
}

.account-menu[open] summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.account-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(360px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 110px));
  overflow: auto;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 30;
}

.account-popover-section {
  display: grid;
  gap: 10px;
}

.account-popover h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.menu-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.scope-control {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background: #f0f3f5;
}

.scope-control span {
  min-height: 24px;
  padding: 0 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.scope-button {
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.scope-button:hover {
  background: #e6ebef;
}

.scope-button.active {
  border-color: #a7d3cb;
  background: var(--green-soft);
  color: var(--green-dark);
}

.scope-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.site-main,
.page-view {
  min-width: 0;
  min-height: 0;
}

.site-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-view {
  display: grid;
  gap: 16px;
}

.home-view {
  width: min(100%, 940px);
  margin: 0 auto;
}

.home-hero {
  width: min(100%, 720px);
  padding: 6px 2px 0;
}

.home-hero h2 {
  margin: 0;
  font-size: 48px;
  line-height: 1.03;
  letter-spacing: 0;
  text-wrap: balance;
}

.home-hero p:not(.eyebrow) {
  margin: 12px 0 0;
  max-width: 680px;
  color: var(--soft-text);
  font-size: 16px;
  line-height: 1.58;
  text-wrap: pretty;
}

.task-desk {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.task-desk-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.task-desk-head h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  text-wrap: balance;
}

.task-desk-head p {
  margin: 6px 0 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.task-status-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.task-status-row span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #d7e8e4;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.session-notice {
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
}

.session-notice[hidden] {
  display: none;
}

.chat-card {
  height: clamp(210px, 28vh, 360px);
  min-height: 210px;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  border: 1px solid #e4eaee;
  border-radius: 10px;
  background: #fbfcfd;
  overflow: hidden;
}

.chat-card-header {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid #eef1f3;
  background: #fbfcfd;
}

.chat-card-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.chat-card-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chat-log {
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 22px;
  background: #fbfcfd;
}

.empty-state {
  height: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  line-height: 1.65;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.composer {
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.composer.dragging {
  border-color: #60a5fa;
  background: #eff6ff;
}

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}

.attachment-tray[hidden] {
  display: none;
}

.attachment-tray-heading {
  flex: 0 0 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.attachment-card {
  width: min(100%, 280px);
  min-height: 68px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #cfd8df;
  border-radius: 8px;
  padding: 7px;
  background: #f8fafc;
  color: var(--text);
}

.attachment-thumb {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid #d8e1e8;
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  cursor: zoom-in;
}

.attachment-thumb:disabled {
  cursor: default;
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.attachment-card-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.attachment-card-body strong,
.attachment-card-body span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-card-body strong {
  font-size: 13px;
}

.attachment-card-body span {
  color: var(--muted);
  font-size: 11px;
}

.composer textarea {
  min-height: 88px;
  border-color: var(--line-strong);
  border-radius: 10px;
  font-size: 16px;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.composer-primary-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.composer-options {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.toggle {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
}

.toggle input {
  width: 16px;
  height: 16px;
}

.panel-section {
  min-height: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.panel-section h2 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.strong-note {
  margin-bottom: 0;
  color: var(--text);
  font-weight: 650;
}

.product-summary {
  min-height: 62px;
  border: 1px solid #cfe4df;
  border-radius: 10px;
  padding: 12px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 13px;
  line-height: 1.45;
}

.product-summary strong {
  display: block;
  margin-bottom: 4px;
  color: #0f3f3a;
  font-size: 15px;
}

.account-summary {
  display: grid;
  gap: 6px;
}

.account-summary p {
  margin: 0;
  color: var(--green-dark);
}

.summary-label {
  display: block;
  margin-bottom: 4px;
  color: #3f766f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.usage-tile {
  min-height: 58px;
  padding: 10px;
  border: 1px solid #e3e8ed;
  border-radius: 10px;
  background: #fbfcfd;
}

.usage-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.usage-tile strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
  line-height: 1.1;
}

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

.product-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.product-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.25;
}

.product-card p {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.product-card .product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.feature-card {
  min-height: 224px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.feature-card h3 {
  margin: 0 0 5px;
  font-size: 14px;
  line-height: 1.25;
}

.feature-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.feature-description {
  min-height: 58px;
  color: var(--soft-text) !important;
  font-size: 13px !important;
}

.feature-card button {
  margin-top: auto;
  width: 100%;
}

.feature-card .product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.product-chip {
  min-height: 23px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: #f0f3f5;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.product-chip.active {
  background: var(--green-soft);
  color: var(--green-dark);
}

.product-chip.preview {
  background: #fff7ed;
  color: var(--amber);
}

.analysis-drawer {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.analysis-drawer > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  user-select: none;
}

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

.analysis-grid .debug-panel {
  grid-column: 1 / -1;
}

.page-heading {
  width: min(100%, 820px);
  padding: 34px 4px 4px;
}

.page-heading h2 {
  margin: 0;
  font-size: 48px;
  line-height: 1.05;
  letter-spacing: 0;
  text-wrap: balance;
}

.page-heading p:not(.eyebrow) {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.pricing-page,
.capabilities-page {
  width: min(100%, 1120px);
  margin: 0 auto;
}

.pricing-layout {
  display: grid;
  gap: 16px;
}

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

.pricing-content {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.pricing-grid .product-card {
  min-height: 244px;
  display: flex;
  flex-direction: column;
  position: relative;
  border-color: #d5dde4;
  padding: 16px;
}

.pricing-grid .product-card h3 {
  font-size: 17px;
}

.pricing-grid .product-card p {
  font-size: 13px;
}

.pricing-grid .product-card .price {
  margin: 10px 0 8px;
  color: var(--text);
}

.pricing-grid .product-card .price span {
  font-size: 30px;
  font-weight: 760;
  letter-spacing: 0;
}

.plan-fit {
  min-height: 42px;
  color: var(--soft-text) !important;
  font-size: 13px !important;
  line-height: 1.45 !important;
}

.plan-badge {
  width: fit-content;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  margin-bottom: 12px;
  border-radius: 999px;
  padding: 0 9px;
  background: #e8f4f1;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.pricing-grid .product-card button {
  margin-top: auto;
  width: 100%;
}

.credit-section {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: #fff;
}

.credit-section h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.credit-section p:not(.eyebrow) {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.credit-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fbfcfd;
}

.credit-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
}

.credit-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.credit-card button {
  width: 100%;
}

.capability-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.capability-copy {
  border: 1px solid #cfe4df;
  border-radius: 12px;
  padding: 18px;
  background: #eef8f6;
  color: var(--green-dark);
}

.capability-copy h3 {
  margin: 0 0 8px;
  color: #0f3f3a;
  font-size: 18px;
}

.capability-copy p {
  margin: 0;
  line-height: 1.55;
}

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

.debug-panel summary,
.insight-panel summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  user-select: none;
}

.debug-panel[open],
.insight-panel[open] {
  display: flex;
  flex-direction: column;
}

.debug-tools,
.insight-grid {
  min-height: 0;
  display: grid;
  gap: 14px;
  padding-top: 12px;
}

.debug-tools {
  max-height: 420px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.debug-tools h3,
.insight-grid h3 {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

.panel-section form {
  display: grid;
  gap: 9px;
}

.mini-output,
.trace-output {
  margin: 10px 0 0;
  min-height: 52px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 9px;
  padding: 10px;
  background: var(--code);
  color: #f4f7fa;
  font-size: 12px;
  line-height: 1.45;
}

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

.source-item {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 10px;
  background: #fffaf4;
}

.source-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
}

.source-path,
.source-snippet {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.source-snippet {
  color: #4d5965;
}

.trace-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 10px;
  margin: 0;
}

.trace-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.trace-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.message {
  margin: 0 0 16px;
  display: grid;
  gap: 6px;
}

.message .role {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.message .message-meta {
  width: fit-content;
  max-width: min(760px, 100%);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.message .bubble {
  width: fit-content;
  max-width: min(780px, 100%);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.58;
  border-radius: 12px;
  padding: 12px 13px;
  border: 1px solid var(--line);
}

.message.user {
  justify-items: end;
}

.message.user .message-meta {
  text-align: right;
}

.message.user .bubble {
  background: #fff7ed;
  border-color: #fed7aa;
}

.message.assistant .bubble {
  background: var(--bubble);
  border-color: #b6e2da;
}

.message.pending .bubble {
  border-style: dashed;
  color: var(--muted);
}

.message.failed .bubble {
  border-color: #fecdd3;
  background: #fff1f2;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: inherit;
  gap: 6px;
}

.attachment-chip {
  max-width: min(360px, 100%);
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cfd8df;
  border-radius: 8px;
  padding: 5px 9px;
  background: #f8fafc;
  color: #3f4954;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.attachment-chip.pending {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.attachment-remove {
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #fff;
  color: #1e3a8a;
  font-size: 11px;
}

.attachment-remove:hover {
  background: #dbeafe;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-preview-modal[hidden] {
  display: none;
}

.image-preview-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.58);
}

.image-preview-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(86vh, 860px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  border: 1px solid #d9e2ea;
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
}

.image-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.image-preview-head h2 {
  margin: 0;
  font-size: 20px;
}

.image-preview-frame {
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  overflow: auto;
}

.image-preview-frame img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.image-preview-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.image-preview-meta dt {
  font-weight: 700;
}

.image-preview-meta dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.audit-card,
.thinking-card {
  width: min(780px, 100%);
  max-width: 100%;
  border: 1px solid #d6e6e3;
  border-radius: 10px;
  background: #fbfefd;
  color: var(--text);
}

.thinking-card {
  border-color: #d8dee4;
  background: #f8fafc;
  color: #3f4954;
}

.audit-card summary,
.thinking-card summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 11px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.audit-card[open] {
  padding-bottom: 8px;
  max-height: 360px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.audit-section {
  padding: 0 11px 7px;
}

.audit-section h3 {
  margin: 4px 0 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.audit-section ul {
  margin: 0;
  padding-left: 1.25em;
}

.audit-section li {
  margin: 0.22em 0;
  color: #3f4954;
  font-size: 12px;
  line-height: 1.45;
}

.audit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: flex-start;
}

.audit-action {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.audit-json {
  flex-basis: 100%;
  max-height: 260px;
  margin: 2px 0 0;
  overflow: auto;
  border-radius: 8px;
  padding: 9px;
  background: var(--code);
  color: #f4f7fa;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.thinking-body {
  max-height: 260px;
  overflow: auto;
  padding: 0 11px 10px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.warning {
  color: var(--rose);
  font-weight: 700;
}

.markdown-body {
  overflow-wrap: anywhere;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body p {
  margin: 0 0 0.72em;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 0.85em 0 0.38em;
  line-height: 1.25;
  letter-spacing: 0;
}

.markdown-body h1 {
  font-size: 20px;
}

.markdown-body h2 {
  font-size: 17px;
}

.markdown-body h3 {
  font-size: 15px;
}

.markdown-body h4 {
  font-size: 14px;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.35em 0 0.85em;
  padding-left: 1.35em;
}

.markdown-body li {
  margin: 0.28em 0;
}

.markdown-body li > p {
  margin: 0;
}

.markdown-body strong {
  font-weight: 750;
}

.markdown-body a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-body code {
  border-radius: 5px;
  padding: 1px 5px;
  background: rgba(32, 36, 42, 0.08);
  color: #0f3f3a;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  font-size: 0.92em;
}

.markdown-body pre {
  margin: 0.75em 0;
  max-width: 100%;
  overflow: auto;
  border-radius: 8px;
  padding: 10px;
  background: var(--code);
  color: #f4f7fa;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  line-height: 1.5;
}

.markdown-body blockquote {
  margin: 0.75em 0;
  padding: 0.55em 0.75em;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fa;
  color: var(--soft-text);
}

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0.9em 0;
}

.markdown-body.compact p {
  margin-bottom: 0.4em;
}

.markdown-body.compact ul,
.markdown-body.compact ol {
  margin-bottom: 0.45em;
}

.markdown-body.compact h1,
.markdown-body.compact h2,
.markdown-body.compact h3,
.markdown-body.compact h4 {
  margin-top: 0.55em;
}

.trace-output.trace-markdown {
  white-space: normal;
  font-family: inherit;
}

.trace-markdown.markdown-body code {
  background: rgba(244, 247, 250, 0.12);
  color: #f4f7fa;
}

.trace-markdown.markdown-body a {
  color: #7dd3fc;
}

.source-snippet.markdown-body h1,
.source-snippet.markdown-body h2,
.source-snippet.markdown-body h3,
.source-snippet.markdown-body h4 {
  margin: 0.35em 0 0.2em;
  font-size: 12px;
  line-height: 1.35;
}

.source-snippet.markdown-body p,
.source-snippet.markdown-body ul,
.source-snippet.markdown-body ol {
  margin-bottom: 0.32em;
}

@media (max-width: 1180px) {
  .app-shell {
    width: min(100vw - 24px, 1040px);
  }

  .credit-section {
    grid-template-columns: 1fr;
  }

  .capability-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .app-shell {
    width: calc(100vw - 20px);
    padding-top: 10px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    position: static;
    min-height: 0;
    gap: 10px;
    padding: 10px 12px;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .site-nav a {
    flex: 1;
    justify-content: center;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  #runtimeLine,
  #modelStatus {
    display: none;
  }

  .header-actions > button,
  .account-menu summary {
    min-height: 34px;
    padding-inline: 10px;
  }

  .account-popover {
    left: 0;
    right: auto;
    width: 100%;
  }

  .brand-block h1 {
    font-size: 24px;
  }

  .brand-block p:last-child {
    font-size: 13px;
  }

  .header-actions,
  .composer-primary-actions {
    justify-content: flex-start;
  }

  .home-hero {
    padding-top: 8px;
  }

  .home-hero h2,
  .page-heading h2 {
    font-size: 34px;
    line-height: 1.08;
  }

  .task-desk {
    padding: 12px;
  }

  .task-desk-head {
    flex-direction: column;
    gap: 8px;
  }

  .task-status-row {
    justify-content: flex-start;
    display: none;
  }

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

  .composer-primary-actions button {
    flex: 1;
  }

  .pricing-grid,
  .credit-grid,
  .capability-grid,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    padding-top: 14px;
  }

  .chat-card {
    height: clamp(160px, 22vh, 220px);
    min-height: 160px;
  }

  .composer {
    padding: 0;
  }

  .composer textarea {
    height: 78px;
    min-height: 78px;
  }

  .composer-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .composer-options,
  .composer-actions .toggle {
    width: 100%;
  }
}

/* Conversation layout states. Keep the existing XiaojinPro visual theme; only
   change where the same surfaces sit before and after the first user turn. */
body[data-route="home"].home-empty .home-view {
  grid-template-rows: minmax(122px, 1fr) auto minmax(110px, 0.72fr);
}

body[data-route="home"].home-empty .task-desk {
  align-self: start;
}

body[data-route="home"].home-empty .chat-card,
body[data-route="home"].home-empty .analysis-drawer {
  display: none;
}

body[data-route="home"].has-chat .home-view {
  width: min(100%, 1040px);
  min-height: 100dvh;
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: stretch;
  padding-top: 88px;
  padding-bottom: 34px;
}

body[data-route="home"].has-chat .home-hero {
  display: none;
}

body[data-route="home"].has-chat .task-desk {
  width: min(100%, 920px);
  height: calc(100dvh - 150px);
  min-height: 520px;
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 22px;
}

body[data-route="home"].has-chat .chat-card {
  order: 1;
  height: auto;
  min-height: 0;
  align-self: stretch;
}

body[data-route="home"].has-chat .chat-log {
  height: 100%;
  padding-top: 40px;
  padding-bottom: 40px;
}

body[data-route="home"].has-chat .composer {
  order: 2;
  width: min(100%, 780px);
  justify-self: center;
  align-self: end;
  position: relative;
  bottom: auto;
}

body[data-route="home"].has-chat .message.user {
  justify-items: center;
  margin-bottom: 46px;
}

body[data-route="home"].has-chat .message.user .message-meta {
  text-align: center;
}

body[data-route="home"].has-chat .message.assistant {
  width: min(100%, 760px);
  margin-left: auto;
  margin-right: auto;
  justify-items: stretch;
}

body[data-route="home"].has-chat .message.assistant .bubble {
  width: 100%;
  max-width: 100%;
}

body[data-route="home"].has-chat .analysis-drawer {
  width: min(100%, 780px);
  margin-top: 10px;
}

.message.is-arriving {
  opacity: 0;
}

.message-flight-bubble {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.58;
  border: 1px solid rgba(217, 149, 78, 0.2);
  border-radius: 12px;
  padding: 12px 13px;
  background: rgba(255, 246, 226, 0.92);
  color: var(--warm-ink);
  box-shadow: 0 18px 42px rgba(87, 70, 37, 0.1);
}

@media (max-width: 700px) {
  body[data-route="home"].home-empty .home-view {
    grid-template-rows: minmax(84px, 0.82fr) auto minmax(72px, 0.52fr);
  }

  body[data-route="home"].has-chat .home-view {
    min-height: calc(100dvh - 72px);
    padding-top: 84px;
    padding-bottom: 24px;
  }

  body[data-route="home"].has-chat .task-desk {
    height: calc(100dvh - 132px);
    min-height: 460px;
    gap: 16px;
  }

  body[data-route="home"].has-chat .chat-log {
    padding: 24px 14px;
  }

  body[data-route="home"].has-chat .composer {
    bottom: auto;
  }

  body[data-route="home"].has-chat .message.user {
    margin-bottom: 32px;
  }
}

/* Expandable conversation rail. This keeps the existing warm XiaojinPro theme
   and changes only the app-shell layout and navigation density. */
:root {
  --side-rail-width: 62px;
  --side-rail-expanded: 276px;
  --rail-icon-size: 38px;
  --rail-icon-glyph: 20px;
  --rail-label-gap: 10px;
  --rail-avatar-size: 30px;
}

body.sidebar-expanded {
  --side-rail-width: var(--side-rail-expanded);
}

.app-shell {
  padding-left: calc(var(--side-rail-width) + 22px);
  transition: padding-left 220ms cubic-bezier(0.2, 0.78, 0.16, 1);
}

.side-rail {
  width: var(--side-rail-width);
  justify-items: stretch;
  align-items: stretch;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 10px;
  overflow: visible;
  padding: 20px 12px 22px;
  transition:
    width 220ms cubic-bezier(0.2, 0.78, 0.16, 1),
    box-shadow 220ms ease;
}

body.sidebar-expanded .side-rail {
  box-shadow: 18px 0 42px rgba(87, 70, 37, 0.1);
}

.rail-brand,
.rail-nav a,
.rail-action,
.sidebar-avatar,
.side-account-menu summary,
.side-settings-menu summary {
  width: var(--rail-icon-size);
  min-height: var(--rail-icon-size);
  display: grid;
  grid-template-columns: var(--rail-icon-size) 0;
  align-items: center;
  justify-items: center;
  place-items: center;
  justify-content: center;
  gap: 0;
  border-radius: 999px;
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
  transition:
    width 220ms cubic-bezier(0.2, 0.78, 0.16, 1),
    border-radius 220ms ease,
    background-color 180ms ease,
    color 180ms ease;
}

body.sidebar-expanded .rail-brand,
body.sidebar-expanded .rail-nav a,
body.sidebar-expanded .rail-action,
body.sidebar-expanded .sidebar-avatar,
body.sidebar-expanded .side-account-menu summary,
body.sidebar-expanded .side-settings-menu summary {
  width: 100%;
  grid-template-columns: var(--rail-icon-size) minmax(0, 1fr);
  justify-content: stretch;
  justify-items: start;
  align-items: center;
  gap: var(--rail-label-gap);
  border-radius: 12px;
  padding-right: 12px;
}

.rail-brand {
  margin: 0 0 8px;
}

.rail-brand .spark-mark {
  grid-column: 1;
  justify-self: center;
}

.rail-brand > .spark-mark,
.rail-nav a > svg,
.rail-action > svg,
.sidebar-avatar > svg,
.side-account-menu summary > .avatar-mark,
.side-settings-menu summary > svg {
  grid-column: 1;
  place-self: center;
  margin: 0;
}

.rail-label {
  min-width: 0;
  justify-self: start;
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity 150ms ease,
    transform 180ms ease;
}

body.sidebar-expanded .rail-label {
  opacity: 1;
  transform: translateX(0);
}

.rail-expand-button {
  position: absolute;
  top: 66px;
  right: -12px;
  z-index: 2;
  width: 24px;
  min-height: 24px;
  border: 1px solid var(--warm-line);
  border-radius: 999px;
  padding: 0;
  background: rgba(255, 253, 246, 0.94);
  color: var(--warm-green-strong);
  box-shadow: 0 8px 22px rgba(87, 70, 37, 0.1);
}

.rail-expand-button span {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 180ms ease;
}

body.sidebar-expanded .rail-expand-button span {
  transform: rotate(135deg);
}

.rail-nav {
  gap: 7px;
  min-height: 0;
  align-content: start;
}

.rail-action {
  border: 1px solid rgba(47, 122, 102, 0.16);
  background: rgba(223, 245, 233, 0.72);
  color: var(--warm-green-strong);
  cursor: pointer;
}

.rail-action:hover {
  background: var(--warm-mint-2);
}

.rail-action svg,
.sidebar-avatar svg,
.side-settings-menu summary > svg {
  width: var(--rail-icon-glyph);
  height: var(--rail-icon-glyph);
  display: block;
  place-self: center;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conversation-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding-top: 4px;
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 220ms cubic-bezier(0.2, 0.78, 0.16, 1);
}

body.sidebar-expanded .conversation-panel {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.conversation-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  color: var(--warm-muted);
  font-size: 12px;
  font-weight: 750;
}

.conversation-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

.conversation-item {
  width: 100%;
  min-height: 50px;
  display: grid;
  gap: 4px;
  justify-items: start;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  background: transparent;
  color: var(--warm-ink-soft);
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  border-color: var(--warm-line);
  background: rgba(255, 253, 246, 0.72);
  color: var(--warm-ink);
}

.conversation-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item small,
.conversation-empty span {
  color: var(--warm-muted);
  font-size: 11px;
}

.conversation-empty {
  display: grid;
  gap: 5px;
  border: 1px solid var(--warm-line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 253, 246, 0.56);
  color: var(--warm-ink-soft);
  font-size: 12px;
}

.rail-bottom {
  display: grid;
  align-content: end;
  justify-items: stretch;
  gap: 8px;
}

.sidebar-avatar,
.side-account-menu summary,
.side-settings-menu summary {
  border: 1px solid var(--warm-line);
  background: rgba(255, 253, 246, 0.82);
  color: var(--warm-ink-soft);
}

.sidebar-avatar:hover,
.side-account-menu summary:hover,
.side-settings-menu summary:hover {
  background: rgba(223, 245, 233, 0.72);
  color: var(--warm-green-strong);
}

.avatar-mark {
  width: var(--rail-avatar-size);
  min-width: var(--rail-avatar-size);
  height: var(--rail-avatar-size);
  min-height: var(--rail-avatar-size);
  display: grid;
  place-items: center;
  place-self: center;
  border-radius: 999px;
  background: var(--warm-mint);
  color: var(--warm-green-strong);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.side-account-menu,
.side-settings-menu {
  width: 100%;
}

.side-account-menu summary,
.side-settings-menu summary {
  cursor: pointer;
}

.side-account-menu summary::after,
.side-settings-menu summary::after {
  display: none;
}

.account-summary-text {
  min-width: 0;
  display: grid;
  gap: 3px;
  justify-self: start;
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity 150ms ease,
    transform 180ms ease;
}

body.sidebar-expanded .account-summary-text {
  opacity: 1;
  transform: translateX(0);
}

.account-summary-text .rail-label {
  opacity: 1;
  transform: none;
  max-width: 170px;
  font-size: 13px;
  line-height: 1.1;
  text-overflow: ellipsis;
}

.account-tier-label {
  max-width: 170px;
  overflow: hidden;
  color: var(--warm-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
}

.side-account-menu .account-popover,
.side-settings-menu .account-popover {
  top: auto;
  right: auto;
  bottom: 2px;
  left: calc(100% + 12px);
  width: min(340px, calc(100vw - var(--side-rail-width) - 38px));
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.96);
  box-shadow: 0 24px 60px rgba(87, 70, 37, 0.16);
}

.side-settings-menu .account-popover {
  bottom: 52px;
}

.account-popover-user {
  display: grid;
  grid-template-columns: var(--rail-icon-size) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 6px 4px 10px;
}

.account-popover-user .avatar-mark {
  place-self: center;
}

.account-popover-user strong,
.account-popover-user span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-popover-user strong {
  color: var(--warm-ink);
  font-size: 14px;
}

.account-popover-user span {
  margin-top: 3px;
  color: var(--warm-muted);
  font-size: 12px;
  font-weight: 700;
}

.menu-action {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--warm-ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.menu-action:hover {
  background: rgba(47, 122, 102, 0.07);
  color: var(--warm-green-strong);
}

.menu-separator {
  height: 1px;
  margin: 8px 0;
  background: var(--warm-line);
}

.admin-only-notice {
  margin: 0 auto;
  width: min(100%, 880px);
}

.network-page.is-admin-locked > :not([data-admin-lock]) {
  display: none !important;
}

.account-page {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 120px 0 64px;
}

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

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

.network-page {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 120px 0 64px;
}

.network-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.network-primary-panel {
  background: linear-gradient(180deg, rgba(255, 253, 246, 0.98), rgba(255, 255, 255, 0.96));
  border-color: var(--warm-line-strong, var(--line));
}

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

.section-title-row h3 {
  margin: 0;
}

.section-title-row p {
  margin: 6px 0 0;
  color: var(--warm-muted, var(--muted));
  line-height: 1.5;
}

.network-badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(47, 122, 102, 0.18);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--warm-mint, var(--green-soft));
  color: var(--warm-green-strong, var(--green-dark));
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.network-form,
.network-search-form,
.compact-form {
  display: grid;
  gap: 12px;
}

.network-form {
  margin-top: 14px;
}

.network-form label {
  color: var(--warm-ink-soft, var(--soft-text));
  font-weight: 680;
}

.network-form select {
  width: 100%;
  border: 1px solid var(--warm-line, var(--line));
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  color: var(--warm-ink, var(--text));
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.network-search-panel {
  border: 1px solid var(--warm-line, var(--line));
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 253, 246, 0.94);
  box-shadow: var(--shadow-soft);
}

.network-search-form {
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 0.35fr) minmax(120px, 0.35fr) auto;
  align-items: end;
}

.network-card-grid,
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.network-card,
.knowledge-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--warm-line, var(--line));
  border-radius: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.network-card h3,
.knowledge-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.network-card p,
.knowledge-card p {
  margin: 0;
  color: var(--warm-ink-soft, var(--soft-text));
  line-height: 1.55;
}

.network-chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.network-chip-row span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: rgba(223, 245, 233, 0.8);
  color: var(--warm-green-strong, var(--green-dark));
  font-size: 12px;
  font-weight: 700;
}

.network-empty {
  border: 1px dashed rgba(47, 122, 102, 0.24);
  border-radius: 14px;
  padding: 18px;
  background: rgba(255, 253, 246, 0.82);
  color: var(--warm-ink-soft, var(--soft-text));
  line-height: 1.6;
}

.network-empty.compact {
  padding: 12px;
  font-size: 13px;
}

.network-empty h3 {
  margin: 0 0 8px;
  color: var(--warm-ink, var(--text));
}

.network-empty p {
  margin: 0 0 14px;
}

.network-draft {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.network-draft h4 {
  margin: 0;
  font-size: 15px;
}

.network-draft p {
  margin: 0;
  color: var(--warm-ink-soft, var(--soft-text));
  line-height: 1.5;
}

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

.network-row {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(47, 122, 102, 0.13);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.network-row strong {
  color: var(--warm-ink, var(--text));
}

.network-row span {
  color: var(--warm-muted, var(--muted));
  font-size: 12px;
}

.network-row p {
  margin: 0;
  color: var(--warm-ink-soft, var(--soft-text));
  line-height: 1.5;
}

.attestation-row {
  background: rgba(255, 253, 246, 0.74);
}

.network-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.network-stat-row span {
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--warm-mint, var(--green-soft));
  color: var(--warm-green-strong, var(--green-dark));
  font-size: 13px;
  font-weight: 760;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  color: var(--warm-ink-soft, var(--soft-text));
  line-height: 1.7;
}

.network-membership-card {
  align-items: start;
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .side-rail,
  .rail-brand,
  .rail-nav a,
  .rail-action,
  .sidebar-avatar,
  .side-account-menu summary,
  .side-settings-menu summary,
  .rail-label,
  .conversation-panel,
  .rail-expand-button span {
    transition: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding-left: calc(var(--side-rail-width) + 14px);
  }

  .brand-block {
    left: calc(var(--side-rail-width) + 12px);
    transition: left 220ms cubic-bezier(0.2, 0.78, 0.16, 1);
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 72px 14px 20px;
  }

  .rail-expand-button,
  .conversation-panel,
  .rail-label {
    display: none;
  }

  .rail-brand,
  .rail-nav a,
  .rail-action,
  .sidebar-avatar,
  .side-account-menu summary,
  .side-settings-menu summary {
    width: var(--rail-icon-size);
    grid-template-columns: var(--rail-icon-size) 0;
    gap: 0;
    padding: 0;
    border-radius: 999px;
  }

  .rail-nav {
    display: flex;
    align-items: center;
  }

  .side-account-menu .account-popover,
  .side-settings-menu .account-popover {
    left: auto;
    right: 0;
    bottom: auto;
    top: calc(100% + 10px);
    width: min(310px, calc(100vw - 24px));
  }

  .account-page {
    padding-top: 88px;
  }

  .account-page-grid,
  .settings-grid,
  .account-usage-grid,
  .network-layout,
  .network-search-form {
    grid-template-columns: 1fr;
  }

.network-page {
    padding-top: 88px;
  }
}

/* Internal diagnostics are available in /admin only. The public chat should
   read like a normal conversation, not like an execution trace. */
.analysis-drawer {
  display: none !important;
}

.admin-page {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 96px 0 64px;
}

.admin-dashboard {
  display: grid;
  grid-template-columns: minmax(260px, 0.76fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: start;
}

.admin-panel {
  border: 1px solid var(--warm-line);
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.84);
  box-shadow: 0 18px 44px rgba(87, 70, 37, 0.08);
}

.admin-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--warm-line);
}

.admin-panel-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.admin-panel-head p {
  margin: 0;
  color: var(--warm-ink-soft);
  font-size: 13px;
}

.admin-turns-panel {
  max-height: calc(100dvh - 132px);
  overflow: hidden;
}

.admin-turn-list {
  max-height: calc(100dvh - 212px);
  overflow: auto;
  padding: 10px;
}

.admin-turn-item {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px;
  background: transparent;
  color: var(--warm-ink);
  cursor: pointer;
}

.admin-turn-item:hover,
.admin-turn-item.active {
  border-color: rgba(47, 122, 102, 0.22);
  background: rgba(221, 246, 235, 0.48);
}

.admin-turn-title {
  font-weight: 760;
  line-height: 1.35;
}

.admin-turn-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--warm-ink-soft);
  font-size: 12px;
}

.admin-turn-meta span {
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(70, 88, 82, 0.08);
}

.admin-detail-panel {
  min-width: 0;
}

.admin-users-panel {
  grid-column: 1 / -1;
}

.admin-turn-detail {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.admin-detail-card {
  border: 1px solid var(--warm-line);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.58);
}

.admin-detail-card h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.admin-kv {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.admin-kv dt,
.admin-label {
  color: var(--warm-ink-soft);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-kv dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.admin-transcript {
  display: grid;
  gap: 12px;
}

.admin-transcript .markdown-body {
  margin-top: 6px;
  border-radius: 12px;
  padding: 12px;
  background: rgba(247, 244, 232, 0.72);
  white-space: pre-wrap;
}

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

.admin-timing-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-timing-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(221, 246, 235, 0.42);
}

.admin-table-wrap {
  overflow: auto;
  border: 1px solid var(--warm-line);
  border-radius: 12px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--warm-line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--warm-ink-soft);
  font-weight: 760;
  background: rgba(247, 244, 232, 0.72);
}

.admin-table td span {
  display: block;
  margin-top: 3px;
  color: var(--warm-ink-soft);
  font-size: 12px;
}

.admin-debug-block {
  min-width: 0;
  border: 1px solid var(--warm-line);
  border-radius: 12px;
  background: rgba(255, 253, 246, 0.72);
}

.admin-debug-block summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--warm-green-strong);
  font-weight: 760;
  cursor: pointer;
}

.admin-debug-block pre {
  max-height: 340px;
  overflow: auto;
  margin: 0;
  border-top: 1px solid var(--warm-line);
  padding: 12px;
  color: var(--warm-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-model-call-details {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.admin-empty {
  border: 1px dashed var(--warm-line);
  border-radius: 14px;
  padding: 18px;
  color: var(--warm-ink-soft);
  background: rgba(255, 253, 246, 0.52);
}

@media (max-width: 980px) {
  .admin-dashboard,
  .admin-audit-grid {
    grid-template-columns: 1fr;
  }

  .admin-turns-panel {
    max-height: none;
  }

  .admin-turn-list {
    max-height: 360px;
  }

  .admin-kv {
    grid-template-columns: 1fr;
  }
}

/* Final chat-surface pass: once a conversation starts, the page should behave
   like a full-screen chat surface. The card remains only as a structural scroll
   container, not as a visible framed panel. */
body[data-route="home"].has-chat .home-view {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 58px clamp(28px, 6vw, 86px) 24px;
}

body[data-route="home"].has-chat .task-desk {
  width: 100%;
  max-width: none;
  height: calc(100dvh - 92px);
  min-height: 540px;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
}

body[data-route="home"].has-chat .task-desk-head {
  display: none;
}

body[data-route="home"].has-chat .chat-card {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

body[data-route="home"].has-chat .chat-log {
  width: min(100%, 920px);
  height: 100%;
  margin: 0 auto;
  padding: 38px 0 108px;
}

body[data-route="home"].has-chat .composer {
  width: min(100%, 860px);
  justify-self: center;
}

body[data-route="home"].has-chat .analysis-drawer {
  width: min(100%, 860px);
  justify-self: center;
}

.side-rail {
  cursor: pointer;
}

.side-rail .account-popover,
.side-rail .account-popover * {
  cursor: auto;
}

.side-rail .account-popover a,
.side-rail .account-popover button,
.side-rail .account-popover summary {
  cursor: pointer;
}

.rail-action,
.rail-brand,
.side-account-menu summary,
.side-settings-menu summary,
.rail-expand-button {
  cursor: pointer;
}

@media (max-width: 700px) {
  body[data-route="home"].has-chat .home-view {
    min-height: calc(100dvh - 72px);
    padding: 74px 14px 18px;
  }

  body[data-route="home"].has-chat .task-desk {
    height: calc(100dvh - 108px);
    min-height: 460px;
  }

  body[data-route="home"].has-chat .chat-log {
    width: 100%;
    padding: 22px 2px 96px;
  }

  body[data-route="home"].has-chat .composer,
  body[data-route="home"].has-chat .analysis-drawer {
    width: 100%;
  }
}

/* Cozy-pixel product surfaces */
:root {
  --cozy-cream: #fff8e6;
  --cozy-parchment: #fffdf3;
  --cozy-mint: #dff5e9;
  --cozy-mint-strong: #9fdcbd;
  --cozy-sage: #557a66;
  --cozy-wood: #b67845;
  --cozy-wood-dark: #83532e;
  --cozy-ink: #25352f;
  --cozy-muted: #6c7d72;
  --cozy-line: rgba(91, 119, 99, 0.22);
  --cozy-shadow: 0 18px 44px rgba(117, 93, 50, 0.12);
}


.cozy-town-page {
  width: min(100%, 1180px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 92px 28px 72px;
  color: var(--cozy-ink);
}

.cozy-heading {
  max-width: 760px;
  margin: 0 0 28px;
}

.cozy-heading .eyebrow,
.cozy-eyebrow {
  margin: 0 0 8px;
  color: var(--cozy-sage);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.cozy-heading h2 {
  margin: 0 0 10px;
  color: var(--cozy-ink);
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 1.03;
  text-wrap: balance;
}

.cozy-heading p {
  max-width: 62ch;
  color: var(--cozy-muted);
  font-size: 16px;
  line-height: 1.7;
}

.cozy-layout,
.town-board {
  display: grid;
  gap: 18px;
}

.cozy-panel,
.town-card {
  border: 1px solid var(--cozy-line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 248, 230, 0.64)),
    var(--cozy-parchment);
  box-shadow: var(--cozy-shadow);
}


.cozy-panel {
  padding: 20px;
}

.cozy-section-title,
.town-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.cozy-section-title {
  margin-bottom: 16px;
}

.cozy-section-title h3,
.town-card h3,
.cozy-card h4,
.resident-title-card h3 {
  margin: 0;
  color: var(--cozy-ink);
  line-height: 1.25;
}

.cozy-section-title p,
.cozy-card p,
.town-card p,
.resident-title-card p,
.capacity-meter p {
  margin: 6px 0 0;
  color: var(--cozy-muted);
  line-height: 1.6;
}

.town-card {
  position: relative;
  padding: 20px;
  overflow: hidden;
}

.town-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(176, 120, 69, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(176, 120, 69, 0.04) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.8;
}

.town-card > * {
  position: relative;
}

.town-card.is-pinned {
  border-color: rgba(182, 120, 69, 0.5);
}

.town-card footer {
  margin-top: 14px;
  color: var(--cozy-muted);
  font-size: 13px;
}

.cozy-token {
  min-height: 25px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(85, 122, 102, 0.16);
  border-radius: 6px;
  padding: 0 9px;
  background: var(--cozy-mint);
  color: #25624d;
  font-size: 12px;
  font-weight: 800;
}

.cozy-token.warm {
  border-color: rgba(182, 120, 69, 0.2);
  background: #f7e4bd;
  color: var(--cozy-wood-dark);
}


.cozy-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

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

.cozy-card,
.cozy-row {
  border: 1px solid var(--cozy-line);
  border-radius: 8px;
  padding: 15px;
  background: rgba(255, 253, 243, 0.72);
}


.cozy-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.pixel-button {
  min-height: 39px;
  border: 1px solid rgba(64, 113, 89, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, #e7f8ee, #d8f1e4);
  color: #2d6b55;
  box-shadow: inset 0 -2px 0 rgba(68, 116, 91, 0.14);
  font-weight: 800;
}

.pixel-button:hover {
  background: linear-gradient(180deg, #eefbf3, #ccebdc);
  color: #215642;
  transform: translateY(-1px);
}

.text-button {
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--cozy-sage);
  font-weight: 800;
}

.text-button:hover {
  background: transparent;
  color: var(--cozy-wood-dark);
}

.text-button.danger {
  color: #a44939;
}

.capacity-meter {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.capacity-meter-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--cozy-ink);
}

.capacity-meter-head span {
  color: var(--cozy-muted);
  font-size: 13px;
}

.capacity-track {
  height: 14px;
  border: 1px solid rgba(85, 122, 102, 0.22);
  border-radius: 4px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.66);
}

.capacity-fill {
  height: 100%;
  display: block;
  border-radius: 2px;
  background: repeating-linear-gradient(
    90deg,
    #8fd6ae 0,
    #8fd6ae 10px,
    #77c79d 10px,
    #77c79d 20px
  );
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 12px;
}

.inventory-slot {
  min-height: 196px;
  display: grid;
  grid-template-rows: 96px auto auto auto;
  gap: 8px;
  border: 1px solid var(--cozy-line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 253, 243, 0.82);
}

.inventory-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(159, 220, 189, 0.2), rgba(246, 224, 181, 0.25)),
    rgba(255, 255, 255, 0.74);
}

.inventory-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.inventory-thumb span,
.resident-mini-avatar,
.resident-badge {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--cozy-mint);
  color: #2d6b55;
  font-weight: 900;
}

.inventory-slot h4,
.inventory-slot p {
  margin: 0;
}

.inventory-slot h4 {
  overflow: hidden;
  color: var(--cozy-ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-slot p {
  color: var(--cozy-muted);
  font-size: 12px;
}

.resident-title-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.resident-badge {
  min-height: 76px;
  padding: 8px;
  text-align: center;
  box-shadow: inset 0 -3px 0 rgba(68, 116, 91, 0.12);
}

.cozy-form {
  display: grid;
  gap: 13px;
}

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

.cozy-form label {
  display: grid;
  gap: 7px;
  color: var(--cozy-muted);
  font-size: 13px;
  font-weight: 800;
}

.cozy-form input,
.cozy-form textarea,
.cozy-form select {
  border: 1px solid var(--cozy-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--cozy-ink);
}


.published-form textarea {
  min-height: 118px;
}

.cozy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.resident-mini-avatar {
  width: 42px;
  height: 42px;
  margin-bottom: 8px;
}

.cozy-empty {
  border: 1px dashed var(--cozy-line);
  border-radius: 8px;
  padding: 20px;
  background: rgba(255, 253, 243, 0.62);
  color: var(--cozy-muted);
}

.cozy-empty.compact {
  padding: 13px;
}

.cozy-empty h3 {
  margin: 0 0 8px;
  color: var(--cozy-ink);
}

.cozy-empty p {
  margin: 0;
}

@media (max-width: 720px) {
  .cozy-town-page {
    padding: 72px 18px 120px;
  }

  .cozy-form-grid,
  .resident-title-card {
    grid-template-columns: 1fr;
  }

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

/* Cozy-pixel town skin: original assets, Stardew-like warmth. */
:root {
  --pixel-ink: #2e222f;
  --pixel-muted: #625565;
  --pixel-earth: #9e4539;
  --pixel-earth-dark: #45293f;
  --pixel-wood: #a45a4a;
  --pixel-wood-light: #cd683d;
  --pixel-paper: #f3e6c8;
  --pixel-paper-soft: #fff6df;
  --pixel-grass: #1ebc73;
  --pixel-grass-dark: #165a4c;
  --pixel-mint: #c7f1d4;
  --pixel-mint-deep: #73c48f;
  --pixel-sky: #8fd3ff;
  --pixel-water: #4d9be6;
  --pixel-gold: #f9c22b;
  --pixel-shadow: rgba(69, 41, 63, 0.2);
  --pixel-panel-shadow: 0 16px 0 rgba(69, 41, 63, 0.08), 0 26px 46px rgba(69, 41, 63, 0.12);
  --bg: #fff6df;
  --panel: #fffaf0;
  --panel-soft: #f3e6c8;
  --line: rgba(69, 41, 63, 0.2);
  --line-strong: rgba(69, 41, 63, 0.35);
  --text: var(--pixel-ink);
  --muted: var(--pixel-muted);
  --green: #239063;
  --green-dark: var(--pixel-grass-dark);
  --green-soft: #e6f6e8;
  --bubble: #fffaf0;
  --shadow: var(--pixel-panel-shadow);
  --shadow-soft: 0 4px 0 rgba(69, 41, 63, 0.08), 0 12px 22px rgba(69, 41, 63, 0.08);
}


html {
  background: var(--bg);
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 62%, rgba(30, 188, 115, 0.2) 0 12%, transparent 29%),
    radial-gradient(circle at 78% 18%, rgba(249, 194, 43, 0.2) 0 5%, transparent 18%),
    linear-gradient(180deg, #fffdf0 0%, #fff6df 44%, #f4e7c6 100%);
  color: var(--text);
  font-family:
    "Nunito Sans", "Avenir Next", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
}


body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: 0;
  opacity: 0.62;
  background:
    linear-gradient(90deg, rgba(69, 41, 63, 0.035) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(69, 41, 63, 0.026) 1px, transparent 1px) 0 0 / 24px 24px;
  image-rendering: pixelated;
}

body::after {
  z-index: 0;
  top: auto;
  height: 176px;
  background:
    linear-gradient(135deg, transparent 0 48%, rgba(35, 144, 99, 0.3) 48% 52%, transparent 52%) 0 32px / 46px 46px repeat-x,
    linear-gradient(0deg, #165a4c 0 16px, #239063 16px 44px, #91db69 44px 62px, transparent 62px),
    linear-gradient(90deg, rgba(69, 41, 63, 0.18) 1px, transparent 1px) 0 58px / 32px 32px;
  opacity: 0.22;
  image-rendering: pixelated;
}



.app-shell,
.topbar,
.site-main,
.side-rail,
.account-popover {
  position: relative;
  z-index: 1;
}

.topbar {
  display: none;
}

.app-shell {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
}

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

.site-main {
  min-width: 0;
  padding: 0;
}

.side-rail {
  position: sticky;
  top: 0;
  width: 74px;
  height: 100dvh;
  padding: 22px 14px 18px;
  background:
    linear-gradient(90deg, rgba(255, 246, 223, 0.98), rgba(255, 246, 223, 0.9)),
    repeating-linear-gradient(0deg, rgba(164, 90, 74, 0.08) 0 2px, transparent 2px 10px);
  border-right: 3px solid rgba(69, 41, 63, 0.12);
  border-radius: 0;
  box-shadow: 8px 0 0 rgba(69, 41, 63, 0.04);
}


body.sidebar-expanded .side-rail {
  width: 286px;
  padding-inline: 18px;
}

.spark-mark {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  background:
    linear-gradient(45deg, transparent 0 36%, #f9c22b 36% 43%, #1ebc73 43% 58%, #4d9be6 58% 64%, transparent 64%),
    linear-gradient(135deg, transparent 0 35%, #f3e6c8 35% 47%, #239063 47% 58%, transparent 58%);
  box-shadow: 0 3px 0 rgba(69, 41, 63, 0.12);
  image-rendering: pixelated;
}

.rail-brand,
.rail-action,
.account-menu > summary {
  border-radius: 8px;
  color: var(--text);
}

.rail-brand,
.rail-action {
  min-height: 44px;
}

.rail-action {
  background: rgba(199, 241, 212, 0.52);
  border: 2px solid rgba(35, 144, 99, 0.18);
  box-shadow: inset 0 -3px 0 rgba(35, 144, 99, 0.08);
}

.rail-action:hover,
.rail-action.active,
.account-menu > summary:hover {
  background: rgba(199, 241, 212, 0.82);
  border-color: rgba(35, 144, 99, 0.36);
  transform: translateY(-1px);
}


.rail-action svg,
.rail-brand svg,
.account-menu svg,
.composer-icon-button svg {
  stroke-width: 2;
}

.rail-expand-button {
  top: 84px;
  right: 9px;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(69, 41, 63, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 4px 0 rgba(69, 41, 63, 0.1);
}

body.sidebar-expanded .rail-expand-button {
  right: 12px;
}

.rail-expand-button:hover {
  background: #fff6df;
  box-shadow: 0 5px 0 rgba(69, 41, 63, 0.12);
}

.rail-expand-button::after {
  border-radius: 7px;
  background: var(--pixel-ink);
  color: var(--pixel-paper-soft);
  box-shadow: 0 4px 0 rgba(69, 41, 63, 0.16);
}

.rail-expand-button span::before,
.rail-expand-button span::after {
  background: var(--pixel-ink);
}

.conversation-panel-head {
  color: var(--muted);
  font-weight: 800;
}

.conversation-item,
.network-empty,
.conversation-empty {
  border: 2px solid rgba(69, 41, 63, 0.13);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
  box-shadow: inset 0 -3px 0 rgba(69, 41, 63, 0.05);
}

.conversation-item:hover,
.conversation-item.active {
  background: rgba(199, 241, 212, 0.86);
  border-color: rgba(35, 144, 99, 0.32);
}

.rail-bottom {
  gap: 10px;
}

.side-settings-menu > summary {
  width: 42px;
  height: 42px;
  margin: 0 auto 4px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body.sidebar-expanded .side-settings-menu > summary {
  margin-left: auto;
  margin-right: 0;
}

.side-settings-menu > summary:hover {
  background: rgba(199, 241, 212, 0.72);
}

.side-account-menu > summary {
  min-height: 50px;
  border: 2px solid rgba(69, 41, 63, 0.14);
  background: rgba(255, 250, 240, 0.76);
  box-shadow: inset 0 -3px 0 rgba(69, 41, 63, 0.06);
}

.avatar-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(249, 194, 43, 0.18), rgba(199, 241, 212, 0.6)),
    #c7f1d4;
  border: 2px solid rgba(35, 144, 99, 0.18);
  color: #165a4c;
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(35, 144, 99, 0.1);
}

.account-popover {
  border: 3px solid rgba(69, 41, 63, 0.18);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.97), rgba(243, 230, 200, 0.96));
  box-shadow: 0 12px 0 rgba(69, 41, 63, 0.08), 0 28px 60px rgba(69, 41, 63, 0.22);
}


.menu-action,
.menu-button,
.secondary-button,
.pixel-button {
  border-radius: 8px;
  border: 2px solid rgba(69, 41, 63, 0.16);
  background: rgba(255, 250, 240, 0.72);
  color: var(--text);
  box-shadow: inset 0 -3px 0 rgba(69, 41, 63, 0.06);
}

.menu-action:hover,
.menu-button:hover,
.secondary-button:hover,
.pixel-button:hover {
  background: rgba(199, 241, 212, 0.8);
  color: var(--text);
  transform: translateY(-1px);
}

.home-view,
.pricing-page,
.capabilities-page,
.network-page,
.account-page,
.admin-page,
.cozy-town-page {
  min-height: 100dvh;
  padding: clamp(28px, 6vh, 90px) clamp(24px, 7vw, 116px) 128px;
}

.home-view {
  display: grid;
  align-content: center;
  gap: 22px;
}

body[data-route="home"].has-chat .home-view {
  align-content: stretch;
  padding-top: 38px;
}

.home-hero {
  max-width: 940px;
  margin-inline: auto;
  padding: 0;
  text-align: center;
}

.home-hero .eyebrow,
.page-heading .eyebrow,
.cozy-heading .eyebrow {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(249, 194, 43, 0.2);
  color: #165a4c;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: none;
  box-shadow: inset 0 -2px 0 rgba(249, 194, 43, 0.22);
}

.home-hero h2,
.page-heading h2,
.cozy-heading h2 {
  margin: 14px 0 8px;
  color: var(--text);
  font-family:
    "Trebuchet MS", "Avenir Next", "PingFang SC", system-ui, sans-serif;
  font-size: clamp(42px, 6.8vw, 84px);
  line-height: 1.03;
  font-weight: 900;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow: 0 4px 0 rgba(249, 194, 43, 0.16);
}

.home-hero p:not(.eyebrow),
.page-heading p,
.cozy-heading p {
  max-width: 760px;
  margin-inline: auto;
  color: var(--muted);
  font-size: clamp(16px, 1.9vw, 20px);
  font-weight: 700;
  line-height: 1.7;
}

.task-desk {
  width: min(960px, 100%);
  margin-inline: auto;
  display: grid;
  gap: 18px;
}

.task-desk-head {
  display: none;
}

.session-notice {
  width: min(900px, 100%);
  margin-inline: auto;
  border: 2px solid rgba(35, 144, 99, 0.24);
  border-radius: 8px;
  background: rgba(199, 241, 212, 0.72);
  color: #165a4c;
  box-shadow: inset 0 -3px 0 rgba(35, 144, 99, 0.08);
}

.composer {
  position: fixed;
  left: calc(74px + (100vw - 74px) / 2);
  right: auto;
  bottom: max(24px, env(safe-area-inset-bottom));
  width: min(920px, calc(100vw - 132px));
  transform: translateX(-50%);
  padding: 0;
  z-index: 8;
  background: transparent;
  border: 0;
  box-shadow: none;
}

body.sidebar-expanded .composer {
  left: calc(286px + (100vw - 286px) / 2);
  width: min(920px, calc(100vw - 344px));
}

.composer-shell {
  min-height: 58px;
  border: 3px solid rgba(69, 41, 63, 0.14);
  border-radius: 13px;
  padding: 8px 9px 8px 12px;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.98), rgba(255, 246, 223, 0.95));
  box-shadow: 0 8px 0 rgba(69, 41, 63, 0.08), 0 18px 42px rgba(69, 41, 63, 0.16);
  backdrop-filter: blur(12px);
}


.composer textarea {
  min-height: 36px;
  max-height: 120px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
}

.composer textarea::placeholder {
  color: rgba(98, 85, 101, 0.72);
}

.composer-icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: rgba(98, 85, 101, 0.78);
  box-shadow: none;
}

.composer-icon-button:hover {
  background: rgba(199, 241, 212, 0.68);
  color: #165a4c;
}

.composer-primary-actions {
  align-items: center;
  gap: 8px;
}

.model-pill {
  color: rgba(98, 85, 101, 0.72);
  font-weight: 900;
}

#sendButton {
  min-width: 70px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background:
    linear-gradient(180deg, #91db69, #1ebc73);
  color: #123d31;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(22, 90, 76, 0.16), 0 3px 0 rgba(69, 41, 63, 0.1);
}

#sendButton:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

#sendButton:disabled {
  background: #dfe7d7;
  color: rgba(98, 85, 101, 0.55);
}

.chat-card {
  min-height: 44vh;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body[data-route="home"].home-empty .chat-card,
body[data-route="home"].has-chat .chat-card,
body[data-route="home"].home-empty .chat-card:has(.empty-state) {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.chat-log {
  width: min(940px, 100%);
  margin: 0 auto;
  padding-bottom: 118px;
}

body[data-route="home"].home-empty .chat-log {
  min-height: 20vh;
}

.empty-state {
  width: min(640px, 100%);
  margin: 0 auto;
  border: 2px solid rgba(35, 144, 99, 0.22);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.62);
  color: var(--muted);
  box-shadow: inset 0 -3px 0 rgba(69, 41, 63, 0.04);
}

.empty-state strong {
  color: var(--text);
}

.message {
  max-width: 100%;
  margin: 38px 0;
}

#homeView .message .role,
#homeView .message.assistant .message-meta {
  display: none;
}

.message.user {
  align-items: flex-end;
}

.message.user .bubble {
  max-width: min(560px, 72vw);
  border: 2px solid rgba(249, 194, 43, 0.35);
  border-radius: 12px;
  background: rgba(255, 246, 223, 0.88);
  color: var(--text);
  box-shadow: inset 0 -3px 0 rgba(249, 194, 43, 0.12);
}

.message.assistant {
  align-items: flex-start;
}

.message.assistant .bubble,
body[data-route="home"].has-chat .message.assistant .bubble {
  width: min(880px, 100%);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  font-size: 17px;
  line-height: 1.85;
}

.message.pending .bubble {
  padding: 14px 18px;
  border: 2px solid rgba(35, 144, 99, 0.22);
  border-radius: 10px;
  background: rgba(199, 241, 212, 0.54);
}

.message.failed .bubble {
  padding: 14px 18px;
  border: 2px solid rgba(158, 69, 57, 0.28);
  border-radius: 10px;
  background: rgba(255, 228, 204, 0.7);
}

.message .message-meta {
  color: rgba(98, 85, 101, 0.7);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  color: var(--text);
}

.markdown-body code {
  border-radius: 4px;
  background: rgba(69, 41, 63, 0.08);
  color: var(--pixel-grass-dark);
}

.markdown-body pre {
  border: 2px solid rgba(69, 41, 63, 0.16);
  border-radius: 8px;
  background: rgba(46, 34, 47, 0.92);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

.analysis-drawer {
  display: none;
}

.page-heading,
.cozy-heading {
  max-width: 1080px;
  margin: 0 auto 28px;
}

.pricing-layout,
.capability-layout,
.network-layout,
.account-page-grid,
.settings-grid,
.usage-grid,
.admin-dashboard,
.town-board,
.cozy-layout,
.knowledge-grid {
  width: min(1120px, 100%);
  margin-inline: auto;
}

.pricing-card,
.feature-card,
.credit-card,
.network-card,
.knowledge-card,
.panel-section,
.admin-panel,
.cozy-panel,
.town-card,
.cozy-card,
.cozy-row,
.capacity-meter,
.resident-title-card,
.network-search-panel {
  border: 3px solid rgba(69, 41, 63, 0.16);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.97), rgba(243, 230, 200, 0.94));
  box-shadow: 0 6px 0 rgba(69, 41, 63, 0.08), 0 18px 40px rgba(69, 41, 63, 0.1);
}


.pricing-card::before,
.feature-card::before,
.credit-card::before,
.town-card::before,
.cozy-panel::before,
.panel-section::before,
.knowledge-card::before {
  content: "";
  display: block;
  height: 6px;
  margin: -1px -1px 14px;
  border-radius: 8px 8px 3px 3px;
  background:
    linear-gradient(90deg, #9e4539 0 16%, #cd683d 16% 26%, #9e4539 26% 46%, #a45a4a 46% 66%, #cd683d 66% 78%, #9e4539 78%);
  image-rendering: pixelated;
}

.pricing-card h3,
.feature-card h3,
.credit-card h3,
.cozy-card h4,
.panel-section h3,
.knowledge-card h3,
.town-card h3 {
  color: var(--text);
  font-weight: 900;
}

.pricing-card .price,
.credit-card strong {
  font-variant-numeric: tabular-nums;
}

.pricing-card button,
.feature-card button,
.credit-card button,
.network-card button,
.form-actions button {
  border-radius: 8px;
  border: 2px solid rgba(35, 144, 99, 0.22);
  background: rgba(199, 241, 212, 0.8);
  color: #165a4c;
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(35, 144, 99, 0.1);
}

.pricing-card button:hover,
.feature-card button:hover,
.credit-card button:hover,
.network-card button:hover,
.form-actions button:hover {
  background: #c7f1d4;
}

.cozy-token,
.network-chip,
.task-status-row span {
  border-radius: 5px;
  background: rgba(199, 241, 212, 0.72);
  color: #165a4c;
  font-weight: 900;
  box-shadow: inset 0 -2px 0 rgba(35, 144, 99, 0.08);
}

.town-board {
  display: grid;
  gap: 18px;
}

.town-card {
  position: relative;
  padding: 22px;
}

.town-card.pinned {
  border-color: rgba(249, 194, 43, 0.46);
}

.town-card.pinned::after {
  content: "";
  position: absolute;
  right: 22px;
  top: 19px;
  width: 18px;
  height: 18px;
  background: #f9c22b;
  box-shadow: 0 4px 0 rgba(69, 41, 63, 0.12);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}

.inventory-grid {
  gap: 14px;
}

.inventory-slot,
.backpack-expansion-card {
  min-height: 148px;
  border: 3px solid rgba(69, 41, 63, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.93), rgba(243, 230, 200, 0.88)),
    repeating-linear-gradient(45deg, rgba(69, 41, 63, 0.04) 0 6px, transparent 6px 12px);
  box-shadow: inset 0 -5px 0 rgba(69, 41, 63, 0.06);
}

.capacity-track {
  border: 2px solid rgba(69, 41, 63, 0.16);
  background: rgba(69, 41, 63, 0.08);
  box-shadow: inset 0 2px 0 rgba(69, 41, 63, 0.06);
}

.capacity-fill {
  background:
    linear-gradient(90deg, #1ebc73, #91db69 56%, #f9c22b);
}

.cozy-form input,
.cozy-form textarea,
.cozy-form select,
.network-search-form input,
.network-search-form textarea,
.panel-section textarea {
  border: 2px solid rgba(69, 41, 63, 0.16);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: inset 0 3px 0 rgba(69, 41, 63, 0.05);
}


.resident-title-card {
  display: grid;
  gap: 10px;
  padding: 22px;
}

.friend-card,
.published-card {
  border: 2px solid rgba(69, 41, 63, 0.14);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
}

.admin-dashboard {
  grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.4fr) minmax(220px, 0.8fr);
}

body[data-route="admin"] .side-rail,
body[data-route="admin"] .topbar {
  z-index: 4;
}

@media (max-width: 980px) {
  .app-shell,
  body.sidebar-expanded .app-shell {
    grid-template-columns: 1fr;
  }

  .side-rail {
    position: fixed;
    z-index: 20;
    width: 74px;
  }

  body.sidebar-expanded .side-rail {
    width: min(286px, calc(100vw - 18px));
  }

  .home-view,
  .pricing-page,
  .capabilities-page,
  .network-page,
  .account-page,
  .admin-page,
  .cozy-town-page {
    padding-left: 96px;
    padding-right: 18px;
  }

  .composer,
  body.sidebar-expanded .composer {
    left: calc(74px + (100vw - 74px) / 2);
    width: calc(100vw - 104px);
  }

  .home-hero h2,
  .page-heading h2,
  .cozy-heading h2 {
    font-size: clamp(38px, 9vw, 60px);
  }

  .admin-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .home-view,
  .pricing-page,
  .capabilities-page,
  .network-page,
  .account-page,
  .admin-page,
  .cozy-town-page {
    padding-left: 86px;
    padding-right: 14px;
  }

  .composer,
  body.sidebar-expanded .composer {
    width: calc(100vw - 96px);
  }

  .composer-primary-actions {
    gap: 4px;
  }

  .model-pill {
    display: none;
  }

  .message.user .bubble {
    max-width: min(80vw, 420px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Final sidebar hit-target normalization for the cozy skin. */
body:not(.sidebar-expanded) .rail-expand-button {
  opacity: 0;
  pointer-events: none;
}

body.sidebar-expanded .rail-expand-button {
  top: 18px;
  right: 18px;
  z-index: 6;
  display: grid;
  width: 42px;
  height: 42px;
  min-height: 42px;
  place-items: center;
  opacity: 1;
  pointer-events: auto;
}

.rail-expand-button::after {
  display: none;
}

body:not(.sidebar-expanded) .composer {
  left: calc(74px + (100vw - 74px) / 2) !important;
  width: min(920px, calc(100vw - 126px)) !important;
  max-width: calc(100vw - 126px) !important;
  transform: translateX(-50%) !important;
}

body.sidebar-expanded .composer {
  left: calc(286px + (100vw - 286px) / 2) !important;
  width: min(880px, calc(100vw - 334px)) !important;
  max-width: calc(100vw - 334px) !important;
  transform: translateX(-50%) !important;
}

.composer,
.composer-shell {
  box-sizing: border-box;
}

@media (max-width: 980px) {
  body:not(.sidebar-expanded) .composer,
  body.sidebar-expanded .composer {
    left: calc(74px + (100vw - 74px) / 2) !important;
    width: calc(100vw - 104px) !important;
    max-width: calc(100vw - 104px) !important;
  }
}

/* Chat mode uses the task desk grid, not the fixed landing composer. */
body[data-route="home"].has-chat .composer,
body.sidebar-expanded[data-route="home"].has-chat .composer {
  position: static !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  width: min(860px, 100%) !important;
  max-width: 100% !important;
  transform: none !important;
  justify-self: center;
  align-self: end;
}
/* ============================================================
   PIXEL TOWN THEME — 星露谷像素小镇整站皮肤（追加覆盖层）
   依赖上方既有结构选择器，仅改视觉，不动布局逻辑。
   日/夜主题由 body[data-cozy-theme] 驱动（居民资料偏好，app.js 已有挂钩）。
   SSOT: rule cozy-pixel-without-gamifying-risk / rule day-night-theme
   ============================================================ */

/* ---------- A. 夜间 token（整站生效） ---------- */

body[data-cozy-theme="night"] {
  color-scheme: dark;
  --bg: #1b2144;
  --panel: #3b2d20;
  --panel-soft: #332619;
  --line: #6b4a28;
  --line-strong: #1f1207;
  --text: #f4e4c0;
  --muted: #c9ae85;
  --soft-text: #e0c89c;
  --green: #58a13f;
  --green-dark: #7fc85c;
  --green-soft: #2c3a1e;
  --blue: #7fb3e8;
  --blue-soft: #253550;
  --amber: #e8b45a;
  --rose: #e0606a;
  --code: #14102a;
  --bubble: #46352a;
  --shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 3px 0 rgba(0, 0, 0, 0.35);
  --sky-hi: #131a3a;
  --sky-lo: #2c3b6e;
  --parchment: #3b2d20;
  --parchment-deep: #33261b;
  --parchment-hi: #4a3928;
  --wood: #8a5a2e;
  --wood-hi: #b4713d;
  --wood-lo: #5c3a1a;
  --wood-dark: #241609;
  --ink: #f4e4c0;
  --grass: #2b5c1e;
  --grass-dark: #1e4416;
  --gold: #ffc93c;
  --gold-hi: #ffe08a;
  --gold-lo: #d9a018;
  --berry: #e0606a;
  --water: #7fb3e8;
  --focus: var(--gold);
}

:root {
  --focus: var(--gold-lo);
  font-synthesis: none;
}

/* 旧 cozy/warm token 并入同一材质体系（值全部走 var，昼夜自动跟随） */
:root,
body[data-cozy-theme="night"] {
  --warm-green-strong: var(--green);
  --warm-ink: var(--ink);
  --warm-ink-soft: var(--soft-text);
  --warm-line: var(--line);
  --warm-line-strong: var(--line-strong);
  --warm-mint: var(--green-soft);
  --warm-mint-2: var(--green-soft);
  --warm-muted: var(--muted);
  --cozy-cream: var(--parchment-deep);
  --cozy-parchment: var(--parchment);
  --cozy-mint: var(--green-soft);
  --cozy-mint-strong: var(--grass);
  --cozy-sage: var(--green);
  --cozy-wood: var(--wood);
  --cozy-wood-dark: var(--wood-dark);
  --cozy-ink: var(--ink);
  --cozy-muted: var(--muted);
  --cozy-line: var(--wood-lo);
  --cozy-shadow: 0 5px 0 rgba(43, 24, 8, 0.25);
}

/* ---------- B. 场景：天空 / 云 / 草地 / 栅栏 / 星星 ---------- */

html {
  background: var(--sky-lo);
}

body {
  background: transparent;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 1;
  pointer-events: none;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='72' shape-rendering='crispEdges'><g fill='%23ffffff'><rect x='20' y='0' width='24' height='4'/><rect x='12' y='4' width='40' height='4'/><rect x='56' y='4' width='16' height='4'/><rect x='4' y='8' width='76' height='4'/><rect x='0' y='12' width='84' height='8'/><rect x='196' y='40' width='16' height='4'/><rect x='188' y='44' width='36' height='4'/><rect x='182' y='48' width='48' height='8'/></g><rect x='0' y='20' width='84' height='4' fill='%23d8ecf8'/><rect x='182' y='56' width='48' height='4' fill='%23d8ecf8'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='28' shape-rendering='crispEdges'><g fill='%23ffffff'><rect x='20' y='0' width='24' height='4'/><rect x='12' y='4' width='40' height='4'/><rect x='56' y='4' width='16' height='4'/><rect x='4' y='8' width='76' height='4'/><rect x='0' y='12' width='84' height='8'/></g><rect x='0' y='20' width='84' height='4' fill='%23d8ecf8'/></svg>"),
    linear-gradient(var(--sky-hi), var(--sky-lo));
  background-repeat: repeat-x, repeat-x, no-repeat;
  background-size: 340px 76px, 150px 18px, 100% 100%;
  background-position: 0 7vh, 90px 30vh, 0 0;
}

@media (prefers-reduced-motion: no-preference) {
  body::before {
    animation: px-cloud-drift 240s linear infinite;
  }
}

@keyframes px-cloud-drift {
  from {
    background-position: 0 7vh, 90px 30vh, 0 0;
  }
  to {
    background-position: 680px 7vh, 540px 30vh, 0 0;
  }
}

body[data-cozy-theme="night"]::before {
  opacity: 1;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='28' shape-rendering='crispEdges'><g fill='%234a5880'><rect x='20' y='0' width='24' height='4'/><rect x='12' y='4' width='40' height='4'/><rect x='56' y='4' width='16' height='4'/><rect x='4' y='8' width='76' height='4'/><rect x='0' y='12' width='84' height='8'/></g><rect x='0' y='20' width='84' height='4' fill='%233a4568'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='100' shape-rendering='crispEdges'><g fill='%23f5f0dc'><rect x='12' y='14' width='3' height='3'/><rect x='48' y='6' width='2' height='2'/><rect x='84' y='26' width='3' height='3'/><rect x='120' y='10' width='2' height='2'/><rect x='30' y='58' width='2' height='2'/><rect x='100' y='70' width='3' height='3'/><rect x='66' y='42' width='2' height='2'/><rect x='8' y='84' width='2' height='2'/></g></svg>"),
    linear-gradient(var(--sky-hi), var(--sky-lo));
  background-repeat: repeat-x, repeat, no-repeat;
  background-size: 260px 34px, 280px 200px, 100% 100%;
  background-position: 0 6vh, 0 0, 0 0;
  animation: none;
}

body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  height: 96px;
  z-index: -1;
  opacity: 1;
  pointer-events: none;
  image-rendering: pixelated;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='64' shape-rendering='crispEdges'><rect x='16' y='2' width='12' height='2' fill='%2359371b'/><rect x='16' y='4' width='2' height='44' fill='%2359371b'/><rect x='26' y='4' width='2' height='44' fill='%2359371b'/><rect x='18' y='4' width='8' height='44' fill='%23e6c084'/><rect x='0' y='14' width='48' height='2' fill='%2359371b'/><rect x='0' y='16' width='48' height='6' fill='%23d9a865'/><rect x='0' y='22' width='48' height='2' fill='%2359371b'/><rect x='0' y='44' width='8' height='4' fill='%2347a335'/><rect x='16' y='44' width='8' height='4' fill='%2347a335'/><rect x='32' y='44' width='8' height='4' fill='%2347a335'/><rect x='0' y='48' width='48' height='16' fill='%2347a335'/><rect x='6' y='54' width='4' height='4' fill='%232f7a24'/><rect x='28' y='52' width='4' height='4' fill='%232f7a24'/><rect x='40' y='56' width='4' height='4' fill='%232f7a24'/><rect x='14' y='50' width='2' height='4' fill='%2368c04e'/><rect x='36' y='50' width='2' height='4' fill='%2368c04e'/></svg>");
  background-repeat: repeat-x;
  background-size: 72px 96px;
  background-position: 0 0;
}

body[data-cozy-theme="night"]::after {
  filter: brightness(0.5) saturate(0.8);
}

@media (max-width: 720px) {
  body::after {
    height: 64px;
    background-size: 48px 64px;
  }
}

/* ---------- C. 基础件：按钮 / 输入 / 焦点 / 选区 / 滚动条 / 代码 ---------- */

::selection {
  background: var(--gold);
  color: #4c2b12;
}

::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--wood);
  border: 3px solid var(--parchment-deep);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--wood-hi);
}

button,
.secondary-link {
  min-height: 40px;
  border: 3px solid var(--wood-dark);
  border-radius: 0;
  background: var(--gold);
  color: #4c2b12;
  letter-spacing: 0.02em;
  transition: background-color 80ms steps(2, jump-none);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.16),
    0 4px 0 var(--wood-dark);
}

button:hover,
.secondary-link:hover {
  background: var(--gold-hi);
}

button:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.16),
    0 0 0 var(--wood-dark);
}

button:disabled {
  opacity: 0.55;
}

.secondary-button,
.secondary-link {
  background: var(--parchment-hi);
  color: var(--ink);
  border: 3px solid var(--wood-lo);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.25),
    inset 0 -4px 0 rgba(0, 0, 0, 0.1),
    0 4px 0 var(--wood-lo);
}

.secondary-button:hover,
.secondary-link:hover {
  background: var(--parchment);
}

input,
textarea,
select {
  border: 3px solid var(--wood-lo);
  border-radius: 0;
  background: var(--parchment-hi);
  color: var(--ink);
  box-shadow: inset 0 3px 0 rgba(89, 55, 27, 0.14);
}

textarea::placeholder,
input::placeholder {
  color: var(--muted);
  opacity: 1;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* 代码与调试证据区保留真等宽字体（边界信息必须易读，不游戏化） */
pre,
code,
kbd,
samp,
.mini-output,
.audit-json,
.admin-transcript {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.markdown-body pre {
  background: var(--code);
  color: #ece6f8;
  border: 3px solid var(--wood-dark);
  border-radius: 0;
}

.markdown-body code {
  background: var(--parchment-deep);
  border: 1px solid var(--wood-lo);
  border-radius: 0;
  color: var(--soft-text);
}

.markdown-body pre code {
  background: transparent;
  border: 0;
  color: inherit;
}

.markdown-body a {
  color: var(--water);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-body blockquote {
  border-left: 4px solid var(--wood);
  background: var(--parchment-deep);
  border-radius: 0;
}

/* ---------- D. 木框面板（两档） ---------- */

/* 一档：整块木框菜单（页面级容器与商品卡） */
.topbar,
.side-rail,
.analysis-drawer,
.admin-panel,
.plan-card,
.credit-card,
.product-card,
.feature-card,
.knowledge-card,
.town-card,
.cozy-panel,
.network-membership-card,
.backpack-expansion-card,
.account-popover,
.credit-section,
.network-search-panel {
  background: var(--parchment);
  border: 3px solid var(--wood-dark);
  border-radius: 0;
  box-shadow:
    inset 3px 3px 0 0 var(--wood-hi),
    inset -3px -3px 0 0 var(--wood-lo),
    inset 0 0 0 6px var(--wood),
    inset 0 0 0 8px var(--wood-dark),
    0 6px 0 rgba(43, 24, 8, 0.3);
}

.topbar,
.analysis-drawer,
.admin-panel,
.credit-section,
.network-search-panel {
  padding: 18px;
}

.chat-card {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.task-desk {
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* 二档：轻量小件（嵌套面板、列表项、便签） */
.panel-section,
.session-notice,
.thinking-card,
.audit-card,
.cozy-card,
.cozy-row,
.conversation-item,
.source-item,
.admin-turn-item,
.attachment-chip,
.message-flight-bubble,
.network-draft,
.admin-detail-card {
  background: var(--parchment-hi);
  border: 2px solid var(--wood-lo);
  border-radius: 0;
  box-shadow: 0 3px 0 rgba(43, 24, 8, 0.18);
}

.mini-output {
  background: var(--parchment-deep);
  border: 2px solid var(--wood-lo);
  border-radius: 0;
  color: var(--soft-text);
}

/* ---------- E. 顶栏 / 侧栏 / 菜单 ---------- */

.topbar {
  backdrop-filter: none;
}

.brand-kicker,
.eyebrow {
  color: var(--green);
  letter-spacing: 0.08em;
}

.site-nav a {
  color: var(--soft-text);
  border: 2px solid transparent;
  border-radius: 0;
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--parchment-hi);
  border-color: var(--wood-lo);
  color: var(--ink);
}

.site-nav a.active {
  background: var(--gold);
  border-color: var(--wood-dark);
  color: #4c2b12;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.spark-mark {
  border-radius: 0;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'><g fill='%23ffc93c'><rect x='7' y='1' width='2' height='2'/><rect x='6' y='3' width='4' height='2'/><rect x='1' y='5' width='14' height='2'/><rect x='2' y='7' width='12' height='2'/><rect x='4' y='9' width='8' height='2'/><rect x='3' y='11' width='4' height='2'/><rect x='9' y='11' width='4' height='2'/><rect x='2' y='13' width='3' height='2'/><rect x='11' y='13' width='3' height='2'/></g></svg>")
    center / contain no-repeat;
  image-rendering: pixelated;
  box-shadow: none;
}

.avatar-mark {
  border-radius: 0;
  background: var(--parchment-hi);
  border: 2px solid var(--wood-dark);
  color: var(--ink);
}

.menu-action {
  border-radius: 0;
  color: var(--ink);
}

.menu-action:hover {
  background: var(--gold-hi);
  color: #4c2b12;
}

.menu-separator {
  border-top: 2px dashed var(--wood);
  background: none;
}

.menu-note {
  color: var(--muted);
}

.conversation-item:hover {
  background: var(--parchment);
}

.conversation-item.active {
  background: var(--gold-hi);
  border-color: var(--wood-dark);
  color: #4c2b12;
}

.rail-action,
.rail-expand-button,
.rail-icon-button {
  border-radius: 0;
}

.account-tier-label {
  background: var(--parchment-deep);
  border: 1px solid var(--wood-lo);
  border-radius: 0;
  color: var(--soft-text);
}

/* ---------- F. 对话工作台：招牌元素 = 星露谷木质对话框 ---------- */

#heroGreeting {
  color: var(--ink);
  text-shadow: 0 3px 0 rgba(89, 55, 27, 0.15);
}

#heroGreeting::before {
  content: "";
  display: inline-block;
  width: 26px;
  height: 26px;
  margin-right: 10px;
  vertical-align: -3px;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'><g fill='%23ffc93c'><rect x='7' y='1' width='2' height='2'/><rect x='6' y='3' width='4' height='2'/><rect x='1' y='5' width='14' height='2'/><rect x='2' y='7' width='12' height='2'/><rect x='4' y='9' width='8' height='2'/><rect x='3' y='11' width='4' height='2'/><rect x='9' y='11' width='4' height='2'/><rect x='2' y='13' width='3' height='2'/><rect x='11' y='13' width='3' height='2'/></g></svg>")
    center / contain no-repeat;
  image-rendering: pixelated;
}

.task-status-row span {
  background: var(--green-soft);
  border: 2px solid var(--green);
  border-radius: 0;
  color: var(--green-dark);
}

.composer-shell {
  background: var(--parchment-hi);
  border: 3px solid var(--wood-dark);
  border-radius: 0;
  box-shadow:
    inset 0 3px 0 rgba(89, 55, 27, 0.12),
    0 4px 0 rgba(43, 24, 8, 0.25);
}

.composer textarea {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
}

.composer-icon-button {
  background: var(--parchment);
  border: 2px solid var(--wood-dark);
  border-radius: 0;
  color: var(--ink);
  box-shadow: 0 3px 0 var(--wood-dark);
  min-height: 34px;
}

.composer-icon-button:hover {
  background: var(--gold-hi);
}

.model-pill {
  background: var(--gold);
  border: 2px solid var(--wood-dark);
  border-radius: 0;
  color: #4c2b12;
}

.chat-log {
  background: transparent;
}

/* 对话框：Stardew dialogue box */
.message .role {
  color: var(--muted);
  letter-spacing: 0.06em;
}

.message .bubble {
  border-radius: 0;
  border: 3px solid var(--wood-dark);
  background: var(--parchment-hi);
  box-shadow:
    inset 0 0 0 2px var(--parchment-hi),
    inset 0 -4px 0 rgba(89, 55, 27, 0.12),
    0 4px 0 rgba(43, 24, 8, 0.22);
  padding: 12px 16px;
  line-height: 1.75;
  font-size: 16px;
}

.message.assistant .bubble {
  background: var(--bubble);
}

.message.assistant .bubble::before {
  content: "";
  float: left;
  width: 38px;
  height: 38px;
  margin: 2px 10px 4px 0;
  background:
    var(--parchment)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'><rect width='16' height='16' fill='%23fcf0d2'/><g fill='%233a2a1e'><rect x='3' y='1' width='10' height='2'/><rect x='2' y='3' width='12' height='2'/><rect x='2' y='5' width='3' height='2'/><rect x='11' y='5' width='3' height='2'/></g><rect x='4' y='5' width='8' height='6' fill='%23f5cf9f'/><rect x='5' y='7' width='2' height='2' fill='%23241609'/><rect x='9' y='7' width='2' height='2' fill='%23241609'/><rect x='7' y='10' width='2' height='1' fill='%23b4713d'/><rect x='6' y='11' width='4' height='1' fill='%23f5cf9f'/><rect x='3' y='12' width='10' height='4' fill='%232f7a8a'/><rect x='6' y='12' width='4' height='1' fill='%23245d6b'/></svg>")
    center / 32px 32px no-repeat;
  border: 2px solid var(--wood-dark);
  image-rendering: pixelated;
}

.message.user .bubble {
  background: var(--panel-soft);
  border-color: var(--wood-dark);
}

.message.pending .bubble {
  border-style: solid;
  color: var(--muted);
}

.message.pending .bubble::after {
  content: "▼";
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  color: var(--wood-dark);
}

@media (prefers-reduced-motion: no-preference) {
  .message.pending .bubble::after {
    animation: px-blink 1s steps(2, jump-none) infinite;
  }
}

@keyframes px-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.message.failed .bubble {
  border-color: var(--berry);
  background: var(--panel-soft);
}

.message.failed .bubble::before {
  display: none;
}

.session-notice {
  color: var(--soft-text);
}

.analysis-drawer > summary {
  color: var(--soft-text);
  cursor: pointer;
}

.trace-grid dt {
  color: var(--green);
}

.source-title {
  color: var(--ink);
}

.source-path {
  color: var(--muted);
}

/* ---------- G. 页面卡片族与后台 ---------- */

.page-heading h2,
.cozy-heading h2 {
  color: var(--ink);
}

.page-heading p,
.cozy-heading p {
  color: var(--soft-text);
}

.town-board .town-card {
  padding: 18px;
}

.admin-table {
  border: 2px solid var(--wood-dark);
  border-radius: 0;
}

.admin-table th {
  background: var(--wood);
  color: #fdf3da;
}

.admin-table tr:nth-child(even) td {
  background: var(--parchment-hi);
}

.admin-turn-item:hover {
  background: var(--parchment);
}

.admin-turn-item.active {
  background: var(--gold-hi);
  color: #4c2b12;
  border-color: var(--wood-dark);
}

/* 危险/销毁类操作保持醒目直白（SSOT: 不游戏化风险） */
#clearHistory,
.danger-button,
button[data-danger] {
  background: var(--berry);
  color: #fff6ec;
  border-color: #5c1620;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.22),
    inset 0 -4px 0 rgba(0, 0, 0, 0.22),
    0 4px 0 #5c1620;
}

#clearHistory:hover,
.danger-button:hover,
button[data-danger]:hover {
  background: #d04a5c;
}

/* ---------- H. 杂项与守底 ---------- */

.capacity-track {
  background: var(--parchment-deep);
  border: 2px solid var(--wood-dark);
  border-radius: 0;
}

.capacity-fill {
  background: var(--grass);
  border-radius: 0;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.3);
}

.cozy-panel,
.town-card {
  background: var(--parchment);
}

img {
  image-rendering: auto;
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }
  .message.pending .bubble::after {
    animation: none;
  }
  button:active {
    transform: none;
  }
}

/* ---------- I. 压制历史改版层（Nunito/Trebuchet/绿渐变一代） ---------- */

body,
button,
input,
textarea,
select {
  font-family:
    "Fusion Pixel SC", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

body,
body[data-cozy-theme="night"] {
  background: transparent;
}

.home-hero h2,
.page-heading h2,
.cozy-heading h2 {
  font-family: inherit;
  font-weight: 400;
  font-size: clamp(30px, 4.6vw, 52px);
  text-shadow: 0 4px 0 rgba(89, 55, 27, 0.18);
}

body[data-cozy-theme="night"] .home-hero h2,
body[data-cozy-theme="night"] .page-heading h2,
body[data-cozy-theme="night"] .cozy-heading h2 {
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45);
}

#sendButton {
  min-width: 80px;
  min-height: 44px;
  border: 3px solid var(--wood-dark);
  border-radius: 0;
  background: var(--gold);
  color: #4c2b12;
  font-weight: 400;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.16),
    0 4px 0 var(--wood-dark);
}

#sendButton:hover {
  filter: none;
  transform: none;
  background: var(--gold-hi);
}

#sendButton:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.16),
    0 0 0 var(--wood-dark);
}

#sendButton:disabled {
  background: var(--parchment-deep);
  color: var(--muted);
}

/* eyebrow 徽章统一羊皮纸材质 */
.home-hero .eyebrow,
.page-heading .eyebrow,
.cozy-heading .eyebrow,
.brand-kicker {
  background: var(--parchment-hi);
  border: 2px solid var(--wood-lo);
  border-radius: 0;
  box-shadow: 0 2px 0 rgba(43, 24, 8, 0.15);
  color: var(--green);
  padding: 3px 10px;
  display: inline-block;
  width: fit-content;
}

/* 对话框压制旧层（含 has-chat 高特异性布局态） */
.message.user .bubble,
body[data-route="home"].has-chat .message.user .bubble {
  border: 3px solid var(--wood-dark);
  border-radius: 0;
  background: var(--panel-soft);
  color: var(--ink);
  box-shadow:
    inset 0 -4px 0 rgba(89, 55, 27, 0.12),
    0 4px 0 rgba(43, 24, 8, 0.22);
}

.message.assistant .bubble,
body[data-route="home"].has-chat .message.assistant .bubble {
  width: fit-content;
  max-width: min(880px, 100%);
  padding: 14px 18px;
  border: 3px solid var(--wood-dark);
  border-radius: 0;
  background: var(--bubble);
  color: var(--ink);
  box-shadow:
    inset 0 -4px 0 rgba(89, 55, 27, 0.12),
    0 4px 0 rgba(43, 24, 8, 0.22);
  font-size: 16px;
  line-height: 1.85;
}

.message.pending .bubble,
body[data-route="home"].has-chat .message.pending .bubble {
  padding: 14px 18px;
  border: 3px solid var(--wood-lo);
  border-radius: 0;
  background: var(--parchment-hi);
  color: var(--muted);
  box-shadow: 0 3px 0 rgba(43, 24, 8, 0.18);
}

.message.failed .bubble,
body[data-route="home"].has-chat .message.failed .bubble {
  padding: 14px 18px;
  border: 3px solid var(--berry);
  border-radius: 0;
  background: var(--panel-soft);
  color: var(--ink);
}

.message .bubble ul,
.message .bubble ol {
  padding-left: 22px;
}

.message .message-meta {
  color: var(--muted);
}

/* pending ▼ 与列表、时间戳收尾 */
.message.pending .bubble::after,
body[data-route="home"].has-chat .message.pending .bubble::after {
  content: "▼";
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  color: var(--wood-dark);
}

@media (prefers-reduced-motion: no-preference) {
  .message.pending .bubble::after,
  body[data-route="home"].has-chat .message.pending .bubble::after {
    animation: px-blink 1s steps(2, jump-none) infinite;
  }
}

.message .bubble li {
  list-style-position: outside;
}

.message .message-meta,
body[data-route="home"].has-chat .message .message-meta {
  color: var(--soft-text);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

body[data-cozy-theme="night"] .message .message-meta {
  color: var(--muted);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

/* 侧栏菜单把手统一羊皮纸材质 */
.account-menu summary {
  background: var(--parchment-hi);
  border: 2px solid var(--wood-lo);
  border-radius: 0;
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(43, 24, 8, 0.18);
}

.account-menu summary:hover {
  background: var(--parchment);
}

.account-menu[open] summary {
  background: var(--gold-hi);
  border-color: var(--wood-dark);
  color: #4c2b12;
}

/* 去掉旧层卡片顶部木纹条（与整框重复），积分包按钮统一材质 */
.credit-card::before,
.town-card::before,
.cozy-panel::before,
.panel-section::before,
.knowledge-card::before {
  display: none;
}

.credit-card button {
  background: var(--parchment-hi);
  color: var(--ink);
  border: 3px solid var(--wood-lo);
  border-radius: 0;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.25),
    inset 0 -4px 0 rgba(0, 0, 0, 0.1),
    0 4px 0 var(--wood-lo);
}

.credit-card button:hover {
  background: var(--gold-hi);
}

/* 侧栏动作钮统一材质 */
.rail-action,
.rail-expand-button,
.rail-icon-button,
#newConversationButton {
  background: var(--parchment-hi);
  border: 2px solid var(--wood-lo);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(43, 24, 8, 0.18);
}

.rail-action:hover,
.rail-expand-button:hover,
.rail-icon-button:hover,
#newConversationButton:hover {
  background: var(--gold-hi);
}

/* 窄屏隐藏对话框头像，把横向空间留给文字 */
@media (max-width: 640px) {
  .message.assistant .bubble::before {
    display: none;
  }
}

/* 弹出菜单像素直角收尾 */
.account-menu .account-popover,
.side-settings-menu .settings-popover,
.account-popover,
.settings-popover {
  border-radius: 0;
  border: 3px solid var(--wood-dark);
  background: var(--parchment);
  box-shadow:
    inset 0 0 0 2px var(--parchment-hi),
    0 6px 0 rgba(43, 24, 8, 0.3);
}

.account-popover .menu-action,
.settings-popover .menu-action {
  border-radius: 0;
  border: 2px solid var(--wood-lo);
  background: var(--parchment-hi);
}

.account-popover .menu-action:hover,
.settings-popover .menu-action:hover {
  background: var(--gold-hi);
  border-color: var(--wood-dark);
}

/* ---------- J. 坍缩收编：原 dark 层携带的结构基底（布局属性，无视觉） ---------- */

.side-rail {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.composer-shell {
  min-height: 58px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
}

.composer textarea {
  min-height: 36px;
  max-height: 150px;
  padding: 8px 2px;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
}

.composer textarea:focus {
  outline: none;
}

.composer-primary-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  font-size: 13px;
}

.attachment-tray {
  margin: 0 0 10px;
  justify-content: center;
}

/* ---------- K. 图片附件卡片与预览弹窗（并行功能迭代的像素皮） ---------- */

.attachment-tray-heading {
  color: var(--soft-text);
}

.attachment-card {
  border: 2px solid var(--wood-lo);
  border-radius: 0;
  background: var(--parchment-hi);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(43, 24, 8, 0.18);
}

.attachment-thumb {
  border: 2px solid var(--wood-dark);
  border-radius: 0;
  background: var(--parchment-deep);
  box-shadow: none;
}

.image-preview-panel {
  border: 3px solid var(--wood-dark);
  border-radius: 0;
  background: var(--parchment);
  box-shadow:
    inset 3px 3px 0 0 var(--wood-hi),
    inset -3px -3px 0 0 var(--wood-lo),
    inset 0 0 0 6px var(--wood),
    inset 0 0 0 8px var(--wood-dark),
    0 6px 0 rgba(43, 24, 8, 0.3);
}

.image-preview-frame {
  border: 2px solid var(--wood-lo);
  border-radius: 0;
  background: var(--parchment-deep);
}

.image-preview-head h2 {
  color: var(--ink);
}

/* ---------- L. 侧栏展开态与弹出层修复 ---------- */

/* 变量宽度与奶油层网格列对齐（74 收起 / 286 展开），轨道回归变量驱动 */
:root {
  --side-rail-width: 74px;
  --side-rail-expanded: 286px;
}

.side-rail {
  width: var(--side-rail-width);
  z-index: 40;
}

/* 弹出层必须脱离文档流(奶油层曾改成 relative 手风琴)、浮在内容层与输入条之上 */
.side-account-menu .account-popover,
.side-settings-menu .account-popover,
.side-settings-menu .settings-popover,
.account-popover,
.settings-popover {
  position: absolute;
  z-index: 60;
}

/* 移动端：收起=74px 细轨，展开=抽屉盖层 */
@media (max-width: 980px) {
  body.sidebar-expanded .side-rail {
    width: min(286px, calc(100vw - 18px));
    box-shadow: 12px 0 0 rgba(43, 24, 8, 0.25);
  }

  /* 抽屉展开时显示条目文字与会话记录 */
  body.sidebar-expanded .rail-label {
    display: inline;
  }

  body.sidebar-expanded .conversation-panel {
    display: grid;
  }

  body.sidebar-expanded .rail-expand-button {
    display: grid;
  }

  /* 内容必须给 74px 固定轨道让位（has-chat 态曾把 padding 压到 14px） */
  .page-view,
  body[data-route="home"].has-chat .home-view {
    padding-left: 96px;
    padding-right: 16px;
  }

  body[data-route="home"].has-chat .composer,
  body.sidebar-expanded[data-route="home"].has-chat .composer {
    margin-left: 0;
  }

  /* 窄屏下弹出层改为视口底部贴片，永不溢出 */
  body.sidebar-expanded .side-account-menu .account-popover,
  body.sidebar-expanded .side-settings-menu .account-popover,
  body.sidebar-expanded .side-settings-menu .settings-popover {
    position: fixed;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-height: min(70vh, 560px);
  }
}

/* ---------- M. 三币钱包与 Lovable 式金币计费 ---------- */

.wallet-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.wallet-card {
  position: relative;
  min-width: 0;
  min-height: 172px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border: 3px solid var(--wood-dark);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 240, 210, 0.98), rgba(239, 213, 155, 0.94));
  color: var(--ink);
  box-shadow:
    inset 3px 3px 0 0 var(--wood-hi),
    inset -3px -3px 0 0 var(--wood-lo),
    0 5px 0 rgba(43, 24, 8, 0.2);
}

.currency-orb {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  align-self: start;
  border: 2px solid rgba(43, 24, 8, 0.32);
  border-radius: 0;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.42),
    inset -2px -2px 0 rgba(43, 24, 8, 0.14),
    0 3px 0 rgba(43, 24, 8, 0.18);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.wallet-card.diamond .currency-orb {
  background: linear-gradient(135deg, #edf8ff 0%, #8ed5ff 42%, #7b67f0 100%);
  color: #1f2d5a;
}

.wallet-card.gold .currency-orb {
  background: linear-gradient(135deg, var(--gold-hi) 0%, var(--gold) 52%, var(--gold-lo) 100%);
  color: #5b3600;
}

.wallet-card.silver .currency-orb {
  background: linear-gradient(135deg, #ffffff 0%, #d7dde2 56%, #9ca7af 100%);
  color: #3b4650;
}

.wallet-kicker {
  display: block;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.wallet-card h3 {
  margin: 3px 0 8px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.15;
  font-weight: 900;
}

.wallet-card p {
  margin: 0 0 10px;
  color: var(--soft-text);
  font-size: 13px;
  line-height: 1.55;
}

.wallet-balance {
  width: fit-content;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 2px solid rgba(43, 24, 8, 0.14);
  padding: 3px 9px;
  background: rgba(255, 255, 255, 0.38);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.wallet-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.wallet-rule-card {
  grid-template-columns: 1fr;
  background:
    linear-gradient(180deg, rgba(224, 248, 226, 0.98), rgba(195, 231, 191, 0.94));
}

.wallet-rule-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--soft-text);
  font-size: 12px;
  line-height: 1.45;
}

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

.account-wallet-item {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border: 2px solid var(--wood-lo);
  background: var(--parchment-hi);
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(43, 24, 8, 0.12);
}

.account-wallet-item b {
  color: var(--soft-text);
  font-size: 12px;
  font-weight: 850;
}

.account-wallet-item strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-wallet-item.diamond {
  border-color: #8f7df2;
}

.account-wallet-item.gold {
  border-color: var(--gold-lo);
}

.account-wallet-item.silver {
  border-color: #9ca7af;
}

@media (max-width: 1180px) {
  .wallet-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .wallet-overview {
    grid-template-columns: 1fr;
  }

  .account-wallet-mini {
    grid-template-columns: 1fr;
  }
}

/* ---------- N. 小镇地图 / 信件 / 皮肤门控 ---------- */

/* N1 皮肤门控：像素皮隐藏 pro 专属菜单项 */
[data-pro-skin-only] {
  display: none !important;
}

/* N2 地图视图全屏化 */
body[data-route="map"] .topbar,
body[data-route="map"] .side-rail,
body[data-route="map"] #townEdgeTab {
  display: none !important;
}

body[data-route="map"]::after {
  display: none;
}

#mapView {
  position: fixed;
  inset: 0;
  height: 100dvh;
  z-index: 60;
  padding: 0;
  margin: 0;
  background: linear-gradient(var(--sky-hi), var(--sky-lo));
  overflow: hidden;
}

.town-stage {
  position: relative;
  width: 100%;
  height: 100%;
}

#townCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

/* N3 HUD */
.town-hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 4;
}

.town-location-plate {
  pointer-events: auto;
  background: var(--wood);
  border: 3px solid var(--wood-dark);
  color: #fff8ec;
  padding: 4px 12px;
  font-size: 15px;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 2px 0 var(--wood-hi), inset 0 -2px 0 var(--wood-lo);
}

.town-exit-button {
  pointer-events: auto;
  margin-left: auto;
  background: var(--parchment);
  border: 3px solid var(--wood-dark);
  color: var(--ink);
  padding: 4px 12px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: inset 0 2px 0 var(--parchment-hi);
}

.town-exit-button:hover {
  filter: brightness(1.05);
}

.town-hud-envelope {
  pointer-events: auto;
  background: var(--gold);
  border: 3px solid var(--wood-dark);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  padding: 4px 10px;
  cursor: pointer;
  animation: town-envelope-bounce 1.6s infinite;
}

/* N4 互动提示条 */
.town-hint {
  position: absolute;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: rgba(20, 14, 8, 0.82);
  color: #ffe9bd;
  border: 2px solid var(--wood-dark);
  padding: 4px 14px;
  font-size: 14px;
  z-index: 4;
  pointer-events: none;
  white-space: nowrap;
}

/* N5 D-pad 与动作键：粗指针设备 */
.town-dpad,
.town-action-btn {
  display: none;
  z-index: 5;
}

@media (pointer: coarse) {
  .town-dpad {
    display: grid;
    position: absolute;
    left: calc(14px + env(safe-area-inset-left, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    gap: 2px;
  }

  .town-dpad button {
    background: rgba(58, 38, 20, 0.78);
    border: 2px solid var(--wood-dark);
    color: #ffe9bd;
    font-size: 18px;
    font-family: inherit;
    touch-action: none;
    padding: 0;
  }

  .town-dpad button[data-dir="up"] { grid-area: 1 / 2; }
  .town-dpad button[data-dir="left"] { grid-area: 2 / 1; }
  .town-dpad button[data-dir="right"] { grid-area: 2 / 3; }
  .town-dpad button[data-dir="down"] { grid-area: 3 / 2; }

  .town-action-btn {
    display: block;
    position: absolute;
    right: calc(18px + env(safe-area-inset-right, 0px));
    bottom: calc(34px + env(safe-area-inset-bottom, 0px));
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--gold);
    border: 3px solid var(--wood-dark);
    color: var(--ink);
    font-size: 20px;
    font-family: inherit;
    touch-action: none;
  }

  .town-action-btn.is-armed {
    animation: town-action-glow 0.9s infinite alternate;
  }
}

@keyframes town-action-glow {
  from { box-shadow: 0 0 0 0 rgba(255, 201, 60, 0.4); }
  to { box-shadow: 0 0 0 8px rgba(255, 201, 60, 0.05); }
}

/* N6 星露谷对话框（board/npc/shop/phone/bed 五模式共用） */
.town-dialog {
  position: absolute;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(680px, calc(100% - 24px));
  z-index: 6;
}

.town-dialog-frame {
  display: flex;
  gap: 12px;
  background: var(--parchment);
  border: 4px solid var(--wood-dark);
  box-shadow: inset 0 3px 0 var(--parchment-hi), inset 0 -3px 0 var(--parchment-deep), 0 6px 0 rgba(0, 0, 0, 0.25);
  padding: 12px;
  position: relative;
  max-height: min(46vh, 380px);
}

.town-dialog-portrait {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  background: var(--wood);
  border: 3px solid var(--wood-dark);
  display: grid;
  place-items: center;
}

.town-dialog-portrait canvas {
  image-rendering: pixelated;
}

.town-dialog-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.town-dialog-name {
  font-size: 15px;
  color: var(--wood-dark);
  font-weight: 700;
}

.town-dialog-body {
  overflow-y: auto;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  min-height: 48px;
}

.town-dialog-body p {
  margin: 0 0 6px;
}

.town-dialog-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px;
  height: 32px;
  background: var(--wood);
  border: 3px solid var(--wood-dark);
  color: #fff8ec;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.town-dialog-cursor::after {
  content: "▼";
  display: inline-block;
  margin-left: 6px;
  color: var(--wood-dark);
  animation: px-blink 1s steps(2, jump-none) infinite;
}

/* 公告板分页 */
.town-board-page h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.town-board-page .town-board-kind {
  display: inline-block;
  background: var(--gold);
  color: var(--ink);
  border: 2px solid var(--wood-dark);
  font-size: 12px;
  padding: 0 6px;
  margin-right: 6px;
}

.town-board-pager {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

/* NPC 聊天 */
.town-npc-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.town-npc-line {
  white-space: pre-wrap;
  word-break: break-word;
}

.town-npc-line.user {
  color: var(--wood-dark);
}

.town-npc-line.user::before {
  content: "你：";
  font-weight: 700;
}

.town-npc-input-row {
  display: flex;
  gap: 8px;
}

.town-npc-input-row input {
  flex: 1 1 auto;
  min-width: 0;
  background: #fffdf5;
  border: 3px solid var(--wood-dark);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  padding: 6px 10px;
}

.town-npc-input-row button,
.town-dialog-actions .pixel-button,
.town-shop-row button {
  background: var(--gold);
  border: 3px solid var(--wood-dark);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  padding: 6px 14px;
  cursor: pointer;
}

.town-npc-input-row button:disabled,
.town-shop-row button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* 酒馆商店 */
.town-shop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 2px dashed var(--wood);
}

.town-shop-row:last-child {
  border-bottom: none;
}

.town-shop-info {
  flex: 1 1 auto;
  min-width: 0;
}

.town-shop-info h5 {
  margin: 0;
  font-size: 15px;
}

.town-shop-info p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.town-shop-price {
  flex: 0 0 auto;
  color: var(--wood-dark);
  font-size: 14px;
  white-space: nowrap;
}

.town-shop-row .is-active {
  color: var(--green-dark);
  font-size: 14px;
}

/* 手机 */
.town-phone-friend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 2px dotted var(--wood);
}

.town-phone-friend:last-child {
  border-bottom: none;
}

.presence-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  background: var(--muted);
  border: 2px solid var(--wood-dark);
}

.presence-dot.online {
  background: var(--green);
}

.town-phone-friend .friend-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.town-phone-friend .friend-state {
  font-size: 13px;
  color: var(--muted);
}

.town-phone-letters {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 3px solid var(--wood);
}

/* 场景过渡 */
.town-fade {
  position: absolute;
  inset: 0;
  background: #0b0805;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s steps(5);
  z-index: 8;
}

.town-fade.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* N7 首页小镇木牌入口 */
#townEdgeTab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--wood);
  border: 3px solid var(--wood-dark);
  border-right: none;
  color: #fff8ec;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  box-shadow: inset 0 2px 0 var(--wood-hi), inset 0 -2px 0 var(--wood-lo);
  writing-mode: vertical-rl;
  text-orientation: upright;
}

body[data-route="home"] #townEdgeTab {
  display: flex;
}

#townEdgeTab:hover {
  filter: brightness(1.08);
}

#townEdgeTab .town-tab-arrow {
  writing-mode: horizontal-tb;
  animation: town-tab-nudge 1.4s ease-in-out infinite;
}

@keyframes town-tab-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-4px); }
}

/* N8 信封徽标（全路由） */
#letterEnvelope {
  position: fixed;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold);
  border: 3px solid var(--wood-dark);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  animation: town-envelope-bounce 1.6s infinite;
}

#letterEnvelope .envelope-count {
  background: var(--berry);
  color: #fff;
  font-size: 12px;
  min-width: 18px;
  text-align: center;
  border: 2px solid var(--wood-dark);
  padding: 0 3px;
}

@keyframes town-envelope-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* N9 信纸卡与读信确认 */
.letter-card {
  margin: 10px auto;
  width: min(440px, 100%);
  background: var(--parchment);
  border: 3px solid var(--wood-dark);
  box-shadow: inset 0 2px 0 var(--parchment-hi), 0 4px 0 rgba(0, 0, 0, 0.18);
  padding: 14px;
}

.letter-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px dashed var(--wood);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.letter-stamp {
  font-size: 22px;
  background: var(--gold);
  border: 2px solid var(--wood-dark);
  padding: 2px 8px;
}

.letter-kicker {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.letter-card-head h4 {
  margin: 0;
  font-size: 17px;
  color: var(--ink);
}

.letter-body {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.letter-card-actions {
  display: flex;
  gap: 10px;
}

.letter-card.letter-sent,
.letter-card.letter-dismissed {
  opacity: 0.85;
}

.letter-sent-note {
  font-size: 14px;
  color: var(--green-dark);
}

.letter-ask-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* N10 头像选择器（居民资料） */
.avatar-picker {
  border: 3px solid var(--wood);
  padding: 10px 12px;
  margin: 0;
}

.avatar-picker legend {
  font-size: 14px;
  color: var(--wood-dark);
  padding: 0 6px;
}

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

.avatar-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 3px solid transparent;
  padding: 8px 4px;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
}

.avatar-option img {
  image-rendering: pixelated;
  width: 32px;
  height: 48px;
}

.avatar-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.avatar-option:has(input:checked) {
  border-color: var(--gold);
  background: rgba(255, 201, 60, 0.12);
}

/* N11 移动端与动效偏好 */
@media (max-width: 720px) {
  .town-dialog-frame {
    max-height: 52vh;
  }

  .town-dialog-portrait {
    width: 56px;
    height: 56px;
  }

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

@media (prefers-reduced-motion: reduce) {
  #letterEnvelope,
  .town-hud-envelope,
  #townEdgeTab .town-tab-arrow,
  .town-action-btn.is-armed {
    animation: none;
  }
}
