/* =========================================================
 *  二维码生成 / 解码 · 页面样式
 *
 *  公共色板在 hub.css，这里是本页专属：文本域、预览区、选项列、上传区。
 * ========================================================= */

.tool-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 20px 24px;
}

.tp-head { text-align: center; margin-bottom: 24px; }
.tp-ic {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(52, 199, 89, .16), rgba(52, 199, 89, .06));
  color: var(--ok);
  font-size: 30px;
}
.tp-head h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.tp-sub { margin: 0; color: var(--tx2); font-size: 14.5px; }

.card {
  padding: 26px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--card-solid);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* iOS 分段控件 */
.seg-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 12px;
  background: rgba(120, 120, 128, .12);
}
.seg button {
  padding: 8px 18px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--tx2);
  font-size: 14px;
  font-family: inherit;
  transition: background .25s var(--ease), color .2s;
}
.seg button.on {
  background: #fff;
  color: var(--tx);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}
.seg.sm { display: inline-flex; }
.seg.sm button { min-width: 44px; padding: 7px 0; text-align: center; }

/* 表单 */
.fld + .fld { margin-top: 20px; }
.fld-label {
  display: block;
  margin-bottom: 8px;
  color: var(--tx2);
  font-size: 13px;
  font-weight: 500;
}
.fld-tip { margin: 9px 2px 0; color: var(--tx3); font-size: 12.5px; }
.fld-tip.err { color: var(--err); }

.ta {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--tx);
  font-size: 15px;
  line-height: 1.6;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color .2s var(--ease), box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}
.ta:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, .12);
}

/* 数字步进器 */
.num-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  transition: border-color .2s var(--ease), box-shadow .2s;
}
.num-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, .12);
}
.num-btn {
  width: 44px;
  min-height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  background: rgba(120, 120, 128, .08);
  color: var(--tx2);
  font-size: 15px;
  transition: background .2s, color .2s;
}
.num-btn:hover { background: rgba(120, 120, 128, .16); color: var(--tx); }
.num-btn:active { background: var(--brand-soft); color: var(--brand); }
.num-in {
  flex: 1;
  min-width: 0;
  padding: 11px 8px;
  border: 0;
  background: transparent;
  outline: none;
  text-align: center;
  color: var(--tx);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.num-in::-webkit-outer-spin-button,
.num-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* 颜色 */
.color-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.color-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--tx2);
  font-size: 13.5px;
  cursor: pointer;
}
.color-item input[type="color"] {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.color-item input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-item input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }

/* iOS 风格复选框 */
.chk {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--tx2);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.chk input {
  width: 21px;
  height: 21px;
  margin: 0;
  flex: none;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: background .2s var(--ease), border-color .2s;
  -webkit-appearance: none;
  appearance: none;
}
.chk input:checked {
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.7 12.9c1.7 1.4 3.2 2.9 4.4 4.5 2.6-4.6 5.7-8.3 9.4-11.2'/%3E%3C/svg%3E") center / 14px no-repeat;
  border-color: var(--brand);
}

/* ---------------- 生成预览 ---------------- */

.qr-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  margin-top: 22px;
}

.qr-box {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 14px;
  border: 1px solid var(--line2);
  border-radius: 16px;
  background: linear-gradient(140deg, rgba(52, 199, 89, .06), rgba(10, 132, 255, .04));
}
.qr-box canvas {
  width: 100%;
  height: auto;
  max-width: 232px;
  border-radius: 8px;
  /* 码点是硬边方块，缩放时不要插值，不然扫不准 */
  image-rendering: pixelated;
}
.qr-empty { margin: 0; padding: 0 18px; color: var(--tx3); font-size: 13px; text-align: center; }

.qr-opt { min-width: 0; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.btn-row .btn-primary, .btn-row .btn-ghost { flex: 1; min-width: 130px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: #fff;
  color: var(--tx);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .2s, color .2s, transform .25s var(--ease);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost:active { transform: scale(.96); }
.btn-ghost:disabled { opacity: .45; cursor: default; transform: none; }

/* ---------------- 解码 ---------------- */

.drop {
  display: grid;
  place-items: center;
  padding: 34px 20px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: rgba(120, 120, 128, .04);
  text-align: center;
  cursor: pointer;
  outline: none;
  transition: border-color .25s var(--ease), background .25s;
}
.drop:hover, .drop:focus-visible, .drop.over {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.drop-ic {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: rgba(10, 132, 255, .12);
  color: var(--brand);
  font-size: 24px;
}
.drop-tx { margin: 0; font-size: 15px; font-weight: 500; }
.drop-sub { margin: 6px 0 0; color: var(--tx3); font-size: 12.5px; }

.rd-out {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 20px;
  margin-top: 22px;
  padding: 18px;
  border: 1px solid rgba(52, 199, 89, .18);
  border-radius: 16px;
  background: linear-gradient(140deg, rgba(52, 199, 89, .07), rgba(10, 132, 255, .04));
  animation: fadeUp .28s var(--ease);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

.rd-pic {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.rd-pic img { width: 100%; height: 100%; object-fit: contain; }

.rd-body { min-width: 0; }
.rd-label { margin-bottom: 8px; color: var(--tx2); font-size: 12.5px; font-weight: 500; }
.rd-tx {
  max-height: 180px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 11px;
  background: #fff;
  color: var(--tx);
  font-size: 14.5px;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
  -webkit-user-select: all;
  user-select: all;
}
.rd-tx.none { color: var(--tx3); font-size: 14px; }

/* ---------------- 常用示例 ---------------- */

.quick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}
.quick-label { margin-right: 4px; color: var(--tx3); font-size: 12.5px; }
.quick button {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: #fff;
  color: var(--tx2);
  font-size: 12.5px;
  font-family: inherit;
  transition: border-color .2s, color .2s, background .2s;
}
.quick button:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------------- 说明 ---------------- */

.note h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.note ul {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--tx2);
  font-size: 14px;
  line-height: 1.8;
}
.note li + li { margin-top: 4px; }
.note b { color: var(--tx); font-weight: 600; }
.note code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(120, 120, 128, .12);
  color: var(--tx);
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

/* ---------------- 深色模式补丁 ---------------- */

@media (prefers-color-scheme: dark) {
  .ta, .num-wrap, .btn-ghost, .quick button, .rd-tx, .rd-pic { background: #2c2c2e; }
  .seg button.on { background: #48484a; color: #fff; }
  /* 二维码本身是黑白图，垫一层白底免得看不清 */
  .qr-box canvas { background: #fff; }
}

/* ---------------- 移动端 ---------------- */

@media (max-width: 700px) {
  .qr-body { grid-template-columns: 1fr; gap: 20px; }
  .qr-box { max-width: 280px; margin: 0 auto; }
}

@media (max-width: 640px) {
  .tool-page { padding: 24px 14px 16px; }
  .tp-head h1 { font-size: 22px; }
  .tp-sub { font-size: 13.5px; }
  .card { padding: 18px 15px; border-radius: 16px; }
  .seg button { padding: 8px 13px; font-size: 13.5px; }
  .seg.sm button { min-width: 40px; padding: 7px 0; }
  .drop { padding: 26px 16px; }
  .rd-out { grid-template-columns: 1fr; gap: 14px; padding: 15px; }
  .rd-pic { max-width: 180px; margin: 0 auto; }
  .btn-row .btn-primary, .btn-row .btn-ghost { min-width: 0; }
}
