:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e7ed;
  --border-hover: #c9cfd8;
  --border-focus: #3b82f6;
  --text: #111827;
  --muted: #6b7280;
  --subtle: #9ca3af;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --accent-light: #eff6ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

/* ── Top nav ────────────────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topnav-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-logo {
  font-weight: 800;
  font-size: 15px;
  color: var(--accent-dark);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg);
}

/* ── Hamburger toggle ────────────────────────────────────────────────────── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Nav dropdown ────────────────────────────────────────────────────────── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-dropdown-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.nav-chevron {
  font-size: 10px;
  transition: transform 0.2s;
}

.nav-dropdown:hover .nav-chevron,
.nav-dropdown.open .nav-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  padding: 6px;
  display: none;
  z-index: 200;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.nav-dropdown-menu a:hover {
  color: var(--text);
  background: var(--bg);
}

/* smooth scroll */
html { scroll-behavior: smooth; }

/* offset anchors so sticky nav doesn't cover headings */
[id] { scroll-margin-top: 68px; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 48px 24px 64px;
}

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  margin-bottom: 32px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
  text-align: center;
}

.lead {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

/* ── Main panel ─────────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 11px;
  padding: 11px 17px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.sep {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.sub {
  color: var(--muted);
  font-size: 13px;
}

/* ── Workspace ──────────────────────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: 24px;
  gap: 20px;
}

/* ── Swap button ────────────────────────────────────────────────────────── */
.swap-wrap {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swap-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  flex-shrink: 0;
  user-select: none;
}

.swap-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(59,130,246,0.2);
}

.swap-btn:active {
  transform: scale(0.95);
}

.swap-btn.spinning {
  animation: swap-spin 0.35s ease;
}

@keyframes swap-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mini-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  box-shadow: var(--shadow-xs);
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 16px;
  font-size: 15px;
  line-height: 1.7;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea::placeholder { color: var(--subtle); }

textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: var(--surface);
}

/* ── Stats ──────────────────────────────────────────────────────────────── */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  color: var(--muted);
  font-size: 12px;
  padding: 0 2px;
}

.stats strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Controls ───────────────────────────────────────────────────────────── */
.controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 0 24px 24px;
}

.control-card {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.control-btn,
.primary-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.control-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.primary-btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.control-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

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

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}

.value {
  min-width: 36px;
  text-align: right;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

/* ── SEO Sections ───────────────────────────────────────────────────────── */
.seo-section {
  margin-top: 48px;
  padding: 36px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.seo-section h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.seo-section p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

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

/* Morse table */
.morse-table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.morse-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.morse-table th,
.morse-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.morse-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg);
}

.morse-table td:nth-child(odd) {
  font-weight: 700;
  color: var(--text);
  width: 48px;
}

.morse-table td:nth-child(even) {
  font-family: 'Courier New', monospace;
  color: var(--accent-dark);
  letter-spacing: 0.1em;
}

.morse-table tbody tr:hover {
  background: var(--bg);
}

/* Steps */
.steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 8px;
}

.step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.step-body strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.step-body p {
  margin: 0;
}

/* FAQ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-item summary {
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background 0.15s;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  color: var(--muted);
  flex-shrink: 0;
}

.faq-item[open] summary::after { content: "−"; }

.faq-item summary:hover { background: var(--bg); }

.faq-item[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.faq-item p {
  margin: 0;
  padding: 14px 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.75;
}

.faq-item code {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--accent-dark);
}

/* ── SEO section H3 ─────────────────────────────────────────────────────── */
.seo-section h3 {
  margin: 28px 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.seo-section h3:first-of-type {
  margin-top: 20px;
}

/* ── Feature grid ────────────────────────────────────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.feature-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.feature-card p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}

/* ── Two-column content grid ─────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

.content-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.content-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.content-card p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.content-card code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--accent-dark);
}

/* ── Morse translation grid ──────────────────────────────────────────────── */
.translation-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.translation-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.translation-card .phrase {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.translation-card .morse-code {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--accent-dark);
  letter-spacing: 0.06em;
  line-height: 1.6;
  word-break: break-word;
  margin-bottom: 10px;
}

.translation-card .phrase-desc {
  font-size: 12px;
  color: var(--subtle);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer-note {
  display: none;
}

.site-footer {
  margin-top: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.footer-links {
  display: flex;
  align-items: center;
}

.footer-links a {
  padding: 0 14px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border-right: 1px solid var(--border);
  line-height: 1;
  transition: color 0.15s;
}

.footer-links a:first-child { padding-left: 0; }
.footer-links a:last-child  { padding-right: 0; border-right: none; }

.footer-links a:hover {
  color: var(--text);
}

.footer-copy {
  margin: 0;
  font-size: 13px;
  color: var(--subtle);
}

@media (max-width: 480px) {
  .footer-links {
    flex-direction: column;
    gap: 8px;
  }
  .footer-links a {
    padding: 0;
    border-right: none;
  }
}

/* ── Light button glow effect ────────────────────────────────────────────── */
#btn-light {
  transition: background 0.04s, border-color 0.04s, color 0.04s, box-shadow 0.04s;
}

#btn-light.light-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

#btn-light.light-on {
  background: #fbbf24;
  border-color: #f59e0b;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(251,191,36,0.7), 0 0 20px rgba(251,191,36,0.35);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .controls {
    grid-template-columns: 1fr;
  }
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .translation-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .swap-wrap {
    padding: 4px 0;
  }
  .swap-btn {
    transform: rotate(90deg);
  }
  .swap-btn:hover {
    transform: rotate(90deg) scale(1.1);
  }
  .swap-btn.spinning {
    animation: swap-spin-v 0.35s ease;
  }
  @keyframes swap-spin-v {
    0%   { transform: rotate(90deg) scale(1); }
    50%  { transform: rotate(270deg) scale(1.15); }
    100% { transform: rotate(450deg) scale(1); }
  }
}

@media (max-width: 600px) {
  /* ── Nav: hamburger ── */
  .nav-toggle { display: flex; }

  .topnav-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 0 16px;
    gap: 0;
    align-items: stretch;
  }

  .nav-logo {
    display: flex;
    align-items: center;
    height: 52px;
  }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0 10px;
    border-top: 1px solid var(--border);
  }

  .nav-links.open { display: flex; }

  .nav-links a {
    padding: 11px 10px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    border-radius: var(--radius-md);
    width: 100%;
  }

  /* ── Nav dropdown (mobile) ── */
  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-btn {
    padding: 11px 10px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    border-radius: var(--radius-md);
    width: 100%;
    background: none;
  }

  .nav-dropdown:hover .nav-dropdown-menu {
    display: none;
  }

  .nav-dropdown.open .nav-dropdown-menu {
    display: block;
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: none;
    padding: 0 0 4px 12px;
  }

  .nav-dropdown.open .nav-dropdown-menu a {
    padding: 9px 10px;
    font-size: 14px;
    color: var(--muted);
  }

  /* ── Layout ── */
  .shell { padding: 24px 16px 48px; }
  .workspace { padding: 16px; }
  .topbar { padding: 14px 16px; flex-direction: column; align-items: flex-start; }
  textarea { min-height: 180px; }

  /* ── Controls: 2×2 grid ── */
  .controls {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 16px 16px;
  }
  .controls .control-card:first-child { grid-column: 1 / -1; }

  /* ── SEO sections ── */
  .seo-section { padding: 24px 20px; }
  .seo-section h2 { font-size: 18px; }
  .feature-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .translation-grid { grid-template-columns: 1fr 1fr; }
}
