/* Xingyu design tokens. This is the only source for shared visual scales. */
:root {
  /* Brand */
  --bg: #f7f4f0;
  --card: #fffefc;
  --panel: #fffefc;
  --ink: #241f22;
  --rose: #b4536b;
  --rose-dark: #8f3f55;
  --rose-soft: #f9ecef;

  /* Neutrals */
  --text: var(--ink);
  --text-dim: #6b6259;
  --text-muted: #918a80;
  --text-faint: #b3aca2;
  --muted: var(--text-muted);
  --soft: var(--text-faint);
  --text-soft: var(--text-dim);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;

  /* Lines */
  --line: #e8ddd5;
  --line-soft: #f1ebe6;
  --line-strong: #d9cbc0;

  /* Status */
  --success: #087a4a;
  --success-soft: #e7f7ee;
  --warning: #a46508;
  --warning-soft: #fdf3e2;
  --error: #b3403a;
  --error-soft: #fbeeed;
  --green: var(--success);
  --green-soft: var(--success-soft);
  --amber: var(--warning);
  --amber-soft: var(--warning-soft);
  --red: var(--error);
  --red-soft: var(--error-soft);
  --blue2: var(--rose-dark);
  --grad: var(--rose-dark);

  /* Typography */
  --fs-xs: 12px;
  --fs-badge: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 16px;
  --lh-body: 1.7;
  --lh-heading: 1.35;
  --lh-meta: 1.5;
  --lh-copy: 1.6;
  /* 按钮等单行控件用：1.7 是给多行正文段落留的，
     单行控件继承它会让文字盒偏高、上下留白与左右留白对不上。 */
  --lh-control: 1.2;
  --fw-regular: 400;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Containers */
  --page-max: 560px;
  --page-max-wide: 720px;
  --page-gutter: 20px;

  /* Spacing */
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;

  /* Shape */
  --radius: 12px;
  --radius-sm: 8px;
  --card-padding: 16px;
  --card-gap: var(--space-12);
  --section-gap: var(--space-16);
  --control-min: 36px;
  --input-min: 34px;
  --textarea-min: 96px;
  --badge-min: 20px;
  --status-dot: 6px;
  --empty-padding-y: 48px;
  --empty-icon: 48px;
  --shadow: 0 2px 20px rgba(72, 48, 45, .05);
  --shadow-menu: 0 8px 24px rgba(56, 39, 38, .10);
}

html {
  box-sizing: border-box;
  font-size: 16px;
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
  font-weight: var(--fw-semibold);
  line-height: var(--lh-heading);
}

strong,
b {
  font-weight: var(--fw-semibold);
}

.danger-zone strong,
.error strong,
.role-card.selected strong,
.preset-card.selected strong,
.choice input:checked + span strong {
  font-weight: var(--fw-bold);
}

body main,
body .wrap {
  padding-bottom: calc(var(--space-24) + env(safe-area-inset-bottom));
}

body > footer {
  padding-top: var(--space-24);
  padding-bottom: calc(var(--space-24) + env(safe-area-inset-bottom));
}

body input:not([type="checkbox"]):not([type="radio"]),
body select {
  min-height: var(--input-min);
}

body textarea {
  min-height: var(--textarea-min);
}

body button,
body .btn,
body .primary,
body .button:not(.compact),
body .new-button {
  min-height: var(--control-min);
}

/* 按钮文字视觉居中：文字在盒内垂直居中，上下留白由 flex 产生，
   不再靠 padding 撑高度 —— 高度仍由上面的 min-height 决定。
   :not() 排除「自己管布局」的特殊按钮：grid 型（头像、菜单、额度列表项）
   和靠 padding 留出双行空间的列表项，强行改它们的 display 会破坏版式。 */
body button:not(.star-avatar):not(.me-avatar):not(.nav-menu-toggle):not(.limit-item),
body .btn:not(.star-avatar):not(.me-avatar):not(.nav-menu-toggle):not(.limit-item),
body .primary:not(.star-avatar):not(.me-avatar):not(.nav-menu-toggle):not(.limit-item),
body .button:not(.compact):not(.star-avatar):not(.me-avatar):not(.nav-menu-toggle):not(.limit-item),
body .new-button:not(.star-avatar):not(.me-avatar):not(.nav-menu-toggle):not(.limit-item) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: var(--lh-control);
  padding-top: 0;
  padding-bottom: 0;
  /* 关于任务书要求的「1px 光学补偿」：像素级实测（截按钮区域逐行扫墨迹）显示
     纯数学居中时中文墨迹为 上11 / 下13（偏上 1px），但两种补偿方案都无效——
     padding-bottom: 2px 实测偏下 2px（更差），relative/top 会连按钮盒子一起移，
     对相对留白零改善。要真正只移文字必须给按钮文字包一层 span（改 DOM），
     超出本任务范围。故不加补偿：像素级差 2px，仍满足「上下差 ≤ 2px」。 */
}

body .status:empty,
body .settings-status:empty,
body .editor-status:empty,
body .preset-status:empty,
body .image-status:empty,
body .kb-status:empty,
body .memory-editor-status:empty,
body .feedback-status:empty,
body .empty-list:empty,
body .thread-empty:empty {
  min-height: 0;
  margin-top: 0;
  margin-bottom: 0;
}

body .list:empty,
body .empty:empty,
body .loading:empty,
body .error:empty,
body .thread-empty:empty,
body .empty-list:empty {
  display: none;
}

body .panel-badge,
body .preset-tag,
body .notice-type,
body .kind,
body .relation-state,
body .memory-kind,
body .reward {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--badge-min);
  padding: var(--space-4) var(--space-8);
}

body .selected-dot,
body .status-dot,
body .notice-dot {
  width: var(--status-dot);
  height: var(--status-dot);
}

body .empty,
body .loading {
  padding: var(--empty-padding-y) var(--space-20);
}

body .empty p,
body .loading p {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

@media (max-width: 480px) {
  :root {
    --page-gutter: var(--space-16);
    --card-padding: var(--space-12);
  }
}

@media (max-width: 760px) {
  body main,
  body .wrap,
  body footer {
    padding-left: var(--page-gutter);
    padding-right: var(--page-gutter);
  }
}
