/* Rajdhani Fonts */
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 300;
  src: url('fonts/rajdhani-v17-latin-300.woff2') format('woff2'),
       url('fonts/rajdhani-v17-latin-300.ttf') format('truetype');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 500;
  src: url('fonts/rajdhani-v17-latin-500.woff2') format('woff2'),
       url('fonts/rajdhani-v17-latin-500.ttf') format('truetype');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 700;
  src: url('fonts/rajdhani-v17-latin-700.woff2') format('woff2'),
       url('fonts/rajdhani-v17-latin-700.ttf') format('truetype');
}

/* Share Tech Mono Font */
@font-face {
  font-family: 'Share Tech Mono';
  font-style: normal;
  font-weight: 400;
  src: url('fonts/share-tech-mono-v16-latin-regular.woff2') format('woff2'),
       url('fonts/share-tech-mono-v16-latin-regular.ttf') format('truetype');
}

:root {
  --bg: #050a0e;
  --surface: #0c1419;
  --surface2: #111d24;
  --border: #1e3340;
  --accent: #00e5ff;
  --accent2: #ff6b35;
  --dot: #00e5ff;
  --dash: #ff6b35;
  --text: #c8dde8;
  --muted: #4a6875;
  --glow: 0 0 20px rgba(0, 229, 255, 0.3);
  --glow2: 0 0 20px rgba(255, 107, 53, 0.3);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  overflow-x: hidden;
}

/* Grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,229,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Radial glow center */
body::after {
  content: '';
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(0,229,255,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 780px;
}

/* Header */
header {
  margin-bottom: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  width: 100%;
}

.signal-bar {
  display: flex;
  gap: 5px;
  align-items: flex-end;
  height: 28px;
}

.signal-bar span {
  display: block;
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  animation: signal-pulse 1.4s ease-in-out infinite;
}

.signal-bar span:nth-child(1) { height: 8px;  animation-delay: 0s; }
.signal-bar span:nth-child(2) { height: 16px; animation-delay: 0.15s; }
.signal-bar span:nth-child(3) { height: 24px; animation-delay: 0.3s; background: var(--accent2); }
.signal-bar span:nth-child(4) { height: 28px; animation-delay: 0.45s; background: var(--accent2); }
.signal-bar span:nth-child(5) { height: 24px; animation-delay: 0.6s; background: var(--accent2); }
.signal-bar span:nth-child(6) { height: 16px; animation-delay: 0.75s; }
.signal-bar span:nth-child(7) { height: 8px;  animation-delay: 0.9s; }

@keyframes signal-pulse {
  0%, 100% { opacity: 0.3; transform: scaleY(0.6); }
  50% { opacity: 1; transform: scaleY(1); }
}

/* Language Selector */
.lang-selector {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 4px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
  letter-spacing: 1px;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--accent);
  color: var(--bg);
  box-shadow: var(--glow);
}

header h1 {
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 700;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #fff;
  line-height: 1;
}

header h1 span {
  color: var(--accent);
  text-shadow: var(--glow);
}

header p {
  margin-top: 10px;
  font-size: 14px;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
}

/* Panels */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 3px;
}

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

.panel {
  background: var(--surface);
  padding: 20px;
  position: relative;
}

.panel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.panel-label .dot-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: blink 2s ease-in-out infinite;
}

.panel:last-child .panel-label .dot-indicator {
  background: var(--accent2);
  box-shadow: 0 0 8px var(--accent2);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

textarea {
  width: 100%;
  min-height: 160px;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: 'Share Tech Mono', 'Courier New', Courier, monospace;
  font-size: 16px;
  line-height: 1.7;
  resize: none;
  caret-color: var(--accent);
}

textarea::placeholder {
  color: var(--muted);
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  font-size: 14px;
  letter-spacing: 1px;
}

#morseOutput {
  color: var(--accent);
  font-family: 'Share Tech Mono', 'Courier New', Courier, monospace;
  font-size: 18px;
  line-height: 1.9;
  letter-spacing: 2px;
  word-break: break-all;
  min-height: 160px;
  white-space: pre-wrap;
}

#morseOutput .morse-dot { color: var(--dot); }
#morseOutput .morse-dash { color: var(--dash); }
#morseOutput .morse-space { opacity: 0.3; }

