/* ==========================================================================
   工具箱（/tools/*）

   结构照搬 HopeDesk 的工具箱组件（class 名一个没改，组件是整份搬过来的），
   外观整套重画：desk 是 macOS 原生风的 px 体系，这里是站点的暖中性纸面 +
   Manrope / JetBrains Mono + rem 体系（根字号 62.5%，1.6rem = 16px）。

   两条约定：
   · 颜色一律走站点 token，本文件不出现任何写死的颜色值；工具自己需要的
     填充色 / 悬停色站点没有对应项，在 .toolbox-root 里定义成局部变量，
     已登记进 DESIGN.md。
   · accent 上的文字用 var(--base)，不是写死的白——accent 在两套主题间翻转，
     写死白色在浅色主题下会消失。
   ========================================================================== */

.toolbox-root {
  /* 站点没有「中性控件填充」这一层，工具里到处要用，在这一层补齐 */
  --tb-fill: color-mix(in srgb, var(--t-medium) 12%, transparent);
  --tb-hover: color-mix(in srgb, var(--t-medium) 7%, transparent);
  --reading-paper: #eeeae8;
  --reading-ink: #121212;
  --reading-signal: #e63b32;
  --tb-radius: 1rem;
  --tb-gap: 1.6rem;

  position: relative;
  font-size: 1.4rem;
  line-height: 1.55;
  color: var(--t-bright);
}

.toolbox-root button,
.toolbox-root input,
.toolbox-root select,
.toolbox-root textarea {
  font-family: inherit;
  color: inherit;
}

.toolbox-root button {
  background: none;
  border: 0;
  cursor: pointer;
}

.toolbox-root button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toolbox-root .grow { flex: 1; }

/* ===== 外壳与卡片 ===== */

.tb-wrap {
  /* desk 里这是个自己滚的应用面板；在网站上让页面滚，Lenis 才不会打架 */
  width: 100%;
}

.tb-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(36rem, 1fr));
  gap: var(--tb-gap);
  align-items: start;
}

.tb-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--st-medium);
  border-radius: var(--tb-radius);
  background: var(--base-tint);
}

.tb-card-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 4.4rem;
  padding: 0.8rem 1.6rem;
  border-bottom: 1px solid var(--st-medium);
}

.tb-card-head strong {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tb-meta {
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: 1.1rem;
  color: var(--t-muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}

.tb-card-body {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  padding: 1.6rem;
}

.tb-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  padding: 1.2rem 1.6rem;
  border-top: 1px solid var(--st-medium);
}

.tb-card-foot .btn { flex: none; white-space: nowrap; }

/* ===== 控件 ===== */

.toolbox-root .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 3.4rem;
  padding: 0 1.4rem;
  border: 1px solid var(--st-medium);
  border-radius: 999px;
  background: var(--base);
  font-size: 1.3rem;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.toolbox-root .btn:hover:not(:disabled) {
  border-color: var(--st-bright);
  background: var(--tb-hover);
}

.toolbox-root .btn.pri {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--base);
  font-weight: 600;
}

.toolbox-root .btn.pri:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 85%, var(--base-opp));
  color: var(--base);
}

/* 「导入备份」是个包着 input[type=file] 的 label，样式要跟按钮一致 */
.toolbox-root label.btn { cursor: pointer; }

.toolbox-root .in {
  width: 100%;
  height: 3.6rem;
  padding: 0 1.2rem;
  border: 1px solid var(--st-medium);
  border-radius: 0.8rem;
  background: var(--base);
  font-size: 1.4rem;
  outline: 0;
}

.toolbox-root .in:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.toolbox-root .seg {
  display: flex;
  gap: 0.3rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: var(--tb-fill);
}

.toolbox-root .seg button {
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  font-size: 1.2rem;
  color: var(--t-medium);
}

.toolbox-root .seg button.on {
  background: var(--base);
  color: var(--t-bright);
  font-weight: 600;
}

