/* ==========================================================================
   daikon AI · H5 品牌 GEO 诊断
   设计 token 对应 SwiftUI 的 DesignSystem/Theme.swift（kimi.css 变量）。
   移动优先；微信内置浏览器（iOS WKWebView / Android XWeb）为主目标。
   ========================================================================== */

:root {
  --ink: #101B30;
  --sub: #8A94A6;
  --muted: #9AA3B2;
  --faint: #AAB2C0;
  --canvas: #F7F8FB;
  --field: #F5F7FB;
  --track: #F0F3F9;
  --border: #EEF1F7;
  --border-soft: #EAEEF6;
  --divider: #F4F6FA;
  --brand: #3F8EF7;
  --brand-deep: #5B5BE6;
  --brand-grad: linear-gradient(135deg, #4F95F8, #5B5BE6);
  --orange: #F06A1D;
  --gold: #D9930D;
  --green: #0D9B5F;
  --red: #D9534F;
  --radius-chip: 8px;
  --radius-small: 12px;
  --radius-card: 16px;
  --radius-large: 18px;
  --radius-sheet: 22px;
  --page: 14px;
  --card-pad: 14px;
  --card-gap: 11px;
  --shadow-card: 0 4px 14px rgba(16, 27, 48, 0.06);
  --shadow-brand: 0 4px 11px rgba(80, 110, 230, 0.3);
  --sheet: 420px;
  --tabbar: 66px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: #E9EDF4;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #E9EDF4;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app {
  position: relative;
  width: 100%;
  max-width: var(--sheet);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  box-shadow: 0 0 0 1px rgba(16, 27, 48, 0.04), 0 18px 60px rgba(16, 27, 48, 0.12);
  overflow-x: hidden;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 56px;
  padding: 0 var(--page);
  background: rgba(247, 248, 251, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  box-shadow: var(--shadow-brand);
}

.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 14px; font-weight: 800; letter-spacing: -0.2px; }
.brand-copy span { font-size: 10.5px; color: var(--sub); margin-top: 2px; }

.topbar-link {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--sub);
  font-size: 12px;
  font-weight: 600;
}
.topbar-link:active { transform: scale(0.97); }

/* ---------- 页面容器 ---------- */

.view {
  flex: 1;
  padding: var(--page);
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 26px);
}

.stack { display: flex; flex-direction: column; gap: var(--card-gap); }

/* ---------- 首页 hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 20px 16px 16px;
  border-radius: var(--radius-sheet);
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(124, 137, 255, 0.55), transparent 55%),
    radial-gradient(90% 80% at 0% 100%, rgba(78, 149, 248, 0.38), transparent 60%),
    linear-gradient(135deg, #1D2D55 0%, #35479E 52%, #5B5BE6 100%);
  box-shadow: 0 12px 30px rgba(53, 71, 158, 0.22);
}

.hero::after {
  content: "";
  position: absolute;
  right: -46px;
  top: -58px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 22px rgba(255, 255, 255, 0.04), 0 0 0 46px rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.hero h1 {
  position: relative;
  z-index: 1;
  margin: 12px 0 6px;
  font-size: 25px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -0.6px;
}

.hero p {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 300px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12.5px;
  line-height: 1.65;
}

.diagnose-form {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.brand-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-size: 16px; /* 低于 16px 时 iOS 会自动放大页面 */
  outline: none;
  transition: background 0.18s, border-color 0.18s;
}
.brand-input::placeholder { color: rgba(255, 255, 255, 0.55); }
.brand-input:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.55);
}

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 48px;
  border-radius: var(--radius-card);
  background: var(--brand-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 6px 18px rgba(20, 30, 80, 0.28);
  transition: transform 0.12s, opacity 0.12s;
}
.primary-btn:active { transform: scale(0.985); opacity: 0.94; }
.primary-btn:disabled { opacity: 0.6; transform: none; }

.hero-hint {
  position: relative;
  z-index: 1;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 10.5px;
  line-height: 1.5;
}

/* ---------- 示例品牌 ---------- */

.samples { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }

.sample-chip {
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.82);
  font-size: 11.5px;
  font-weight: 600;
}
.sample-chip:active { background: rgba(255, 255, 255, 0.22); }

/* ---------- 通用卡片 ---------- */

.card {
  padding: var(--card-pad);
  border-radius: var(--radius-card);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
}
.card-title h2 { margin: 0; font-size: 14.5px; font-weight: 800; letter-spacing: -0.2px; }
.card-title span { font-size: 11px; color: var(--sub); }

