/* 心智棱镜 PRISM · 免费页和工作台共用样式
   CSP 不允许内联样式：所有样式都在这里，JS 只改 class 和 element.style */
:root {
  --bg: #0B0B0D;
  --panel: #141518;
  --line: #2A2C31;
  --gold: #C8A96A;
  --gold-soft: rgba(200, 169, 106, 0.12);
  --text: #E8E6E1;
  --muted: #8C8A85;
  --danger: #D2705F;
  --ok: #7FA88A;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 var(--font);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold); }
button, input, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); }
.gold { color: var(--gold); }
.center { text-align: center; }

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(32px + var(--safe-b));
}
/* 底部标签栏 56px + 急救舱热线条约 30px */
.page.with-tabbar { padding-bottom: calc(120px + var(--safe-b)); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 15px; letter-spacing: 0.04em; }
.brand img { width: 28px; height: 28px; }
.top-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--gold); border-radius: var(--radius);
  color: var(--gold); text-decoration: none; font-size: 14px; white-space: nowrap;
}
.top-btn:active { background: var(--gold-soft); }

.notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 12px 0 0; padding: 10px 12px;
  border: 1px solid var(--line); border-left: 2px solid var(--gold); border-radius: var(--radius);
  background: var(--panel); font-size: 13px;
}
.notice p { flex: 1; margin: 0; }
.icon-btn {
  flex: none; width: 44px; height: 44px; margin: -10px -10px -10px 0;
  background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer;
}

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
}
.card h3 { margin: 0 0 8px; font-size: 17px; }
.card p { margin: 0 0 8px; }
.card p:last-child { margin-bottom: 0; }
.label { font-size: 12px; color: var(--gold); letter-spacing: 0.08em; margin-bottom: 4px; }

.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; margin: 12px 0 0; padding: 0 16px;
  background: none; border: 1px solid var(--gold); border-radius: var(--radius);
  color: var(--gold); font-size: 16px; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:active { background: var(--gold-soft); }
.btn.sub { border-color: var(--line); color: var(--muted); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.inline { display: inline-flex; width: auto; min-height: 44px; font-size: 14px; margin: 8px 8px 0 0; }
.btn:disabled { opacity: 0.5; cursor: default; }
.link-btn {
  background: none; border: 0; padding: 10px 4px; min-height: 44px;
  color: var(--gold); font-size: 13px; cursor: pointer; text-decoration: underline;
}

h1.hero { font-size: 26px; line-height: 1.4; margin: 36px 0 8px; font-weight: 600; }
.sub-title { color: var(--muted); margin: 0 0 20px; }
.promise { list-style: none; margin: 20px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.promise li { padding: 6px 0 6px 16px; position: relative; border-top: 1px solid var(--line); }
.promise li::before { content: ''; position: absolute; left: 0; top: 16px; width: 6px; height: 1px; background: var(--gold); }
.invite-tip { margin-top: 20px; padding: 12px; border: 1px solid var(--gold); border-radius: var(--radius); color: var(--gold); font-size: 14px; }

/* ---------- 答题 ---------- */
.quiz-head { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; min-height: 44px; }
.quiz-head .link-btn { text-decoration: none; color: var(--muted); }
.quiz-head .progress-text { font-family: var(--mono); color: var(--gold); font-size: 14px; }
.progress { height: 2px; background: var(--line); margin: 4px 0 24px; }
.progress .bar { height: 2px; background: var(--gold); width: 0; transition: width 0.2s; }
.q-text { font-size: 19px; line-height: 1.6; margin: 0 0 20px; min-height: 90px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  width: 100%; min-height: 56px; padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  text-align: left; font-size: 15px; line-height: 1.5; cursor: pointer;
}
.opt:active, .opt.on { border-color: var(--gold); background: var(--gold-soft); }

/* ---------- 结果 ---------- */
.index-box { text-align: center; padding-top: 28px; }
.index-num { font: 600 64px/1 var(--mono); color: var(--gold); }
.index-num small { font-size: 18px; color: var(--muted); margin-left: 4px; }
.level { font-size: 18px; margin-top: 8px; }
.radar { width: 100%; max-width: 340px; margin: 8px auto 0; }
.radar .grid { fill: none; stroke: var(--line); stroke-width: 1; }
.radar .axis { stroke: var(--line); stroke-width: 1; }
.radar .area { fill: var(--gold-soft); stroke: var(--gold); stroke-width: 1.5; }
.radar .area2 { fill: none; stroke: var(--text); stroke-width: 1.2; stroke-dasharray: 4 3; }
.radar .dot { fill: var(--gold); }
.radar .lbl { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.radar .val { fill: var(--gold); font-size: 11px; font-family: var(--mono); }
.legend { display: flex; justify-content: center; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend span::before { content: ''; display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--gold); margin-right: 6px; vertical-align: middle; }
.legend span.second::before { border-top: 2px dashed var(--text); }

.locked { position: relative; overflow: hidden; min-height: 130px; }
.locked .locked-body { filter: blur(6px); user-select: none; color: var(--muted); }
.locked .locked-mask {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(11, 11, 13, 0.6); text-align: center; padding: 16px;
}
.locked .locked-mask svg { width: 22px; height: 22px; stroke: var(--gold); fill: none; stroke-width: 1.5; }
.locked .locked-mask b { font-size: 16px; font-weight: 600; }
.locked .locked-mask span { font-size: 12px; color: var(--muted); }

.fit-num { font: 600 52px/1 var(--mono); color: var(--gold); text-align: center; margin: 8px 0; }
.shop-text { text-align: center; color: var(--gold); margin-top: 12px; font-size: 14px; }
.disclaimer { font-size: 12px; color: var(--muted); margin-top: 24px; }
.footer { border-top: 1px solid var(--line); margin-top: 32px; padding-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- 遮罩、弹窗、提示 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(11, 11, 13, 0.96);
  display: flex; flex-direction: column; align-items: center;
  overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-b));
}
.overlay .share-img { width: 100%; max-width: 420px; border: 1px solid var(--line); border-radius: 6px; margin-top: 8px; -webkit-touch-callout: default; }
.overlay .overlay-tip { color: var(--gold); margin: 12px 0 0; font-size: 14px; }
.overlay .close-row { width: 100%; max-width: 420px; display: flex; justify-content: flex-end; }
.overlay .loading { margin-top: 40vh; color: var(--muted); }

.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.modal pre { white-space: pre-wrap; font: 13px/1.8 var(--font); margin: 0; }
.modal .btn-row { display: flex; gap: 10px; }
.modal .btn-row .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); z-index: 70;
  transform: translateX(-50%); max-width: 86vw;
  background: #222327; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 16px; font-size: 14px; text-align: center;
}

