/* ============================================================
   YuuToolbox · components.css
   通用组件 + 各工具样式
   ============================================================ */

/* ---------- 通用文本 ---------- */
.muted { color: var(--text-dim); }
.tiny { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease),
              transform .08s var(--ease), opacity .15s var(--ease);
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-mute); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: transparent; }

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.btn-danger:hover { background: var(--err-soft); border-color: var(--err); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.menu-btn { display: none; }

/* ---------- 表单控件 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-dim);
  text-transform: uppercase;
}

input[type="text"], input[type="number"], input[type="search"], input[type="url"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
textarea { resize: vertical; font-family: var(--font-mono); line-height: 1.55; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
                    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

input[type="color"] {
  width: 44px; height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
}

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

/* ---------- 页面头部 ---------- */
.page-head { margin-bottom: 22px; }
.page-head h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-head .desc { color: var(--text-dim); margin-top: 6px; max-width: 78ch; }
.tool-ico-big { font-size: 22px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.plain { background: var(--bg-hover); color: var(--text-dim); }

/* ---------- 网格 / 行 ---------- */
.grid { display: grid; gap: 14px; }
.grid-top { align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 工具网格（首页） ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  transition: transform .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.tool-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.tool-card .tc-ico { font-size: 22px; }
.tool-card .tc-name { font-weight: 650; font-size: 14.5px; }
.tool-card .tc-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.tool-card .tc-tag {
  align-self: flex-start;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg-hover);
  padding: 1px 8px;
  border-radius: 999px;
}

.hero {
  padding: 24px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 0% 0%, var(--accent-soft), transparent 60%),
    var(--bg-soft);
  border: 1px solid var(--border);
  margin-bottom: 22px;
}
.hero h1 { font-size: 27px; letter-spacing: -.4px; }
.hero p { color: var(--text-dim); margin-top: 8px; max-width: 70ch; }
.hero .row { margin-top: 16px; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 24px 0 12px;
}

/* ---------- 结果 / 输出区 ---------- */
.output {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: auto;
  max-height: 480px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--text-mute); }
.kv dd { margin: 0; font-family: var(--font-mono); word-break: break-all; }

.stat {
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.stat .s-label { font-size: 11.5px; color: var(--text-mute); letter-spacing: .05em; text-transform: uppercase; }
.stat .s-value { font-size: 20px; font-weight: 700; font-family: var(--font-mono); margin-top: 2px; }
.stat .s-value.ok { color: var(--ok); }
.stat .s-value.err { color: var(--err); }
.stat .s-value.warn { color: var(--warn); }

.empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  border: 1px solid transparent;
  margin-top: 10px;
}
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th, table.data td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  background: var(--bg-hover);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data td.mono { font-family: var(--font-mono); }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.run { background: var(--accent-soft); color: var(--accent); }

/* 延迟条 */
.lat-bar { display: flex; align-items: center; gap: 8px; }
.lat-bar .track {
  position: relative;
  flex: 1;
  min-width: 60px;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}
.lat-bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--ok); transition: width .2s var(--ease); }
.lat-bar .fill.warn { background: var(--warn); }
.lat-bar .fill.err { background: var(--err); }

/* ---------- 分页标签 ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- 提示条 ---------- */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  min-width: 180px;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in .22s var(--ease);
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--err); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 网络状态 ---------- */
.offline-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.offline-dot::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.offline-dot.off::before { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }

/* ============================================================
   站点 Ping
   ============================================================ */
.ping-form { display: grid; gap: 14px; grid-template-columns: minmax(0, 2.4fr) repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .ping-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 560px) { .ping-form { grid-template-columns: minmax(0, 1fr); } }

.ping-url-cell { grid-column: 1 / -1; }

.target-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.target-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 10px;
  font-size: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
}
.target-chip button {
  border: none;
  background: none;
  color: var(--text-mute);
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
}
.target-chip button:hover { color: var(--err); background: var(--err-soft); }

.ping-summary { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 68px;
  max-width: 420px;
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.spark .bar {
  flex: 1 1 0;
  max-width: 26px;
  min-width: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--ok);
  transition: height .2s var(--ease);
  position: relative;
}
.spark .bar.warn { background: var(--warn); }
.spark .bar.err { background: var(--err); }

/* ============================================================
   代码编辑器（带行号）
   ============================================================ */
