/* ==========================================================================
   TechErics Tools — shared tool UI kit
   Same tokens as the homepage (assets/css/style.css / design-tokens.css).
   Every class is prefixed with `te-` so it never collides with older pages.
   ========================================================================== */
.te-page {
  --te-brand: #2563eb;
  --te-brand-hover: #1d4ed8;
  --te-brand-light: #eff6ff;
  --te-brand-border: #bfdbfe;
  --te-ink: #0f172a;
  --te-ink-2: #1e293b;
  --te-muted: #475569;
  --te-dim: #64748b;
  --te-faint: #94a3b8;
  --te-line: #e2e8f0;
  --te-line-2: #cbd5e1;
  --te-canvas: #f8fafc;
  --te-surface: #f1f5f9;
  --te-ok: #059669;
  --te-ok-bg: #ecfdf5;
  --te-err: #dc2626;
  --te-err-bg: #fef2f2;
  --te-warn: #d97706;
  --te-warn-bg: #fffbeb;
  --te-radius: 16px;
  --te-radius-sm: 10px;
  --te-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --te-shadow-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.1), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  --te-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --te-display: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  --te-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  max-width: 1120px;
  margin: 32px auto 56px;
  padding: 0 20px;
  font-family: var(--te-font);
  color: var(--te-ink-2);
  text-align: left;
  position: relative;
  z-index: 1;
}
.te-page *, .te-page *::before, .te-page *::after { box-sizing: border-box; }
.te-page [hidden] { display: none !important; }

