/* Google Fonts loaded via <link> in HTML for non-blocking performance */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --secondary: #06b6d4;
  --bg: #f8fafc;
  --bg-white: #ffffff;
  --bg-alt: #f1f5f9;
  --surface: #ffffff;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --card-shadow-hover: 0 10px 25px -5px rgba(0,0,0,0.1), 0 4px 10px -2px rgba(0,0,0,0.05);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
  --max-width: 1200px;
  --header-height: 64px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

/* ===== HEADER ===== */
#site-header { min-height: var(--header-height); }
.site-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.site-logo {
  font-size: 1.4rem;
  font-weight: 800;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.site-logo .logo-text {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.site-nav { display: flex; gap: 2px; align-items: center; }
.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
}
.site-nav a:hover { color: var(--primary); background: var(--primary-light); }
.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 6px 10px;
  color: var(--text);
  font-size: 1.1rem;
}

/* ===== AD SPACES ===== */
.ad-banner {
  background: #f1f5f9;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ad-banner-top { width: 100%; height: 90px; margin-bottom: 28px; }
.ad-banner-bottom { width: 100%; height: 90px; margin-top: 28px; }
.ad-sidebar { width: 300px; min-height: 250px; height: 600px; }
.ad-inline { width: 100%; height: 250px; margin: 32px 0; }

/* ===== LAYOUT ===== */
.page-wrapper { max-width: var(--max-width); margin: 0 auto; padding: 28px 20px; }
.page-wrapper-top { padding-bottom: 0; }
.page-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 28px 20px;
}
.main-content { min-width: 0; }
.sidebar { display: flex; flex-direction: column; gap: 24px; }

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 56px 24px 40px;
  background: linear-gradient(135deg, #eef2ff 0%, #faf5ff 50%, #ecfeff 100%);
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.2;
}
.hero h1 .highlight {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p { font-size: 1.1rem; color: var(--text-muted); max-width: 580px; margin: 0 auto 28px; }
.hero-badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.hero-badge {
  background: white;
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}
/* ── Flip Counter ── */
.hero-counter { text-align: center; margin-bottom: 28px; min-height: 86px; }
.hero-counter-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.flip-counter {
  display: inline-flex;
  gap: 4px;
  justify-content: center;
  min-height: 64px;
}
.flip-digit {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 64px;
  border-radius: 8px;
  background: linear-gradient(180deg, #334155 0%, #1e293b 40%, #1e293b 60%, #0f172a 100%);
  box-shadow: 0 4px 16px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.06);
  overflow: hidden;
}
.flip-digit::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: rgba(0,0,0,0.4);
  z-index: 2;
  pointer-events: none;
}
.flip-digit .digit-inner {
  position: absolute;
  left: 0; right: 0;
  top: 0;
  height: 100%;
  transition: none;
}
.flip-digit .digit-inner.rolling {
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.flip-digit .digit-val {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 64px;
  font-size: 2rem;
  font-weight: 800;
  color: #e2e8f0;
  font-family: 'Courier New', Courier, monospace;
}
.flip-comma {
  display: flex;
  align-items: flex-end;
  padding-bottom: 6px;
  font-size: 1.6rem;
  font-weight: 800;
  color: #64748b;
  font-family: 'Courier New', Courier, monospace;
}
.search-bar { max-width: 520px; margin: 0 auto; position: relative; }
.search-bar input {
  width: 100%;
  padding: 14px 20px 14px 50px;
  border-radius: 50px;
  border: 2px solid var(--border);
  font-size: 1rem;
  background: white;
  outline: none;
  transition: var(--transition);
  box-shadow: var(--card-shadow);
}
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,0.1); }
.search-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.1rem; }

/* ===== CATEGORIES ===== */
.category-section { margin-bottom: 48px; }
.category-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  gap: 10px;
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.tool-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--card-shadow);
  transition: all var(--transition);
  display: block;
}
.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-3px);
}
.tool-card-icon { font-size: 2rem; margin-bottom: 10px; display: block; }
.tool-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 5px; }
.tool-card p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }

