/* ===== CSS VARIABLES ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-xlight: #eff6ff;
  --accent: #f59e0b;
  --text: #1e293b;
  --text-muted: #64748b;
  --bg: #f1f5f9;
  --bg-white: #ffffff;
  --border: #e2e8f0;
  --border-focus: #93c5fd;
  --success: #10b981;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.07);
  --shadow: 0 2px 6px rgba(0,0,0,0.09);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --sidebar-w: 220px;
  --header-h: 62px;
  --transition: 0.2s ease;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --bg: #0f172a;
  --bg-white: #1e293b;
  --border: #334155;
  --border-focus: #3b82f6;
  --primary-light: #1e3a5f;
  --primary-xlight: #172a44;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 2px 6px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .search-dropdown { background: var(--bg-white); border-color: var(--border); }
[data-theme="dark"] .search-item { color: var(--text); border-bottom-color: var(--border); }
[data-theme="dark"] .search-item:hover { background: var(--bg); }
[data-theme="dark"] .calc-card,
[data-theme="dark"] .cat-card { background: var(--bg-white); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .calc-box,
[data-theme="dark"] .info-box,
[data-theme="dark"] .static-page { background: var(--bg-white); border-color: var(--border); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .ad-placeholder { background: #1e293b; border: 1px solid var(--border); }

/* Dark mode toggle button */
#dark-toggle {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 20px;
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px 10px;
  flex-shrink: 0;
  transition: background var(--transition);
  line-height: 1;
}
#dark-toggle:hover { background: rgba(255,255,255,0.28); }

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  height: var(--header-h);
  box-shadow: var(--shadow-md);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon { font-size: 1.6rem; }
.logo:hover { text-decoration: none; opacity: 0.9; }

/* Search */
.search-wrapper {
  flex: 1;
  max-width: 520px;
  position: relative;
}
#search-input {
  width: 100%;
  padding: 9px 18px;
  border: none;
  border-radius: 24px;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.22);
  color: #fff;
  outline: none;
  transition: background var(--transition);
}
#search-input::placeholder { color: rgba(255,255,255,0.65); }
#search-input:focus { background: rgba(255,255,255,0.32); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  border: 1px solid var(--border);
}
.search-dropdown.active { display: block; }
.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background var(--transition);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg); }
.search-item-icon { font-size: 1.1rem; flex-shrink: 0; }
.search-item-info { flex: 1; min-width: 0; }
.search-item-name { font-weight: 600; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-cat { font-size: 0.72rem; color: var(--text-muted); }
.search-no-result { padding: 16px; color: var(--text-muted); font-size: 0.875rem; text-align: center; }

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.3s;
}