.tb-seg { width: fit-content; max-width: 100%; flex-wrap: wrap; }
.tb-seg button:disabled { opacity: 0.4; }

.tb-field {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tb-field-label {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--t-muted);
}

.tb-field-label em {
  margin-left: auto;
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.tb-field input[type="range"],
.tb-file-line input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.tb-field-row { display: flex; gap: 1.2rem; }
.tb-field-row .tb-field { flex: 1; }

/* 下面这几个都是在 .in 基础上改的，必须跟 .toolbox-root .in 同一层特异性，
   否则宽度 / 高度改不动（.in 那条是 0,2,0） */
.toolbox-root .tb-textarea {
  height: auto;
  min-height: 9rem;
  padding: 1rem 1.2rem;
  line-height: 1.6;
  resize: vertical;
}

.toolbox-root .tb-color {
  height: 3.6rem;
  padding: 0.3rem;
  cursor: pointer;
  background: var(--base);
}

.toolbox-root .tb-color:disabled { opacity: 0.4; cursor: default; }

.tb-chips { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.tb-chips button {
  height: 3rem;
  padding: 0 1.3rem;
  border: 1px solid var(--st-medium);
  border-radius: 999px;
  font-size: 1.2rem;
  color: var(--t-medium);
}

.tb-chips button.on {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--base);
  font-weight: 600;
}

/* 开关。原生 checkbox 换不出这个形状，保留 desk 那套结构 */
.tb-switch {
  position: relative;
  width: 3.8rem;
  height: 2.2rem;
  flex: none;
  cursor: pointer;
}

.tb-switch input { position: absolute; width: 0; height: 0; opacity: 0; }

.tb-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--tb-fill);
  transition: background 0.15s ease;
}

.tb-switch span::before {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--base);
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
  transition: transform 0.15s ease;
}

.tb-switch input:checked + span { background: var(--accent); }
.tb-switch input:checked + span::before { transform: translateX(1.6rem); }

/* ===== 上传区、预览、状态 ===== */

.tb-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 18rem;
  padding: 2.4rem;
  border: 1px dashed var(--st-medium);
  border-radius: var(--tb-radius);
  background: var(--base);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.tb-drop:hover { border-color: var(--accent); background: var(--tb-hover); }

.tb-drop.over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--base));
}

.tb-drop strong { font-size: 1.5rem; font-weight: 600; }
.tb-drop span { font-size: 1.2rem; color: var(--t-muted); }

.tb-drop-over {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--tb-radius);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 600;
}

.tb-preview {
  width: 100%;
  max-height: 34rem;
  object-fit: contain;
  border-radius: 0.8rem;
  background: var(--tb-fill);
}

.tb-preview.busy { opacity: 0.4; transition: opacity 0.15s ease; }
video.tb-preview { background: var(--base-opp); }

.tb-progress {
  height: 0.6rem;
  border-radius: 999px;
  background: var(--tb-fill);
  overflow: hidden;
}

.tb-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.tb-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}

.tb-stats > div {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--st-medium);
  border-radius: 0.8rem;
}

.tb-stats span {
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  color: var(--t-muted);
}

.tb-stats strong {
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: 1.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tb-empty {
  display: grid;
  place-items: center;
  min-height: 13rem;
  padding: 2rem;
  border: 1px dashed var(--st-medium);
  border-radius: var(--tb-radius);
  font-size: 1.3rem;
  color: var(--t-muted);
  text-align: center;
}

.tb-status {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--t-muted);
}

.tb-warn {
  margin: 0;
  padding: 1rem 1.2rem;
  border-radius: 0.8rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: 1.2rem;
  line-height: 1.65;
  color: var(--t-bright);
}

.toolbox-loading {
  display: grid;
  place-items: center;
  min-height: 24rem;
  font-size: 1.3rem;
  color: var(--t-muted);
}

.share-poster-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  background: var(--reading-paper);
  border: 1px solid var(--st-medium);
}

@media (max-width: 40rem) {
  .tb-cols { grid-template-columns: minmax(0, 1fr); }
}

