/* ============================================================
   域名网络体检 · 对话式界面样式
   亮色主题，卡片内嵌在助手气泡中，信息密度高但层级清晰
   ============================================================ */

:root {
  --bg: #f3f6fc;
  --bg-2: #e9eefa;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --line: #e4e9f4;
  --line-strong: #d3dbeb;
  --text: #17203a;
  --text-2: #3d4a66;
  --muted: #78849e;
  --brand: #2f6bff;
  --brand-2: #1d4ed8;
  --brand-soft: #edf3ff;
  --ok: #0f9d58;
  --ok-soft: #e9f8f0;
  --warn: #c2740a;
  --warn-soft: #fff5e4;
  --bad: #dc2f3c;
  --bad-soft: #fdecec;
  --info: #5b6bd6;
  --info-soft: #eef0ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 32, 58, 0.04), 0 8px 24px -12px rgba(23, 32, 58, 0.12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 500px at 12% -8%, #e6edff 0%, transparent 60%),
    radial-gradient(700px 420px at 92% 0%, #eef4ff 0%, transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.65;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #4b7dff, #1d4ed8);
  box-shadow: 0 6px 16px -6px rgba(45, 90, 220, 0.55);
  flex: none;
}
.logo svg { width: 22px; height: 22px; }

.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: 0.2px; }
.brand-text p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }

.actions { display: flex; gap: 8px; flex: none; }

.btn {
  font: inherit;
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #fff; border-color: var(--line-strong); color: var(--text-2); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary {
  background: linear-gradient(135deg, #3f74ff, #1d4ed8);
  color: #fff;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 12px;
  box-shadow: 0 8px 18px -10px rgba(45, 90, 220, 0.8);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------------- 聊天区 ---------------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg { display: flex; gap: 10px; align-items: flex-start; animation: rise 0.32s ease both; }
.msg.user { flex-direction: row-reverse; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #4b7dff, #1d4ed8);
  box-shadow: 0 6px 14px -8px rgba(45, 90, 220, 0.7);
  margin-top: 2px;
}
.msg.user .avatar { background: linear-gradient(135deg, #9aa7c7, #6b7a9e); }

.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-top-left-radius: 6px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  max-width: min(100%, 780px);
  min-width: 0;
  overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: linear-gradient(135deg, #3f74ff, #2358e0);
  border-color: transparent;
  color: #fff;
  border-radius: var(--radius);
  border-top-right-radius: 6px;
  font-weight: 500;
  max-width: 78%;
}

.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 10px; }
.bubble h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bubble h3::before {
  content: "";
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--brand);
  flex: none;
}
.lead { color: var(--text-2); font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

/* 打字指示 */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--line-strong);
  animation: blink 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.35; } 30% { opacity: 1; } }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 600;
  white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); border-color: #c7ebd8; color: var(--ok); }