/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr 180px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h) - 130px);
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar-inner { padding: 12px 0 24px; }
.sidebar-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 18px 6px;
}
.cat-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.855rem;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
}
.cat-nav-item:hover {
  background: var(--primary-xlight);
  color: var(--primary);
  border-left-color: var(--primary);
  text-decoration: none;
}
.cat-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.cat-nav-icon { font-size: 1.1rem; flex-shrink: 0; }
.cat-nav-name { flex: 1; }
/* Sidebar: Favorites & Recent sections */
.sidebar-section {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}
.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 18px 4px;
}
.sidebar-shortcut {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  font-size: 0.8rem;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-shortcut:hover {
  background: var(--primary-xlight);
  color: var(--primary);
  border-left-color: var(--primary);
  text-decoration: none;
}
.sidebar-shortcut-icon { flex-shrink: 0; font-size: 0.85rem; }
.sidebar-empty {
  padding: 4px 18px 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Star (favorite) button on calc page */
.calc-header-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.btn-fav, .btn-share {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-white);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-fav:hover { border-color: var(--accent); color: var(--accent); }
.btn-fav.active { background: #fef9c3; border-color: var(--accent); color: #b45309; }
[data-theme="dark"] .btn-fav.active { background: #422006; border-color: var(--accent); color: var(--accent); }
.btn-share:hover { border-color: var(--primary); color: var(--primary); }

.cat-nav-count {
  font-size: 0.68rem;
  background: var(--border);
  padding: 1px 7px;
  border-radius: 10px;
  color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main-content { padding: 28px 28px 40px; min-width: 0; }

/* ===== AD SIDEBAR ===== */
.ad-sidebar {
  background: var(--bg-white);
  border-left: 1px solid var(--border);
  padding: 20px 12px;
}
.ad-placeholder { display: none; }

/* ===== OVERLAY (mobile) ===== */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 80;
}
.overlay.active { display: block; }

/* ===== HOME PAGE ===== */
.home-hero {
  text-align: center;
  padding: 40px 20px 32px;
}
.home-hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 12px;
}
.home-hero h1 span { color: var(--primary); }
.home-hero p {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 8px;
}
.home-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.home-stat {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.home-stat strong { color: var(--primary); font-size: 1.1rem; }

/* Section title */
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title span { color: var(--text-muted); font-size: 0.85rem; font-weight: 400; }

/* Generator subcategory header */
.gen-subcat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 32px 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.gen-subcat-icon { font-size: 1.4rem; line-height: 1; }
.gen-subcat-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.gen-subcat-count {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Category grid on home */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 40px;
}
.cat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 14px 18px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  display: block;
}
.cat-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}
.cat-card-icon { font-size: 2.2rem; margin-bottom: 8px; display: block; }
.cat-card-name { font-weight: 700; font-size: 0.875rem; display: block; margin-bottom: 4px; }
.cat-card-count { font-size: 0.75rem; color: var(--text-muted); display: block; }

/* Calculator grid */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.calc-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--text);
}
.calc-card-name { font-weight: 600; font-size: 0.9rem; }
.calc-card-desc { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
.calc-card-cat {
  font-size: 0.7rem;
  color: var(--primary);
  background: var(--primary-xlight);
  padding: 2px 8px;
  border-radius: 10px;
  align-self: flex-start;
  margin-top: 4px;
}

/* ===== CALCULATOR PAGE ===== */
.calc-page { max-width: 100%; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb-sep { color: var(--border); }

.calc-header { margin-bottom: 22px; }
.calc-header h1 { font-size: 1.7rem; font-weight: 800; margin-bottom: 6px; }
.calc-header p { color: var(--text-muted); font-size: 0.95rem; }

/* Calc box */
.calc-box {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
}

.form-group { margin-bottom: 16px; }
.form-group:last-of-type { margin-bottom: 8px; }
.form-group label {
  display: block;
  font-size: 0.855rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  background: #fff;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.input-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.btn-calculate {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
  margin-top: 8px;
  letter-spacing: 0.01em;
}
.btn-calculate:hover { background: var(--primary-dark); }
.btn-calculate:active { transform: scale(0.99); }

/* Result box */
.result-box {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-xlight));
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  padding: 22px;
  margin-top: 20px;
  display: none;
  animation: fadeIn 0.3s ease;
}
.result-box.show { display: block; }
.result-main {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 4px;
}
.result-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 14px; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.result-item {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.result-item .val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-dark);
  display: block;
}
.result-item .lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: block;
}


/* Info box */
.info-box {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
}
.info-box h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 10px; }
.info-box p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 8px; line-height: 1.7; }
.info-box p:last-child { margin-bottom: 0; }
.info-box ul { padding-left: 18px; margin: 8px 0; }
.info-box li { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 4px; }

/* Conversion table */
.conversion-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.conversion-table th, .conversion-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.conversion-table th { font-weight: 600; background: var(--bg); }
.conversion-table tr:last-child td { border-bottom: none; }

/* Tag chip */
.tag { display: inline-block; background: var(--primary-xlight); color: var(--primary); font-size: 0.72rem; font-weight: 600; padding: 2px 9px; border-radius: 10px; }

/* Related calculators */
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }

/* Category page */
.cat-page-header { margin-bottom: 24px; }
.cat-page-header h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 6px; }
.cat-page-header p { color: var(--text-muted); }