.editor {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  overflow: hidden;
}
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor .gutter {
  margin: 0;
  padding: 10px 8px;
  min-width: 44px;
  text-align: right;
  color: var(--text-mute);
  background: var(--bg-hover);
  border-right: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  overflow: hidden;
  user-select: none;
}
.editor .gutter-lines { margin: 0; font: inherit; }
.editor textarea {
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: 220px;
  box-shadow: none !important;
}
.editor textarea:focus { border: none; box-shadow: none; }

/* ============================================================
   JSON 格式化 / 树
   ============================================================ */
.json-tree {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow: auto;
  max-height: 560px;
}
.jt-line { white-space: pre; }
.jt-key { color: var(--code-key); }
.jt-str { color: var(--code-str); }
.jt-num { color: var(--code-num); }
.jt-bool { color: var(--code-bool); }
.jt-null { color: var(--code-null); font-style: italic; }
.jt-toggle {
  display: inline-block;
  width: 14px;
  cursor: pointer;
  color: var(--text-mute);
  user-select: none;
}
.jt-toggle:hover { color: var(--accent); }
.jt-meta { color: var(--text-mute); }
.jt-children.collapsed { display: none; }
.jt-line.match { background: var(--accent-soft); }

/* 差异 */
.diff-line { white-space: pre-wrap; padding: 0 6px; border-radius: 3px; }
.diff-line.add { background: var(--ok-soft); color: var(--ok); }
.diff-line.del { background: var(--err-soft); color: var(--err); }
.diff-line.eq { color: var(--text-dim); }

/* ============================================================
   哈希工具
   ============================================================ */
.algo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.algo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.algo-item:hover { border-color: var(--accent); background: var(--bg-hover); }
.algo-item input { margin-top: 3px; }
.algo-item span { display: flex; flex-direction: column; line-height: 1.35; }
.algo-item span strong { font-size: 13.5px; }
.algo-item span small { font-size: 11.5px; }

.dropzone {
  margin-top: 12px;
  padding: 16px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   Base64 / 编码转换
   ============================================================ */
.io-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 780px) { .io-grid { grid-template-columns: minmax(0, 1fr); } }
.io-grid textarea { min-height: 200px; }
.io-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* ============================================================
   URL 解析
   ============================================================ */
.url-split { word-break: break-all; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.9; }
.url-split .u-scheme { color: var(--code-bool); }
.url-split .u-host { color: var(--code-key); font-weight: 600; }
.url-split .u-path { color: var(--code-str); }
.url-split .u-query { color: var(--code-num); }
.url-split .u-hash { color: var(--code-null); }

/* ============================================================
   正则
   ============================================================ */
.regex-input { font-family: var(--font-mono); }
.match-count { font-family: var(--font-mono); font-weight: 700; color: var(--accent); }

/* ============================================================
   时间戳
   ============================================================ */
.clock-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.tz-table { font-size: 12.5px; }
.clock-face {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
}

/* ============================================================
   正则高亮（与「正则」同组）
   ============================================================ */
.hl-wrap {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: auto;
  max-height: 400px;
}
.hl-wrap mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 60%, transparent);
}
.hl-wrap mark:nth-child(even) { background: var(--warn-soft); color: var(--warn); }

/* ============================================================
   UUID
   ============================================================ */
.uuid-list { display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow: auto; }
.uuid-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.uuid-item:hover { border-color: var(--accent); }
.uuid-item code { word-break: break-all; }

/* ============================================================
   颜色
   ============================================================ */
.color-swatch {
  height: 120px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 16px;
  transition: background-color .2s var(--ease);
}
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.palette .sw {
  border-radius: var(--radius-sm);
  height: 62px;
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: transform .12s var(--ease);
}
.palette .sw:hover { transform: scale(1.05); }

/* ============================================================
   二维码
   ============================================================ */
.qr-stage {
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 260px;
}
.qr-stage canvas {
  background: #fff;
  border-radius: 6px;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   文本统计 / 差异
   ============================================================ */
.textarea-lg { min-height: 190px; }

.bar-list { display: grid; gap: 8px; }
.bar-item { display: grid; grid-template-columns: 110px minmax(0, 1fr) 70px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-item .track { height: 8px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; }
.bar-item .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar-item .val { text-align: right; font-family: var(--font-mono); color: var(--text-dim); }
