/* ==========================================================================
   kis6 工具箱 · 主样式
   ========================================================================== */

:root {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-alt: #f8fafc;
  --border: #e4e8f0;
  --border-strong: #d3d9e6;
  --text: #16213a;
  --text-dim: #5d6b85;
  --text-faint: #8a97ad;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #0f9d58;
  --success-soft: #e6f4ea;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 268px;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --panel: #161b22;
  --panel-alt: #1c2128;
  --border: #2a313c;
  --border-strong: #3a434f;
  --text: #e6edf3;
  --text-dim: #9aa7b8;
  --text-faint: #6b7684;
  --primary: #6366f1;
  --primary-hover: #7c7ff5;
  --primary-soft: #1e2138;
  --success: #3fb950;
  --success-soft: #14261b;
  --warn: #d29922;
  --warn-soft: #2b2314;
  --danger: #f85149;
  --danger-soft: #2d1618;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 4px 16px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------- 布局 ------------------------------- */

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: margin-left .2s ease;
}

.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar-head {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.brand { font-weight: 600; font-size: 15px; }

/* 侧栏顶部的站点名，点回首页。是 <a>，去掉下划线和链接色 */
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

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

.site-footer {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

.site-footer .footer-line { line-height: 1.9; }

.site-footer a {
  color: var(--text-faint);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* 后台「页脚文字」支持 HTML，这里让常见标签在页脚的居中窄栏里不跑版 */
.site-footer .footer-note { color: var(--text-dim); }
.site-footer .footer-note a { color: var(--primary); }
.site-footer p { margin: 0; }
.site-footer img { max-height: 20px; vertical-align: middle; }
.site-footer code,
.site-footer kbd {
  padding: 0 4px;
  border-radius: 4px;
  background: var(--panel-alt);
  font-family: var(--mono);
}
.site-footer ul,
.site-footer ol {
  display: inline-block;
  margin: 4px 0;
  padding-left: 20px;
  text-align: left;
}
.site-footer hr {
  width: 60px;
  margin: 6px auto;
  border: 0;
  border-top: 1px solid var(--border);
}

.sidebar-search {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-alt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a97ad' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 10px center;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  background-color: var(--panel);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
}

.nav-group-title {
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13.5px;
  transition: background .12s, color .12s;
  border: none;
  background: none;
  /* 侧栏项已改成 <a href>，得把链接的下划线和默认色去掉 */
  text-decoration: none;
  width: calc(100% - 16px);
  text-align: left;
  font-family: inherit;
}

.nav-item:hover { background: var(--panel-alt); color: var(--text); }

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

.nav-item .icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--panel-alt);
  color: var(--text-faint);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: var(--header-h);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
}

.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-desc { color: var(--text-dim); font-size: 12.5px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ------------------------------- 控件 ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}

.btn:hover { background: var(--panel-alt); border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

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

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.textarea {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
  min-height: 120px;
}

.field { margin-bottom: 14px; }
.field-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  user-select: none;
}
.checkbox-row input { cursor: pointer; }

/* ------------------------------- 卡片 ------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px;
}

.tool-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  font-family: inherit;
  /* 卡片也改成了 <a href>：a 默认 inline，撑不满网格格子 */
  display: block;
  color: inherit;
  text-decoration: none;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.tool-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tool-card-icon { font-size: 20px; }
.tool-card-name { font-weight: 600; font-size: 13.5px; }
.tool-card-desc { color: var(--text-dim); font-size: 12px; line-height: 1.5; }

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* ------------------------------- 工具工作区 ------------------------------- */

/* ------------------------------ 广告位 ------------------------------ */

.ad-slot { margin: 14px 0; }
.ad-slot[style*="display: none"] { margin: 0; }

/* 工具主体 + 右侧广告：宽屏并排，窄屏自动堆成一列 */
.tool-body { display: flex; gap: 16px; align-items: flex-start; }
.tool-main { flex: 1 1 auto; min-width: 0; }
.ad-sidebar { flex: 0 0 300px; width: 300px; margin: 0; position: sticky; top: 8px; }

@media (max-width: 1100px) {
  .tool-body { flex-direction: column; }
  .ad-sidebar { flex: none; width: 100%; position: static; }
}

.tool-header { margin-bottom: 16px; }
.tool-header h1 {
  font-size: 20px;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tool-header p { margin: 0; color: var(--text-dim); font-size: 13px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar .spacer { flex: 1; }
.toolbar:last-child { margin-bottom: 0; }

/* 操作组的小标题，用来把一排按钮按语义分开 */
.toolbar-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .4px;
  color: var(--text-faint);
  white-space: nowrap;
  padding-right: 2px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}

.pane { display: flex; flex-direction: column; }
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.output {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 120px;
  max-height: 520px;
  overflow: auto;
}

.status {
  margin-top: 8px;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}
.status-ok { background: var(--success-soft); color: var(--success); }
.status-err { background: var(--danger-soft); color: var(--danger); }
.status-info { background: var(--primary-soft); color: var(--primary); }

.kv-table { width: 100%; border-collapse: collapse; }
.kv-table th, .kv-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}
.kv-table th { color: var(--text-dim); font-weight: 500; width: 120px; background: var(--panel-alt); }
.kv-table tr:last-child td, .kv-table tr:last-child th { border-bottom: none; }

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-faint);
}
.empty .icon { font-size: 40px; margin-bottom: 10px; }

