* { box-sizing: border-box; }

/* ══════════════════
   LAYOUT
══════════════════ */
#main-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.mc-right-col { display: flex; flex-direction: column; gap: 16px; }
.mc-examples-outer { display: none; }
.mc-examples-inner { display: block; }

.mc-input-section,
.mc-output-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(99,102,241,0.07);
  display: flex;
  flex-direction: column;
}

/* ══════════════════
   SECTION TITLE
══════════════════ */
label.mc-section-title,
.mc-section-title {
  font-size: 1.05rem; font-weight: 700; color: #1e293b;
  margin: 0 0 14px 0; display: flex; align-items: center;
  gap: 8px; cursor: default;
}
label.mc-section-title svg,
.mc-section-title svg { stroke: #6366f1; flex-shrink: 0; }

/* ══════════════════
   MODE TOGGLE
══════════════════ */
.mc-mode-toggle {
  display: flex; background: #f1f5f9;
  border-radius: 10px; padding: 4px; gap: 4px; margin-bottom: 14px;
}
.mc-mode-btn {
  flex: 1; padding: 8px 10px; border: none; border-radius: 7px;
  font-size: 0.82rem; font-weight: 700; cursor: pointer;
  background: transparent; color: #64748b; transition: all 0.18s;
}
.mc-mode-btn.active {
  background: #ffffff; color: #4338ca;
  box-shadow: 0 1px 4px rgba(99,102,241,0.15);
}

/* ══════════════════
   TEXTAREA
══════════════════ */
.mc-input-wrap { position: relative; margin-bottom: 14px; }
.mc-textarea {
  width: 100%; resize: none; padding: 12px 14px;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  font-size: 0.92rem; outline: none;
  font-family: 'Courier New', monospace; color: #1e293b;
  background: #ffffff; line-height: 1.7;
  transition: border-color 0.18s; min-height: 120px;
}
.mc-textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}
.mc-clear-btn {
  position: absolute; top: 10px; right: 10px;
  background: #f1f5f9; border: 1px solid #e2e8f0;
  border-radius: 7px; padding: 4px 12px;
  font-size: 0.78rem; font-weight: 600; color: #64748b;
  cursor: pointer; transition: background 0.15s;
}
.mc-clear-btn:hover { background: #e2e8f0; color: #ef4444; }

/* ══════════════════
   FIELD GROUP
══════════════════ */
.mc-field-group { margin-bottom: 14px; }
.mc-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}
.mc-speed-val {
  font-size: 0.80rem; font-weight: 700;
  color: #6366f1; text-transform: none; letter-spacing: 0;
}

