/* ============================================================
   ToolsKit — Shared Stylesheet
   ============================================================ */

:root {
  --bg-primary:   #0d1117;
  --bg-secondary: #161b22;
  --bg-card:      #21262d;
  --bg-input:     #0d1117;
  --border:       #30363d;
  --border-focus: #58a6ff;
  --text-primary: #e6edf3;
  --text-muted:   #8b949e;
  --accent:       #58a6ff;
  --accent-hover: #79c0ff;
  --accent-bg:    rgba(88, 166, 255, 0.10);
  --success:      #3fb950;
  --success-bg:   rgba(63, 185, 80, 0.10);
  --error:        #f85149;
  --error-bg:     rgba(248, 81, 73, 0.10);
  --warning:      #d29922;
  --warning-bg:   rgba(210, 153, 34, 0.10);
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
  --transition:   0.15s ease;
  --max-width:    1200px;
  --header-h:     64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img, svg { display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
code, pre { font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace; }

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.header-inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.site-logo:hover { color: var(--accent); }
.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #58a6ff 0%, #3b82f6 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.site-nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.site-nav a:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-home-btn {
  background: var(--accent-bg) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(88, 166, 255, 0.3) !important;
}
.nav-home-btn:hover { background: rgba(88, 166, 255, 0.2) !important; }

/* ── Hero (homepage) ── */
.hero {
  text-align: center;
  padding: 72px 24px 56px;
  background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(88,166,255,0.12) 0%, transparent 70%);
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #e6edf3 30%, #58a6ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 32px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success-bg);
  border: 1px solid rgba(63, 185, 80, 0.3);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

/* ── Tools Grid (homepage) ── */
.tools-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 64px;
  scroll-margin-top: 72px;
}
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 24px;
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-bg) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition);
}
.tool-card:hover { border-color: var(--border-focus); transform: translateY(-2px); box-shadow: var(--shadow); }
.tool-card:hover::before { opacity: 1; }
.tool-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-bg);
  border: 1px solid rgba(88, 166, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 20px;
  position: relative;
}
.tool-card-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.tool-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1;
  line-height: 1.5;
}
.tool-card-arrow {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Tool Page Layout ── */
.tool-page-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--border); }
.tool-page-wrapper h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}
.tool-intro {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 680px;
  margin-bottom: 32px;
  line-height: 1.7;
}
.tool-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

/* ── Form Elements ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.input-row .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }
input[type="text"],
input[type="number"],
input[type="email"],
textarea,
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.95rem;
  transition: border-color var(--transition);
  outline: none;
}
input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
textarea.mono { font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace; font-size: 0.88rem; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* Range input */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  padding: 0;
  border: none;
  box-shadow: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: background var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover { background: var(--accent-hover); }
.range-label { display: flex; justify-content: space-between; align-items: center; }
.range-label span { font-size: 0.85rem; color: var(--text-muted); }
.range-value { font-weight: 600; color: var(--accent) !important; }

/* Checkbox groups */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
}
.checkbox-label:hover { border-color: var(--border-focus); background: var(--accent-bg); }
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"]:checked + span { color: var(--accent); }

/* Toggle (mode switch) */
.toggle-group {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.toggle-btn {
  padding: 8px 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.toggle-btn.active { background: var(--accent); color: #fff; }
.toggle-btn:hover:not(.active) { background: var(--bg-card); color: var(--text-primary); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-focus); background: var(--accent-bg); }
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-icon { padding: 8px; border-radius: var(--radius); }
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ── Output Area ── */
.output-area {
  margin-top: 20px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.output-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.output-body {
  padding: 16px;
  min-height: 80px;
  font-size: 0.9rem;
}
.output-body.mono {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}
.output-body.scroll { max-height: 400px; overflow-y: auto; }
.output-placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.88rem;
}

/* ── Result Grid (IP lookup etc.) ── */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.result-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.result-item .result-key {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.result-item .result-val {
  font-size: 0.95rem;
  font-weight: 500;
  word-break: break-all;
}

/* ── Hash row ── */
.hash-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.hash-row:last-child { border-bottom: none; }
.hash-algo {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  min-width: 60px;
}
.hash-value {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 0.82rem;
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
}

/* ── JSON Syntax Highlighting ── */
.json-output {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.json-key    { color: #79c0ff; }
.json-string { color: #a5d6ff; }
.json-number { color: #ffa657; }
.json-bool   { color: #ff7b72; }
.json-null   { color: #ff7b72; }
.json-punct  { color: var(--text-muted); }

/* ── Regex highlighting ── */
.regex-highlight { background: rgba(255, 212, 0, 0.25); border-radius: 2px; color: #ffd700; }
.regex-output {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.8;
  word-break: break-all;
  white-space: pre-wrap;
}

/* ── Status / Alerts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.alert-error   { background: var(--error-bg); border: 1px solid rgba(248,81,73,0.3); color: var(--error); }
.alert-success { background: var(--success-bg); border: 1px solid rgba(63,185,80,0.3); color: var(--success); }
.alert-info    { background: var(--accent-bg); border: 1px solid rgba(88,166,255,0.3); color: var(--accent); }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: toastIn 0.2s ease, toastOut 0.3s ease 2.2s forwards;
  pointer-events: none;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--error); color: #fff; }
.toast-info    { background: var(--accent); color: #fff; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-4px); } }

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ── AdSense placeholder ── */
.ad-slot {
  width: 100%;
  min-height: 90px;
  background: rgba(255,255,255,0.02);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin: 20px 0;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
}
.ad-slot-leaderboard { min-height: 90px; }
.ad-slot-rectangle   { min-height: 250px; max-width: 360px; }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 40px 24px 24px;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-logo {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.footer-about {
  font-size: 0.83rem;
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.5;
}
.footer-links {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
}
.footer-links a {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.footer-links a:hover { color: var(--accent); }
.footer-bottom {
  max-width: var(--max-width);
  margin: 20px auto 0;
}
.footer-bottom p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Loading spinner ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility classes ── */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.font-mono    { font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace; }
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.full-width { width: 100%; }
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--success-bg);
  border: 1px solid rgba(63,185,80,0.3);
}
.live-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --header-h: 56px; }
  .hero { padding: 48px 16px 40px; }
  .tools-section { padding: 32px 16px 48px; }
  .tool-page-wrapper { padding: 24px 16px 48px; }
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
  .input-row { flex-direction: column; }
  .input-row .form-group { min-width: 100%; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .tool-container { padding: 20px 16px; }
}
@media (max-width: 480px) {
  .tools-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .checkbox-group { flex-direction: column; }
  .hash-row { flex-wrap: wrap; }
  .site-nav a:not(.nav-home-btn) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
