/* ============================================================
   JVM 工具页样式（/tools/jvm.html）
   复用 /style.css 里的 CSS 变量（--bg/--card/--ink/--brand/--shadow…），
   保持和首页、地图页同一套视觉；移动端优先（375px 起）。
   ============================================================ */

.tool-page { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---------- 头部 ---------- */
.tool-hero {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: max(18px, env(safe-area-inset-top)) 16px 20px;
  background: linear-gradient(160deg, #0b1220 0%, #16233f 55%, #1e3a8a 100%);
  color: #f8fafc;
  border-radius: 0 0 24px 24px;
}
.tool-back {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  margin-top: 2px;
  border: 1px solid rgba(147, 197, 253, .35);
  border-radius: 10px;
  color: #dbeafe;
  font-size: 18px;
  background: rgba(15, 23, 42, .35);
}
.tool-hero-text { min-width: 0; }
.tool-hero .brand {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: .16em;
  color: #93c5fd;
  border: 1px solid rgba(147, 197, 253, .45);
  border-radius: 999px;
  padding: 1px 9px;
  margin-bottom: 8px;
}
.tool-hero h1 { margin: 0; font-size: 24px; line-height: 1.3; letter-spacing: -.01em; }
.tool-hero p { margin: 6px 0 0; font-size: 12.5px; color: #cbd5e1; }

/* ---------- Tab ---------- */
.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(244, 246, 251, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 600;
}
.tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 2px 10px rgba(29, 78, 216, .25);
}

/* ---------- 主体 ---------- */
.tool-main { max-width: 880px; margin: 0 auto; padding: 16px 16px 8px; }
.panel { display: block; }
.panel[hidden] { display: none; }

.card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.field { margin-bottom: 18px; }
.field:last-of-type { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.field input[type="number"],
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  outline: none;
}
.field input[type="number"]:focus,
.field textarea:focus {
  border-color: var(--brand-2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .14);
}
.field textarea {
  min-height: 150px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-3);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
}
.chips button.is-on {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--brand);
  font-weight: 600;
}

.seg {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 12px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 13.5px;
  font-weight: 600;
}
.seg button.is-on {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}

.hint { margin: 8px 0 0; font-size: 12px; color: var(--ink-4); line-height: 1.6; }
.hint code,
.method code,
.param-item code,
.verdict code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .94em;
  background: #eef2f7;
  border-radius: 5px;
  padding: 1px 4px;
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn {
  width: 100%;
  border: 0;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 18px rgba(29, 78, 216, .28);
}
.primary-btn:active { transform: scale(.99); }
.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-weight: 500;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row .primary-btn { width: auto; flex: 1; min-width: 140px; }

/* ---------- 结果区 ---------- */
.result { margin-top: 16px; }
.result[hidden] { display: none; }

.verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(150deg, #0b1220, #1e3a8a);
  color: #e2e8f0;
  box-shadow: var(--shadow);
}
.verdict .verdict-label { font-size: 12px; color: #93c5fd; letter-spacing: .08em; }
.verdict .verdict-main { font-size: 19px; font-weight: 700; line-height: 1.35; }
.verdict .verdict-sub { width: 100%; font-size: 12.5px; color: #cbd5e1; }
.verdict code { background: rgba(147, 197, 253, .16); color: #dbeafe; }

.block {
  margin-top: 14px;
  padding: 16px;
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.block > h2 {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: .02em;
  color: var(--ink-2);
}
.block > h2 .sub { font-weight: 400; color: var(--ink-4); font-size: 12px; }

/* 内存预算表 */
.budget-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.budget-table th,
.budget-table td {
  padding: 7px 6px;
  text-align: left;
  border-bottom: 1px dashed var(--line);
  vertical-align: top;
}
.budget-table th { color: var(--ink-4); font-weight: 500; font-size: 11.5px; }
.budget-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.budget-table tr.total td { font-weight: 700; color: var(--ink-2); border-bottom: 0; }
.budget-table .ok { color: #047857; }
.budget-table .tight { color: #b45309; }
.budget-table .over { color: #b91c1c; }

/* 参数列表 */
.params-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.param-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}
.param-item .flag {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: #0f172a;
  font-weight: 700;
  word-break: break-all;
}
.param-item .why { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-2); }
.param-item .risk {
  margin: 6px 0 0;
  font-size: 12px;
  color: #7c2d12;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 9px;
  padding: 8px 10px;
}
.param-item .risk b { color: #b45309; }

/* 启动命令 */
.cmd-block { position: relative; }
.cmd-code {
  margin: 0;
  padding: 13px 12px;
  background: #0f172a;
  color: #cbd5e1;
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}
.cmd-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cmd-actions .ghost-btn { padding: 8px 12px; font-size: 12.5px; }

/* 提示 / 警告 */
.warn-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
  font-size: 12.5px;
  line-height: 1.7;
}
.warn-box b { color: #b45309; }
.warn-box ul { margin: 6px 0 0; padding-left: 18px; }
.info-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 12.5px;
  line-height: 1.7;
}
.error-box {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #7f1d1d;
}
.error-box h2 { margin: 0 0 8px; font-size: 15px; }
.error-box p, .error-box li { font-size: 13px; line-height: 1.7; }
.error-box ul { padding-left: 18px; margin: 8px 0 0; }
.error-box pre {
  margin: 10px 0 0;
  padding: 10px;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 11.5px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 统计卡片 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}
.stat .stat-num { font-size: 20px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.stat .stat-num small { font-size: 12px; font-weight: 500; color: var(--ink-4); margin-left: 3px; }
.stat .stat-label { margin-top: 4px; font-size: 11.5px; color: var(--ink-4); }

/* 问题卡片 */
.problems { display: grid; gap: 12px; }
.problem {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.problem.sev-high { border-color: #fecaca; background: #fffafa; }
.problem.sev-mid { border-color: #fde68a; background: #fffdf5; }
.problem-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.problem-head h3 { margin: 0; font-size: 14.5px; color: var(--ink); }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge.high { background: #fee2e2; color: #b91c1c; }
.badge.mid { background: #fef3c7; color: #b45309; }
.badge.low { background: #e0f2fe; color: #0369a1; }
.problem-detail { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.evidence { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.evidence li {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #475569;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.evidence li .ln { color: #94a3b8; margin-right: 6px; }
.next-list { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); line-height: 1.8; }
.next-list li::marker { color: var(--brand); }

.method { margin-top: 8px; font-size: 12px; color: var(--ink-3); line-height: 1.75; }
.method ul { margin: 6px 0 0; padding-left: 18px; }

/* 分享图浮层 */
.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}
.share-overlay[hidden] { display: none; }
.share-mask { position: absolute; inset: 0; background: rgba(2, 6, 23, .86); }
.share-panel {
  position: relative;
  width: min(88vw, 330px);
  max-height: 88vh;
  overflow-y: auto;
  text-align: center;
  color: #e2e8f0;
}
.share-panel img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  display: block;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  background: #0b1220;
}
.share-panel .tip { margin: 12px 0 0; font-size: 12.5px; color: #cbd5e1; }
.share-actions { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.share-actions .ghost-btn {
  border-color: rgba(226, 232, 240, .3);
  background: transparent;
  color: #e2e8f0;
  text-decoration: none;
  font-size: 12.5px;
  padding: 8px 14px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: 86vw;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .92);
  color: #f8fafc;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.toast[hidden] { display: none; }

/* 页脚 */
.tool-footer { padding-top: 26px; }
.tool-footer .footer-brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.tool-footer p { margin: 2px 0; }

/* 桌面端 */
@media (min-width: 720px) {
  .tool-hero { padding-left: max(16px, calc((100vw - 880px) / 2)); padding-right: max(16px, calc((100vw - 880px) / 2)); }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card { padding: 20px; }
}