.muted { color: var(--sub); }
.small { font-size: 11.5px; line-height: 1.65; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.feature {
  padding: 11px 10px;
  border-radius: var(--radius-small);
  background: var(--field);
  border: 1px solid var(--divider);
}
.feature strong { display: block; font-size: 15px; font-weight: 800; letter-spacing: -0.3px; }
.feature span { display: block; margin-top: 3px; font-size: 10.5px; color: var(--sub); line-height: 1.45; }

/* ---------- 诊断进度 ---------- */

.progress-wrap { padding: 8px 4px 4px; text-align: center; }

.scan-ring {
  position: relative;
  width: 112px;
  height: 112px;
  margin: 10px auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff 0 46%, transparent 47%),
    conic-gradient(from -90deg, var(--brand) 0 var(--p, 6%), var(--track) var(--p, 6%) 100%);
  box-shadow: 0 0 0 1px var(--border), 0 10px 26px rgba(63, 142, 247, 0.14);
}
.scan-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px dashed rgba(63, 142, 247, 0.34);
  animation: spin 7s linear infinite;
}
.scan-ring b { font-size: 24px; font-weight: 900; letter-spacing: -1px; }
.scan-ring small { display: block; margin-top: 1px; font-size: 9.5px; color: var(--sub); font-weight: 700; }

@keyframes spin { to { transform: rotate(360deg); } }

.progress-title { margin: 0; font-size: 16px; font-weight: 800; }
.progress-sub { margin: 5px 0 14px; font-size: 11.5px; color: var(--sub); line-height: 1.6; }

.progress-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.progress-bar i {
  display: block;
  height: 100%;
  width: 4%;
  border-radius: inherit;
  background: var(--brand-grad);
  transition: width 0.45s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--sub);
  font-size: 10.5px;
}

.platform-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 16px; }
.platform-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--sub);
}
.platform-chip.is-done { color: var(--green); border-color: rgba(13, 155, 95, 0.22); background: rgba(13, 155, 95, 0.06); }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--sub);
  font-size: 12.5px;
  font-weight: 600;
}
.ghost-btn:active { transform: scale(0.97); }

/* ---------- 报告 ---------- */

.report-head {
  position: relative;
  overflow: hidden;
  padding: 18px 16px;
  border-radius: var(--radius-sheet);
  background: linear-gradient(140deg, #16244A 0%, #2D3C8C 58%, #5B5BE6 100%);
  color: #fff;
}
.report-head::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -64px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}
.report-brand { font-size: 12px; color: rgba(255, 255, 255, 0.62); font-weight: 600; }
.report-head h1 { margin: 4px 0 0; font-size: 22px; font-weight: 900; letter-spacing: -0.5px; }
.report-mode { display: inline-block; margin-top: 7px; padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); font-size: 9.5px; font-weight: 700; }

.score-row { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.score-ring {
  --score: 0;
  --ring: #6FD3FF;
  position: relative;
  flex: 0 0 auto;
  width: 94px;
  height: 94px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring) calc(var(--score) * 1%), rgba(255, 255, 255, 0.16) 0);
}
.score-ring::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: #22326B;
}
.score-ring b { position: relative; font-size: 25px; font-weight: 900; letter-spacing: -1px; }
.score-ring small { position: relative; display: block; margin-top: -2px; font-size: 9px; color: rgba(255, 255, 255, 0.6); }

.score-copy { min-width: 0; }
.score-copy strong { display: block; font-size: 16px; font-weight: 800; }
.score-copy p { margin: 6px 0 0; font-size: 11.5px; line-height: 1.6; color: rgba(255, 255, 255, 0.72); }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.metric {
  padding: 10px;
  border-radius: var(--radius-small);
  background: var(--field);
  border: 1px solid var(--divider);
}
.metric b { display: block; font-size: 17px; font-weight: 900; letter-spacing: -0.4px; }
.metric span { display: block; margin-top: 2px; font-size: 10px; color: var(--sub); }

