/* ==========================================================================
   工具页样式：浅色、系统字体、细边框。
   刻意做得「普通」——和展示页的杂志风完全相反，两者不该被联想到一起。
   ========================================================================== */

:root {
  --t-bg: #ffffff;
  --t-panel: #fbfbfb;
  --t-ink: #16181a;
  --t-ink-2: #4a4f55;
  --t-mute: #8b9199;
  --t-line: #e6e8ea;
  --t-line-strong: #d3d7db;
  --t-accent: #111418;
  --t-ok: #1f7a4d;
  --t-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
            "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --t-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body.page-tool {
  margin: 0;
  background: var(--t-bg);
  color: var(--t-ink);
  font-family: var(--t-font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

.tool-wrap {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  padding: clamp(1.5rem, 5vw, 4rem) clamp(1rem, 4vw, 2rem) 3rem;
  flex: 1;
}

/* ------------------------------------------------------------------ 标题 */

.tool-head {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.tool-head h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tool-head p {
  margin: 0;
  color: var(--t-ink-2);
  font-size: 0.92rem;
  max-width: 46ch;
}

/* ------------------------------------------------------------------ 面板 */

.tool-card {
  border: 1px solid var(--t-line);
  background: var(--t-panel);
  padding: clamp(1rem, 3vw, 1.5rem);
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field > label,
.field__label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--t-ink-2);
}

.field textarea,
.field input,
.field select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--t-line-strong);
  background: #fff;
  color: var(--t-ink);
  font-family: var(--t-font);
  font-size: 0.92rem;
  border-radius: 4px;
  resize: vertical;
}

.field textarea {
  min-height: 82px;
  font-family: var(--t-mono);
  font-size: 0.86rem;
  line-height: 1.6;
}

.field textarea:focus,
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--t-ink);
  box-shadow: 0 0 0 3px rgba(17, 20, 24, 0.08);
}

.tool-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.6rem 1rem;
  border: 1px solid var(--t-line-strong);
  background: #fff;
  color: var(--t-ink);
  font-size: 0.9rem;
  font-family: var(--t-font);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover { border-color: var(--t-mute); }
.btn:active { background: #f2f3f4; }

.btn--primary {
  background: var(--t-accent);
  border-color: var(--t-accent);
  color: #fff;
}

.btn--primary:hover { background: #262b31; border-color: #262b31; }

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --------------------------------------------------------------- 预览台 */

.qr-stage {
  display: grid;
  place-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border: 1px dashed var(--t-line-strong);
  border-radius: 6px;
  background:
    linear-gradient(45deg, #fafafa 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #fafafa 25%, transparent 25%) 0 8px / 16px 16px,
    #fff;
  min-height: 240px;
}

.qr-stage canvas {
  width: min(320px, 100%);
  height: auto;
  image-rendering: pixelated;
  display: none;
  background: #fff;
  border: 1px solid var(--t-line);
}

.qr-stage.has-code canvas { display: block; }

.qr-empty {
  color: var(--t-mute);
  font-size: 0.84rem;
}

.qr-stage.has-code .qr-empty { display: none; }

.qr-meta {
  font-family: var(--t-mono);
  font-size: 0.72rem;
  color: var(--t-mute);
  text-align: center;
  min-height: 1.2em;
}

/* ------------------------------------------------------------------ 备注 */

.tool-note {
  margin: 1rem 0 0;
  font-size: 0.78rem;
  color: var(--t-mute);
}

.tool-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--t-mute);
}

.err {
  color: #b3261e;
  font-size: 0.82rem;
  min-height: 1.2em;
}

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

.tool-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-top: 1px solid var(--t-line);
  color: var(--t-mute);
  font-size: 0.75rem;
}

@media (max-width: 480px) {
  body.page-tool { font-size: 14px; }
  .qr-stage { min-height: 200px; padding: 1rem; }
}
