* { box-sizing: border-box; }

/* ══════════════════════════════
   MAIN SECTION LAYOUT
   Top Row : Input | Mode (50/50)
   Bottom  : Output (full width, centered)
══════════════════════════════ */
#main-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}

.rlb-input-section  { grid-column: 1 / 2; grid-row: 1; }
.rlb-mode-section   { grid-column: 2 / 3; grid-row: 1; }
.rlb-output-section { grid-column: 1 / -1; grid-row: 2; }

/* ── Section base ── */
.rlb-input-section,
.rlb-mode-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;
}

.rlb-output-section {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

/* ══════════════════
   SECTION TITLE
══════════════════ */
label.rlb-section-title,
.rlb-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: default;
}

label.rlb-section-title svg,
.rlb-section-title svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: #6366f1;
}

/* ══════════════════
   INPUT
══════════════════ */
.rlb-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.rlb-textarea {
  flex: 1;
  width: 100%;
  min-height: 200px;
  resize: none;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  color: #1e293b;
  background: #ffffff;
  line-height: 1.7;
  transition: border-color 0.18s;
}

.rlb-textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

.rlb-clear-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 4px 12px;
  font-size: 0.80rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: background 0.18s;
}

.rlb-clear-btn:hover {
  background: #e2e8f0;
  color: #ef4444;
}

/* ══════════════════
   MODE BUTTONS
══════════════════ */
.rlb-mode-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.rlb-mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
  width: 100%;
  flex: 1;
}

.rlb-mode-btn:hover {
  border-color: #a5b4fc;
  background: #ede9fe;
}

.rlb-mode-btn.active {
  border-color: #6366f1;
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  box-shadow: 0 2px 10px rgba(99,102,241,0.12);
}

.rlb-mode-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.rlb-mode-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  flex: 1;
}

.rlb-mode-btn.active .rlb-mode-name { color: #4338ca; }

.rlb-mode-ex {
  font-size: 0.75rem;
  color: #94a3b8;
  font-family: monospace;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.rlb-mode-btn.active .rlb-mode-ex {
  background: #ddd6fe;
  color: #6d28d9;
}

/* ══════════════════════════════
   OUTPUT BOX
══════════════════════════════ */
.rlb-output-box {
  background: linear-gradient(135deg, #f8f9ff, #ede9fe33);
  border: 2px solid #c7d2fe;
  border-radius: 14px;
  padding: 20px 24px;
  max-width: 700px;
  margin: 0 auto;
  box-shadow: 0 4px 24px rgba(99,102,241,0.10);
}

.rlb-output-label {
  font-size: 0.80rem;
  font-weight: 700;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rlb-output-area {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  padding: 12px 14px;
  border: 1.5px solid #e0e7ff;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  color: #1e293b;
  background: #ffffff;
  line-height: 1.7;
  cursor: default;
}

/* ══════════════════
   COPY BUTTON
══════════════════ */
.rlb-copy-btn {
  margin-top: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 11px 0;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.18s, transform 0.15s;
  letter-spacing: 0.03em;
}

.rlb-copy-btn:hover {
  opacity: 0.88;
  transform: scale(1.02);
}

.rlb-copy-btn.copied {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

/* ══════════════════
   DARK MODE
══════════════════ */
body.dark-mode .rlb-input-section,
body.dark-mode .rlb-mode-section {
  background: #0f172a;
  border-color: #1e293b;
}

body.dark-mode label.rlb-section-title,
body.dark-mode .rlb-section-title { color: #e2e8f0; }

body.dark-mode label.rlb-section-title svg,
body.dark-mode .rlb-section-title svg { stroke: #a5b4fc; }

body.dark-mode .rlb-textarea {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .rlb-textarea:focus {
  border-color: #818cf8;
}

body.dark-mode .rlb-clear-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .rlb-clear-btn:hover {
  background: #334155;
  color: #ef4444;
}

body.dark-mode .rlb-mode-btn {
  background: #1e1b4b;
  border-color: #312e81;
}

body.dark-mode .rlb-mode-btn:hover {
  background: #2e1b6b;
  border-color: #6366f1;
}

body.dark-mode .rlb-mode-btn.active {
  background: linear-gradient(135deg, #1e1b4b, #2e1b6b);
  border-color: #6366f1;
}

body.dark-mode .rlb-mode-name { color: #e2e8f0; }
body.dark-mode .rlb-mode-btn.active .rlb-mode-name { color: #a5b4fc; }

body.dark-mode .rlb-mode-ex {
  background: #0f172a;
  color: #64748b;
}

body.dark-mode .rlb-mode-btn.active .rlb-mode-ex {
  background: #312e81;
  color: #a5b4fc;
}

body.dark-mode .rlb-output-box {
  background: #1e1b4b;
  border-color: #312e81;
  box-shadow: 0 4px 24px rgba(99,102,241,0.15);
}

body.dark-mode .rlb-output-label { color: #a5b4fc; }

body.dark-mode .rlb-output-area {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

/* ══════════════════
   RESPONSIVE
══════════════════ */
@media (max-width: 700px) {
  #main-section {
    grid-template-columns: 1fr;
  }

  .rlb-input-section  { grid-column: 1 / -1; grid-row: 1; }
  .rlb-mode-section   { grid-column: 1 / -1; grid-row: 2; }
  .rlb-output-section { grid-column: 1 / -1; grid-row: 3; }

  .rlb-textarea { min-height: 160px; }
  .rlb-output-area { min-height: 120px; }
  .rlb-output-box { max-width: 100%; }
}