/* ===== 列表行（批量重命名、传 GitHub、二维码识别、配色历史共用）===== */

.tb-rows {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-height: 46rem;
  overflow: auto;
}

.tb-rows .tb-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--st-medium);
  border-radius: 0.9rem;
  background: var(--base);
}

.tb-rows .tb-row.dragging { opacity: 0.5; border-color: var(--accent); }

.tb-rows img {
  width: 4.4rem;
  height: 4.4rem;
  flex: none;
  object-fit: cover;
  border-radius: 0.6rem;
  background: var(--tb-fill);
}

.tb-row-index {
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: 1.1rem;
  color: var(--t-muted);
  font-variant-numeric: tabular-nums;
  cursor: grab;
}

.tb-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.tb-row-name { font-size: 1.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-row-hint { font-size: 1.1rem; color: var(--t-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbox-root .tb-name-in { width: auto; flex: 1; min-width: 10rem; max-width: 22rem; }

.tb-file-line {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--st-medium);
  border-radius: 0.9rem;
  background: var(--base);
}

.tb-file-line strong {
  flex: 1;
  min-width: 0;
  font-size: 1.3rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-file-line span { flex: none; font-size: 1.2rem; color: var(--t-muted); }

/* ===== 宫格切图 ===== */

.tb-grid-preview { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; }
.tb-grid-preview .tb-preview { display: block; width: auto; max-width: 100%; max-height: 32rem; }

.tb-grid-lines {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(var(--rows), 1fr);
  grid-template-columns: repeat(var(--cols), 1fr);
  pointer-events: none;
}

.tb-grid-lines span {
  border-right: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
}

.tb-slices { display: grid; gap: 0.8rem; }

.tb-slices figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--st-medium);
  border-radius: 0.7rem;
  background: var(--base);
}

.tb-slices img { display: block; width: 100%; height: 8.4rem; object-fit: contain; background: var(--tb-fill); }
.tb-slices figcaption { padding: 0.5rem 0.7rem; font-size: 1.1rem; color: var(--t-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== PDF ===== */

.tb-pdf-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.8rem;
  max-height: 46rem;
  overflow: auto;
}

.tb-pdf-pages figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--st-medium);
  border-radius: 0.8rem;
  background: var(--base);
}

.tb-pdf-pages img { display: block; width: 100%; background: var(--base-bright); }
.tb-pdf-pages figcaption { padding: 0.5rem; text-align: center; font-size: 1.1rem; color: var(--t-muted); }

/* ===== 二维码 ===== */

.tb-qr-preview { max-height: 36rem; padding: 0.8rem; border-radius: var(--tb-radius); background: var(--base-bright); }
.tb-logo-thumb { width: 4rem; height: 4rem; flex: none; object-fit: contain; border-radius: 0.6rem; background: var(--tb-fill); }
.tb-scan-row { align-items: flex-start; }

.tb-scan-text {
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  background: var(--tb-fill);
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--t-medium);
  overflow-wrap: anywhere;
}

/* ===== 取配色 ===== */

.tb-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.9rem;
}

.tb-swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem;
  border: 1px solid var(--st-medium);
  border-radius: 0.9rem;
  background: var(--base);
  text-align: left;
}

.tb-swatch:hover { border-color: var(--st-bright); }
.tb-swatch-chip { height: 5.4rem; margin-bottom: 0.4rem; border-radius: 0.6rem; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 12%); }

.tb-swatch strong {
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: 1.3rem;
  font-weight: 600;
}

.tb-swatch em {
  font-style: normal;
  font-size: 1.1rem;
  color: var(--t-muted);
  font-variant-numeric: tabular-nums;
}

.tb-swatch-area {
  position: absolute;
  top: 1.4rem;
  right: 1.4rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: rgb(0 0 0 / 45%);
  color: #fff;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.tb-history { max-height: 52rem; }
.tb-history-row { align-items: flex-start; }

.tb-history-bar {
  display: flex;
  height: 1.8rem;
  overflow: hidden;
  border-radius: 0.4rem;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 12%);
}

