/* ============================================================
   格物 GEWU · 纸墨设计系统
   风格：暖纸白底、墨色文字、单一墨绿强调、细线分隔
   ============================================================ */

/* ---------- 设计变量 ---------- */
:root {
  /* 表面 */
  --bg: #faf9f7;            /* 暖纸白 */
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  /* 墨色 */
  --ink: #211f1a;
  --ink-soft: #5c574c;
  --ink-faint: #8d8778;
  /* 线条 */
  --line: #e5e1d8;
  --line-strong: #cfc9bc;
  /* 强调：墨绿 */
  --accent: #2e5949;
  --accent-soft: #e7efe9;
  --on-accent: #ffffff;
  /* 状态色（低饱和） */
  --ok: #35694b;
  --warn: #8a6116;
  --err: #96442e;
  --err-bg: #f7ece7;
  --ok-bg: #ebf2ec;
  /* 版式 */
  --font-sans: "MiSans", "MiSans VF", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(33, 31, 26, .05);
  --shadow-2: 0 10px 32px rgba(33, 31, 26, .09);
  --wrap: 1080px;
}

[data-theme="dark"] {
  --bg: #171614;
  --surface: #1f1e1b;
  --surface-2: #262420;
  --ink: #ebe7de;
  --ink-soft: #a89f8e;
  --ink-faint: #756e5f;
  --line: #2e2b26;
  --line-strong: #454036;
  --accent: #8fb8a6;
  --accent-soft: #24322c;
  --on-accent: #10201a;
  --ok: #86b295;
  --warn: #c39a55;
  --err: #cf8a72;
  --err-bg: #33251f;
  --ok-bg: #212b23;
  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 12px 36px rgba(0,0,0,.45);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  font-weight: 400;
  transition: background .25s ease, color .25s ease;
}
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; margin: 0; letter-spacing: .01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }

.mono { font-family: var(--font-mono); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--wrap); margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; flex-shrink: 0; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--ink); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; letter-spacing: 0;
}
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.site-nav a {
  padding: 6px 12px; border-radius: var(--radius-s);
  color: var(--ink-soft); font-size: 14px;
  transition: color .15s, background .15s;
}
.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a.active { color: var(--ink); font-weight: 500; background: var(--surface-2); }

.theme-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  cursor: pointer; transition: all .15s;
}
.theme-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--radius-s);
  border: 1px solid transparent; cursor: pointer;
  font-size: 14px; font-weight: 500; line-height: 1.4;
  transition: all .15s;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
label.field-label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 500; }

.checkbox { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 14px; color: var(--ink); }
.checkbox input { accent-color: var(--accent); width: 15px; height: 15px; }

input[type="range"] { accent-color: var(--accent); width: 100%; }

/* ---------- 卡片与面板 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
}
.tool-shell { max-width: var(--wrap); margin: 0 auto; padding: 40px 24px 80px; }
.tool-head { margin-bottom: 28px; }
.tool-breadcrumb { font-size: 13px; color: var(--ink-faint); margin-bottom: 10px; }
.tool-breadcrumb a:hover { color: var(--accent); }
.tool-title { font-size: 26px; margin-bottom: 6px; }
.tool-desc { color: var(--ink-soft); font-size: 14.5px; max-width: 620px; }
.panel { padding: 22px; }
.panel + .panel { margin-top: 16px; }
.panel-title { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.result-box {
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  border-radius: var(--radius-s); padding: 14px 16px;
  font-family: var(--font-mono); font-size: 14px; word-break: break-all;
  white-space: pre-wrap; min-height: 44px;
}

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; line-height: 1.7;
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.tag-ok   { background: var(--ok-bg);  color: var(--ok);  border-color: transparent; }
.tag-err  { background: var(--err-bg); color: var(--err); border-color: transparent; }

/* ---------- Toast ---------- */
#toast-wrap {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--bg);
  padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; box-shadow: var(--shadow-2);
  animation: toast-in .25s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: none;} }
.toast.hide { animation: toast-out .3s ease both; }
@keyframes toast-out { from { opacity: 1;} to { opacity: 0; transform: translateY(6px);} }

/* ---------- 页脚 ---------- */
.footer { border-top: 1px solid var(--line); margin-top: 40px; }
.footer-inner {
  max-width: var(--wrap); margin: 0 auto; padding: 28px 24px;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--ink-faint); font-size: 13px; flex-wrap: wrap; gap: 10px;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 768px) {
  /* 16px 起步，杜绝 iOS Safari 聚焦自动放大 */
  .input, .select, .textarea { font-size: 16px; }
  .tool-shell { padding: 28px 16px 64px; }
  .panel { padding: 16px; }
  .topbar-inner { height: 54px; padding: 0 16px; gap: 10px; }
  .wrap { padding: 0 16px; }
}
@media (max-width: 480px) {
  .brand > span:last-child { font-size: 15.5px; }
  .site-nav a { padding: 6px 9px; font-size: 13.5px; }
  .tool-title { font-size: 22px; }
}