/* ------------------------------- Toast ------------------------------- */

.toast-host {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}

.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------- 加载 ------------------------------- */

.boot-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  color: var(--text-dim);
}

.boot-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.boot-error {
  max-width: 640px;
  margin: 80px auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  line-height: 1.8;
}
.boot-error h2 { color: var(--danger); margin-top: 0; }
.boot-error pre {
  background: var(--panel-alt);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--mono);
}

/* ------------------------------- 杂项 ------------------------------- */

.announce {
  background: var(--warn-soft);
  color: #92400e;
  border: 1px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

[data-theme="dark"] .announce { color: var(--warn); }

.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
  background: var(--panel-alt);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.drop-zone .icon { font-size: 32px; display: block; margin-bottom: 8px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.muted { color: var(--text-dim); font-size: 12.5px; }
.mono { font-family: var(--mono); }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th, table.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
table.data-table th {
  background: var(--panel-alt);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
}
table.data-table tbody tr:hover { background: var(--panel-alt); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid var(--bg);
}

/* ==========================================================================
   在线 PS 图片编辑器
   ========================================================================== */

.pe-wrap {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.pe-side { display: flex; flex-direction: column; gap: 12px; }

/* 侧栏自己滚，画布一直留在视野里。
   不然侧栏一长（图层多了尤其明显），往下滚面板时画布就跑没了。 */
.pe-side {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

/* 当前工具的参数面板：紧跟工具网格，用左侧色条和它连成一组，
   一眼能看出这块属于刚点的那个工具 */
.pe-side > .pe-panel > .card {
  box-shadow: inset 3px 0 0 var(--primary), var(--shadow-sm);
  border-color: var(--primary-soft);
}
.pe-side > .pe-panel { margin-top: -4px; }

/* 提示"先输入文字"时把对应的输入框闪一下：光有文案没人知道框在哪 */
.pe-flash { animation: pe-flash 1.4s ease; }
@keyframes pe-flash {
  0%, 55% { box-shadow: 0 0 0 2px var(--primary); border-color: var(--primary); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.pe-stage {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.pe-stage-top {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: auto;
  /* 棋盘格背景：透明 PNG 能一眼看出来哪里是空的 */
  background-color: var(--panel-alt);
  background-image:
    linear-gradient(45deg, var(--border) 25%, transparent 25%),
    linear-gradient(-45deg, var(--border) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--border) 75%),
    linear-gradient(-45deg, transparent 75%, var(--border) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.pe-canvas {
  display: none;
  max-width: 100%;
  max-height: 66vh;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(16, 24, 40, .18);
  touch-action: none;
  background: var(--bg-elevated);
}

.pe-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 16px;
}
.pe-empty .icon { font-size: 46px; display: block; margin-bottom: 10px; }

.pe-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel-alt);
  font-size: 12.5px;
  color: var(--text-dim);
}

.pe-panel { display: flex; flex-direction: column; gap: 12px; }
.pe-sliders { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }

/* 工具入口：图标 + 文字的方块网格。格子必须等大等高，
   不然 emoji 宽窄不一 + 文字长短不齐会挤出一堆参差的按钮 */
.pe-modes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.pe-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 2px 7px;
  min-height: 54px;
  line-height: 1;
  font-size: 12px;
  white-space: nowrap;
}
.pe-mode-btn span:first-child {
  font-size: 18px;
  line-height: 1;
  /* 统一图标格的视觉占位，emoji 高低胖瘦不一会把行高顶乱 */
  height: 20px;
  display: flex;
  align-items: center;
}
.pe-mode-btn span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 图层列表 */
.pe-layer-list { display: flex; flex-direction: column; gap: 6px; }
.pe-layer-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--panel-alt);
  cursor: pointer;
}
.pe-layer-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.pe-layer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.pe-layer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}
.pe-layer-size { color: var(--text-faint); font-size: 11.5px; font-family: var(--mono); }
.pe-layer-ops { display: flex; gap: 4px; margin: 4px 0 2px; }
.pe-layer-ops .btn { padding: 2px 6px; font-size: 12px; }

/* 色块与信息行 */
.pe-swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  vertical-align: middle;
}
.pe-swatches { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.pe-info-box { font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.pe-info-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
}
.pe-private { color: var(--danger); }
.pe-private .mono { color: var(--danger); }

/* 扩展画布的四边输入 */
.pe-pad-grid {
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  gap: 5px;
  align-items: center;
  margin-bottom: 8px;
}
.pe-pad-grid .input { padding: 4px 6px; text-align: center; }
.pe-pad-grid .muted { text-align: center; font-size: 11.5px; }

.pe-mini-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.pe-mini-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.pe-clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
}