.tb-history-bar i { display: block; min-width: 0.3rem; }
.tb-history-acts { display: flex; flex: none; align-items: center; gap: 0.6rem; }
.tb-history-acts .btn { height: 2.8rem; padding: 0 1rem; font-size: 1.2rem; }

/* ===== 税费计算 ===== */

.tb-factors {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--st-medium);
  border-radius: 0.9rem;
}

.tb-factor {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--st-medium);
  background: var(--base);
}

.tb-factor:last-child { border-bottom: 0; }
.tb-factor.off .tb-factor-name,
.tb-factor.off .tb-factor-in { opacity: 0.45; }
.tb-factor-name { flex: none; min-width: 8.4rem; font-size: 1.3rem; }
.tb-factor-pct { flex: 1; font-size: 1.2rem; color: var(--t-muted); font-variant-numeric: tabular-nums; }
.toolbox-root .tb-factor-in { width: 9.6rem; flex: none; text-align: right; font-variant-numeric: tabular-nums; }

.tb-big { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.4rem 0; }
.tb-big-label { font-size: 1.1rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--t-muted); }

.tb-big strong {
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: clamp(3.4rem, 5vw, 4.6rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tb-big-sub { font-size: 1.2rem; color: var(--t-muted); font-variant-numeric: tabular-nums; }

.tb-steps {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--st-medium);
  border-radius: 0.9rem;
}

.tb-step {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 1.2rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--st-medium);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.tb-step:last-child { border-bottom: 0; }
.tb-step span:not(:first-child) { min-width: 7.6rem; text-align: right; }
.tb-step.head { font-size: 1.1rem; letter-spacing: 0.04em; color: var(--t-muted); background: var(--base); }
.tb-step.total { font-weight: 600; background: var(--base); }

.tb-formula {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--st-medium);
  border-radius: 0.9rem;
  background: var(--base);
}

.tb-formula-label { font-size: 1.1rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--t-muted); }

.tb-formula code {
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: 1.3rem;
  color: var(--t-bright);
  font-variant-numeric: tabular-nums;
}

/* ===== 轻提示 ===== */

.tb-toast {
  position: fixed;
  left: 50%;
  bottom: 3.2rem;
  z-index: 60;
  transform: translateX(-50%);
  padding: 1rem 1.8rem;
  border-radius: 999px;
  background: var(--base-opp);
  color: var(--base);
  font-size: 1.3rem;
  box-shadow: 0 8px 30px rgb(0 0 0 / 22%);
}

.tb-toast.err { background: var(--reading-signal); color: #fff; }

/* ===== 工具页外壳（Nunjucks 模板那一层）===== */

.hope-tool-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.6rem 2.4rem;
  margin-bottom: 3.2rem;
  padding-bottom: 2.4rem;
  border-bottom: 1px solid var(--st-medium);
}

.hope-tool-head__main { flex: 1; min-width: 28rem; }

.hope-tool-head__kicker {
  display: block;
  margin-bottom: 0.8rem;
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t-muted);
}

.hope-tool-head__title { margin: 0; font-size: clamp(3.2rem, 4vw, 5rem); letter-spacing: -0.02em; }
.hope-tool-head__desc { margin: 0.8rem 0 0; font-size: 1.6rem; color: var(--t-medium); }

.hope-tool-head__note {
  /* flex: none 会让这段中文按内容撑开，窄屏上直接把页面顶出横向滚动条 */
  flex: 1 1 22rem;
  min-width: 0;
  max-width: 32rem;
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--t-muted);
}

.hope-tool-siblings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 2.4rem;
}

.hope-tool-siblings a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  height: 3.2rem;
  padding: 0 1.3rem;
  border: 1px solid var(--st-medium);
  border-radius: 999px;
  font-size: 1.2rem;
  color: var(--t-medium);
  text-decoration: none;
  transition: border-color 0.18s ease, color 0.18s ease;
}

