:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #f97316;
  --accent-light: #fff7ed;
  --bg-page: #ffffff;
  --bg-surface: #ffffff;
  --bg-section: #f8fafc;
  --text-main: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border-light: #e5e7eb;
  --border-muted: #f3f4f6;
  --input-border: #d1d5db;
  --nav-bg: #f8fafc;
  --nav-text: #6b7280;
  --nav-text-active: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --max-width: 1200px;
  --speed: 0.2s;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a5f;
  --accent: #fb923c;
  --accent-light: #3d2a1a;
  --bg-page: #0f172a;
  --bg-surface: #1e293b;
  --bg-section: #182234;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --border-light: #334155;
  --border-muted: #1e293b;
  --input-border: #475569;
  --nav-bg: #182234;
  --nav-text: #94a3b8;
  --nav-text-active: #60a5fa;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-page);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--speed) var(--ease);
}

a:hover {
  color: var(--primary-hover);
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.site-header {
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-surface);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.header-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--speed) var(--ease);
}

.header-link:hover {
  color: var(--text-main);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  background: var(--bg-section);
  transition: all var(--speed) var(--ease);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.hero {
  background: var(--bg-section);
  border-bottom: 1px solid var(--border-muted);
  padding: 40px 24px 18px;
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.hero-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 12px;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 28px;
  line-height: 1.6;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.hero-stat-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
}

.category-nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-muted);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  padding: 0 24px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-inner::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--nav-text);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all var(--speed) var(--ease);
  margin-bottom: -1px;
}

.cat-btn:hover {
  color: var(--nav-text-active);
}

.cat-btn.is-active {
  color: var(--nav-text-active);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.page-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 28px 24px;
  flex: 1;
  width: 100%;
}

.layout-two-col {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
}

.layout-main {
  min-width: 0;
}

.layout-sidebar {
  position: sticky;
  top: 64px;
}

.sidebar-section {
  background: var(--bg-section);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-list {
  list-style: none;
  counter-reset: item;
}

.sidebar-list li {
  counter-increment: item;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: color var(--speed) var(--ease);
  color: var(--text-main);
}

.sidebar-list li:last-child {
  border-bottom: none;
}

.sidebar-list li::before {
  content: counter(item);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-list li:hover {
  color: var(--primary);
}

.tool-grid {
  margin-bottom: 24px;
}

.category-section {
  margin-bottom: 28px;
}

.category-section:last-child {
  margin-bottom: 0;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-muted);
}

.category-header-icon {
  font-size: 20px;
  line-height: 1;
}

.category-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.category-header-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.tool-card.is-active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.tool-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.tool-card-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.tool-card-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-main);
}

.tool-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.tool-card-badges {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.tool-badge.popular {
  background: var(--primary-light);
  color: var(--primary);
}

.tool-badge.new {
  background: var(--accent-light);
  color: var(--accent);
}

/* ==========================================================================
   Modal Overlay
   ========================================================================== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-container {
  position: relative;
  width: 90vw;
  max-width: 780px;
  max-height: 85vh;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  animation: modal-in 0.2s var(--ease);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-muted);
  flex-shrink: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
}

.modal-close:hover {
  background: var(--bg-section);
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-body .tool-workspace {
  margin-top: 0;
}

.modal-body .workspace-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-section);
}

.modal-body .workspace-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.15;
}

.tool-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.tool-panel h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.tool-panel .tool-description {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 5px;
  color: var(--text-main);
}

.input-group-icon {
  position: relative;
}

.input-group-icon .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-group-icon input,
.input-group-icon select {
  padding-left: 38px !important;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 14px;
  transition: all var(--speed) var(--ease);
  box-shadow: var(--shadow-sm);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
  min-height: 110px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
}

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
  min-width: 150px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: all var(--speed) var(--ease);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-section);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  color: var(--text-main);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  border-radius: 3px;
}

.result-box {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-section);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.result-label {
  font-weight: 700;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.result-item {
  padding: 10px 14px;
  background: var(--bg-section);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.result-item .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.result-item .value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-all;
}

.strength-meter {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.strength-bar {
  flex: 1;
  height: 6px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--speed) var(--ease);
  width: 0%;
}

.strength-fill.weak {
  width: 25%;
  background: var(--danger);
}

.strength-fill.medium {
  width: 50%;
  background: var(--warning);
}

.strength-fill.strong {
  width: 75%;
  background: var(--success);
}

.strength-fill.very-strong {
  width: 100%;
  background: var(--primary);
}

.strength-label {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  min-width: 55px;
  color: var(--text-main);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stat-card {
  padding: 14px;
  background: var(--bg-section);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--border-light);
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
  font-family: var(--font-sans);
  color: var(--primary);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}

.conversion-result {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
  padding: 16px 0 8px;
  text-align: center;
}

.conversion-formula {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 500;
}

.anagram-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.anagram-tag {
  padding: 5px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
}

.fin-sub {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 20px;
  margin-bottom: 20px;
}

.fin-sub:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.fin-sub h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-footer {
  background: var(--nav-bg);
  color: var(--text-muted);
  padding: 28px 24px;
  margin-top: auto;
  border-top: 1px solid var(--border-muted);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer-copy {
  font-size: 13px;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

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

  .layout-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    position: static;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 32px 20px 28px;
  }

  .hero-title {
    font-size: 26px;
  }

  .hero-subtitle {
    font-size: 14px;
  }

  .hero-stats {
    gap: 24px;
  }

  .hero-stat-value {
    font-size: 22px;
  }

  .page-container {
    padding: 20px 16px;
  }

  .header-inner {
    padding: 12px 16px;
  }

  .logo-text {
    font-size: 17px;
  }

  .nav-inner {
    padding: 0 16px;
  }

  .cat-btn {
    padding: 12px 14px;
    font-size: 13px;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .tool-card {
    padding: 14px;
  }

  .tool-card-icon {
    font-size: 18px;
  }

  .tool-card-title {
    font-size: 13px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  .form-row .form-group {
    min-width: 100%;
  }

  .layout-sidebar {
    grid-template-columns: 1fr;
  }
}

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

  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .conversion-result {
    font-size: 20px;
  }
}