/* ===== TOOL PAGE ===== */
.tool-header { margin-bottom: 24px; }
.breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.tool-header h1 { font-size: 1.9rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.tool-header p { color: var(--text-muted); font-size: 1rem; }
.tool-container {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  margin-bottom: 24px;
}

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.88rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.tool-container label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
textarea.tool-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  resize: vertical;
  min-height: 140px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: #fafafa;
  color: var(--text);
}
textarea.tool-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
  background: white;
}
input[type="text"].tool-input,
input[type="number"].tool-input,
input[type="date"].tool-input,
input[type="email"].tool-input,
select.tool-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: white;
  color: var(--text);
  font-family: inherit;
}
input[type="text"].tool-input:focus,
input[type="number"].tool-input:focus,
input[type="date"].tool-input:focus,
select.tool-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.input-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* --- Global input styling inside tool containers --- */
.tool-container input:where(:not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.btn):not(.kb-key)),
.tool-container textarea,
.tool-container select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--bg-white);
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
}
.tool-container textarea {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  resize: vertical;
  min-height: 100px;
  padding: 12px 16px;
}
.tool-container input:where(:not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.btn):not(.kb-key)):focus,
.tool-container textarea:focus,
.tool-container select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.tool-container select {
  appearance: none;
  -webkit-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='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--error); color: white; }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ===== OUTPUT ===== */
.output-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 0.88rem;
  min-height: 80px;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
  color: var(--text);
}
.result-card {
  background: linear-gradient(135deg, var(--primary-light), #f0fdf4);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 16px;
  text-align: center;
}
.result-value { font-size: 2.2rem; font-weight: 800; color: var(--primary); }
.result-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.stat-item {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--card-shadow);
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ===== COPY BUTTON ===== */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.76rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  font-family: inherit;
}
.copy-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  gap: 0;
}
.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all var(--transition);
  font-family: inherit;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== RANGE SLIDER ===== */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: var(--border); outline: none; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--primary); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

/* ===== CHECKBOX GROUP ===== */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; user-select: none; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ===== SEO CONTENT ===== */
.seo-content {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 32px;
  box-shadow: var(--card-shadow);
}
.seo-content h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.seo-content h3 { font-size: 1rem; font-weight: 600; margin: 18px 0 8px; color: var(--text); }
.seo-content h4 { font-size: 0.92rem; font-weight: 600; margin: 14px 0 6px; color: var(--text); }
.seo-content p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.75; margin-bottom: 12px; }
.seo-content ul { list-style: disc; padding-left: 20px; color: var(--text-muted); font-size: 0.9rem; line-height: 1.8; }

/* ===== RELATED TOOLS ===== */
.related-tools { margin-top: 32px; }
.related-tools h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 10px; }
.related-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--card-shadow);
}
.related-card:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }

