/* ============================================================
   369宇宙 App · 设计地基（Design Foundation）
   ------------------------------------------------------------
   来源：369-visual-design-system/assets/DESIGN.md + tokens.css（技能·单一事实来源）
        + App 线上现有取值（app.html 的层色 / chip / tab 高度，保持观感连续）
   版本：v1.0 · 2026-09-24
   用法：<link rel="stylesheet" href="/app/app.css">
   规矩：页面只写结构，不写色值。页面里出现硬编码颜色 = 错误。
   ============================================================ */

/* ---------- §1 令牌 ---------- */
:root {
  /* 核心色板（技能令牌） */
  --bg:        #FAF5F0;   /* 暖白底 */
  --text:      #2D2D2D;   /* 墨色 */
  --accent:    #B98E52;   /* 暖金 · 强调 */
  --lgold:     #E8D5B5;   /* 浅金 · 边框/次级强调 */
  --muted:     #6B6560;   /* 次要文字 */
  --line:      #E5DED5;   /* 分隔线 */
  --card:      #FFFFFF;   /* 卡片底 */
  --code-bg:   #F0ECE5;
  --tile:      #F3EFE8;   /* 图占位底：无图时垫在 .hero / 网格缩略图下 */
  --code-text: #7A3D27;

  /* 频率层色（App 线上取值，勿改：用户已经认这三个颜色） */
  --z147: #C8755B;   /* 落地 · 砖红 */
  --z258: #B98E52;   /* 关系 · 纸金 */
  --z369: #5B7A9D;   /* 认知 · 蓝灰 */

  /* 层色的「文字版」：同一色相压暗到在卡白 #FFF 上过 4.5:1。
     层色本身只用于色条/边框（非文字，3:1 即可），凡是当文字用就换这一组。 */
  --z147-ink: #A35E49;   /* 4.94:1 on #FFF */
  --z258-ink: #8D6B3D;   /* 4.88:1 on #FFF */
  --z369-ink: #567395;   /* 4.90:1 on #FFF */

  /* 状态色 */
  --ok:     #6F9E6F;
  --warn:   #C89B4C;
  --danger: #B4544A;

  /* 兼容别名（老代码过渡期用；迁移完成后删这一节） */
  --ink: var(--text); --ink-2: var(--muted); --ink-3: #767068; /* 4.62:1 达标 */
  --gold: #C9A84C; --gold-soft: var(--lgold); --gold-deep: var(--accent);
  --brand: #8B6F47;

  /* 字体 */
  --font-serif: Georgia, 'Noto Serif SC', 'Songti SC', serif;
  --font-kai:   'Kaiti SC', 'KaiTi', 'STKaiti', serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* 排版尺度（七级，DESIGN.md §3.1） */
  --h1: 1.75rem;      /* 28 页面主标题 */
  --h2: 1.3125rem;    /* 21 区块标题 */
  --h3: 1.125rem;     /* 18 三级标题 */
  --text-base: 1.0625rem; /* 17 正文 */
  --text-lg: 1.125rem;    /* 18 引言 */
  --text-sm: 0.9375rem;   /* 15 图注（正文下限） */
  --text-xs: 0.8125rem;   /* 13 元信息 */
  --leading: 1.9; --leading-tight: 1.4; --lh-h: 1.35; --lh-tight: 1.6;

  /* 容器 */
  --w-app: 720px; --w-content: 680px; --w-narrow: 560px;

  /* 间距 */
  --gap-xs: 10px; --gap-sm: 20px; --gap-md: 28px; --gap-lg: 48px;

  /* 圆角（三档，不加第四档） */
  --radius-sm: 6px; --radius-md: 12px; --radius-lg: 18px;

  /* 尺寸 · 触摸 */
  --tab-h:  58px;                 /* 底部导航高 */
  --tap:    44px;                 /* 最小热区（手机端） */
  --icon:   30px;                 /* 图标视觉尺寸；热区靠 .ico 补到 44 */
  --safe-b: env(safe-area-inset-bottom, 0px);

  /* 响应式 */
  --bp-mobile: 640px; --gutter-m: 20px;

  /* 动效 */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.4s;
}