.hope-tool-siblings a:hover { border-color: var(--st-bright); color: var(--t-bright); }
.hope-tool-siblings a[aria-current="page"] { border-color: var(--accent); background: var(--accent); color: var(--base); }

/* ===== 工具索引页 ===== */

/* —— 左右两栏 ——
   左栏定宽：筛选项不需要跟着变宽，多出来的空间全给卡片网格。 */
.hope-tools-layout {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  gap: 3.2rem;
  align-items: start;
}

.hope-tools-side {
  /* 工具多起来右边会很长，筛选跟着滚走就得先滚回顶部才能换分类。
     top 要避开站点的固定头部。 */
  position: sticky;
  top: 10rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

/* —— 分类筛选（纵向） —— */

.hope-tools-filters {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hope-tools-filters button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 0.8rem;
  background: none;
  color: var(--t-medium);
  font: inherit;
  font-size: 1.4rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.hope-tools-filters button:hover {
  background: var(--tb-hover);
  color: var(--t-bright);
}

.hope-tools-filters button.is-active {
  background: var(--tb-fill);
  color: var(--t-bright);
}

/* 数量用等宽字体，几行叠在一起时右边缘才对得齐 */
.hope-tools-filters__count {
  flex: 0 0 auto;
  font-family: var(--_font-accent, monospace);
  font-size: 1.15rem;
  color: var(--t-muted);
}

.hope-tools-filters button.is-active .hope-tools-filters__count {
  color: var(--accent);
}

/* 搜索框。
   这段一度被误删 —— 改左右布局时替换了 filters 到 grid 之间的整块 CSS，
   而搜索框的样式正好夹在中间，结果输入框掉回浏览器默认的白底方框。
   两栏下它占满左栏宽度，所以不要 min-width。 */
.hope-tools-search {
  width: 100%;
  height: 3.4rem;
  padding: 0 1.4rem;
  border: 1px solid var(--st-medium);
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 1.3rem;
  color: var(--t-bright);
  outline: 0;
}

.hope-tools-search::placeholder { color: var(--t-muted); }

.hope-tools-search:focus { border-color: var(--accent); }

.hope-tools-side__note {
  margin: 0;
  padding-top: 1.2rem;
  border-top: 1px solid color-mix(in srgb, var(--t-medium) 18%, transparent);
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--t-muted);
}

.hope-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr));
  gap: 1.6rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.hope-tools-grid li { margin: 0; }

.hope-tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  height: 100%;
  padding: 2rem;
  border: 1px solid var(--st-medium);
  border-radius: var(--tb-radius, 1rem);
  color: var(--t-bright);
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.hope-tool-card:hover {
  border-color: var(--st-bright);
  background: var(--base-tint);
  transform: translateY(-2px);
}

.hope-tool-card__icon {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 1rem;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 1.8rem;
}

.hope-tool-card__name { font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em; }
.hope-tool-card__desc { margin: 0; font-size: 1.3rem; line-height: 1.6; color: var(--t-medium); }

.hope-tool-card__cat {
  margin-top: auto;
  padding-top: 1.2rem;
  font-family: var(--_font-accent, "JetBrains Mono", monospace);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--t-muted);
}

.hope-tools-empty { padding: 4rem 0; font-size: 1.4rem; color: var(--t-muted); }

/* 网格底下那句指路。原来跟 .hope-tools-empty 共用，上下各 4rem 空白 + 站点蓝链接，
   一句配角文案被撑成了一屏里最跳的东西。这里单独一份：贴着网格、字更小、
   链接用正文色 + 下划线，不抢眼。 */
.hope-tools-more { margin: 2.4rem 0 0; font-size: 1.3rem; color: var(--t-muted); }
.hope-tools-more a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.3rem;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
.hope-tools-more a:hover { text-decoration-color: currentColor; }