/* Sep buttons */
.mc-sep-options { display: flex; gap: 7px; flex-wrap: wrap; }
.mc-sep-btn {
  background: #f8f9ff; border: 1.5px solid #e2e8f0;
  border-radius: 8px; padding: 6px 14px;
  font-size: 0.80rem; font-weight: 600; color: #64748b;
  cursor: pointer; transition: all 0.15s;
}
.mc-sep-btn:hover { background: #ede9fe; border-color: #a5b4fc; color: #4338ca; }
.mc-sep-btn.active { background: #ede9fe; border-color: #6366f1; color: #4338ca; }

/* Slider */
.mc-slider {
  width: 100%; height: 4px; -webkit-appearance: none;
  appearance: none; border-radius: 2px;
  background: linear-gradient(to right, #6366f1 0%, #e2e8f0 0%);
  outline: none; cursor: pointer;
}
.mc-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  background: #6366f1; border-radius: 50%; cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(99,102,241,0.3);
}
.mc-slider::-moz-range-thumb {
  width: 18px; height: 18px; background: #6366f1;
  border-radius: 50%; cursor: pointer; border: 2px solid #fff;
}

/* Audio row */
.mc-audio-row {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.mc-play-btn {
  flex: 1; background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff; border: none; border-radius: 10px; padding: 10px 14px;
  font-size: 0.88rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: 7px; transition: opacity 0.18s, transform 0.15s;
}
.mc-play-btn:hover { opacity: 0.88; transform: scale(1.02); }
.mc-play-btn.playing { background: linear-gradient(135deg, #f59e0b, #d97706); }

.mc-stop-btn {
  background: #f1f5f9; border: 1.5px solid #e2e8f0;
  border-radius: 10px; padding: 10px 14px;
  font-size: 0.84rem; font-weight: 700; color: #64748b;
  cursor: pointer; display: flex; align-items: center;
  gap: 6px; transition: all 0.15s;
}
.mc-stop-btn:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* ══════════════════
   CONVERT BTN
══════════════════ */
.mc-convert-btn {
  width: 100%; background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 11px; padding: 13px;
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: 8px; transition: opacity 0.18s, transform 0.15s; margin-top: auto;
}
.mc-convert-btn:hover { opacity: 0.88; transform: scale(1.02); }
.mc-convert-btn:active { transform: scale(0.98); }

/* ══════════════════
   OUTPUT
══════════════════ */
.mc-output-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.mc-copy-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 8px;
  padding: 7px 18px; font-size: 0.84rem; font-weight: 700;
  cursor: pointer; transition: opacity 0.18s;
}
.mc-copy-btn:hover { opacity: 0.85; }
.mc-copy-btn.copied { background: linear-gradient(135deg, #22c55e, #16a34a); }

.mc-result-placeholder {
  background: linear-gradient(135deg, #f8f9ff, #ede9fe22);
  border: 2px dashed #c7d2fe; border-radius: 12px;
  padding: 28px 20px; text-align: center;
  color: #cbd5e1; font-size: 0.92rem; font-weight: 500;
  margin-bottom: 14px;
}

.mc-output-textarea {
  width: 100%; min-height: 120px; resize: none;
  padding: 12px 14px; border: 1.5px solid #e2e8f0;
  border-radius: 10px; font-size: 1rem;
  font-family: 'Courier New', monospace; color: #1e293b;
  background: #f8faff; outline: none; line-height: 2;
  font-weight: 700; word-break: break-all; margin-bottom: 14px;
  letter-spacing: 0.05em;
}

/* ── Visual Bar ── */
.mc-visual-wrap { margin-bottom: 14px; }
.mc-visual-label {
  font-size: 0.78rem; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}
.mc-visual-bar {
  display: flex; flex-wrap: wrap; gap: 3px; align-items: center;
  background: #0f172a; border-radius: 10px; padding: 12px 14px;
  min-height: 48px;
}
.mc-dot {
  width: 8px; height: 8px; background: #22c55e;
  border-radius: 50%; flex-shrink: 0;
}
.mc-dash {
  width: 24px; height: 8px; background: #22c55e;
  border-radius: 4px; flex-shrink: 0;
}
.mc-letter-gap {
  width: 10px; height: 8px; flex-shrink: 0;
}
.mc-word-gap {
  width: 22px; height: 8px;
  border-left: 2px dashed #334155; flex-shrink: 0;
}

/* Stats */
.mc-stats-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.mc-stat-chip {
  background: #f1f5f9; border: 1px solid #e2e8f0;
  border-radius: 20px; padding: 5px 13px;
  font-size: 0.76rem; font-weight: 600; color: #475569;
}

/* ── Char Map ── */
.mc-map-wrap { }
.mc-map-label {
  font-size: 0.78rem; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}
.mc-char-map {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 180px; overflow-y: auto;
}
.mc-char-map::-webkit-scrollbar { width: 4px; }
.mc-char-map::-webkit-scrollbar-track { background: #f1f5f9; }
.mc-char-map::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 2px; }

.mc-char-cell {
  display: flex; flex-direction: column; align-items: center;
  background: #f8f9ff; border: 1.5px solid #e2e8f0;
  border-radius: 8px; padding: 6px 10px; min-width: 52px;
}
.mc-char-cell .mc-cc-char {
  font-size: 1rem; font-weight: 700; color: #6366f1;
  font-family: 'Courier New', monospace; line-height: 1.2;
}
.mc-char-cell .mc-cc-code {
  font-size: 0.68rem; font-weight: 700; color: #94a3b8;
  font-family: 'Courier New', monospace; margin-top: 3px;
  letter-spacing: 0.1em;
}

/* ══════════════════
   REFERENCE CHART
══════════════════ */
.mc-reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
}
.mc-ref-cell {
  background: #f8f9ff; border: 1.5px solid #e2e8f0;
  border-radius: 8px; padding: 8px 6px;
  text-align: center;
}
.mc-ref-char {
  font-size: 1rem; font-weight: 700; color: #1e293b;
  display: block; margin-bottom: 3px;
}
.mc-ref-code {
  font-size: 0.72rem; font-weight: 700; color: #6366f1;
  font-family: 'Courier New', monospace; letter-spacing: 0.1em;
}

/* ══════════════════
   EXAMPLES
══════════════════ */
.mc-examples-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.mc-example-btn {
  background: #f8f9ff; border: 1.5px solid #e2e8f0;
  border-radius: 20px; padding: 6px 16px;
  font-size: 0.82rem; font-weight: 600; color: #4338ca;
  cursor: pointer; transition: all 0.15s;
}
.mc-example-btn:hover {
  background: #ede9fe; border-color: #a5b4fc;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99,102,241,0.12);
}

/* ══════════════════
   DARK MODE
══════════════════ */
body.dark-mode .mc-input-section,
body.dark-mode .mc-output-section { background: #0f172a; border-color: #1e293b; }
body.dark-mode label.mc-section-title,
body.dark-mode .mc-section-title { color: #e2e8f0; }
body.dark-mode label.mc-section-title svg,
body.dark-mode .mc-section-title svg { stroke: #a5b4fc; }
body.dark-mode .mc-mode-toggle { background: #1e293b; }
body.dark-mode .mc-mode-btn { color: #475569; }
body.dark-mode .mc-mode-btn.active { background: #1e1b4b; color: #a5b4fc; }
body.dark-mode .mc-textarea { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark-mode .mc-textarea:focus { border-color: #818cf8; }
body.dark-mode .mc-clear-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
body.dark-mode .mc-label { color: #475569; }
body.dark-mode .mc-sep-btn { background: #1e1b4b; border-color: #312e81; color: #94a3b8; }
body.dark-mode .mc-sep-btn.active { background: #312e81; color: #a5b4fc; border-color: #6366f1; }
body.dark-mode .mc-sep-btn:hover { background: #2e1b6b; color: #a5b4fc; }
body.dark-mode .mc-slider { background: linear-gradient(to right, #a5b4fc 0%, #334155 0%); }
body.dark-mode .mc-stop-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
body.dark-mode .mc-stop-btn:hover { background: #2d1515; border-color: #7f1d1d; color: #fca5a5; }
body.dark-mode .mc-result-placeholder { background: #1e1b4b; border-color: #312e81; color: #475569; }
body.dark-mode .mc-output-textarea { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark-mode .mc-stat-chip { background: #1e293b; border-color: #334155; color: #94a3b8; }
body.dark-mode .mc-char-cell { background: #1e1b4b; border-color: #312e81; }
body.dark-mode .mc-char-cell .mc-cc-char { color: #a5b4fc; }
body.dark-mode .mc-char-cell .mc-cc-code { color: #475569; }
body.dark-mode .mc-ref-cell { background: #1e1b4b; border-color: #312e81; }
body.dark-mode .mc-ref-char { color: #e2e8f0; }
body.dark-mode .mc-ref-code { color: #a5b4fc; }
body.dark-mode .mc-char-map::-webkit-scrollbar-track { background: #1e293b; }
body.dark-mode .mc-char-map::-webkit-scrollbar-thumb { background: #312e81; }
body.dark-mode .mc-example-btn { background: #1e1b4b; border-color: #312e81; color: #a5b4fc; }
body.dark-mode .mc-example-btn:hover { background: #2e1b6b; border-color: #6366f1; }

/* ══════════════════
   RESPONSIVE
══════════════════ */
@media (max-width: 768px) {
  #main-section { grid-template-columns: 1fr; }
  .mc-examples-inner { display: none !important; }
  .mc-examples-outer { display: block; }
  .mc-reference-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }
}