/* =============================================================
   工具详情页样式
   ============================================================= */

.tool-head { margin: 14px 0 16px; }
.tool-head { display: flex; align-items: center; gap: 18px; }
.tool-head-icon { width: 88px; height: 88px; flex: 0 0 88px; border-radius: var(--r-3); }
.tool-head > div, .two-col > *, .three-col > * { min-width: 0; }
.tool-jump { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 18px; font-size: 13px; }
.tool-jump a { color: var(--link); }
.tool-body section, #tool-workspace { scroll-margin-top: 20px; }
.tool-body h3 { font-size: 13px; color: var(--muted); }
.tool-body pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-illustration { margin: 0; }
.tool-illustration img { display: block; width: 100%; border: 1px solid var(--line); border-radius: var(--r-2); }
.tool-illustration figcaption { margin-top: 8px; font-size: 12px; color: var(--muted); }
.tool-helpers { margin-bottom: 14px; }
.table-scroll { overflow-x: auto; }
.tool-quickstart { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; line-height: 1.6; max-width: 820px; }
.tool-shortcut { margin: -6px 0 12px; color: var(--muted); font-size: 12px; }
.output-actions { margin: 0; }
.reference-scroll { max-height: min(65vh, 560px); }
.reference-scroll thead th { position: sticky; top: 0; z-index: 1; }
.reference-status { table-layout: fixed; }
.reference-status th:first-child { width: 22%; }
.reference-status th:nth-child(2) { width: 34%; }
.reference-status td { overflow-wrap: anywhere; }
.reference-mime { min-width: 600px; table-layout: fixed; }
.reference-mime th:first-child { width: 18%; }
.reference-mime th:nth-child(2) { width: 48%; }
.reference-mime td { overflow-wrap: anywhere; }
.btn-mini:focus-visible, .btn-primary:focus-visible, .table-scroll:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 3px;
}
@media (max-width: 480px) {
  .tool-head { gap: 12px; align-items: flex-start; }
  .tool-head-icon { width: 64px; height: 64px; flex-basis: 64px; }
  .tool-card-panel { padding: 14px; }
  .related-list { grid-template-columns: 1fr; }
}
.tool-head h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 1.5vw + 1rem, 1.85rem); }
.tool-head .lede { color: var(--muted); margin: 0; max-width: 780px; }

.tool-meta {
  display: flex; align-items: center; gap: 6px 10px;
  color: var(--muted); font-size: 12.5px;
  margin: 8px 0 0;
  flex-wrap: wrap;
}
.tool-meta .chip {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; letter-spacing: .01em;
}
.tool-meta .chip--server { border-color: rgba(160,30,43,.25); background: var(--accent-soft); color: var(--accent); }
.tool-meta .chip--local  { border-color: rgba(23,91,52,.25); background: var(--success-bg); color: var(--success-ink); }

.tool-card-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow-1);
}

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.field .hint { color: var(--muted-2); font-size: 12px; }
.field input[type=text],
.field input[type=search],
.field input[type=number],
.field input[type=password],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: var(--r-2);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--focus); box-shadow: var(--shadow-focus);
}
.field textarea.error { border-color: var(--danger-ink); color: var(--danger-ink); background: var(--danger-bg); }
.field textarea {
  min-height: 140px; resize: vertical;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.55;
}
.field.mono input, .field.mono textarea { font-family: var(--font-mono); font-size: 13.5px; }

.actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center;
  margin: 6px 0 0;
}
.actions .grow { flex: 1; }