/* Static pages */
.static-page { max-width: 680px; }
.static-page h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 16px; }
.static-page h2 { font-size: 1.2rem; font-weight: 700; margin: 20px 0 8px; }
.static-page p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.8; margin-bottom: 12px; }

/* ===== FOOTER ===== */
.site-footer {
  background: #0f172a;
  color: rgba(255,255,255,0.65);
  padding: 32px 20px;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 1.05rem;
}
.footer-disclaimer { font-size: 0.8rem; max-width: 580px; line-height: 1.6; }
.footer-nav { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.footer-nav a { color: rgba(255,255,255,0.65); font-size: 0.85rem; }
.footer-nav a:hover { color: #fff; text-decoration: none; }
.footer-copy { font-size: 0.78rem; }

/* ===== FIELD VALIDATION ===== */
.field-required {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
  background: #fff5f5 !important;
  animation: shake 0.35s ease, pulse-ring 1s ease 0.35s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 3px rgba(239,68,68,0.25); }
  50%  { box-shadow: 0 0 0 6px rgba(239,68,68,0.12); }
  100% { box-shadow: 0 0 0 3px rgba(239,68,68,0.25); }
}

.field-label-required::after {
  content: ' *';
  color: var(--danger);
  font-weight: 700;
}

/* Error message */
.result-error {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius);
  padding: 12px 18px;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 16px;
  display: none;
  align-items: center;
  gap: 8px;
}
.result-error.show { display: flex; }