/* Toolbar */
.toolbar {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 4px 4px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 8px 18px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn:hover::before { opacity: 0.08; }

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

.btn.primary {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 0 var(--accent);
}

.btn.primary:hover {
  background: rgba(0,229,255,0.1);
  box-shadow: var(--glow);
}

.btn.danger:hover {
  border-color: #ff4444;
  color: #ff4444;
}

.btn.play-btn {
  border-color: var(--accent2);
  color: var(--accent2);
}

.btn.play-btn:hover {
  background: rgba(255,107,53,0.1);
  box-shadow: var(--glow2);
}

.btn.play-btn:hover::before { background: var(--accent2); opacity: 0.08; }

.btn-icon { font-size: 14px; }

.spacer { flex: 1; }

/* Stats bar */
.stats {
  display: flex;
  gap: 24px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-bottom: 3px;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 16px;
}

.stat-item span {
  color: var(--accent);
  font-family: 'Share Tech Mono', 'Courier New', Courier, monospace;
  font-size: 13px;
}

/* Visual morse display */
.visual-morse {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  min-height: 80px;
  overflow-x: auto;
}

.visual-morse-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.morse-visual-track {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 32px;
}

.mv-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 8px var(--dot);
  flex-shrink: 0;
}

.mv-dash {
  width: 28px;
  height: 10px;
  border-radius: 5px;
  background: var(--dash);
  box-shadow: 0 0 8px var(--dash);
  flex-shrink: 0;
}

.mv-char-gap {
  width: 14px;
  flex-shrink: 0;
}

.mv-word-gap {
  width: 30px;
  flex-shrink: 0;
  height: 1px;
  background: var(--border);
  opacity: 0.5;
}

/* Reference table */
.reference-toggle {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.ref-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s;
}

.ref-header:hover { color: var(--accent); }

.ref-header .chevron {
  transition: transform 0.3s;
  font-size: 10px;
}

.ref-header.open .chevron { transform: rotate(180deg); }

.ref-body {
  display: none;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
}

.ref-body.open { display: block; }

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 6px;
}

.ref-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  transition: border-color 0.2s;
}

.ref-item:hover { border-color: var(--accent); }

.ref-char {
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.ref-code {
  font-family: 'Share Tech Mono', 'Courier New', Courier, monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 1px;
}

/* Notification */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 12px 20px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-radius: 2px;
  box-shadow: var(--glow);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Playing animation */
@keyframes playing {
  0%, 100% { box-shadow: 0 0 10px var(--accent2); }
  50% { box-shadow: 0 0 30px var(--accent2), 0 0 60px rgba(255,107,53,0.3); }
}

.is-playing {
  animation: playing 0.5s ease-in-out infinite;
}

/* Virtual Morse Keyboard */
.mors-keyboard {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 15px 20px;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.k-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Share Tech Mono', 'Courier New', Courier, monospace;
  font-size: 20px;
  font-weight: 700;
  padding: 10px 24px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
}

.k-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--glow);
}

.k-btn.wide {
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 30px;
}

.k-btn.danger-btn {
  border-color: rgba(255, 68, 68, 0.4);
  color: #ff4444;
}

.k-btn.danger-btn:hover {
  border-color: #ff4444;
  box-shadow: 0 0 15px rgba(255, 68, 68, 0.3);
}

/* Footer */
footer {
  margin-top: 30px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
}

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

/* Settings Panel */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px 20px;
  margin-bottom: 3px;
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1.6fr;
  gap: 20px;
  align-items: center;
}

@media (max-width: 768px) {
  .settings-panel {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-item.checkbox-item {
  flex-direction: row;
  align-items: center;
  height: 100%;
  padding-top: 15px;
}

@media (max-width: 768px) {
  .setting-item.checkbox-item {
    padding-top: 0;
  }
}

.setting-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

/* Custom Range Input */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--glow);
  cursor: pointer;
  transition: transform 0.1s, background-color 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--glow);
  cursor: pointer;
  transition: transform 0.1s, background-color 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* Checkbox Container */
.checkbox-container {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  height: 16px;
  width: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: all 0.2s;
}

.checkbox-container:hover input ~ .checkmark {
  border-color: var(--accent);
}

.checkbox-container input:checked ~ .checkmark {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-container .checkmark:after {
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Visualizer Highlight Active Symbol */
.mv-dot.active {
  background: #fff;
  box-shadow: 0 0 15px #fff, 0 0 30px var(--dot);
  transform: scale(1.3);
  transition: all 0.08s ease-out;
}

.mv-dash.active {
  background: #fff;
  box-shadow: 0 0 15px #fff, 0 0 30px var(--dash);
  transform: scaleY(1.3);
  transition: all 0.08s ease-out;
}