.btn-mini, .btn-primary {
  padding: 8px 14px; border-radius: var(--r-2);
  font-family: inherit; font-size: 13.5px;
  transition: background .12s, border-color .12s, color .12s;
  cursor: pointer;
}
.btn-mini {
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
}
.btn-mini:hover { border-color: var(--ink); background: var(--bg-alt); }
.btn-mini:disabled { color: var(--muted-2); cursor: not-allowed; }
.btn-primary {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.result {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13.2px; line-height: 1.55;
  color: var(--code-ink);
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 460px;
  overflow: auto;
}
.result.is-empty { color: var(--muted-2); }
.result.error   { border-color: rgba(143,28,28,.25); background: var(--danger-bg); color: var(--danger-ink); }
.result.success { border-color: rgba(23,91,52,.25); background: var(--success-bg); color: var(--success-ink); }

.two-col { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.three-col { display: grid; gap: 12px; grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 720px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}

table.datatable {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  background: var(--surface);
}
table.datatable th, table.datatable td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  vertical-align: top;
  text-align: left;
}
table.datatable th {
  background: var(--bg-alt);
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
table.datatable td.mono, table.datatable .mono { font-family: var(--font-mono); font-size: 12.8px; }
table.datatable tr:hover td { background: rgba(0,0,0,.015); }

.ip-section-heading { background: var(--bg-alt); }
.ip-history { margin-top: 20px; }
.ip-history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.ip-history-head h2 { margin: 0; font-size: 1rem; }
.ip-history-empty { margin: 0; color: var(--muted); font-size: 13px; }
.ip-history-table th:last-child, .ip-history-table td:last-child { width: 1%; white-space: nowrap; }
.ip-history-table td { overflow-wrap: anywhere; }

/* Mortgage calculator: dense financial data, kept distinct from generic code output. */
.mortgage-input-note { margin: -2px 0 12px; }
.mortgage-status { min-height: 1.4em; margin: 12px 0 0; color: var(--success-ink); font-size: 13px; }
.mortgage-status.error { color: var(--danger-ink); }
.mortgage-result { margin-top: 16px; display: grid; gap: 22px; }
.mortgage-result[hidden] { display: none; }
.mortgage-result,
.mortgage-result > section,
.mortgage-result .table-scroll { min-width: 0; max-width: 100%; }
.mortgage-summary > h2,
.mortgage-schedule-head h2 { margin: 0; font-size: 1rem; }
.mortgage-plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.mortgage-plan { border: 1px solid var(--line); border-radius: var(--r-2); padding: 14px; background: var(--bg-alt); }
.mortgage-plan h3 { margin: 0 0 10px; font-size: 14px; }
.mortgage-plan dl { margin: 0; display: grid; gap: 8px; }
.mortgage-plan dl div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mortgage-plan dt { color: var(--muted); font-size: 12.5px; }
.mortgage-plan dd { margin: 0; font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; text-align: right; }
.mortgage-difference { display: flex; gap: 18px 28px; flex-wrap: wrap; padding: 11px 13px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r-2) var(--r-2); color: var(--muted); font-size: 12.5px; }
.mortgage-difference strong { display: block; margin-bottom: 2px; color: var(--accent); font-family: var(--font-mono); font-size: 14px; }
.mortgage-schedule-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.mortgage-tabs { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-2); overflow: hidden; background: var(--surface); }
.mortgage-tabs button { padding: 8px 12px; border-right: 1px solid var(--line-2); color: var(--muted); font-size: 13px; }
.mortgage-tabs button:last-child { border-right: 0; }
.mortgage-tabs button[aria-selected="true"] { color: #fff; background: var(--ink); }
.mortgage-tabs button:focus-visible { box-shadow: inset var(--shadow-focus); }
.mortgage-table td:not(:first-child), .mortgage-table th:not(:first-child) { text-align: right; }
.mortgage-table-gap td { color: var(--muted-2); text-align: center !important; font-size: 12px; }
.mortgage-schedule-actions { justify-content: center; margin-top: 10px; }
.suite-model-note { margin: -2px 0 12px; }
.suite-status { min-height: 1.4em; margin: 12px 0 0; color: var(--success-ink); font-size: 13px; }
.suite-status.error { color: var(--danger-ink); }
.suite-result { margin-top: 16px; min-width: 0; }
.suite-result h2 { margin: 0 0 10px; font-size: 1rem; }
.suite-output { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); border: 1px solid var(--line); border-radius: var(--r-2); overflow: hidden; background: var(--bg-alt); }
.suite-output > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; padding: 11px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.suite-output dt { color: var(--muted); font-size: 12.5px; }
.suite-output dd { margin: 0; font-family: var(--font-mono); font-weight: 600; text-align: right; overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .mortgage-plan-grid { grid-template-columns: 1fr; }
  .mortgage-schedule-head { align-items: stretch; flex-direction: column; }
  .mortgage-tabs { align-self: flex-start; }
}

.tool-body {
  margin-top: 32px;
  display: grid;
  gap: 26px;
  max-width: 820px;
}
.tool-body section h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.tool-body p  { margin: 6px 0 10px; color: var(--ink-2); }
.tool-body ul { padding-left: 22px; }
.tool-body ul li { margin: 3px 0; color: var(--ink-2); }
.tool-body ol.steps { counter-reset: st; padding-left: 0; list-style: none; }
.tool-body ol.steps li {
  position: relative; padding-left: 30px; margin: 8px 0; color: var(--ink-2);
}
.tool-body ol.steps li::before {
  counter-increment: st;
  content: counter(st);
  position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.tool-body dt { font-weight: 600; margin: 12px 0 2px; color: var(--ink); }
.tool-body dd { margin: 0 0 10px; color: var(--ink-2); }
.tool-body pre { background: var(--code-bg); }

.related-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.related-list a {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 8px 10px; border-radius: var(--r-2);
  border: 1px solid var(--line); background: var(--surface);
  text-decoration: none; color: var(--ink);
}
.related-list a:hover { border-color: var(--ink); color: var(--accent); }
.related-list .name    { font-weight: 500; font-size: 14px; }
.related-list .summary { color: var(--muted); font-size: 12.5px; max-width: 100%; padding-left: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Keep controls comfortably tappable, and avoid small editable text on phones. */
@media (max-width: 480px) {
  .tool-card-panel { padding: 14px; }
  .btn-mini, .btn-primary { min-height: 44px; }
  .field input[type=text], .field input[type=search], .field input[type=number],
  .field textarea, .field.mono input, .field.mono textarea, .field select { font-size: 16px; }
  .actions select { max-width: 100%; min-height: 36px; }
  .related-list { grid-template-columns: minmax(0, 1fr); }
}
