* { box-sizing: border-box; }

/* ══════════════════
   LAYOUT
══════════════════ */
#main-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.b64-right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.b64-examples-outer { display: none; }
.b64-examples-inner { display: block; }

.b64-input-section,
.b64-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.b64-section-title,
.b64-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.b64-section-title svg,
.b64-section-title svg { stroke: #6366f1; flex-shrink: 0; }

/* ══════════════════
   MODE TOGGLE
══════════════════ */
.b64-mode-toggle {
  display: flex;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}
.b64-mode-btn {
  flex: 1;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  font-size: 0.80rem;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: #64748b;
  transition: all 0.18s;
  white-space: nowrap;
}
.b64-mode-btn.active {
  background: #ffffff;
  color: #4338ca;
  box-shadow: 0 1px 4px rgba(99,102,241,0.15);
}

/* ══════════════════
   TEXTAREA INPUT
══════════════════ */
.b64-input-wrap {
  position: relative;
  margin-bottom: 14px;
}
.b64-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: 140px;
}
.b64-textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}
.b64-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;
}
.b64-clear-btn:hover { background: #e2e8f0; color: #ef4444; }

/* ══════════════════
   FIELD GROUP
══════════════════ */
.b64-field-group { margin-bottom: 14px; }
.b64-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

/* Radio */
.b64-variant-options { display: flex; flex-direction: column; gap: 8px; }
.b64-radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.87rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  user-select: none;
}
.b64-radio-label input[type="radio"] { display: none; }
.b64-radio-mark {
  width: 18px; height: 18px;
  border: 2px solid #c7d2fe;
  border-radius: 50%;
  background: #f8f9ff;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.b64-radio-label input:checked + .b64-radio-mark {
  border-color: #6366f1; background: #6366f1;
}
.b64-radio-label input:checked + .b64-radio-mark::after {
  content: ''; width: 6px; height: 6px;
  background: #fff; border-radius: 50%; display: block;
}

/* Checkbox */
.b64-checkbox-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.87rem; font-weight: 500; color: #475569;
  cursor: pointer; user-select: none;
}
.b64-checkbox-label input[type="checkbox"] { display: none; }
.b64-checkmark {
  width: 18px; height: 18px;
  border: 2px solid #c7d2fe; border-radius: 5px;
  background: #f8f9ff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.b64-checkbox-label input:checked + .b64-checkmark {
  background: #6366f1; border-color: #6366f1;
}
.b64-checkbox-label input:checked + .b64-checkmark::after {
  content: ''; width: 5px; height: 9px;
  border: 2px solid #fff; border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px); display: block;
}

/* ══════════════════
   CONVERT BTN
══════════════════ */
.b64-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;
}
.b64-convert-btn:hover { opacity: 0.88; transform: scale(1.02); }
.b64-convert-btn:active { transform: scale(0.98); }

/* ══════════════════
   OUTPUT
══════════════════ */
.b64-output-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.b64-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;
}
.b64-copy-btn:hover { opacity: 0.85; }
.b64-copy-btn.copied { background: linear-gradient(135deg, #22c55e, #16a34a); }

.b64-result-wrap { margin-bottom: 14px; }

.b64-result-placeholder {
  background: linear-gradient(135deg, #f8f9ff, #ede9fe22);
  border: 2px dashed #c7d2fe;
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  color: #cbd5e1;
  font-size: 0.92rem;
  font-weight: 500;
}

.b64-output-textarea {
  width: 100%; min-height: 160px; resize: none;
  padding: 12px 14px; border: 1.5px solid #e2e8f0;
  border-radius: 10px; font-size: 0.88rem;
  font-family: 'Courier New', monospace;
  color: #1e293b; background: #f8faff; outline: none;
  line-height: 1.8; font-weight: 600; word-break: break-all;
}

/* Error */
.b64-error {
  background: #fef2f2; border: 1.5px solid #fecaca;
  border-radius: 10px; padding: 10px 14px;
  font-size: 0.84rem; font-weight: 600; color: #dc2626;
  margin-bottom: 14px;
}

/* Stats */
.b64-stats-row { display: flex; gap: 7px; flex-wrap: wrap; }
.b64-stat-chip {
  background: #f1f5f9; border: 1px solid #e2e8f0;
  border-radius: 20px; padding: 5px 13px;
  font-size: 0.76rem; font-weight: 600; color: #475569;
}

/* ══════════════════
   EXAMPLES
══════════════════ */
.b64-examples-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.b64-example-btn {
  background: #f8f9ff; border: 1.5px solid #e2e8f0;
  border-radius: 20px; padding: 6px 16px;
  font-size: 0.80rem; font-weight: 600; color: #4338ca;
  cursor: pointer; transition: all 0.15s;
  font-family: 'Courier New', monospace; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.b64-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 .b64-input-section,
body.dark-mode .b64-output-section { background: #0f172a; border-color: #1e293b; }
body.dark-mode label.b64-section-title,
body.dark-mode .b64-section-title { color: #e2e8f0; }
body.dark-mode label.b64-section-title svg,
body.dark-mode .b64-section-title svg { stroke: #a5b4fc; }
body.dark-mode .b64-mode-toggle { background: #1e293b; }
body.dark-mode .b64-mode-btn { color: #475569; }
body.dark-mode .b64-mode-btn.active { background: #1e1b4b; color: #a5b4fc; }
body.dark-mode .b64-textarea { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark-mode .b64-textarea:focus { border-color: #818cf8; }
body.dark-mode .b64-clear-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
body.dark-mode .b64-label { color: #475569; }
body.dark-mode .b64-radio-label,
body.dark-mode .b64-checkbox-label { color: #94a3b8; }
body.dark-mode .b64-radio-mark,
body.dark-mode .b64-checkmark { background: #1e1b4b; border-color: #312e81; }
body.dark-mode .b64-result-placeholder { background: #1e1b4b; border-color: #312e81; color: #475569; }
body.dark-mode .b64-output-textarea { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark-mode .b64-error { background: #2d1515; border-color: #7f1d1d; color: #fca5a5; }
body.dark-mode .b64-stat-chip { background: #1e293b; border-color: #334155; color: #94a3b8; }
body.dark-mode .b64-example-btn { background: #1e1b4b; border-color: #312e81; color: #a5b4fc; }
body.dark-mode .b64-example-btn:hover { background: #2e1b6b; border-color: #6366f1; }

/* ══════════════════
   RESPONSIVE
══════════════════ */
@media (max-width: 768px) {
  #main-section { grid-template-columns: 1fr; }
  .b64-examples-inner { display: none !important; }
  .b64-examples-outer { display: block; }
}