/* ============================================================
 * style.css · Privacy-First AI Gateway
 * 纯本地样式，无字体/CDN/外链。深色模式跟随系统。打印样式只留脱敏稿与对照表。
 * ============================================================ */

:root {
  color-scheme: light dark;
  --ink: #14181f;
  --muted: #4d5766;
  --bg: #f6f7fb;
  --card: #ffffff;
  --line: #dfe3ec;
  --brand: #1c3f8f;
  --brand-ink: #ffffff;
  --brand-soft: #eef3ff;
  --ok: #14653a;
  --err: #a1121b;
  --warn: #7a4a00;
  --chip: #fbfcfe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef2f8;
    --muted: #b9c3d4;
    --bg: #10141b;
    --card: #171d27;
    --line: #2c3543;
    --brand: #8fb4ff;
    --brand-ink: #0c1220;
    --brand-soft: #1b2436;
    --ok: #7fd6a1;
    --err: #ff9aa2;
    --warn: #f0c274;
    --chip: #131924;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  overflow-wrap: break-word;
}

a { color: var(--brand); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 10px 14px;
  border-radius: 0 0 var(--radius) 0;
  z-index: 10;
}
.skip:focus { left: 0; }

/* ---------- 页头 ---------- */
.site-head {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.head-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand svg { flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.2px;
}
.brand-tag {
  font-size: 12.5px;
  color: var(--muted);
}
.lang-switch {
  display: flex;
  gap: 6px;
  align-items: center;
}
.lang-switch .lbl {
  font-size: 12.5px;
  color: var(--muted);
  margin-right: 2px;
}
.lang-btn {
  min-height: 44px;
  min-width: 52px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font: 600 14px/1 var(--font);
  cursor: pointer;
}
.lang-btn[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

/* ---------- 主体 ---------- */
main { padding: 24px 0 40px; }

h1 {
  font-size: clamp(24px, 4.4vw, 34px);
  line-height: 1.25;
  letter-spacing: -.4px;
  margin: 4px 0 12px;
}
.lead {
  color: var(--muted);
  font-size: 17px;
  margin: 0 0 20px;
  max-width: 74ch;
}
h2 {
  font-size: 20px;
  margin: 0 0 4px;
  letter-spacing: -.2px;
}
h3 { font-size: 16px; margin: 0 0 6px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 0 18px;
}
.card > .sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 14px;
}

/* 三步条 */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}
.steps li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.steps .st {
  font-weight: 700;
  font-size: 14px;
  color: var(--brand);
  display: block;
  margin-bottom: 4px;
}
.steps .sd {
  font-size: 13.5px;
  color: var(--muted);
}

/* ---------- 表单 ---------- */
label.field {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 6px;
}
textarea,
input[type="text"],
input[type="email"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: 15px/1.55 var(--font);
}
textarea {
  min-height: 132px;
  resize: vertical;
}
textarea#output,
textarea#restored {
  font-family: var(--mono);
  font-size: 14px;
  min-height: 150px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}
.row.tight { margin-top: 8px; }

button.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--ink);
  font: 600 15px/1.2 var(--font);
  cursor: pointer;
}
button.btn:hover { filter: brightness(.97); }
button.btn:disabled { opacity: .55; cursor: not-allowed; }
button.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}
button.btn.ghost { background: transparent; }

.hint {
  font-size: 12.5px;
  color: var(--muted);
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 8px 0;
  font-size: 14px;
  cursor: pointer;
}
.check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}

/* 规则折叠区 */
details.rules {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  background: var(--chip);
}
details.rules > summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
}
details.rules[open] > summary { border-bottom: 1px solid var(--line); }
.rules-body { padding: 12px 0 6px; }
fieldset {
  border: 0;
  margin: 0 0 10px;
  padding: 0;
}
legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 0 4px;
}
.rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}
.custom-field { margin-top: 6px; }

/* ---------- 状态提示 ---------- */
.status {
  min-height: 22px;
  font-size: 14px;
  margin: 12px 0 0;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.info { color: var(--muted); }

/* ---------- 结果区 ---------- */
.stats {
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 0;
}
.table-wrap {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  max-height: 40vh;
}
table.map {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.map caption {
  text-align: left;
  padding: 10px 12px 4px;
  font-weight: 700;
  font-size: 14px;
}
table.map th,
table.map td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.map thead th {
  position: sticky;
  top: 0;
  background: var(--chip);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  z-index: 1;
}
table.map td.ph { font-family: var(--mono); overflow-wrap: anywhere; }
table.map td.value { font-family: var(--mono); overflow-wrap: anywhere; }
table.map td.hidden-value { color: var(--muted); letter-spacing: 2px; font-style: normal; }
#originals-hint { margin-top: 10px; }
table.map tr:last-child td { border-bottom: 0; }

.note {
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 0;
}

/* ---------- FAQ ---------- */
.faq details {
  border-bottom: 1px solid var(--line);
  padding: 4px 0;
}
.faq details:last-of-type { border-bottom: 0; }
.faq summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 15px;
}
.faq p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14.5px;
}

/* ---------- 页脚 ---------- */
.site-foot {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 18px 0 26px;
  font-size: 13px;
  color: var(--muted);
}
.site-foot p { margin: 0 0 6px; }
.disclaimer {
  font-weight: 600;
  color: var(--ink);
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .steps { grid-template-columns: 1fr; }
  .rule-grid { grid-template-columns: 1fr; }
  .head-row { gap: 8px; }
  .brand-name { font-size: 15px; }
  h1 { font-size: 22px; }
  .lead { font-size: 16px; }
  .card { padding: 14px; }
  /* 375px 下让 4 列表格靠换行收窄，而不是把页面撑出横向滚动 */
  table.map { table-layout: fixed; font-size: 13px; }
  table.map th,
  table.map td { padding: 6px 8px; }
  table.map td.value { overflow-wrap: anywhere; }
}
@media (max-width: 360px) {
  .lang-btn { min-width: 46px; padding: 8px 10px; }
}

/* ---------- 打印：只留脱敏稿与对照表 ---------- */
@media print {
  :root { --ink: #000; --muted: #333; --bg: #fff; --card: #fff; --line: #999; }
  body { background: #fff; }
  .site-head,
  .no-print,
  #bac-intent,
  .faq,
  .steps,
  .site-foot { display: none !important; }
  .card { box-shadow: none; border: 1px solid #999; page-break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
  textarea {
    border: 1px solid #999;
    min-height: 0;
    height: auto;
    overflow: visible;
  }
}