@media (max-width: 767px) {
  .tb-cols { grid-template-columns: 1fr; }
  .tb-stats { grid-template-columns: 1fr 1fr; }
  .tb-card-body { padding: 1.4rem; }
  .hope-tool-head__note { flex-basis: 100%; max-width: none; }
}

/* 「需上传」徽标。
   全站只有图片反推带这个 —— 其余工具都承诺文件不出浏览器，
   它正好相反，所以要在点进去之前就看得见。
   用 accent 而不是警示色：这不是危险，是差异。 */
.hope-tool-card {
  position: relative;
}

.hope-tool-card__badge {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  padding: 0.2rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--accent);
  white-space: nowrap;
}

/* 同类工具列表里的「需上传」徽标。理由同索引页的卡片徽标：
   这一排里只有图片反推会上传文件，不标就是让人按错误预期点进去。 */
.hope-tool-siblings__badge {
  padding: 0 0.4rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 0.8em;
  color: var(--accent);
  white-space: nowrap;
}

/* 两栏塌成一栏。900px 是按「左栏 20rem + 右栏至少放得下两列卡片」定的，
   再窄右边就只剩一列，侧栏反而在挤压内容。 */
@media (max-width: 900px) {
  .hope-tools-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
  }

  .hope-tools-side {
    /* 一栏时 sticky 会把整块筛选钉在屏幕上挡住卡片，关掉 */
    position: static;
  }

  /* 窄屏恢复横排 chip：纵向列表在手机上会占掉一整屏 */
  .hope-tools-filters {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.8rem;
  }

  .hope-tools-filters button {
    width: auto;
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    background: var(--tb-fill);
  }

  /* 横排时数量会把 chip 撑得很宽，收掉 */
  .hope-tools-filters__count {
    display: none;
  }

  .hope-tools-side__note {
    padding-top: 0;
    border-top: 0;
  }
}

/* ==========================================================================
   抠图工作台（/tools/matting/）

   这个工具不套 .tb-card 那套两栏卡片：主角是图，切成两半塞进 36rem 的卡片
   就什么都看不清。改成一整块工作台——工具栏 / 胶片条 + 舞台 / 状态行。
   class 前缀用 mt- 与 tb- 区分开，避免以后误改到别的工具。
   ========================================================================== */

.mt-wrap { width: 100%; }

.mt-shell {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--st-medium);
  border-radius: var(--tb-radius);
  overflow: hidden;
  background: var(--base);
}
.mt-shell.over { border-color: var(--accent); }

/* ----- 顶部工具栏 ----- */

.mt-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.2rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--st-medium);
}
.mt-bar-gap { flex: 1; }
.mt-bar-actions { display: flex; align-items: center; gap: 0.8rem; }

.mt-seg {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.mt-seg-label {
  margin-right: 0.2rem;
  color: var(--t-muted);
  font-size: 1.2rem;
}
.mt-seg button {
  padding: 0.4rem 0.9rem;
  border-radius: 0.7rem;
  color: var(--t-medium);
  font-size: 1.3rem;
  line-height: 1.4;
}
.mt-seg button:hover:not(:disabled) { background: var(--tb-hover); }
.mt-seg button.on {
  background: var(--accent);
  /* accent 在两套主题间翻转，写死白色浅色主题下会消失 */
  color: var(--base);
}

.mt-save,
.mt-ghost {
  padding: 0.6rem 1.4rem;
  border-radius: 0.8rem;
  font-size: 1.3rem;
}
.mt-save { background: var(--accent); color: var(--base); }
.mt-ghost { color: var(--t-medium); border: 1px solid var(--st-medium); }
.mt-ghost:hover { background: var(--tb-hover); }

/* ----- 主体：胶片条 + 舞台 ----- */

.mt-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: stretch;
  min-height: 30rem;
}

.mt-rail {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 9.6rem;
  padding: 1.2rem;
  border-right: 1px solid var(--st-medium);
  overflow-y: auto;
  /* 图多了让胶片条自己滚，别把整页撑长 */
  max-height: 52rem;
}

