/* ═══════════════════════════════════════════════════
   CSS VARIABLES & THEME SYSTEM
   ═══════════════════════════════════════════════════ */
:root {
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.18);
  --shadow-glow: 0 0 20px rgba(var(--accent-rgb), 0.15);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-primary: #0c0e14;
  --bg-secondary: #141722;
  --bg-tertiary: #1a1e2e;
  --bg-card: #171b28;
  --bg-input: #0f1119;
  --bg-hover: #1e2336;
  --border-color: #262d42;
  --border-light: #1e2336;
  --text-primary: #e8ecf4;
  --text-secondary: #8b92a8;
  --text-muted: #555d75;
  --accent: #f0a830;
  --accent-rgb: 240, 168, 48;
  --accent-hover: #f5bc56;
  --accent-soft: rgba(240, 168, 48, 0.1);
  --accent-border: rgba(240, 168, 48, 0.25);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.1);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.1);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.1);
  --gradient-hero: linear-gradient(135deg, #0c0e14 0%, #141722 50%, #1a1530 100%);
  --gradient-accent: linear-gradient(135deg, #f0a830, #e8793a);
  --noise-opacity: 0.03;
  --dots-color: rgba(240, 168, 48, 0.06);
}

[data-theme="light"] {
  --bg-primary: #f8f6f1;
  --bg-secondary: #efece5;
  --bg-tertiary: #e8e4db;
  --bg-card: #ffffff;
  --bg-input: #f4f1ea;
  --bg-hover: #ebe7de;
  --border-color: #d8d3c8;
  --border-light: #e5e0d6;
  --text-primary: #1a1612;
  --text-secondary: #6b6358;
  --text-muted: #9e9588;
  --accent: #c47a15;
  --accent-rgb: 196, 122, 21;
  --accent-hover: #a86610;
  --accent-soft: rgba(196, 122, 21, 0.08);
  --accent-border: rgba(196, 122, 21, 0.2);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.08);
  --error: #dc2626;
  --error-soft: rgba(220, 38, 38, 0.08);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.08);
  --gradient-hero: linear-gradient(135deg, #f8f6f1 0%, #efece5 50%, #f0ebe0 100%);
  --gradient-accent: linear-gradient(135deg, #c47a15, #b8621a);
  --noise-opacity: 0.02;
  --dots-color: rgba(196, 122, 21, 0.05);
}

/* ═══════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}

/* Background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: radial-gradient(var(--dots-color) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}

/* Skip navigation */
.skip-nav {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
}
.skip-nav:focus {
  left: 50%;
  transform: translateX(-50%);
}

/* ═══════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════ */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ═══════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════ */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.logo-text .tagline {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(52, 211, 153, 0.1);
  color: #34d399;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.privacy-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: pulse-privacy 2s ease infinite;
}

@keyframes pulse-privacy {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Theme toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--transition);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ═══════════════════════════════════════════════════
   HERO / INTRO
   ═══════════════════════════════════════════════════ */
.hero-section {
  text-align: center;
  padding: 24px 0 36px;
}

.hero-section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.hero-section p {
  color: var(--text-secondary);
  font-size: 1.02rem;
  max-width: 600px;
  margin: 0 auto;
}

.format-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.format-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════
   CONVERTER PANEL
   ═══════════════════════════════════════════════════ */
.converter-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* Controls bar */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  background: var(--bg-secondary);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 160px;
}

.control-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.control-select {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 9px 34px 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238b92a8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.control-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.swap-btn {
  align-self: flex-end;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.swap-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: rotate(180deg);
}

/* Editors area */
.editors-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 320px;
}

@media (max-width: 700px) {
  .editors-area { grid-template-columns: 1fr; }
}

.editor-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
}

.editor-pane:last-child { border-right: none; }

@media (max-width: 700px) {
  .editor-pane {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .editor-pane:last-child { border-bottom: none; }
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-tertiary);
}

.pane-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

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

.pane-btn {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.pane-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

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

.editor-textarea {
  flex: 1;
  width: 100%;
  min-height: 260px;
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.7;
  border: none;
  background: transparent;
  color: var(--text-primary);
  resize: vertical;
  transition: background var(--transition);
}

.editor-textarea::placeholder {
  color: var(--text-muted);
}

.editor-textarea:focus {
  outline: none;
  background: var(--accent-soft);
}

.editor-textarea[readonly] {
  cursor: default;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════
   FILE UPLOAD DROP ZONE
   ═══════════════════════════════════════════════════ */
.drop-zone {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px 20px;
  min-height: 260px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  margin: 12px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.drop-zone.visible { display: flex; }

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone-icon {
  font-size: 36px;
  opacity: 0.5;
}

.drop-zone-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.drop-zone-text strong {
  color: var(--accent);
  cursor: pointer;
}

.drop-zone-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-preview {
  display: none;
  padding: 14px 18px;
  background: var(--info-soft);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82rem;
  color: var(--text-secondary);
  align-items: center;
  gap: 8px;
}

.file-preview.visible { display: flex; }

.file-preview .file-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.file-preview .file-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}

.file-preview .file-remove:hover {
  background: var(--error-soft);
}

/* ═══════════════════════════════════════════════════
   ACTION BAR
   ═══════════════════════════════════════════════════ */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  gap: 12px;
  flex-wrap: wrap;
}

.convert-btn {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 11px 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient-accent);
  color: #fff;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-glow);
}