.platform-row { padding: 11px 0; border-top: 1px solid var(--divider); }
.platform-row:first-of-type { border-top: 0; padding-top: 2px; }
.platform-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.platform-line strong { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.platform-line span { flex: 0 0 auto; font-size: 10.5px; color: var(--sub); }
.bar { height: 6px; margin-top: 7px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand-grad); }
.bar.is-low i { background: linear-gradient(135deg, #F5A25D, #F06A1D); }
.platform-sub { margin-top: 6px; font-size: 10px; color: var(--faint); }

.blind-list { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; list-style: none; }
.blind-list li {
  position: relative;
  padding: 9px 10px 9px 28px;
  border-radius: var(--radius-small);
  background: rgba(240, 106, 29, 0.06);
  border: 1px solid rgba(240, 106, 29, 0.14);
  font-size: 11.5px;
  line-height: 1.55;
  color: #8A4A1C;
}
.blind-list li::before {
  content: "!";
  position: absolute;
  left: 10px;
  top: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 12px;
  text-align: center;
}

.advice { display: flex; flex-direction: column; gap: 9px; }
.advice-item { display: flex; gap: 10px; }
.advice-index {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
}
.advice-item p { margin: 0; font-size: 11.5px; line-height: 1.65; color: #3B475C; }
.advice-item strong { color: var(--ink); }

.sample-card { border: 1px solid var(--divider); border-radius: var(--radius-small); overflow: hidden; background: var(--field); }
.sample-card + .sample-card { margin-top: 7px; }
.sample-card summary {
  padding: 10px 11px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.sample-card summary::-webkit-details-marker { display: none; }
.sample-card summary::before { content: "›"; color: var(--faint); font-size: 14px; transition: transform 0.18s; }
.sample-card[open] summary::before { transform: rotate(90deg); }
.sample-card .sample-body {
  padding: 0 11px 11px;
  color: var(--sub);
  font-size: 11.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.sample-flag { margin-left: auto; flex: 0 0 auto; font-size: 9.5px; color: var(--green); font-weight: 700; }
.sample-flag.is-blind { color: var(--orange); }

.report-actions { display: flex; gap: 8px; margin-top: 3px; }
.report-actions .primary-btn { flex: 1; height: 46px; }
.report-actions .ghost-btn { flex: 0 0 auto; height: 46px; padding: 0 14px; }

.notice {
  padding: 11px 12px;
  border-radius: var(--radius-small);
  background: #FFF7ED;
  border: 1px solid #FBE3C8;
  color: #92500E;
  font-size: 11.5px;
  line-height: 1.65;
}

/* ---------- 历史 / 我的 ---------- */

.page-head { margin: 4px 2px 13px; }
.page-head h1 { margin: 0; font-size: 21px; font-weight: 900; letter-spacing: -0.5px; }
.page-head p { margin: 5px 0 0; font-size: 11.5px; color: var(--sub); line-height: 1.6; }

.history-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-card);
  background: #fff;
  border: 1px solid var(--border);
  text-align: left;
  box-shadow: var(--shadow-card);
}
.history-item + .history-item { margin-top: 8px; }
.history-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  background: none;
  text-align: left;
}
.history-score {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--brand-grad);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}
.history-copy { flex: 1; min-width: 0; }
.history-copy strong { display: block; font-size: 13.5px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-copy span { display: block; margin-top: 3px; font-size: 10.5px; color: var(--sub); }
.history-del {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 17px;
}
.history-del:active { background: var(--field); }

.empty {
  padding: 34px 18px;
  border-radius: var(--radius-card);
  background: #fff;
  border: 1px dashed var(--border-soft);
  text-align: center;
}
.empty b { display: block; font-size: 14px; font-weight: 800; }
.empty p { margin: 6px 0 14px; font-size: 11.5px; color: var(--sub); line-height: 1.6; }

.field { margin-bottom: 11px; }
.field label { display: block; margin: 0 0 6px 2px; font-size: 11px; font-weight: 700; color: var(--sub); }
.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
  background: var(--field);
  font-size: 16px;
  outline: none;
}
.field input:focus { border-color: rgba(63, 142, 247, 0.55); background: #fff; }
.field-hint { margin: 5px 2px 0; font-size: 10px; color: var(--faint); line-height: 1.5; }

.status-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(13, 155, 95, 0.12); }
.status-dot.warn { background: var(--gold); box-shadow: 0 0 0 3px rgba(217, 147, 13, 0.14); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.12); }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--divider); font-size: 11.5px; }
.kv:first-of-type { border-top: 0; }
.kv span { color: var(--sub); }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }

/* ---------- 底栏 ---------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: 100%;
  max-width: var(--sheet);
  transform: translateX(-50%);
  display: flex;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
}

.tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0 4px;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 700;
}
.tab.is-active { color: var(--brand-deep); }
.tab-icon { width: 23px; height: 23px; display: grid; place-items: center; }
.tab-icon svg { width: 22px; height: 22px; fill: currentColor; }
.tab-badge {
  position: absolute;
  top: 3px;
  left: calc(50% + 8px);
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 8.5px;
  font-style: normal;
  line-height: 15px;
  text-align: center;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 22px);
  z-index: 60;
  max-width: min(340px, calc(100vw - 32px));
  padding: 10px 15px;
  border-radius: 12px;
  background: rgba(16, 27, 48, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 分享弹层 ---------- */

.share-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(16, 27, 48, 0.46);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.share-sheet {
  width: 100%;
  max-width: var(--sheet);
  padding: 16px;
  border-radius: var(--radius-sheet);
  background: #fff;
  box-shadow: 0 18px 50px rgba(16, 27, 48, 0.26);
}
.share-sheet h3 { margin: 0; font-size: 16px; font-weight: 900; }
.share-sheet textarea {
  width: 100%;
  height: 118px;
  padding: 10px;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
  background: var(--field);
  color: #3B475C;
  font-size: 12px;
  line-height: 1.65;
  resize: none;
  outline: none;
}
.share-row { display: flex; gap: 8px; margin-top: 10px; }
.share-row .primary-btn { flex: 1; height: 42px; }
.share-row .ghost-btn { flex: 0 0 auto; height: 42px; }

/* ---------- 响应式与降级 ---------- */

@media (min-width: 480px) {
  body { padding: 20px 0; }
  .app { min-height: calc(100vh - 40px); min-height: calc(100dvh - 40px); border-radius: 26px; }
  .tabbar { bottom: 20px; border-radius: 0 0 26px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
