/* ==========================================================================
   实训工具箱 —— 面向计算机初学者的静态工具站
   纯 CSS，无任何框架依赖；设计令牌统一，支持明暗主题
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f9fc;
  --bg-elev: #ffffff;
  --bg-code: #f6f8fb;
  --text: #17202e;
  --text-2: #4b5668;
  --text-3: #8893a5;
  --border: #e5eaf1;
  --border-strong: #cfd8e5;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eef4ff;
  --accent-text: #1d4ed8;
  --mint: #0e9f8a;
  --mint-soft: #e8f8f5;
  --amber: #b7791f;
  --amber-soft: #fff7e6;
  --rose: #d1495b;
  --rose-soft: #fff0f2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lift: 0 12px 30px -14px rgba(23, 32, 46, .22);
  --radius: 14px;
  --radius-sm: 9px;
  --max: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", "JetBrains Mono", "Courier New", monospace;
}

[data-theme="dark"] {
  --bg: #0f131a;
  --bg-soft: #151a23;
  --bg-elev: #181e28;
  --bg-code: #121822;
  --text: #e9edf5;
  --text-2: #adb8c9;
  --text-3: #7d889a;
  --border: #262f3d;
  --border-strong: #38445a;
  --accent: #5b8cff;
  --accent-hover: #7aa2ff;
  --accent-soft: #17233d;
  --accent-text: #8db0ff;
  --mint: #43c9b0;
  --mint-soft: #12302c;
  --amber: #e6b35f;
  --amber-soft: #352a17;
  --rose: #f08090;
  --rose-soft: #3a1f26;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lift: 0 14px 34px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 8px; top: 8px; color: #fff; }

/* ------------------------------ 顶部导航 ------------------------------ */

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); flex-shrink: 0; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; background: var(--accent); color: #fff;
  font-family: var(--mono); font-size: 15px; font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15.5px; letter-spacing: -.2px; }
.brand-text em { font-style: normal; font-size: 11px; color: var(--text-3); letter-spacing: .5px; }

.site-nav { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; margin-left: auto; }
.site-nav > a {
  padding: 7px 11px; border-radius: var(--radius-sm);
  font-size: 14.5px; color: var(--text-2); white-space: nowrap;
  transition: background .15s, color .15s;
}
.site-nav > a:hover { background: var(--bg-soft); color: var(--text); }
.site-nav > a.active { color: var(--accent-text); background: var(--accent-soft); font-weight: 600; }

.icon-btn {
  width: 34px; height: 34px; margin-left: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); color: var(--text-2);
  font-size: 16px; cursor: pointer; line-height: 1;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border-strong); }

.nav-toggle {
  display: none; width: 36px; height: 36px; margin-left: auto;
  flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); cursor: pointer;
}
.nav-toggle span { display: block; width: 16px; height: 1.5px; background: var(--text-2); border-radius: 2px; }

/* -------------------------------- 按钮 -------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 14px; line-height: 1.2; padding: 10px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--text-2);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.btn:hover { background: var(--bg-soft); border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-mint { background: var(--mint); border-color: var(--mint); color: #fff; }
.btn-mint:hover { filter: brightness(1.06); color: #fff; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 11px; }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* -------------------------------- 首页 -------------------------------- */