.convert-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.3);
}

.convert-btn:active {
  transform: translateY(0);
}

.action-secondary {
  display: flex;
  gap: 8px;
  align-items: center;
}

.char-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 5px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════════════
   STATUS / TOAST
   ═══════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.35s ease;
  max-width: 360px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.info { border-color: var(--info); }

.toast.hiding { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

/* ═══════════════════════════════════════════════════
   MORSE AUDIO PLAYER
   ═══════════════════════════════════════════════════ */
.audio-controls {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-tertiary);
}

.audio-controls.visible { display: flex; }

.audio-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
}

.audio-btn:hover {
  background: var(--accent);
  color: #fff;
}

.speed-control {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-control input[type="range"] {
  width: 80px;
  accent-color: var(--accent);
}

/* ═══════════════════════════════════════════════════
   REFERENCE TABLE
   ═══════════════════════════════════════════════════ */
.reference-section {
  margin-top: 36px;
}

.reference-toggle {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reference-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.reference-content {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}

.reference-content.open { display: block; }

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.ref-table th {
  background: var(--bg-secondary);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
}

.ref-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.ref-table tr:hover td {
  background: var(--accent-soft);
}

.ref-table-scroll {
  max-height: 400px;
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════ */
.site-footer {
  padding: 30px 0 20px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ═══════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-section { animation: fadeUp 0.5s ease; }
.converter-panel { animation: fadeUp 0.6s ease 0.08s both; }
.reference-section { animation: fadeUp 0.6s ease 0.16s both; }

/* ═══════════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .header-inner { height: 56px; }
  .logo-text h1 { font-size: 17px; }
  .logo-text .tagline { display: none; }
  .privacy-badge span:not(.privacy-dot) { display: none; }
  .privacy-badge { padding: 8px; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .swap-btn { align-self: center; transform: rotate(90deg); }
  .swap-btn:hover { transform: rotate(270deg); }
  .action-bar { flex-direction: column; align-items: stretch; }
  .convert-btn { width: 100%; text-align: center; }
  .action-secondary { justify-content: center; }
  .toast-container { left: 16px; right: 16px; }
  .toast { max-width: 100%; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Selection */
::selection {
  background: rgba(var(--accent-rgb), 0.3);
  color: var(--text-primary);
}

/* ===== SITE FOOTER ===== */
.site-footer{
  margin-top:60px;padding:48px 28px 36px;
  border-top:1px solid var(--border-color);
  background:var(--bg-primary);color:var(--text-secondary);
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  font-size:14px;line-height:1.6;
}
.site-footer .footer-inner{max-width:1100px;margin:0 auto}
.site-footer .footer-grid{
  display:grid;grid-template-columns:2fr 1fr 1fr 1fr;
  gap:40px;margin-bottom:40px;
}
.site-footer .footer-brand{display:flex;align-items:center;gap:10px;margin-bottom:16px}
.site-footer .footer-brand svg{width:32px;height:32px;color:#a855f7;flex-shrink:0}
.site-footer .footer-brand-name{
  font-size:20px;font-weight:700;
  background:linear-gradient(90deg,#8B5CF6,#EC4899,#3B82F6);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
}
.site-footer .footer-desc{color:var(--text-muted);margin-bottom:16px;max-width:360px}
.site-footer .footer-copy{font-size:12px;color:var(--text-muted);opacity:.7}
.site-footer h4{font-weight:700;margin-bottom:16px;color:var(--text-primary);font-size:15px}
.site-footer ul{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:10px}
.site-footer a{color:var(--text-secondary);text-decoration:none;transition:color .2s}
.site-footer a:hover{color:#a855f7}
.site-footer .footer-bottom{
  border-top:1px solid var(--border-color);
  padding-top:20px;text-align:center;
}
.site-footer .footer-bottom p{color:var(--text-muted);font-size:13px;opacity:.7}
.site-footer .footer-bottom span{color:#a855f7}

@media(max-width:768px){
  .site-footer .footer-grid{grid-template-columns:1fr;gap:32px}
  .site-footer{padding:36px 16px 28px}
}