/* ---------- §2 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--text-base)/var(--leading) var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--lgold); }

/* ---------- §3 排版（七级，只用这些） ---------- */
h1, .t1 { font: 700 var(--h1)/var(--lh-h) var(--font-serif); margin: 0 0 var(--gap-sm); letter-spacing: .01em; }
h2, .t2 { font: 600 var(--h2)/var(--lh-h) var(--font-serif); margin: var(--gap-md) 0 var(--gap-xs); }
h3, .t3 { font: 600 var(--h3)/1.45            var(--font-sans);  margin: var(--gap-sm) 0 var(--gap-xs); }
.t4 { font-size: var(--text-base); line-height: var(--leading); }      /* 正文 */
.t5 { font-size: var(--text-lg);   line-height: var(--leading-tight); }/* 引言 */
.t6 { font-size: var(--text-sm);   line-height: var(--lh-tight); color: var(--muted); } /* 图注 */
.t7 { font-size: var(--text-xs);   line-height: var(--lh-tight); color: var(--muted); } /* 元信息 */
.num { font-family: var(--font-serif); font-variant-numeric: tabular-nums; }

/* ---------- §4 布局 ---------- */
.app      { max-width: var(--w-app); margin: 0 auto; padding: 0 var(--gap-md) calc(var(--tab-h) + var(--safe-b) + 24px); }
.app--flush { padding: 0 0 calc(var(--tab-h) + var(--safe-b)); }  /* 整屏列表用 */
.tbar { display: flex; align-items: center; gap: 12px; padding: 16px 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 20; }
.tbar .ttl { font: 600 var(--h3)/1.4 var(--font-sans); margin: 0; }
.tbar .sub { font-size: var(--text-xs); color: var(--muted); }
.tbar .sp  { margin-left: auto; }

/* 底部导航（保持四位，勿加第五位） */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: flex; background: var(--card); border-top: 1px solid var(--line); z-index: 30; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; color: var(--muted); min-height: var(--tap); }
.tabs a.on { color: var(--accent); }

/* 吸底条：一个动作只在一处收口 */
.sticky-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b));
  display: flex; align-items: center; gap: 12px; padding: 12px var(--gap-md);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); z-index: 25; }
.sticky-bar .price { font: 700 var(--h3)/1.2 var(--font-serif); color: var(--accent); }
.sticky-bar .btn { width: auto; flex: 1; }
.sticky-bar--bare { bottom: 0; }  /* 无底栏的页面（如商品详情） */

/* 全屏覆盖层：筛选 / 搜索 / 菜单 */
.overlay { position: fixed; inset: 0; background: var(--bg); z-index: 60;
  display: flex; flex-direction: column; opacity: 0; pointer-events: none; transition: opacity .22s var(--ease); }
.overlay.on { opacity: 1; pointer-events: auto; }
.overlay .oh { display: flex; align-items: center; gap: 12px; padding: 14px var(--gutter-m); border-bottom: 1px solid var(--line); }
.overlay .ob { flex: 1; overflow-y: auto; padding: var(--gap-sm) var(--gutter-m); }

/* ---------- §5 组件 ---------- */

/* 按钮 · 五态（默认 / 悬停 / 按下 / 禁用 / 加载） */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: var(--tap); padding: 11px 18px; border: 0; border-radius: 11px;
  background: var(--brand); color: #fff; font-size: var(--text-sm); cursor: pointer; }
.btn:hover:not([disabled]) { filter: brightness(1.06); }
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn.is-loading { color: transparent; position: relative; }
.btn.is-loading::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn--ghost { background: transparent; color: var(--accent); border: 1px solid var(--lgold); }
.btn--sm { width: auto; padding: 8px 14px; min-height: 36px; font-size: var(--text-xs); }

/* 图标按钮：视觉 30 / 热区 44（DESIGN.md §4.3） */
.ico { position: relative; width: var(--icon); height: var(--icon); display: inline-flex;
  align-items: center; justify-content: center; border: 0; background: none; cursor: pointer; color: var(--muted); }
.ico::after { content: ''; position: absolute; inset: -7px; }  /* 30 + 14 = 44 热区 */

/* chip · 一行放不下就横滑（不换行） */
.chips { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-size: var(--text-xs); color: var(--muted); white-space: nowrap; cursor: pointer; }
.chip.on { border-color: var(--accent); color: var(--accent); }