/* ---------- 表单 ---------- */
.form-title { font-size: 22px; margin: 28px 0 4px; }
.field { margin-top: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px;
  background: #0F1012; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 16px; outline: none;
}
.field input:focus, textarea.input:focus { border-color: var(--gold); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-err, .form-err { color: var(--danger); font-size: 13px; margin-top: 4px; min-height: 0; }
.form-err:empty, .field-err:empty { display: none; }
.form-err { margin-top: 12px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--gold); flex: none; }
.check .link-btn { padding: 0; min-height: 0; display: inline; font-size: 13px; }
.switch-row { text-align: center; margin-top: 8px; }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.6; }
.count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; font-family: var(--mono); }

/* ---------- 工作台 ---------- */
.app-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 60px; }
.app-head .who { font-size: 15px; }
.app-head .no { font-family: var(--mono); font-size: 12px; color: var(--gold); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center;
  background: rgba(11, 11, 13, 0.97); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar .inner { display: flex; width: 100%; max-width: 480px; }
.tabbar button { flex: 1; min-height: 56px; background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; }
.tabbar button.on { color: var(--gold); }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 16px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; background: none; border: 0; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--gold-soft); color: var(--gold); }

.arch-head { text-align: center; padding: 20px 0 0; }
.arch-head .no { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.arch-name { font-size: 26px; font-weight: 600; margin: 8px 0 0; }
.arch-code { font-family: var(--mono); color: var(--gold); letter-spacing: 0.2em; font-size: 13px; }
.arch-line { color: var(--muted); margin: 10px 0 0; }

.dim-row { padding: 12px 0; border-top: 1px solid var(--line); }
.dim-row:first-of-type { border-top: 0; }
.dim-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dim-top .score { font-family: var(--mono); color: var(--gold); }
.dim-top .lv { font-size: 12px; color: var(--muted); margin-left: 6px; }
.bar-track { height: 4px; background: var(--line); border-radius: 2px; margin: 6px 0; }
.bar-fill { height: 4px; background: var(--gold); border-radius: 2px; width: 0; }
.dim-row p { font-size: 13px; color: var(--muted); margin: 0; }

.enemy { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 12px; }
.enemy .idx { font-family: var(--mono); color: var(--gold); font-size: 12px; }
.enemy b { display: block; font-size: 16px; margin: 4px 0; }
.enemy .why { font-size: 13px; color: var(--muted); }
.enemy .rule { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 14px; }
.actions { margin: 0; padding-left: 22px; }
.actions li { margin-top: 10px; }
.actions li::marker { color: var(--gold); font-family: var(--mono); }
.actions b { display: block; }
.actions span { font-size: 13px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 20px; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.chip.on { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }

.ai-block { border-top: 1px solid var(--line); padding: 12px 0 0; margin-top: 12px; }
.ai-block:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.ai-block p { white-space: pre-wrap; margin: 0; }
.ai-status { font-size: 13px; color: var(--muted); margin-top: 10px; }
.quota { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: right; }
.hotline {
  position: fixed; left: 0; right: 0; bottom: calc(56px + var(--safe-b)); z-index: 39;
  text-align: center; font-size: 12px; color: var(--muted);
  background: var(--bg); padding: 6px 16px; border-top: 1px solid var(--line);
}
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-of-type { border-top: 0; }
.kv span:first-child { color: var(--muted); }
.copy-box { word-break: break-all; font-family: var(--mono); font-size: 12px; background: #0F1012; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-top: 8px; }
.ok-text { color: var(--ok); font-size: 13px; margin-top: 8px; }

@media (prefers-reduced-motion: no-preference) {
  .fade { animation: fade 0.25s ease-out; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}