/* ---------- Header ---------- */
.te-head { text-align: center; margin: 0 auto 28px; max-width: 760px; }
.te-pills { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.te-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; line-height: 1.2;
  background: var(--te-brand-light); color: var(--te-brand); border: 1px solid var(--te-brand-border);
}
.te-pill--slate { background: var(--te-canvas); color: var(--te-muted); border-color: var(--te-line); }
.te-pill--ok { background: var(--te-ok-bg); color: var(--te-ok); border-color: #a7f3d0; }
.te-page h1.te-title {
  font-family: var(--te-display); font-size: clamp(1.7rem, 3.2vw, 2.3rem); font-weight: 800;
  letter-spacing: -0.025em; color: var(--te-ink) !important; margin: 0 0 10px; line-height: 1.15;
}
.te-sub { color: var(--te-muted); font-size: 1.02rem; line-height: 1.6; margin: 0; }

/* ---------- Layout ---------- */
.te-grid { display: grid; gap: 20px; }
.te-grid--2 { grid-template-columns: 1fr 1fr; }
.te-grid--side { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.te-grid--side-r { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
.te-grid--3 { grid-template-columns: repeat(3, 1fr); }
.te-stack { display: flex; flex-direction: column; gap: 16px; }
.te-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.te-row--between { justify-content: space-between; }
.te-row--end { justify-content: flex-end; }
.te-mt { margin-top: 16px; }
.te-mb { margin-bottom: 16px; }
@media (max-width: 860px) {
  .te-grid--2, .te-grid--side, .te-grid--side-r, .te-grid--3 { grid-template-columns: 1fr; }
}

/* ---------- Cards ---------- */
.te-card {
  background: #ffffff; border: 1px solid var(--te-line); border-radius: var(--te-radius);
  box-shadow: var(--te-shadow); padding: 24px; min-width: 0;
}
.te-card--tight { padding: 18px; }
.te-card--flat { box-shadow: none; background: var(--te-canvas); }
.te-card-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 16px;
  font-size: 0.98rem; font-weight: 700; color: var(--te-ink) !important; letter-spacing: -0.01em;
}
.te-card-title .te-step {
  width: 24px; height: 24px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--te-brand); color: #fff; font-size: 0.75rem; font-weight: 700;
}
.te-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.te-card-head .te-card-title { margin: 0; }

/* ---------- Form controls ---------- */
.te-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.te-label { font-size: 0.84rem; font-weight: 600; color: var(--te-ink); display: flex; justify-content: space-between; gap: 8px; }
.te-label small { font-weight: 500; color: var(--te-dim); }
.te-hint { font-size: 0.8rem; color: var(--te-dim); margin: 0; }
.te-input, .te-select, .te-textarea {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--te-ink) !important;
  background: #ffffff !important; border: 1px solid var(--te-line-2) !important; border-radius: var(--te-radius-sm);
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s; outline: none;
}
.te-input:focus, .te-select:focus, .te-textarea:focus {
  border-color: var(--te-brand) !important; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.te-textarea { min-height: 220px; resize: vertical; line-height: 1.6; }
.te-textarea--mono, .te-mono { font-family: var(--te-mono) !important; font-size: 0.86rem; }
.te-textarea[readonly], .te-input[readonly] { background: var(--te-canvas) !important; }
.te-select { appearance: auto; }
.te-range { width: 100%; accent-color: var(--te-brand); }
.te-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--te-muted); cursor: pointer; }
.te-check input { accent-color: var(--te-brand); width: 16px; height: 16px; }
.te-color { width: 52px; height: 42px; padding: 3px; border: 1px solid var(--te-line-2); border-radius: var(--te-radius-sm); background: #fff; cursor: pointer; }

/* ---------- Buttons ---------- */
.te-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: var(--te-radius-sm); font: inherit; font-size: 0.9rem; font-weight: 600;
  background: var(--te-surface); color: var(--te-ink-2); border: 1px solid var(--te-line);
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .05s; text-decoration: none; line-height: 1.2;
}
.te-btn:hover { background: #e2e8f0; color: var(--te-ink); }
.te-btn:active { transform: translateY(1px); }
.te-btn:disabled { opacity: .55; cursor: not-allowed; }
.te-btn--primary { background: var(--te-brand); border-color: var(--te-brand); color: #fff; }
.te-btn--primary:hover { background: var(--te-brand-hover); border-color: var(--te-brand-hover); color: #fff; }
.te-btn--ghost { background: #fff; }
.te-btn--danger { background: #fff; color: var(--te-err); border-color: #fecaca; }
.te-btn--danger:hover { background: var(--te-err-bg); color: var(--te-err); }
.te-btn--sm { padding: 6px 11px; font-size: 0.8rem; border-radius: 8px; }
.te-btn--lg { padding: 13px 22px; font-size: 1rem; }
.te-btn--block { width: 100%; }

/* ---------- Segmented control / tabs ---------- */
.te-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--te-surface); padding: 4px; border-radius: 12px; border: 1px solid var(--te-line); }
.te-seg button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font: inherit; font-size: 0.85rem; font-weight: 600;
  color: var(--te-muted); cursor: pointer;
}
.te-seg button[aria-pressed="true"], .te-seg button.is-active { background: #fff; color: var(--te-brand); box-shadow: var(--te-shadow); }

/* ---------- Chips ---------- */
.te-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.te-chip {
  border: 1px solid var(--te-line-2); background: #fff; color: var(--te-muted); border-radius: 999px;
  padding: 6px 12px; font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.te-chip:hover { border-color: var(--te-brand); color: var(--te-brand); }

/* ---------- Drop zone ---------- */
.te-drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; padding: 34px 20px; border: 2px dashed var(--te-brand-border); border-radius: var(--te-radius);
  background: var(--te-brand-light); color: var(--te-muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.te-drop:hover, .te-drop.is-over { border-color: var(--te-brand); background: #dbeafe; }
.te-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.te-drop-icon { font-size: 2rem; line-height: 1; }
.te-drop strong { color: var(--te-ink); font-size: 1rem; }
.te-drop small { font-size: 0.8rem; color: var(--te-dim); }

/* ---------- Output / preview ---------- */
.te-preview {
  display: grid; place-items: center; min-height: 280px; border-radius: var(--te-radius-sm);
  background-color: #fff;
  background-image: linear-gradient(45deg, #f1f5f9 25%, transparent 25%), linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%), linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  border: 1px solid var(--te-line); overflow: hidden; position: relative;
}
.te-preview img, .te-preview canvas { max-width: 100%; max-height: 460px; display: block; }
.te-empty { color: var(--te-faint); font-size: 0.9rem; text-align: center; padding: 24px; }
.te-out {
  font-family: var(--te-mono); font-size: 0.86rem; background: var(--te-canvas); border: 1px solid var(--te-line);
  border-radius: var(--te-radius-sm); padding: 14px; min-height: 52px; word-break: break-all; white-space: pre-wrap; color: var(--te-ink);
}
.te-big { font-family: var(--te-display); font-size: 2rem; font-weight: 800; color: var(--te-ink); letter-spacing: -0.02em; }

/* ---------- Stats ---------- */
.te-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.te-stat { background: var(--te-canvas); border: 1px solid var(--te-line); border-radius: 12px; padding: 12px 14px; }
.te-stat b { display: block; font-size: 1.25rem; font-weight: 800; color: var(--te-ink); font-variant-numeric: tabular-nums; }
.te-stat span { font-size: 0.75rem; font-weight: 600; color: var(--te-dim); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Status messages ---------- */
.te-note { font-size: 0.86rem; border-radius: 10px; padding: 10px 12px; background: var(--te-canvas); color: var(--te-muted); border: 1px solid var(--te-line); }
.te-note--ok { background: var(--te-ok-bg); color: var(--te-ok); border-color: #a7f3d0; }
.te-note--err { background: var(--te-err-bg); color: var(--te-err); border-color: #fecaca; }
.te-note--warn { background: var(--te-warn-bg); color: #b45309; border-color: #fde68a; }
.te-badge { display: inline-flex; padding: 3px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.te-badge--ok { background: var(--te-ok-bg); color: var(--te-ok); }
.te-badge--err { background: var(--te-err-bg); color: var(--te-err); }
.te-badge--warn { background: var(--te-warn-bg); color: #b45309; }

/* ---------- Swatches ---------- */
.te-swatch { border-radius: 12px; border: 1px solid var(--te-line); min-height: 64px; }
.te-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.te-swatch-card { border: 1px solid var(--te-line); border-radius: 14px; overflow: hidden; background: #fff; cursor: pointer; text-align: left; padding: 0; font: inherit; }
.te-swatch-card .te-swatch { border: 0; border-radius: 0; height: 88px; }
.te-swatch-card div:last-child { padding: 10px 12px; font-family: var(--te-mono); font-size: 0.82rem; color: var(--te-ink); }

/* ---------- File list ---------- */
.te-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.te-files li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--te-line); border-radius: 10px; background: #fff; font-size: 0.88rem; }
.te-files li .te-grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--te-ink); }
.te-files li small { color: var(--te-dim); }

/* ---------- Table ---------- */
.te-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.te-table th, .te-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--te-line); vertical-align: top; }
.te-table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--te-dim); font-weight: 700; }
.te-table td code { font-family: var(--te-mono); font-size: 0.82rem; }

/* ---------- Toast ---------- */
.te-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--te-ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 0.88rem; font-weight: 600;
  transition: opacity .2s, transform .2s; z-index: 9999; font-family: var(--te-font);
}
.te-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.te-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