/* Placeholder style hint */
input::placeholder { color: #b0bec5; font-style: italic; font-size: 0.875rem; }

/* ===== GENERATOR UI ===== */
.gen-form { display: flex; flex-direction: column; gap: 14px; }
.gen-select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.95rem; background: var(--bg-white); color: var(--text);
  transition: border-color var(--transition);
}
.gen-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.gen-result {
  margin-top: 20px; padding: 20px;
  background: var(--primary-xlight); border: 1.5px solid var(--primary-light);
  border-radius: var(--radius); animation: fadeIn .25s ease;
}
.gen-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); margin-bottom: 10px; }
.gen-output { margin-bottom: 14px; }
.gen-mono { font-family: 'Courier New', monospace; font-size: 1.25rem; font-weight: 700; color: var(--primary-dark); word-break: break-all; line-height: 1.5; }
.gen-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--primary-light); gap: 12px; }
.gen-row:last-child { border-bottom: none; }
.gen-row-key { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.gen-row-val { font-family: 'Courier New', monospace; font-size: 0.92rem; font-weight: 700; color: var(--text); word-break: break-all; text-align: right; }
.gen-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-copy {
  padding: 8px 18px; background: var(--bg-white);
  border: 1.5px solid var(--primary); border-radius: var(--radius-sm);
  color: var(--primary); font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: var(--transition);
}
.btn-copy:hover { background: var(--primary-light); }
.btn-sm { padding: 8px 18px !important; font-size: 0.9rem !important; }
@media (max-width: 600px) {
  .gen-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .gen-row-val { text-align: left; }
  .gen-mono { font-size: 1rem; }
}

/* ── Decoder / Encoder UI ─────────────────────────────────────────── */
.dec-form { display: flex; flex-direction: column; gap: 12px; }
.dec-label {
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
}
.dec-input, .dec-output {
  width: 100%; box-sizing: border-box;
  padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg);
  color: var(--text); font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem; line-height: 1.6; resize: vertical;
  transition: border-color 0.2s;
}
.dec-input:focus { outline: none; border-color: var(--primary); }
.dec-output {
  background: var(--bg-white); color: var(--text-muted);
  border-style: dashed;
}
.dec-output.dec-error-state { border-color: #ef4444; color: #ef4444; }
.dec-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.dec-btn {
  padding: 9px 22px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 0.9rem; cursor: pointer; transition: var(--transition);
}
.dec-btn:hover { background: var(--primary-dark, #1d4ed8); }
.dec-clear {
  padding: 9px 16px; background: transparent;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 0.85rem; cursor: pointer;
  transition: var(--transition);
}
.dec-clear:hover { border-color: var(--primary); color: var(--primary); }
.dec-copy {
  padding: 8px 18px; background: var(--bg-white);
  border: 1.5px solid var(--primary); border-radius: var(--radius-sm);
  color: var(--primary); font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: var(--transition);
}
.dec-copy:hover { background: var(--primary-light); }
.dec-status { font-size: 0.82rem; color: #ef4444; font-weight: 500; }
.dec-dir-label {
  font-size: 0.85rem; font-weight: 600; color: var(--primary);
  padding: 8px 0;
}

/* ── Word Counter stats grid ──────────────────────────────────────── */
.wc-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-top: 4px;
}
.wc-stat {
  background: var(--bg-white); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.wc-val { font-size: 1.5rem; font-weight: 700; color: var(--primary); line-height: 1; }
.wc-key { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }

/* ── Text Diff ────────────────────────────────────────────────────── */
.diff-output {
  font-family: 'Courier New', monospace; font-size: 0.83rem;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); overflow-x: auto; margin-top: 4px;
}
.diff-summary {
  display: flex; gap: 8px; padding: 8px 12px;
  background: var(--bg-white); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.diff-badge { padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.diff-badge-add { background:#dcfce7; color:#166534; }
.diff-badge-rem { background:#fee2e2; color:#991b1b; }
.diff-badge-eq  { background:#f1f5f9; color:#475569; }
.diff-line { padding: 2px 12px; white-space: pre-wrap; word-break: break-all; }
.diff-add { background: #f0fdf4; color: #166534; }
.diff-rem { background: #fef2f2; color: #991b1b; }
.diff-eq  { color: var(--text-muted); }
@media (max-width: 600px) {
  .wc-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Checksum verifier result ─────────────────────────────────────── */
/* ── Number Base Converter ────────────────────────────────────────── */
.base-form { display: flex; flex-direction: column; gap: 10px; }
.base-row { display: flex; align-items: center; gap: 10px; }
.base-label { width: 160px; flex-shrink: 0; font-size: 0.88rem; font-weight: 600; color: var(--text); }
.base-radix { color: var(--text-muted); font-weight: 400; }
.base-input {
  flex: 1; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-family: 'Courier New', monospace;
  font-size: 0.9rem; background: var(--bg); color: var(--text);
  transition: border-color .2s;
}
.base-input:focus { outline: none; border-color: var(--primary); }
.base-copy { flex-shrink: 0; }
@media (max-width:600px) { .base-label{width:90px;font-size:.8rem;} }

/* ── IEEE 754 Visualizer ──────────────────────────────────────────── */
.ieee-bits-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 6px; }
.ieee-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ieee-group-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.ieee-bits-inner { display: flex; gap: 2px; flex-wrap: wrap; }
.ieee-bit { width: 22px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 3px; font-family: monospace; font-size: .85rem; font-weight: 700; }
.ieee-sign-bit  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.ieee-exp-bit   { background: #fef9c3; color: #78350f; border: 1px solid #fde68a; }
.ieee-mant-bit  { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.ieee-legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ieee-leg { padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.ieee-leg-sign  { background: #fee2e2; color: #991b1b; }
.ieee-leg-exp   { background: #fef9c3; color: #78350f; }
.ieee-leg-mant  { background: #d1fae5; color: #065f46; }
.ieee-info { margin-top: 4px; }
.ieee-info-grid { display: flex; flex-direction: column; gap: 4px; }
.ieee-info-row { display: flex; gap: 12px; padding: 6px 10px; background: var(--bg-white); border-radius: 4px; font-size: .85rem; }
.ieee-info-key { color: var(--text-muted); min-width: 120px; flex-shrink: 0; }
.ieee-info-val { font-family: monospace; word-break: break-all; }

/* ── Unix Timestamp ───────────────────────────────────────────────── */
.unix-result { margin-top: 8px; }
.unix-grid { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.unix-row { display: flex; gap: 12px; padding: 7px 12px; background: var(--bg-white); border-radius: 4px; font-size: .85rem; border: 1px solid var(--border); }
.unix-row span:first-child { color: var(--text-muted); min-width: 130px; flex-shrink: 0; font-weight: 500; }
.unix-row span:last-child { font-family: monospace; word-break: break-all; }

/* ── Regex Tester ─────────────────────────────────────────────────── */
.regex-pat-row { display: flex; align-items: center; gap: 4px; background: var(--bg-white); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; }
.regex-slash { font-size: 1.2rem; font-weight: 700; color: var(--primary); font-family: monospace; }
.regex-pat-input { flex: 1; border: none; outline: none; background: transparent; font-family: monospace; font-size: .9rem; color: var(--text); }
.regex-flags-input { width: 52px; border: none; border-left: 1.5px solid var(--border); outline: none; background: transparent; font-family: monospace; font-size: .9rem; color: var(--primary); padding-left: 8px; }
.regex-stat-bar { font-size: .85rem; font-weight: 600; padding: 4px 0; }
.rx-match-count { color: var(--primary); }
.regex-hl { font-family: 'Courier New', monospace; font-size: .85rem; line-height: 1.7; padding: 12px 14px; background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm); white-space: pre-wrap; word-break: break-all; margin-top: 4px; }
mark.rx-mark { background: #fef08a; color: #713f12; border-radius: 2px; padding: 1px 0; }
.regex-groups { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.rx-group-row { display: flex; gap: 8px; align-items: flex-start; font-size: .82rem; flex-wrap: wrap; }
.rx-group-idx { color: var(--text-muted); min-width: 60px; font-weight: 600; }
.rx-group-val { background: #eff6ff; color: #1e40af; border-radius: 4px; padding: 1px 7px; font-family: monospace; }

/* ── Color Picker ─────────────────────────────────────────────────── */
.cp-display { margin: 10px 0; border-radius: 8px; overflow: hidden; }

/* ── Checksum verifier result ─────────────────────────────────────── */
.checksum-result {
  padding: 14px 18px; border-radius: var(--radius-sm);
  font-size: 0.95rem; display: flex; align-items: flex-start; gap: 10px;
  margin-top: 4px;
}
.checksum-ok   { background: #f0fdf4; border: 1.5px solid #86efac; color: #166534; }
.checksum-fail { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; }
.checksum-icon { font-size: 1.2rem; flex-shrink: 0; }

/* ── CSV Table viewer ─────────────────────────────────────────────── */
.csv-table-wrap { overflow-x: auto; margin-top: 8px; }
.csv-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.csv-table th {
  background: var(--primary); color: #fff; padding: 8px 12px;
  text-align: left; font-weight: 600; white-space: nowrap;
}
.csv-table td {
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.csv-table tr:nth-child(even) td { background: var(--bg); }
.csv-table tr:hover td { background: var(--primary-light); }

/* ===== FAQ ACCORDION ===== */
.faq-section { margin-top: 32px; }
.faq-section h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--bg-white);
}
.faq-item summary {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  font-size: 1.3rem;
  color: var(--primary);
  flex-shrink: 0;
  font-weight: 400;
}
.faq-item[open] summary::after { content: '−'; }
.faq-item[open] summary { color: var(--primary); }
.faq-item p { padding: 0 16px 14px; color: var(--text-muted); line-height: 1.65; font-size: 0.9rem; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
  .ad-sidebar { display: none; }
}

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: -100%;
    width: 260px;
    height: calc(100vh - var(--header-h));
    z-index: 90;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { left: 0; }

  .hamburger { display: flex; }

  .main-content { padding: 16px 16px 32px; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  .home-hero { padding: 28px 8px 20px; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }

  .calc-box { padding: 18px; }
}

@media (max-width: 480px) {
  .logo-text { display: none; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .calc-grid { grid-template-columns: 1fr; }
}
