/* tools.css — shared styling for the client-side tool apps.
   Uses the existing design tokens (pure black/white surfaces, 0 radius,
   hairline borders, mono labels). Every tool app renders inside
   `.tool-app[data-tool]`; JS builds the interior. */

.tool-app {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.tool-app noscript {
  display: block;
  border: 1px solid var(--border, #404040);
  padding: 16px;
  color: var(--muted, #9aa0a6);
}

/* ── generic panel / card ── */
.tp-panel {
  border: 1px solid var(--border, #404040);
  background: var(--surface, #0a0a0a);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.tp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 180px;
  min-width: 0;
}

.tp-label {
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #9aa0a6);
}

.tp-hint {
  font-size: 13px;
  color: var(--muted, #9aa0a6);
  line-height: 1.5;
}

.tp-input,
.tp-select,
.tp-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg, #000);
  color: var(--fg, #fff);
  border: 1px solid var(--border, #404040);
  border-radius: 0;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
}

.tp-input:focus,
.tp-select:focus,
.tp-textarea:focus {
  outline: none;
  border-color: var(--accent, #22d3ee);
}

.tp-textarea {
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  min-height: 200px;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}

.tp-textarea.tp-wrap { white-space: pre-wrap; word-break: break-word; }

.tp-mono { font-family: var(--font-mono, "Geist Mono", monospace); }

/* ── controls row ── */
.tp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.tp-btn {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--border, #404040);
  background: var(--bg, #000);
  color: var(--fg, #fff);
  border-radius: 0;
  padding: 9px 16px;
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.tp-btn:hover { border-color: var(--accent, #22d3ee); color: var(--accent, #22d3ee); }
.tp-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.tp-btn.tp-primary {
  background: linear-gradient(135deg, var(--accent, #22d3ee), var(--accent-2, #0891b2));
  color: var(--accent-ink, #000);
  border-color: transparent;
}
.tp-btn.tp-primary:hover { color: var(--accent-ink, #000); filter: brightness(1.08); }

.tp-btn.tp-ghost { background: transparent; }

/* ── inline stat / result grid ── */
.tp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.tp-stat {
  border: 1px solid var(--border, #404040);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tp-stat-val {
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 26px;
  font-weight: 500;
  color: var(--fg, #fff);
  line-height: 1.1;
  word-break: break-word;
}

.tp-stat-label {
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted, #9aa0a6);
}

/* ── kv table ── */
.tp-kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.tp-kv th, .tp-kv td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border, #404040);
  vertical-align: top;
}
.tp-kv th {
  width: 40%;
  color: var(--muted, #9aa0a6);
  font-weight: 400;
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 12px;
}
.tp-kv td { font-family: var(--font-mono, "Geist Mono", monospace); word-break: break-word; }

/* ── status pills / badges ── */
.tp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--border, #404040);
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.tp-pill.is-good { border-color: #16a34a; color: #4ade80; }
.tp-pill.is-warn { border-color: #d97706; color: #fbbf24; }
.tp-pill.is-bad  { border-color: #dc2626; color: #f87171; }

.tp-msg { font-size: 13px; line-height: 1.5; }
.tp-msg.is-error { color: #f87171; }
.tp-msg.is-ok { color: #4ade80; }
.tp-msg.is-muted { color: var(--muted, #9aa0a6); }

.tp-error-line {
  border-left: 2px solid #dc2626;
  padding: 8px 12px;
  background: rgba(220, 38, 38, 0.08);
  color: #f87171;
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 13px;
}

/* ── json highlighting ── */
.tp-json-out {
  margin: 0;
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 460px;
}
.tp-jk { color: var(--accent, #22d3ee); }
.tp-js { color: #4ade80; }
.tp-jn { color: #fbbf24; }
.tp-jb { color: #f472b6; }
.tp-jnull { color: var(--muted, #9aa0a6); }

/* ── diff ── */
.tp-diff {
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid var(--border, #404040);
  overflow: auto;
  max-height: 520px;
}
.tp-diff-line { display: flex; white-space: pre-wrap; word-break: break-word; }
.tp-diff-gutter {
  flex: 0 0 3ch;
  text-align: center;
  color: var(--muted, #9aa0a6);
  user-select: none;
  border-right: 1px solid var(--border, #404040);
}
.tp-diff-text { padding: 0 10px; flex: 1 1 auto; }
.tp-diff-add { background: rgba(22, 163, 74, 0.14); }
.tp-diff-add .tp-diff-text { color: #4ade80; }
.tp-diff-del { background: rgba(220, 38, 38, 0.14); }
.tp-diff-del .tp-diff-text { color: #f87171; }

/* ── canvas / media surfaces ── */
.tp-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--border, #404040);
  background: #fff;
  min-height: 120px;
}
.tp-canvas-wrap canvas, .tp-canvas-wrap svg, .tp-canvas-wrap img { max-width: 100%; height: auto; display: block; }

.tp-video {
  width: 100%;
  max-height: 420px;
  background: #000;
  border: 1px solid var(--border, #404040);
  display: block;
}

.tp-meter {
  width: 100%;
  height: 22px;
  border: 1px solid var(--border, #404040);
  background: var(--bg, #000);
  overflow: hidden;
}
.tp-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent, #22d3ee), var(--accent-2, #0891b2));
  transition: width 0.06s linear;
}

.tp-scope { width: 100%; height: 120px; background: var(--bg, #000); border: 1px solid var(--border, #404040); display: block; }

/* ── password strength bar ── */
.tp-strength { display: flex; gap: 6px; }
.tp-strength-seg { flex: 1; height: 8px; background: var(--border, #404040); }
.tp-strength-seg.on-0 { background: #dc2626; }
.tp-strength-seg.on-1 { background: #d97706; }
.tp-strength-seg.on-2 { background: #eab308; }
.tp-strength-seg.on-3 { background: #22c55e; }
.tp-strength-seg.on-4 { background: #16a34a; }

/* ── checkbox / range rows ── */
.tp-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.tp-check input { width: 16px; height: 16px; accent-color: var(--accent, #22d3ee); }
.tp-range { width: 100%; accent-color: var(--accent, #22d3ee); }

/* ── clicker target ── */
.tp-clicker {
  border: 1px dashed var(--border, #404040);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.tp-clicker:hover { border-color: var(--accent, #22d3ee); }
.tp-clicker.is-live { border-style: solid; border-color: var(--accent, #22d3ee); background: rgba(34, 211, 238, 0.05); }
.tp-clicker-big {
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 46px;
  line-height: 1;
  color: var(--fg, #fff);
}

.tp-out-mono {
  font-family: var(--font-mono, "Geist Mono", monospace);
  font-size: 18px;
  word-break: break-all;
  color: var(--fg, #fff);
  padding: 12px;
  border: 1px solid var(--border, #404040);
  background: var(--bg, #000);
}

.tp-swatch { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--border, #404040); vertical-align: middle; }

.tp-list { display: flex; flex-direction: column; gap: 8px; }
.tp-title { font-size: 15px; font-weight: 500; margin: 0; }
.tp-note { font-size: 12px; color: var(--muted, #9aa0a6); line-height: 1.5; }

@media (max-width: 640px) {
  .tp-kv th { width: 45%; }
  .tp-stat-val { font-size: 22px; }
}