/* ===== DIFF ===== */
.diff-container { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-family: monospace; font-size: 0.85rem; }
.diff-line { padding: 3px 12px; white-space: pre-wrap; word-break: break-all; }
.diff-added { background: #dcfce7; color: #166534; }
.diff-removed { background: #fee2e2; color: #991b1b; }
.diff-unchanged { color: #64748b; }

/* ===== COLOR PREVIEW ===== */
.color-preview { width: 80px; height: 80px; border-radius: var(--radius); border: 1px solid var(--border); margin: 10px 0; display: inline-block; }
.color-swatches { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.color-swatch { width: 40px; height: 40px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; transition: transform var(--transition); }
.color-swatch:hover { transform: scale(1.1); }

/* ===== PASSWORD STRENGTH ===== */
.strength-bar { height: 6px; border-radius: 3px; background: var(--border); margin: 8px 0; overflow: hidden; }
.strength-fill { height: 100%; border-radius: 3px; transition: width 0.3s, background 0.3s; }

/* ===== PROGRESS / METER ===== */
.meter-bar { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; margin: 8px 0; }
.meter-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease, background 0.5s; }

/* ===== INFO CARD ===== */
.info-card { background: #f0f4ff; border: 1px solid #c7d2fe; border-radius: var(--radius); padding: 14px 18px; margin: 12px 0; font-size: 0.88rem; color: var(--text); }
.info-card strong { color: var(--primary); }
.warn-card { background: #fffbeb; border: 1px solid #fde68a; }
.warn-card strong { color: var(--warning); }

/* ===== SIDEBAR WIDGET ===== */
.sidebar-widget {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--card-shadow);
}
.sidebar-widget h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 14px; color: var(--text); text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-tool-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text-muted); font-size: 0.88rem; padding: 7px 0; border-bottom: 1px solid var(--border); transition: color var(--transition); }
.sidebar-tool-link:last-child { border-bottom: none; }
.sidebar-tool-link:hover { color: var(--primary); }

/* ===== FOOTER ===== */
.site-footer { background: #0f172a; color: #94a3b8; padding: 56px 20px 24px; margin-top: 72px; }
.footer-inner { max-width: var(--max-width); margin: 0 auto; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 44px; }
.footer-logo { font-size: 1.3rem; font-weight: 800; color: white; text-decoration: none; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.footer-brand p { font-size: 0.85rem; line-height: 1.7; color: #94a3b8; }
.footer-col h4 { font-size: 0.78rem; font-weight: 700; color: #e2e8f0; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px; }
.footer-col a { display: block; color: #94a3b8; text-decoration: none; font-size: 0.85rem; margin-bottom: 9px; transition: color var(--transition); }
.footer-col a:hover { color: white; }
.footer-bottom { border-top: 1px solid #1e293b; padding-top: 24px; display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: #94a3b8; flex-wrap: wrap; gap: 8px; }

/* ===== ACCESSIBILITY (WCAG 2.1 AA) ===== */

/* Screen-reader-only utility — hides visually but keeps in accessibility tree */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Skip navigation link — visible on focus for keyboard users (WCAG 2.4.1) */
.skip-nav {
  position: absolute;
  top: -100%;
  left: 8px;
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  z-index: 10000;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: top 0.15s ease;
}
.skip-nav:focus { top: 0; outline: 3px solid #fff; outline-offset: 3px; }

/* Remove default :focus outline — replaced with :focus-visible (WCAG 2.4.7) */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
.tool-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: var(--radius-lg); box-shadow: var(--card-shadow-hover); }
.btn:focus-visible { outline: 3px solid var(--primary-dark); outline-offset: 2px; }
.tab-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: -1px; }
.site-nav a:focus-visible,
.footer-col a:focus-visible,
.sidebar-tool-link:focus-visible,
.related-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: var(--radius); }
input:focus-visible,
textarea:focus-visible,
select:focus-visible { border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(79,70,229,0.15) !important; outline: none; }

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --primary: #818cf8;
  --primary-dark: #6366f1;
  --primary-light: #1e1b4b;
  --bg: #0f172a;
  --bg-white: #1e293b;
  --bg-alt: #1e293b;
  --surface: #1e293b;
  --card-bg: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --border: #334155;
  --border-dark: #475569;
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.4);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.5);
  color-scheme: dark;
}

/* --- Layout & Global --- */
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .site-header { background: #1e293b; border-bottom-color: var(--border); }
[data-theme="dark"] .site-nav { background: #1e293b; }
[data-theme="dark"] .site-nav a { color: var(--text-muted); }
[data-theme="dark"] .site-nav a:hover { color: var(--primary); }
[data-theme="dark"] .hero { background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%); }
[data-theme="dark"] .search-bar input { background: #1e293b; border-color: var(--border); color: var(--text); }
[data-theme="dark"] .search-bar input:focus { border-color: var(--primary); }
[data-theme="dark"] .ad-banner { background: #1e293b; border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .related-card { background: #1e293b; }
[data-theme="dark"] .related-card:hover { color: var(--primary); }
[data-theme="dark"] .seo-content { color: var(--text-muted); }
[data-theme="dark"] .seo-content h2 { color: var(--text); }
[data-theme="dark"] .breadcrumb,
[data-theme="dark"] .breadcrumb a { color: var(--text-muted); }

/* --- Form Inputs (all types) --- */
[data-theme="dark"] textarea.tool-input,
[data-theme="dark"] input[type="text"].tool-input,
[data-theme="dark"] input[type="number"].tool-input,
[data-theme="dark"] input[type="date"].tool-input,
[data-theme="dark"] input[type="time"].tool-input,
[data-theme="dark"] input[type="datetime-local"].tool-input,
[data-theme="dark"] input[type="email"].tool-input,
[data-theme="dark"] input[type="url"].tool-input,
[data-theme="dark"] input[type="tel"].tool-input,
[data-theme="dark"] input[type="password"].tool-input,
[data-theme="dark"] select.tool-input { background-color: #0f172a; color: var(--text); border-color: var(--border); }
[data-theme="dark"] textarea.tool-input:focus,
[data-theme="dark"] input.tool-input:focus,
[data-theme="dark"] select.tool-input:focus { background-color: #1e293b; }
[data-theme="dark"] .tool-container input:where(:not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.btn)),
[data-theme="dark"] .tool-container textarea,
[data-theme="dark"] .tool-container select {
  background-color: #0f172a;
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] .tool-container select {
  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='%2394a3b8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
}
[data-theme="dark"] .tool-container label { color: var(--text); }
[data-theme="dark"] input[type="range"] { background: var(--border); }
[data-theme="dark"] input[type="checkbox"] { accent-color: var(--primary); }
[data-theme="dark"] input[type="radio"] { accent-color: var(--primary); }

/* --- Buttons --- */
[data-theme="dark"] .output-box { background: #0f172a; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .copy-btn { background: #334155; color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .copy-btn:hover { background: var(--primary); color: white; }
[data-theme="dark"] .btn-secondary { background: #334155; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn-secondary:hover { background: #475569; }

/* --- Tabs --- */
[data-theme="dark"] .tab-btn { color: var(--text-muted); }
[data-theme="dark"] .tab-btn.active { color: var(--primary); }

/* --- Cards & Info Boxes --- */
[data-theme="dark"] .result-card { background: linear-gradient(135deg, #1e1b4b, #0f2922); border-color: #4338ca; }
[data-theme="dark"] .info-card { background: #1e1b4b; border-color: #4338ca; }
[data-theme="dark"] .warn-card { background: #451a03; border-color: #92400e; }
[data-theme="dark"] .stat-card,
[data-theme="dark"] .res-card,
[data-theme="dark"] .sum-card,
[data-theme="dark"] .code-card { background: #1e293b; color: var(--text); border-color: var(--border); }

/* --- Diff --- */
[data-theme="dark"] .diff-added { background: #14532d; color: #86efac; }
[data-theme="dark"] .diff-removed { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .diff-unchanged { color: #94a3b8; }
[data-theme="dark"] .diff-container { border-color: var(--border); }

/* --- Tables --- */
[data-theme="dark"] .tool-container table { border-color: var(--border); color: var(--text); }
[data-theme="dark"] .tool-container th { background: #1e293b; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .tool-container td { background: #0f172a; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .tool-container tr:nth-child(even) td { background: #1e293b; }
[data-theme="dark"] .tool-container tr:hover td { background: #334155; }

/* --- Code / Pre --- */
[data-theme="dark"] .tool-container pre,
[data-theme="dark"] .tool-container code { background: #0f172a; color: #e2e8f0; border-color: var(--border); }

/* --- Tool-specific common classes across many tools --- */
[data-theme="dark"] .drop-zone {
  background: #1e293b !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}
[data-theme="dark"] .drop-zone.over,
[data-theme="dark"] .drop-zone.drag-over {
  background: #1e1b4b !important;
  border-color: var(--primary) !important;
}
[data-theme="dark"] .editor-pane {
  background: #0f172a;
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] .conv-grid,
[data-theme="dark"] .converter-grid,
[data-theme="dark"] .info-grid,
[data-theme="dark"] .summary-grid,
[data-theme="dark"] .result-grid,
[data-theme="dark"] .form-grid,
[data-theme="dark"] .form-panel,
[data-theme="dark"] .stats-row,
[data-theme="dark"] .opts-row,
[data-theme="dark"] .range-row,
[data-theme="dark"] .ctrl-row,
[data-theme="dark"] .act-row,
[data-theme="dark"] .btn-row,
[data-theme="dark"] .preset-row { color: var(--text); }

[data-theme="dark"] .stat-bar,
[data-theme="dark"] .progress-bar,
[data-theme="dark"] .stats-bar { background: #334155; }
[data-theme="dark"] .bar-fill { background: var(--primary); }

[data-theme="dark"] .stat .lbl,
[data-theme="dark"] .stat .val,
[data-theme="dark"] .stat-val,
[data-theme="dark"] .sum-label,
[data-theme="dark"] .sum-val,
[data-theme="dark"] .section-title,
[data-theme="dark"] .stat-chip { color: var(--text); }
[data-theme="dark"] .stat .big { color: var(--text); }

[data-theme="dark"] .code-badge,
[data-theme="dark"] .code-num { background: #1e293b; color: var(--text-muted); border-color: var(--border); }

[data-theme="dark"] .swap-btn { background: #334155; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .swap-btn:hover { background: #475569; }

[data-theme="dark"] .conv-btn { background: #334155; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .conv-btn:hover,
[data-theme="dark"] .conv-btn.active { background: var(--primary); color: white; }

[data-theme="dark"] .preset-btn { background: #1e293b; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .preset-btn:hover,
[data-theme="dark"] .preset-btn.active { background: var(--primary); color: white; }

[data-theme="dark"] .output-area { background: #0f172a; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .char-count { color: var(--text-muted); }

[data-theme="dark"] .start-btn { background: var(--primary); }
[data-theme="dark"] .stop { background: var(--error); }

/* --- Platform tabs (social tools) --- */
[data-theme="dark"] .platform-tabs button { background: #1e293b; color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .platform-tabs button.active,
[data-theme="dark"] .platform-tabs button:hover { background: var(--primary); color: white; }

/* --- Morse / Reference tables --- */
[data-theme="dark"] .ref-table { background: #1e293b; border-color: var(--border); }

/* --- Timer / Display --- */
[data-theme="dark"] .timer-label { color: var(--text-muted); }

/* --- Pill / Tag / Badge generic --- */
[data-theme="dark"] .cat-pill,
[data-theme="dark"] .tag,
[data-theme="dark"] .badge { background: #334155; color: var(--text); border-color: var(--border); }

/* --- Generic containers that tools set to white/light backgrounds --- */
[data-theme="dark"] .tool-container [style*="background:#fff"],
[data-theme="dark"] .tool-container [style*="background: #fff"],
[data-theme="dark"] .tool-container [style*="background:#ffffff"],
[data-theme="dark"] .tool-container [style*="background: #ffffff"],
[data-theme="dark"] .tool-container [style*="background:white"],
[data-theme="dark"] .tool-container [style*="background: white"] {
  background: #1e293b !important;
  color: var(--text) !important;
}
[data-theme="dark"] .tool-container [style*="background:#f8fafc"],
[data-theme="dark"] .tool-container [style*="background: #f8fafc"],
[data-theme="dark"] .tool-container [style*="background:#f1f5f9"],
[data-theme="dark"] .tool-container [style*="background: #f1f5f9"],
[data-theme="dark"] .tool-container [style*="background:#f3f4f6"],
[data-theme="dark"] .tool-container [style*="background: #f3f4f6"],
[data-theme="dark"] .tool-container [style*="background:#fafafa"],
[data-theme="dark"] .tool-container [style*="background: #fafafa"],
[data-theme="dark"] .tool-container [style*="background:#f5f5f5"],
[data-theme="dark"] .tool-container [style*="background: #f5f5f5"],
[data-theme="dark"] .tool-container [style*="background:#e9ecef"],
[data-theme="dark"] .tool-container [style*="background: #e9ecef"] {
  background: #0f172a !important;
  color: var(--text) !important;
}
[data-theme="dark"] .tool-container [style*="color:#333"],
[data-theme="dark"] .tool-container [style*="color: #333"],
[data-theme="dark"] .tool-container [style*="color:#222"],
[data-theme="dark"] .tool-container [style*="color: #222"],
[data-theme="dark"] .tool-container [style*="color:#1e293b"],
[data-theme="dark"] .tool-container [style*="color: #1e293b"],
[data-theme="dark"] .tool-container [style*="color:black"],
[data-theme="dark"] .tool-container [style*="color: black"] {
  color: var(--text) !important;
}

/* --- Status colors (light-bg variants) --- */
[data-theme="dark"] .tool-container [style*="background:#dcfce7"],
[data-theme="dark"] .tool-container [style*="background: #dcfce7"],
[data-theme="dark"] .tool-container [style*="background:#f0fdf4"],
[data-theme="dark"] .tool-container [style*="background: #f0fdf4"],
[data-theme="dark"] .tool-container [style*="background:#d1fae5"],
[data-theme="dark"] .tool-container [style*="background: #d1fae5"] {
  background: #14532d !important;
  color: #86efac !important;
}
[data-theme="dark"] .tool-container [style*="background:#fee2e2"],
[data-theme="dark"] .tool-container [style*="background: #fee2e2"],
[data-theme="dark"] .tool-container [style*="background:#fef2f2"],
[data-theme="dark"] .tool-container [style*="background: #fef2f2"],
[data-theme="dark"] .tool-container [style*="background:#fecaca"],
[data-theme="dark"] .tool-container [style*="background: #fecaca"] {
  background: #7f1d1d !important;
  color: #fca5a5 !important;
}
[data-theme="dark"] .tool-container [style*="background:#fef3c7"],
[data-theme="dark"] .tool-container [style*="background: #fef3c7"],
[data-theme="dark"] .tool-container [style*="background:#fffbeb"],
[data-theme="dark"] .tool-container [style*="background: #fffbeb"] {
  background: #451a03 !important;
  color: #fbbf24 !important;
}
[data-theme="dark"] .tool-container [style*="background:#eff6ff"],
[data-theme="dark"] .tool-container [style*="background: #eff6ff"],
[data-theme="dark"] .tool-container [style*="background:#dbeafe"],
[data-theme="dark"] .tool-container [style*="background: #dbeafe"],
[data-theme="dark"] .tool-container [style*="background:#eef2ff"],
[data-theme="dark"] .tool-container [style*="background: #eef2ff"],
[data-theme="dark"] .tool-container [style*="background:#e0e7ff"],
[data-theme="dark"] .tool-container [style*="background: #e0e7ff"] {
  background: #1e1b4b !important;
  color: #c7d2fe !important;
}
[data-theme="dark"] .tool-container [style*="background:#ede9fe"],
[data-theme="dark"] .tool-container [style*="background: #ede9fe"] {
  background: #2e1065 !important;
  color: #c4b5fd !important;
}
[data-theme="dark"] .tool-container [style*="background:#e2e8f0"],
[data-theme="dark"] .tool-container [style*="background: #e2e8f0"],
[data-theme="dark"] .tool-container [style*="background:#e5e7eb"],
[data-theme="dark"] .tool-container [style*="background: #e5e7eb"] {
  background: #334155 !important;
  color: var(--text) !important;
}

/* --- Dark text on status backgrounds --- */
[data-theme="dark"] .tool-container [style*="color:#166534"],
[data-theme="dark"] .tool-container [style*="color: #166534"],
[data-theme="dark"] .tool-container [style*="color:#15803d"],
[data-theme="dark"] .tool-container [style*="color: #15803d"] { color: #86efac !important; }
[data-theme="dark"] .tool-container [style*="color:#991b1b"],
[data-theme="dark"] .tool-container [style*="color: #991b1b"],
[data-theme="dark"] .tool-container [style*="color:#dc2626"],
[data-theme="dark"] .tool-container [style*="color: #dc2626"] { color: #fca5a5 !important; }
[data-theme="dark"] .tool-container [style*="color:#92400e"],
[data-theme="dark"] .tool-container [style*="color: #92400e"] { color: #fbbf24 !important; }
[data-theme="dark"] .tool-container [style*="color:#1d4ed8"],
[data-theme="dark"] .tool-container [style*="color: #1d4ed8"] { color: #93c5fd !important; }

/* --- Borders on inline-styled elements --- */
[data-theme="dark"] .tool-container [style*="border:1px solid #e"],
[data-theme="dark"] .tool-container [style*="border:1px solid #d"],
[data-theme="dark"] .tool-container [style*="border:1px solid #c"],
[data-theme="dark"] .tool-container [style*="border: 1px solid #e"],
[data-theme="dark"] .tool-container [style*="border: 1px solid #d"],
[data-theme="dark"] .tool-container [style*="border: 1px solid #c"] {
  border-color: var(--border) !important;
}

/* --- Hamburger menu in dark mode --- */
[data-theme="dark"] .hamburger { background: #1e293b; color: var(--text); border-color: var(--border); }

/* ===== CATEGORY ICON COLORS ===== */
.cat-icon-developer  { color: #4f46e5; }
.cat-icon-text       { color: #ec4899; }
.cat-icon-calculator { color: #f59e0b; }
.cat-icon-generator  { color: #8b5cf6; }
.cat-icon-datetime   { color: #06b6d4; }
.cat-icon-math       { color: #10b981; }
.cat-icon-finance    { color: #f97316; }
.cat-icon-health     { color: #ef4444; }
.cat-icon-image      { color: #3b82f6; }
.cat-icon-content    { color: #a855f7; }
.cat-icon-connected  { color: #14b8a6; }
.cat-icon-converter  { color: #6366f1; }
.cat-icon-seo        { color: #0ea5e9; }
.cat-icon-security   { color: #dc2626; }
.cat-icon-social     { color: #e11d48; }
.cat-icon-utility    { color: #84cc16; }
.cat-icon-css-gen    { color: #d946ef; }
.cat-icon-testing    { color: #f472b6; }
.cat-icon-design     { color: #2dd4bf; }

[data-theme="dark"] .cat-icon-developer  { color: #818cf8; }
[data-theme="dark"] .cat-icon-text       { color: #f472b6; }
[data-theme="dark"] .cat-icon-calculator { color: #fbbf24; }
[data-theme="dark"] .cat-icon-generator  { color: #a78bfa; }
[data-theme="dark"] .cat-icon-datetime   { color: #22d3ee; }
[data-theme="dark"] .cat-icon-math       { color: #34d399; }
[data-theme="dark"] .cat-icon-finance    { color: #fb923c; }
[data-theme="dark"] .cat-icon-health     { color: #f87171; }
[data-theme="dark"] .cat-icon-image      { color: #60a5fa; }
[data-theme="dark"] .cat-icon-content    { color: #c084fc; }
[data-theme="dark"] .cat-icon-connected  { color: #2dd4bf; }
[data-theme="dark"] .cat-icon-converter  { color: #818cf8; }
[data-theme="dark"] .cat-icon-seo        { color: #38bdf8; }
[data-theme="dark"] .cat-icon-security   { color: #f87171; }
[data-theme="dark"] .cat-icon-social     { color: #fb7185; }
[data-theme="dark"] .cat-icon-utility    { color: #a3e635; }
[data-theme="dark"] .cat-icon-css-gen    { color: #e879f9; }
[data-theme="dark"] .cat-icon-testing    { color: #f9a8d4; }
[data-theme="dark"] .cat-icon-design     { color: #5eead4; }

/* Dark mode toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  font-family: inherit;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-toggle .theme-icon-dark,
[data-theme="dark"] .theme-toggle .theme-icon-light { display: inline; }
.theme-toggle .theme-icon-light,
[data-theme="dark"] .theme-toggle .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-light { display: inline; }

/* Reduced motion — respect user OS preference (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .tool-card:hover { transform: none; }
  .btn-primary:hover, .btn-success:hover { transform: none; }
  .color-swatch:hover { transform: none; }
  .related-card:hover { transform: none; }
  .skip-nav { transition: none; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .page-with-sidebar { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}
@media (max-width: 640px) {
  /* Hero */
  .hero { padding: 36px 16px 28px; }
  .hero h1 { font-size: 1.9rem; }
  .hero p { font-size: 1rem; margin-bottom: 20px; }

  /* Navigation */
  .hamburger { display: block; min-width: 48px; min-height: 48px; }
  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--bg-white);
    flex-direction: column;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 99;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 16px; font-size: 1rem; min-height: 48px; display: flex; align-items: center; }

  /* Layout */
  .page-wrapper { padding: 20px 16px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .tool-header h1 { font-size: 1.5rem; }
  .two-col { grid-template-columns: 1fr; }
  .ad-banner-top, .ad-banner-bottom { height: 60px; font-size: 0.65rem; }

  /* Tool grid — larger cards with bigger tap targets */
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .tool-card { padding: 16px; min-height: 48px; }
  .tool-card h3 { font-size: 0.95rem; }
  .tool-card p { font-size: 0.85rem; line-height: 1.6; }
  .tool-card-icon { font-size: 1.6rem; margin-bottom: 8px; }

  /* Category headings */
  .category-section h2 { font-size: 1.2rem; }

  /* Search bar */
  .search-bar input { padding: 14px 16px 14px 46px; font-size: 1rem; }

  /* Buttons — minimum 48px tap target */
  .btn { padding: 12px 20px; font-size: 0.95rem; min-height: 48px; }
  .btn-sm { padding: 10px 16px; font-size: 0.88rem; min-height: 44px; }
  .btn-group { gap: 10px; }

  /* Form elements — larger tap targets */
  .form-group label { font-size: 0.92rem; }
  .form-group input,
  .form-group textarea,
  .form-group select { font-size: 1rem; padding: 12px; min-height: 48px; }

  /* SEO content */
  .seo-content h2 { font-size: 1.1rem; }
  .seo-content p { font-size: 0.92rem; }
  .seo-content ul { font-size: 0.92rem; }

  /* Footer — larger tap targets for links */
  .footer-col a { padding: 6px 0; font-size: 0.9rem; min-height: 44px; display: flex; align-items: center; }
}