.mt-thumb {
  position: relative;
  flex: none;
}
.mt-thumb-pick {
  display: block;
  width: 7.2rem;
  height: 7.2rem;
  padding: 0;
  border-radius: 0.8rem;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--tb-fill);
}
.mt-thumb-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mt-thumb.on .mt-thumb-pick { border-color: var(--accent); }
.mt-thumb.is-pending .mt-thumb-pick img,
.mt-thumb.is-busy .mt-thumb-pick img { opacity: 0.35; }

.mt-thumb-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  background: var(--base-opp);
  color: var(--base);
  font-size: 1.1rem;
}
.mt-thumb-badge.err { background: var(--reading-signal); color: var(--reading-paper); }

.mt-thumb-spin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border-radius: 999px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  animation: mt-spin 0.8s linear infinite;
}

/* × 常驻而不是 hover 才出：触屏上没有 hover，藏起来等于没有。
   放在缩略图角内而不是外挂：外挂 0.5rem 会压到相邻那张上（间距才 0.8rem），
   手机上一戳就点错图。 */
.mt-thumb-close {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--base-opp);
  color: var(--base);
  font-size: 1.5rem;
  line-height: 1;
  /* 缩略图什么颜色都可能，压在深色照片上时纯 base-opp 会糊掉，补一圈亮描边 */
  box-shadow: 0 0 0 1.5px rgb(255 255 255 / 0.85);
}
.mt-thumb-close:hover { background: var(--reading-signal); color: var(--reading-paper); }

.mt-thumb-retry {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.2rem;
  border-radius: 0.5rem;
  background: var(--tb-fill);
  color: var(--t-medium);
  font-size: 1.1rem;
}

.mt-thumb-add {
  flex: none;
  width: 7.2rem;
  height: 7.2rem;
  border-radius: 0.8rem;
  border: 1px dashed var(--st-medium);
  color: var(--t-muted);
  font-size: 2.2rem;
  line-height: 1;
}
.mt-thumb-add:hover { border-color: var(--accent); color: var(--accent); }

/* ----- 舞台 ----- */

.mt-stage {
  position: relative;
  overflow: hidden;
  place-self: center;
  margin: 1.6rem;
  border-radius: 0.8rem;
  /* 比例跟着原图走，不写死 4:3——竖图套进 4:3 会上下留两条空白。
     先定高再按比例推宽，max-width 反过来压高度，横幅图在窄屏也不溢出。 */
  aspect-ratio: var(--mt-ar, 4 / 3);
  /* 高度分档：竖图的宽度是高度推出来的，高度给死 46rem 的话 1440 宽的屏上
     舞台只有 265px 宽，两边空一大片。大屏放开到 70vh，小屏再收回去。 */
  height: var(--mt-h, min(70vh, 64rem));
  width: auto;
  max-width: calc(100% - 3.2rem);
  touch-action: none;
}

.mt-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* 三种预览底。这里的颜色是「真实底色」而不是主题色：
   选「白」就得是纯白，跟着主题翻转反而看不出边缘毛刺，故意不走 token。 */
.mt-bg-checker {
  background-color: #fff;
  background-image:
    conic-gradient(from 90deg at 50% 50%, #e6e6e6 25%, transparent 0 50%, #e6e6e6 0 75%, transparent 0);
  background-size: 1.6rem 1.6rem;
}
.mt-bg-white { background: #fff; }
.mt-bg-black { background: #111; }

.mt-split {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--base-opp);
  cursor: ew-resize;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.6);
}
/* 线本身太细抓不住，两侧各伸出一条透明区域接手势 */
.mt-split::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1.6rem;
  right: -1.6rem;
}

.mt-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3rem;
  height: 3rem;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: var(--base-opp);
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.7);
}
.mt-grip::after {
  content: "‹ ›";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--base);
  font-size: 1.2rem;
  letter-spacing: 0.08em;
}

