/* =====================================================================================
   猫语测试台样式（内部工具，不随客户端交付）
   - 设计基调：暖沙色 + 深墨文字，贴近"猫"的内容调性，但克制、不做视觉噪音
   - 断点：320 / 375 / 768 / 1024 / 1440 均可用，无横向滚动
   - 无外部字体/CDN，内网可离线打开
   ===================================================================================== */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f4f0e9;
  --line: #e6dfd4;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #6b7280;
  --brand: #b45309;
  --brand-soft: #fdf1e3;
  --ok: #047857;
  --ok-soft: #e7f6ef;
  --warn: #b45309;
  --warn-soft: #fdf1e3;
  --err: #b91c1c;
  --err-soft: #fdecec;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(31, 41, 55, 0.06), 0 8px 24px rgba(31, 41, 55, 0.05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(12px, 3vw, 28px);
  background: rgba(250, 247, 242, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(145deg, #f6c987, #d97706);
  display: grid; place-items: center;
  font-size: 15px; color: #3b2f1c; font-weight: 700;
  flex: none;
}
.brand-title { font-weight: 650; letter-spacing: 0.2px; }
.brand-sub { color: var(--ink-3); font-size: 12px; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- 布局 ---------- */
.page { padding: clamp(14px, 3vw, 28px); max-width: 1280px; margin: 0 auto; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) {
  .grid-2 { grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); align-items: start; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(14px, 2vw, 18px);
  min-width: 0;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 650; margin: 0; }
.card-hint { color: var(--ink-3); font-size: 12px; }

/* ---------- 表单控件 ---------- */
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; color: var(--ink-2); font-size: 12px; margin-bottom: 4px; }
input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(180, 83, 9, 0.35);
  outline-offset: 1px;
  border-color: var(--brand);
}

button {
  font: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:focus-visible { outline: 2px solid rgba(180, 83, 9, 0.5); outline-offset: 2px; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover:not(:disabled) { background: #9a4708; }
button.ghost { background: transparent; }
button.danger { border-color: #f0c4c4; color: var(--err); background: var(--err-soft); }
button.small { padding: 4px 8px; font-size: 12px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.spacer { flex: 1 1 auto; }

/* ---------- 状态与徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; line-height: 1.6;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe6d5; }
.badge.err { background: var(--err-soft); color: var(--err); border-color: #f3c4c4; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f0d6b4; }
.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

/* ---------- 上传区 ---------- */
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--brand); background: var(--brand-soft); }
.dropzone strong { display: block; margin-bottom: 4px; }
.preview {
  margin-top: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.preview img { display: block; width: 100%; max-height: 320px; object-fit: contain; background: #fff; }

/* ---------- 玩法入口 ---------- */
.types { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.type-card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  text-align: left;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
.type-card:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.type-card[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.type-card .t-title { font-weight: 620; }
.type-card .t-sub { color: var(--ink-3); font-size: 12px; }
.type-card .t-type { font-family: var(--mono); font-size: 11px; color: var(--brand); }
.t-cover-wrap {
  position: relative;
  display: grid; place-items: center;
  width: 100%; aspect-ratio: 4 / 3;
  border-radius: 6px; overflow: hidden;
  background: linear-gradient(145deg, #f7ead7, #efe2cd);
}
.t-cover-wrap .t-cover {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.t-cover-wrap .t-fallback {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px;
  color: #a06a25; text-transform: uppercase;
}
/* 封面加载失败（后台误配、测试占位地址）：隐藏坏图，保留占位底色 + type 文案 */
.t-cover-wrap.noimg .t-cover { display: none; }

/* ---------- 结果渲染 ---------- */
.result-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.score-hero { display: flex; align-items: baseline; gap: 10px; }
.score-hero .num { font-size: 40px; font-weight: 700; line-height: 1; color: var(--brand); }
.score-hero .of { color: var(--ink-3); }

.bars { display: grid; gap: 8px; margin: 10px 0; }
.bar-item { display: grid; gap: 4px; }
.bar-item .bar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #f6c987, #d97706); border-radius: 99px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  background: var(--brand-soft); color: #8a4106;
  border: 1px solid #f0d6b4; border-radius: 999px;
  padding: 2px 10px; font-size: 12.5px;
}

.kv { display: grid; grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); gap: 6px 12px; margin: 8px 0; }
.kv dt { color: var(--ink-3); font-size: 12.5px; }
.kv dd { margin: 0; min-width: 0; }

.icons { letter-spacing: 2px; font-size: 16px; }
.icons .off { opacity: 0.18; }

ul.notes { margin: 6px 0 0; padding-left: 18px; }
ul.notes li { margin: 2px 0; }

.radar-wrap { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .radar-wrap { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); align-items: center; } }
.radar-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 6px; }
.radar-box canvas { display: block; width: 100%; height: 260px; }

details.raw { margin-top: 12px; }
details.raw summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
pre.json {
  margin: 8px 0 0;
  padding: 12px;
  background: #1f2937;
  color: #e5e7eb;
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 420px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 表格（调试记录） ---------- */
table.records { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.records th, table.records td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.records th { color: var(--ink-3); font-weight: 600; }
table.records td.wrap { white-space: normal; }
.table-scroll { overflow-x: auto; }

/* ---------- 提示条 ---------- */
.note {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--brand-soft);
  border: 1px solid #f0d6b4;
  color: #7c3d06;
  font-size: 12.5px;
}
.note.err { background: var(--err-soft); border-color: #f3c4c4; color: #7f1d1d; }
.note.ok { background: var(--ok-soft); border-color: #bfe6d5; color: #065f46; }

/* 固定顶栏会盖住 scrollIntoView 的目标，留出滚动余量（窄屏顶栏会换行，留更多） */
#resultCard { scroll-margin-top: 84px; }
@media (max-width: 640px) { #resultCard { scroll-margin-top: 132px; } }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(180, 83, 9, 0.25);
  border-top-color: var(--brand);
  display: inline-block; vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), #ece6dc, var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty { text-align: center; color: var(--ink-3); padding: 22px 8px; font-size: 13px; }

/* 顶部小工具条里的输入框在窄屏也要可用 */
.inline-field { display: flex; align-items: center; gap: 6px; }
.inline-field > span { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.inline-field input, .inline-field select { width: auto; min-width: 120px; }
@media (max-width: 480px) {
  .inline-field input, .inline-field select { min-width: 0; width: 100%; }
  .inline-field { flex: 1 1 140px; }
}