.pe-slider { display: flex; flex-direction: column; gap: 5px; }
.pe-slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-dim);
}
.pe-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  min-width: 44px;
  text-align: right;
}

.pe-range {
  width: 100%;
  height: 22px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.pe-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 3px;
  background: var(--border-strong);
}
.pe-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
.pe-range::-moz-range-track {
  height: 4px;
  border-radius: 3px;
  background: var(--border-strong);
}
.pe-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-elevated);
}

.pe-color {
  width: 44px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

/* ==========================================================================
   统计卡 / 二维码 logo / 网站测速
   （.stat-grid 这套原本只写在 admin.css 里，而前台不会加载后台样式，
     所以用到它的工具页一直是"裸"的 —— 这里补一份给前台用）
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-value { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

/* 二维码：logo 缩略图 */
.qr-logo-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-alt);
}

/* ------------------------------ 网站测速 ------------------------------ */

.sp-form { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 12px; align-items: start; }
.sp-opts { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 760px) {
  .sp-form { grid-template-columns: minmax(0, 1fr); }
}

/* 进度条：跑一组要好几秒，没有反馈会以为卡住了 */
.sp-progress {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-alt);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.sp-progress::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: var(--p, 0%);
  background: var(--primary);
  transition: width .25s ease;
}

/* 大号读数：带宽结果用它比挤表格里好认得多 */
.sp-readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.sp-readout {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-alt);
  padding: 14px 16px;
  text-align: center;
}
.sp-readout-label { font-size: 12.5px; color: var(--text-dim); }
.sp-readout-main { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin: 4px 0 2px; }
.sp-readout-num { font-size: 34px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sp-readout-unit { font-size: 13px; color: var(--text-dim); }
.sp-readout-grade { font-size: 12.5px; font-weight: 600; }

/* 节点列表 */
.sp-nodes { display: flex; flex-direction: column; gap: 8px; }
.sp-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--panel-alt);
}
.sp-node-name { font-weight: 600; font-size: 13.5px; }
.sp-node-url { font-size: 12px; color: var(--text-dim); word-break: break-all; }

.sp-code {
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-alt);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}
.sp-steps { margin: 0; padding-left: 20px; color: var(--text-dim); font-size: 13px; line-height: 1.9; }

@media (max-width: 980px) {
  .pe-wrap { grid-template-columns: minmax(0, 1fr); }
  .pe-stage { min-height: 380px; }
  .pe-canvas { max-height: 50vh; }
  /* 单列时再给侧栏加自己的滚动条只会把内容关在小盒子里 */
  .pe-side { position: static; max-height: none; overflow: visible; }
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
