/* 遗忘之海配装分析 — 移动优先单页（浅色主题） */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --card2: #eef2f7;
  --line: #dde3ea;
  --text: #1c2733;
  --muted: #6b7a8c;
  --accent: #1a7bf3;
  --accent2: #0d9488;
  --warn: #b45309;
  --danger: #dc2626;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
#app { max-width: 720px; margin: 0 auto; padding-bottom: 60px; overflow-x: hidden; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.brand-sub { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  font-size: 14px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center;
}
.tab.active { color: var(--text); background: var(--card2); font-weight: 600; }

/* 鉴权条 */
.auth-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 14px 0; padding: 8px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.auth-bar.hidden { display: none; }
.auth-bar input { flex: 1; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 10px 14px 0;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(16,32,48,.04);
}
.card h2 { font-size: 15px; margin-bottom: 10px; color: var(--text); }
.hint { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }

/* 主操作卡：预设 + 分析队伍（最上、相邻） */
.hero-card { background: linear-gradient(180deg, #fbfdff 0%, #f2f8ff 100%); border-color: rgba(26,123,243,.22); }
.hero-hint { margin: 10px 0 0; }

/* 船员卡片 */
.crew-item {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}
.crew-item .row { display: flex; gap: 8px; align-items: center; }
.crew-item select { flex: 1; min-width: 0; }
.crew-item .path { width: 100%; margin-top: 6px; }

/* 折叠卡（队伍/配装路径） */
.collapse-card summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 15px; font-weight: 600; color: var(--text);
}
.collapse-card summary::-webkit-details-marker { display: none; }
.collapse-card summary::after { content: "▾"; color: var(--muted); font-size: 13px; transition: transform .15s; }
.collapse-card[open] summary::after { transform: rotate(180deg); }
.collapse-card[open] summary { margin-bottom: 10px; }
.summary-hint { color: var(--muted); font-weight: 400; font-size: 12.5px; }

/* 决策点卡片 */
.dp-item {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}
.dp-item .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dp-item label { color: var(--muted); font-size: 12px; }
.dp-item select { min-width: 0; }
.dp-candidates { margin-top: 8px; }
.cand-list { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.cand-chip {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  gap: 2px; max-width: 100%;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 10px; font-size: 13px; color: var(--text);
  cursor: pointer; user-select: none; transition: border-color .12s, background .12s;
}
.cand-chip:hover { border-color: var(--accent); }
.cand-chip.selected { border-color: var(--accent); background: rgba(26,123,243,.08); }
.cand-chip .cand-name { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.cand-chip.selected .cand-name { color: var(--accent); }
.cand-chip .cand-desc {
  color: var(--muted); font-size: 12px; line-height: 1.35; max-width: 220px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cand-chip.selected .cand-desc { color: #4b6073; }
.cand-add { display: flex; gap: 6px; margin-top: 8px; }
.cand-add input { flex: 1; min-width: 90px; }
.suggest-row { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.suggest-row select { flex: 1; min-width: 0; }

/* 表单 */
input, select, textarea {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 16px; /* 16px 避免 iOS 聚焦自动放大 */
  font-family: inherit;
  min-height: 44px;
}
select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7a8c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
  padding-right: 32px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px;
  font-size: 15px; cursor: pointer; background: var(--card2); color: var(--text);
  min-height: 44px;
}
.btn:active { opacity: .85; }
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn.dashed {
  background: transparent; border: 1px dashed var(--line);
  color: var(--muted); width: 100%; margin-top: 4px;
}
.btn.small { padding: 8px 14px; font-size: 13px; min-height: 44px; }
.btn-lg { width: 100%; font-size: 16px; min-height: 52px; margin-top: 2px; }
.preset-row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn.preset {
  flex: 1; background: var(--card2); border: 1px solid var(--line);
  color: var(--text); font-weight: 600; min-height: 48px;
}
.btn.preset:hover { border-color: var(--accent); color: var(--accent); }
.ask-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.ask-row select { flex: 1; min-width: 0; }
.ask-row .btn { min-width: 88px; }

/* 思考中状态 */
.thinking {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; background: var(--card2);
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); font-size: 14px;
}
.thinking-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); animation: pulse 1.2s ease-in-out infinite;
}
.thinking-time { color: var(--accent); font-variant-numeric: tabular-nums; margin-left: auto; }
@keyframes pulse { 0%, 100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.2); } }

/* 答案区 */
.answer { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.answer .stream-cursor::after { content: "▌"; color: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.reasoning-toggle {
  color: var(--accent2); font-size: 13px; cursor: pointer; margin-bottom: 8px; user-select: none;
}
.reasoning-toggle summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.reasoning-body {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-size: 13px; color: var(--muted); white-space: pre-wrap;
  margin-bottom: 10px;
}
.err-msg { color: var(--warn); font-size: 13px; margin-top: 8px; }

/* 自查页 */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip {
  background: var(--card2); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; color: var(--muted); cursor: pointer;
  min-height: 40px; display: inline-flex; align-items: center;
}
.chip.active { border-color: var(--accent); color: var(--accent); }
.ref-results .r-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.r-item .r-title { font-weight: 600; font-size: 14px; }
.r-item .r-meta { color: var(--muted); font-size: 12px; }
.r-item .r-desc { font-size: 13px; margin-top: 3px; color: var(--text); }

/* 矩阵页 */
#matrix-content .m-empty { color: var(--muted); font-size: 14px; }
#matrix-content .m-group { margin-bottom: 16px; }
#matrix-content .m-group h3 { font-size: 14px; margin-bottom: 6px; color: var(--accent2); }
.m-combo {
  background: var(--card2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; margin-bottom: 8px; font-size: 13.5px;
}
.m-combo .m-name { font-weight: 600; }
.m-combo .m-chain { color: var(--muted); font-size: 12.5px; margin-top: 4px; white-space: pre-wrap; }

.foot {
  text-align: center; color: var(--muted); font-size: 12px;
  padding: 20px 0 10px;
}
.hidden { display: none !important; }

/* 配装参考（离线分析） */
.tr-team { margin-bottom: 4px; }
.tr-crew {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  margin: 8px 0; padding: 8px 10px;
}
.tr-crew summary { font-weight: 600; cursor: pointer; list-style: none; min-height: 40px; display: flex; align-items: center; }
.tr-crew summary::before { content: "▸ "; color: var(--muted); transition: transform .15s; }
.tr-crew[open] summary::before { transform: rotate(90deg); }
.tr-crew[open] summary { margin-bottom: 6px; }
.tr-block { margin: 6px 0; }
.tr-block h4 { font-size: 13px; color: var(--accent2); margin: 8px 0 3px; }
.tr-body { font-size: 13.5px; line-height: 1.55; color: var(--text); }
.tr-body ul { margin: 4px 0 4px 18px; padding: 0; }
.tr-body li { margin: 2px 0; }
.tr-body code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; font-size: 12px; }
.tr-body pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow-x: auto; font-size: 12px; }