/* 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; }
.card + .card { margin-top: 12px; }
.card--tap { cursor: pointer; }
.card--tap:active { background: #FBF8F4; }
.card__t { font-weight: 600; margin: 0 0 6px; }
.card__d { font-size: var(--text-sm); color: var(--muted); margin: 0; }

/* 徽章 */
.bdg { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; border: 1px solid var(--line); color: var(--muted); background: var(--card); }
.bdg.z147 { color: var(--z147-ink); border-color: color-mix(in srgb, var(--z147) 35%, var(--line)); }
.bdg.z258 { color: var(--z258-ink); border-color: color-mix(in srgb, var(--z258) 35%, var(--line)); }
.bdg.z369 { color: var(--z369-ink); border-color: color-mix(in srgb, var(--z369) 35%, var(--line)); }

/* 层色条（列表项左侧） */
.layer { border-left: 3px solid var(--line); padding-left: 15px; margin: 0 0 26px; }
.layer.z147 { border-left-color: var(--z147); }
.layer.z258 { border-left-color: var(--z258); }
.layer.z369 { border-left-color: var(--z369); }

/* 锁（灰锁=未达成 / 金锁=可升级） */
.locked { position: relative; opacity: .55; }
.lock { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); color: var(--muted); }
.lock--gold { color: var(--accent); border: 1px solid var(--lgold); border-radius: 999px; padding: 2px 9px; }

/* 盖章：引擎算的 vs 人工评的，来源必须分开署（不许混） */
.seal { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 12px; border: 1px dashed var(--line); color: var(--muted); }
.seal--engine { border-color: color-mix(in srgb, var(--z369) 45%, var(--line)); color: var(--z369-ink); border-style: solid; }
.seal--manual { border-color: var(--lgold); color: var(--accent); }
.seal--admin  { border-color: var(--line); color: var(--muted); }

/* 表格（评估报告 / 参数） */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.tbl th, .tbl td { text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-weight: 600; color: var(--muted); width: 34%; }
.tbl tr:last-child th, .tbl tr:last-child td { border-bottom: 0; }

/* 表单 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: var(--text-xs); color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--lgold); outline-offset: 0; }

/* 列表项 */
.item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item__t { font-weight: 600; margin: 0 0 4px; }
.item__d { font-size: var(--text-sm); color: var(--muted); margin: 0; }
.item__r { margin-left: auto; text-align: right; font-size: var(--text-xs); color: var(--muted); }

/* 空 / 加载 / 错 · 三态都有样子（不许留白） */
.state { text-align: center; padding: 56px 20px; color: var(--muted); }
.state__i { font-size: 34px; line-height: 1; margin-bottom: 12px; opacity: .8; }
.state__t { font-size: var(--text-base); color: var(--text); margin: 0 0 6px; }
.state__d { font-size: var(--text-sm); margin: 0 0 16px; }
.skel { background: linear-gradient(90deg, var(--line) 25%, #F2EEE8 37%, var(--line) 63%);
  background-size: 400% 100%; animation: sk 1.3s ease-in-out infinite; border-radius: var(--radius-sm); height: 14px; margin: 10px 0; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* 额度条（小恩首页） */
.quota { display: flex; align-items: center; gap: 10px; font-size: var(--text-xs); color: var(--muted); }
.quota__bar { flex: 1; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.quota__in { height: 100%; background: var(--accent); border-radius: 999px; }

/* 对话气泡 */
.msg { max-width: 86%; padding: 11px 14px; border-radius: var(--radius-md); margin: 0 0 12px; line-height: 1.75; }
.msg--me { margin-left: auto; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg--it { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }

/* 指引行（把次要入口降级成一行，别占卡片） */
.hint { font-size: var(--text-sm); color: var(--muted); padding: 12px 0; }
.hint a { color: var(--accent); }

/* ---------- §6 响应式（单断点收合，不做多档阶梯） ---------- */
@media (max-width: 640px) {
  .app { padding: 0 var(--gutter-m) calc(var(--tab-h) + var(--safe-b) + 20px); }
  h1, .t1 { font-size: 1.625rem; }   /* 28 → 26 */
  .sticky-bar { padding: 10px var(--gutter-m); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }   /* 手机端一律一列 */
}

/* ---------- §7 工具类 ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }
.sp { margin-left: auto; }
.mt-sm { margin-top: var(--gap-sm); } .mt-md { margin-top: var(--gap-md); }
.mb-sm { margin-bottom: var(--gap-sm); } .mb-md { margin-bottom: var(--gap-md); }
.muted { color: var(--muted); }
.sm { font-size: var(--text-sm); } .xs { font-size: var(--text-xs); }
.center { text-align: center; }
.hide { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