.hero {
  position: relative; overflow: hidden;
  padding: 82px 0 64px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(900px 320px at 82% -8%, var(--accent-soft), transparent 70%),
    radial-gradient(600px 280px at 8% 20%, var(--mint-soft), transparent 72%);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 48px; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .4px;
  padding: 5px 12px; border-radius: 999px;
  color: var(--accent-text); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.hero-title {
  font-size: clamp(30px, 4.6vw, 46px); line-height: 1.22;
  letter-spacing: -1.1px; margin: 20px 0 16px; font-weight: 750;
}
.hero-title .em { color: var(--accent); }
.hero-intro { font-size: 16.5px; color: var(--text-2); line-height: 1.9; max-width: 640px; margin: 0 0 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-note { margin-top: 18px; font-size: 13px; color: var(--text-3); }

.hero-panel {
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--bg-elev); box-shadow: var(--shadow-lift);
  padding: 18px; font-family: var(--mono); font-size: 13px;
}
.hero-panel-bar { display: flex; gap: 6px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.hero-panel-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); display: block; }
.hero-panel-bar i:nth-child(1) { background: var(--rose); }
.hero-panel-bar i:nth-child(2) { background: var(--amber); }
.hero-panel-bar i:nth-child(3) { background: var(--mint); }
.hero-panel-bar span { margin-left: auto; color: var(--text-3); font-size: 11px; }
.hero-panel pre { margin: 14px 0 0; color: var(--text-2); line-height: 1.85; white-space: pre-wrap; }
.tok-k { color: var(--accent-text); font-weight: 600; }
.tok-s { color: var(--mint); }
.tok-c { color: var(--text-3); font-style: italic; }

.section { padding: 58px 0; }
.section + .section { border-top: 1px solid var(--border); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.section-title { font-size: 21px; font-weight: 700; letter-spacing: -.3px; margin: 0 0 6px; }
.section-desc { margin: 0; color: var(--text-2); font-size: 14.5px; }
.section-link { font-size: 14px; font-weight: 600; }

.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); }
.tool-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 22px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.tool-card:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow-lift); color: var(--text); }
.tool-card-icon {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 11px; font-family: var(--mono); font-size: 15px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-text);
}
.tool-card:nth-child(3n+2) .tool-card-icon { background: var(--mint-soft); color: var(--mint); }
.tool-card:nth-child(3n) .tool-card-icon { background: var(--amber-soft); color: var(--amber); }
.tool-card h3 { margin: 2px 0 0; font-size: 17px; letter-spacing: -.2px; }
.tool-card p { margin: 0; font-size: 14px; color: var(--text-2); line-height: 1.75; flex: 1; }
.tool-card-foot { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--accent-text); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.step { padding: 18px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--bg-soft); }
.step b { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 8px; border-radius: 7px; background: var(--accent); color: #fff; font-family: var(--mono); font-size: 12px; }
.step strong { font-size: 15px; }
.step p { margin: 9px 0 0; font-size: 13.5px; color: var(--text-2); }

/* ------------------------------ 工具页面 ------------------------------ */

.page-head { padding: 42px 0 26px; }
.crumb { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-3); margin-bottom: 16px; }
.page-title { font-size: clamp(26px, 3.6vw, 34px); line-height: 1.3; letter-spacing: -.6px; margin: 0 0 10px; }
.page-desc { margin: 0; color: var(--text-2); max-width: 760px; font-size: 15.5px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; padding-bottom: 56px; align-items: start; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow); overflow: hidden; }
.stack > .panel + .panel { margin-top: 14px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg-soft);
}
.panel-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-title .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.panel-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.panel-body { padding: 14px 16px; }
.editor {
  display: block; width: 100%; min-height: 360px; resize: vertical;
  border: 0; outline: 0; background: transparent; color: var(--text);
  font-family: var(--mono); font-size: 13.5px; line-height: 1.8; tab-size: 2;
}
.editor::placeholder { color: var(--text-3); }
.panel-body.wc-editor { padding: 6px 16px 12px; }
.panel-body.wc-editor .editor { min-height: 300px; }
.output { margin: 0; padding: 16px; min-height: 140px; max-height: 420px; overflow: auto; background: var(--bg-code); font-family: var(--mono); font-size: 13px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.output:empty::before { content: "处理后的结果会显示在这里"; color: var(--text-3); }

.side-card { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow); margin-bottom: 14px; }
.side-card h3 { font-size: 14px; margin: 0 0 14px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-size: 13.5px; color: var(--text-2); }
.opt-row:last-child { margin-bottom: 0; }
.opt-row select {
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
  padding: 5px 8px; font-size: 13px;
}
.switch { position: relative; width: 38px; height: 21px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong);
  cursor: pointer; transition: background .18s;
}
.switch span::before {
  content: ""; position: absolute; left: 3px; top: 3px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; transition: transform .18s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.status { font-size: 13px; padding: 10px 12px; border-radius: 9px; margin-top: 12px; line-height: 1.6; }
.status.ok { color: var(--mint); background: var(--mint-soft); }
.status.err { color: var(--rose); background: var(--rose-soft); }
.status.info { color: var(--text-2); background: var(--bg-soft); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; background: var(--bg-soft); }
.stat b { display: block; font-size: 20px; line-height: 1.3; color: var(--text); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--text-3); }