.tag.warn { background: var(--warn-soft); border-color: #f4dfb6; color: var(--warn); }
.tag.bad { background: var(--bad-soft); border-color: #f7cfcf; color: var(--bad); }
.tag.info { background: var(--info-soft); border-color: #d6daff; color: var(--info); }

/* ---------------- 键值面板 ---------------- */
.grid { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.kv {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 12px;
  background: var(--surface);
  padding: 9px 12px;
  font-size: 13.5px;
}
.kv b { color: var(--muted); font-weight: 500; }
.kv span { color: var(--text); min-width: 0; }
.kv.wide { grid-template-columns: 168px 1fr; }
@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--surface); }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
td.ok { color: var(--ok); font-weight: 600; }
td.no { color: var(--bad); font-weight: 600; }
td.warn { color: var(--warn); font-weight: 600; }

/* ---------------- 进度阶段 ---------------- */
.stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stages li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  transition: background 0.2s, border-color 0.2s;
}
.stages li i {
  width: 15px; height: 15px; flex: none; border-radius: 50%;
  border: 2px solid var(--line-strong);
  display: grid; place-items: center;
}
.stages li em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--muted); flex: none; }
.stages li.running { background: var(--brand-soft); border-color: #cfdeff; color: var(--brand-2); }
.stages li.running i {
  border-color: var(--brand);
  border-top-color: transparent;
  animation: spin 0.75s linear infinite;
}
.stages li.done i { border-color: var(--ok); background: var(--ok); position: relative; }
.stages li.done i::after {
  content: "";
  width: 6px; height: 3px;
  border-left: 1.6px solid #fff;
  border-bottom: 1.6px solid #fff;
  transform: rotate(-45deg) translate(0.5px, -0.5px);
}
.stages li.fail { background: var(--bad-soft); border-color: #f7cfcf; color: var(--bad); }
.stages li.fail i { border-color: var(--bad); position: relative; }
.stages li.fail i::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(45deg, transparent 44%, var(--bad) 44%, var(--bad) 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--bad) 44%, var(--bad) 56%, transparent 56%);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 实时状态条（常驻，避免看起来像卡死） ---------------- */
.live {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 20px 2px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid #cfdeff;
  background: linear-gradient(135deg, #f2f7ff, #eaf1ff);
  box-shadow: 0 8px 22px -16px rgba(47, 107, 255, 0.7);
  animation: rise 0.24s ease both;
}
.live[hidden] { display: none; }

.live-spin {
  width: 16px; height: 16px; flex: none;
  border-radius: 50%;
  border: 2px solid rgba(47, 107, 255, 0.25);
  border-top-color: var(--brand);
  animation: spin 0.75s linear infinite;
}

.live-main { flex: 1; min-width: 0; }
.live-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--brand-2); }
.live-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-hint { font-size: 12px; color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-time { font-family: var(--mono); font-size: 12px; color: var(--brand-2); flex: none; font-variant-numeric: tabular-nums; }

.live-bar { margin-top: 7px; height: 4px; border-radius: 999px; background: rgba(47, 107, 255, 0.14); overflow: hidden; }
.live-bar > i {
  display: block;
  height: 100%;
  width: 2%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5c8bff, #1d4ed8);
  transition: width 0.4s ease;
}
.live-step { font-family: var(--mono); font-size: 12px; color: var(--muted); flex: none; }

/* ---------------- 结论横幅 ---------------- */
.conclusion {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.conclusion.ok { border-color: #bfe9d2; background: linear-gradient(135deg, #f1fcf6, #e9f8f0); }
.conclusion.warn { border-color: #f2dcae; background: linear-gradient(135deg, #fffaf0, #fff5e4); }
.conclusion.bad { border-color: #f6cece; background: linear-gradient(135deg, #fff6f6, #fdecec); }

.conclusion-icon {
  width: 42px; height: 42px; flex: none;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: #fff;
  letter-spacing: 0;
}
.conclusion.ok .conclusion-icon { background: linear-gradient(135deg, #26b36e, #0f9d58); box-shadow: 0 8px 18px -10px rgba(15,157,88,0.9); }
.conclusion.warn .conclusion-icon { background: linear-gradient(135deg, #eda02a, #c2740a); box-shadow: 0 8px 18px -10px rgba(194,116,10,0.9); }
.conclusion.bad .conclusion-icon { background: linear-gradient(135deg, #f2695b, #dc2f3c); box-shadow: 0 8px 18px -10px rgba(220,47,60,0.9); }

.conclusion-body { min-width: 0; flex: 1; }
.conclusion-headline { font-size: 16.5px; font-weight: 700; line-height: 1.45; letter-spacing: 0.2px; }
.conclusion.ok .conclusion-headline { color: #0b7a44; }
.conclusion.warn .conclusion-headline { color: #9a5c05; }
.conclusion.bad .conclusion-headline { color: #b32330; }
.conclusion-reason { font-size: 13px; color: var(--text-2); margin-top: 5px; }
.conclusion-action {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(23, 32, 58, 0.07);
}
.conclusion-action b { font-size: 12.5px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 2px; }
.conclusion-action p { margin: 0; font-size: 13.5px; color: var(--text); }

/* ---------------- 结论框最下方的「最终结论」 ---------------- */
.final-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
}
.final-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 9px;
}
.final-label::before {
  content: '';
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: linear-gradient(180deg, #5c8bff, #1d4ed8);
}
.final-block .conclusion { margin-bottom: 0; }

.tips { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.tips li { margin-bottom: 6px; }
.tips li:last-child { margin-bottom: 0; }

@media (max-width: 620px) {
  .live { margin: 0 14px 2px; padding: 9px 11px; gap: 9px; }
  .live-hint { display: none; }
  .conclusion { padding: 13px; gap: 11px; }
  .conclusion-headline { font-size: 15px; }
}

/* ---------------- 结论卡片 ---------------- */
.verdict {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: linear-gradient(180deg, #fbfcff, #f6f9ff);
  margin-bottom: 12px;
}
.verdict-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.grade {
  width: 50px; height: 50px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 21px; font-weight: 750;
  color: #fff; flex: none;
  letter-spacing: -0.5px;
}
.grade.ok { background: linear-gradient(135deg, #26b36e, #0f9d58); box-shadow: 0 8px 18px -10px rgba(15,157,88,0.9); }
.grade.info { background: linear-gradient(135deg, #5f7bff, #2f6bff); box-shadow: 0 8px 18px -10px rgba(47,107,255,0.9); }
.grade.warn { background: linear-gradient(135deg, #eda02a, #c2740a); box-shadow: 0 8px 18px -10px rgba(194,116,10,0.9); }
.grade.bad { background: linear-gradient(135deg, #f2695b, #dc2f3c); box-shadow: 0 8px 18px -10px rgba(220,47,60,0.9); }
.verdict-title { font-size: 15px; font-weight: 650; }
.verdict-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.findings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.findings li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
}
.findings li .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 7px; background: var(--muted); }
.findings li.ok { border-color: #cdecdc; background: #f6fdf9; }
.findings li.ok .dot { background: var(--ok); }
.findings li.warn { border-color: #f2e0bd; background: #fffcf6; }
.findings li.warn .dot { background: var(--warn); }
.findings li.bad { border-color: #f6d3d3; background: #fff8f8; }
.findings li.bad .dot { background: var(--bad); }
.findings li.info .dot { background: var(--info); }
.findings li b { font-weight: 650; }
.findings li span { color: var(--text-2); }

/* ---------------- 折叠块 ---------------- */
details.block {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0;
  margin-top: 10px;
  overflow: hidden;
}
details.block > summary {
  cursor: pointer;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::before {
  content: "▸";
  color: var(--muted);
  transition: transform 0.16s;
  display: inline-block;
}
details.block[open] > summary::before { transform: rotate(90deg); }
details.block > .block-body { padding: 0 12px 12px; }

pre.raw {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  background: #0f172a;
  color: #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 重定向链路 */
.hop { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 8px; }
.hop-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  font-size: 12.5px;
  flex-wrap: wrap;
}
.hop-head .idx { color: var(--muted); font-family: var(--mono); }
.hop-head .st { font-weight: 700; color: var(--ok); font-family: var(--mono); }
.hop-head .st.bad { color: var(--bad); }
.hop-head .url { font-family: var(--mono); font-size: 12px; color: var(--text-2); flex: 1; min-width: 120px; word-break: break-all; }
.hop-head .ms { color: var(--muted); font-family: var(--mono); }
.hop table { font-size: 12px; }
.hop table th { width: 190px; font-family: var(--mono); font-weight: 500; color: var(--text-2); background: #fff; }
.hop table td { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }

/* ---------------- 输入区 ---------------- */
.composer {
  position: sticky;
  bottom: 0;
  padding: 12px 20px 16px;
  background: linear-gradient(180deg, rgba(243, 246, 252, 0), rgba(243, 246, 252, 0.95) 34%);
}
.composer-inner {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
}
.composer-inner:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12); }
#ipt-domain {
  flex: 1;
  border: none;
  outline: none;
  font: inherit;
  font-size: 15px;
  background: transparent;
  color: var(--text);
  min-width: 0;
}
.hint { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: #17203a;
  color: #fff;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 12px 28px -12px rgba(23, 32, 58, 0.6);
  z-index: 60;
  animation: rise 0.24s ease both;
}

/* 快捷示例 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 12.5px;
  font-family: var(--mono);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

@media (max-width: 620px) {
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .chat { padding: 16px 14px 4px; }
  .composer { padding: 10px 14px 14px; }
  .btn.ghost { padding: 7px 10px; font-size: 12px; }
  .msg.user .bubble { max-width: 88%; }
}