.mt-tag {
  position: absolute;
  top: 0.8rem;
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  font-size: 1.1rem;
  pointer-events: none;
}
.mt-tag.left { left: 0.8rem; }
.mt-tag.right { right: 0.8rem; }

/* ----- 空态与加载 ----- */

.mt-empty {
  /* 没有图时胶片条不渲染，但 .mt-body 那两列还在，空态会掉进左边那条
     auto 宽的胶片列里、右边空一大片。让它横跨所有列。 */
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 30rem;
  margin: 1.6rem;
  border: 1px dashed var(--st-medium);
  border-radius: 0.8rem;
  color: var(--t-medium);
  text-align: center;
}
.mt-empty:hover { border-color: var(--accent); }
.mt-empty strong { font-size: 1.6rem; color: var(--t-bright); }
.mt-empty-quiet { color: var(--t-muted); font-size: 1.2rem; }

.mt-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(2px);
  color: #fff;
}

.mt-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 1.6rem;
  text-align: center;
}
.mt-loader strong { font-weight: 500; }

.mt-spinner {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: mt-spin 0.8s linear infinite;
}
@keyframes mt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .mt-spinner, .mt-thumb-spin { animation-duration: 2.4s; }
}

.mt-bar-track {
  width: min(28rem, 60vw);
  height: 0.5rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.25);
  overflow: hidden;
}
.mt-bar-track span {
  display: block;
  height: 100%;
  background: currentColor;
  transition: width 0.2s ease;
}

/* ----- 底部状态行 ----- */

.mt-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1.2rem;
  border-top: 1px solid var(--st-medium);
  color: var(--t-medium);
  font-size: 1.2rem;
}
.mt-foot-name {
  min-width: 0;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--t-bright);
}
.mt-foot-gap { flex: 1; }
.mt-foot-arrow, .mt-foot-quiet { color: var(--t-muted); }
.mt-foot-err { color: var(--reading-signal); }

.mt-note {
  margin-top: 1.2rem;
  color: var(--t-muted);
  font-size: 1.2rem;
  line-height: 1.7;
}

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

/* 平板：舞台收一档，胶片条还留在左边 */
@media (max-width: 1023px) {
  .mt-body { --mt-h: min(62vh, 52rem); }
  .mt-rail { width: 8.8rem; padding: 1rem; }
  .mt-thumb-pick, .mt-thumb-add { width: 6.4rem; height: 6.4rem; }
}

/* 窄屏：胶片条翻到舞台下面横着走，舞台再让出一档高度 */
@media (max-width: 760px) {
  .mt-body {
    grid-template-columns: minmax(0, 1fr);
    --mt-h: min(54vh, 44rem);
  }
  .mt-rail {
    flex-direction: row;
    width: auto;
    max-height: none;
    padding: 1rem 1.2rem;
    border-right: 0;
    border-top: 1px solid var(--st-medium);
    order: 2;
    overflow-x: auto;
  }
  .mt-stage { margin: 1.2rem; max-width: calc(100% - 2.4rem); }
  /* 分组标签收掉——「对比 / 只看结果」这些按钮本身已经说清楚了，
     留着标签会把工具栏顶成两行 */
  .mt-seg-label { display: none; }
  .mt-seg { gap: 0.3rem; }
  .mt-bar { gap: 0.8rem 1rem; padding: 0.9rem 1rem; }
  .mt-foot { padding: 0.8rem 1rem; }
}

/* 手机：分组标签收掉——「对比 / 只看结果」这些按钮本身已经说清楚了，
   留着标签会把工具栏顶成三行。动作组换到单独一行占满宽度。 */
@media (max-width: 600px) {
  .mt-seg button { padding: 0.4rem 0.7rem; }
  .mt-bar-gap { flex-basis: 100%; height: 0; }
  .mt-bar-actions { width: 100%; }
  .mt-bar-actions .mt-save { flex: 1; }
  .mt-empty { min-height: 22rem; margin: 1.2rem; }
  .mt-foot-name { max-width: 100%; }
}