.tip-box { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 12px 14px; border-radius: 0 9px 9px 0; font-size: 13px; color: var(--text-2); }
.tip-box b { color: var(--accent-text); }

/* ---------------------------- 示例 / 模板 ---------------------------- */

.tab-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.tab {
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-2);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.tab:hover { border-color: var(--border-strong); color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.example { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); overflow: hidden; margin-bottom: 18px; box-shadow: var(--shadow); }
.example-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-soft); flex-wrap: wrap; }
.example-head h3 { margin: 0; font-size: 16px; }
.example-head .level { font-size: 12px; color: var(--mint); background: var(--mint-soft); padding: 3px 9px; border-radius: 999px; }
.example-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(230px, .6fr); }
.example-code { padding: 16px 18px; background: var(--bg-code); overflow-x: auto; }
.example-note { padding: 16px 18px; border-left: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
.example-note b { color: var(--text); display: block; margin-bottom: 6px; }
.example-note ul { margin: 6px 0 0; padding-left: 18px; }
.example-note li { margin: 4px 0; }

pre code { font-family: var(--mono); font-size: 13px; line-height: 1.8; color: var(--text); }
.code-k { color: var(--accent-text); font-weight: 600; }
.code-s { color: var(--mint); }
.code-c { color: var(--text-3); font-style: italic; }
.code-n { color: var(--amber); }
.code-f { color: #a05ad6; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.tpl-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.tpl-head { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.tpl-head h3 { margin: 0 0 4px; font-size: 16px; }
.tpl-head p { margin: 0; font-size: 13px; color: var(--text-2); }
.tpl-fields { padding: 14px 18px 4px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.field input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; background: var(--bg); color: var(--text); font-size: 13.5px;
}
.field input:focus { border-color: var(--accent); outline: none; }
.tpl-preview { margin: 4px 18px 14px; padding: 12px; max-height: 190px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-code); color: var(--text-2); font-family: var(--mono); font-size: 12px; line-height: 1.75; white-space: pre-wrap; }
.tpl-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg-soft); margin-top: auto; }

/* ------------------------------- 页脚 ------------------------------- */

.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); margin-top: 40px; }
.footer-inner { display: flex; justify-content: space-between; gap: 28px; flex-wrap: wrap; padding-top: 32px; padding-bottom: 26px; }
.footer-brand { margin: 0 0 6px; font-weight: 700; font-size: 15px; }
.footer-note { margin: 0; font-size: 13px; color: var(--text-2); max-width: 460px; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13.5px; align-items: flex-start; }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 16px; padding-bottom: 22px; font-size: 12.5px; color: var(--text-3); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ------------------------------- 提示条 ------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  z-index: 80; padding: 11px 18px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px;
  box-shadow: var(--shadow-lift); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 900px) {
  .hero-grid, .workspace, .example-body { grid-template-columns: 1fr; }
  .hero-panel { max-width: 520px; }
  .example-note { border-left: 0; border-top: 1px solid var(--border); }
  .side-card { margin-bottom: 12px; }
}

@media (max-width: 720px) {
  .header-inner { height: 56px; gap: 10px; }
  .nav-toggle { display: flex; }
  .site-nav {
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 10px 18px 16px; background: var(--bg-elev);
    border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lift);
  }
  .site-nav.open { display: flex; }
  .site-nav > a { padding: 10px 12px; }
  .icon-btn { margin: 4px 2px 0; }
  .hero { padding: 52px 0 44px; }
  .section { padding: 44px 0; }
  .page-head { padding: 30px 0 20px; }
  .editor { min-height: 280px; }
  .footer-inner { flex-direction: column; }
}
