* { box-sizing: border-box; }

#main-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}

.cs-input-section  { grid-column: 1 / 2; grid-row: 1; }
.cs-mode-section   { grid-column: 2 / 3; grid-row: 1; }
.cs-output-section { grid-column: 1 / -1; grid-row: 2; }

.cs-input-section,
.cs-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;
}

.cs-output-section { background: transparent; border: none; padding: 0; }

/* ══════════════════
   SECTION TITLE
══════════════════ */
label.cs-section-title,
.cs-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.cs-section-title svg,
.cs-section-title svg { flex-shrink: 0; stroke: #6366f1; }

/* ══════════════════
   INPUT
══════════════════ */
.cs-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cs-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;
}

.cs-textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

.cs-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;
}

.cs-clear-btn:hover { background: #e2e8f0; color: #ef4444; }

.cs-input-stats {
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
}

/* ══════════════════
   OPTIONS
══════════════════ */
.cs-opts-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.cs-opt-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cs-opt-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Separator grid */
.cs-sep-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.cs-sep-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
}

.cs-sep-btn:hover { border-color: #a5b4fc; background: #ede9fe; }

.cs-sep-btn.active {
  border-color: #6366f1;
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  box-shadow: 0 2px 8px rgba(99,102,241,0.12);
}

.cs-sep-preview {
  font-size: 0.85rem;
  font-family: monospace;
  font-weight: 800;
  color: #1e293b;
}

.cs-sep-btn.active .cs-sep-preview { color: #4338ca; }

.cs-sep-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cs-sep-btn.active .cs-sep-name { color: #6366f1; }

.cs-custom-input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #818cf8;
  border-radius: 9px;
  font-size: 0.88rem;
  font-family: monospace;
  font-weight: 600;
  color: #1e293b;
  background: #f8f9ff;
  outline: none;
  transition: border-color 0.15s;
  margin-top: 4px;
}

.cs-custom-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

/* Wrap grid */
.cs-wrap-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.cs-wrap-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
}

.cs-wrap-btn:hover { border-color: #a5b4fc; background: #ede9fe; }

.cs-wrap-btn.active {
  border-color: #6366f1;
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  box-shadow: 0 2px 8px rgba(99,102,241,0.12);
}

.cs-wrap-preview {
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: 700;
  color: #1e293b;
}

.cs-wrap-btn.active .cs-wrap-preview { color: #4338ca; }

.cs-wrap-name {
  font-size: 0.65rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cs-wrap-btn.active .cs-wrap-name { color: #6366f1; }

/* Toggles */
.cs-toggle-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cs-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.cs-toggle:hover { border-color: #a5b4fc; background: #ede9fe; }

.cs-toggle.active {
  border-color: #6366f1;
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  color: #4338ca;
}

.cs-toggle-dot {
  width: 32px;
  height: 18px;
  background: #e2e8f0;
  border-radius: 9px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.18s;
}

.cs-toggle-dot::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.cs-toggle.active .cs-toggle-dot { background: #6366f1; }
.cs-toggle.active .cs-toggle-dot::after { transform: translateX(14px); }

/* ══════════════════════════════
   OUTPUT BOX
══════════════════════════════ */
.cs-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);
}

.cs-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;
}

.cs-output-stats {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 700;
  color: #22c55e;
  background: #dcfce7;
  padding: 2px 10px;
  border-radius: 20px;
  text-transform: none;
  letter-spacing: 0;
}

.cs-output-area {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  padding: 12px 14px;
  border: 1.5px solid #e0e7ff;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  font-family: monospace;
  color: #1e293b;
  background: #ffffff;
  line-height: 1.7;
  cursor: default;
}

.cs-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;
}

.cs-copy-btn:hover { opacity: 0.88; transform: scale(1.02); }
.cs-copy-btn.copied { background: linear-gradient(135deg, #22c55e, #16a34a); }

/* ══════════════════
   DARK MODE
══════════════════ */
body.dark-mode .cs-input-section,
body.dark-mode .cs-mode-section {
  background: #0f172a;
  border-color: #1e293b;
}

body.dark-mode label.cs-section-title,
body.dark-mode .cs-section-title { color: #e2e8f0; }

body.dark-mode label.cs-section-title svg,
body.dark-mode .cs-section-title svg { stroke: #a5b4fc; }

body.dark-mode .cs-textarea {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .cs-textarea:focus { border-color: #818cf8; }

body.dark-mode .cs-clear-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .cs-clear-btn:hover { background: #334155; color: #ef4444; }
body.dark-mode .cs-input-stats { color: #475569; }
body.dark-mode .cs-opt-label { color: #475569; }

body.dark-mode .cs-sep-btn,
body.dark-mode .cs-wrap-btn {
  background: #1e1b4b;
  border-color: #312e81;
}

body.dark-mode .cs-sep-btn:hover,
body.dark-mode .cs-wrap-btn:hover {
  background: #2e1b6b;
  border-color: #6366f1;
}

body.dark-mode .cs-sep-btn.active,
body.dark-mode .cs-wrap-btn.active {
  background: linear-gradient(135deg, #1e1b4b, #2e1b6b);
  border-color: #6366f1;
}

body.dark-mode .cs-sep-preview,
body.dark-mode .cs-wrap-preview { color: #e2e8f0; }

body.dark-mode .cs-sep-btn.active .cs-sep-preview,
body.dark-mode .cs-wrap-btn.active .cs-wrap-preview { color: #a5b4fc; }

body.dark-mode .cs-custom-input {
  background: #1e293b;
  border-color: #6366f1;
  color: #e2e8f0;
}

body.dark-mode .cs-toggle {
  background: #1e1b4b;
  border-color: #312e81;
  color: #94a3b8;
}

body.dark-mode .cs-toggle:hover { background: #2e1b6b; border-color: #6366f1; }

body.dark-mode .cs-toggle.active {
  background: linear-gradient(135deg, #1e1b4b, #2e1b6b);
  border-color: #6366f1;
  color: #a5b4fc;
}

body.dark-mode .cs-output-box {
  background: #1e1b4b;
  border-color: #312e81;
  box-shadow: 0 4px 24px rgba(99,102,241,0.15);
}

body.dark-mode .cs-output-label { color: #a5b4fc; }
body.dark-mode .cs-output-stats { background: #14532d; color: #86efac; }

body.dark-mode .cs-output-area {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

/* ══════════════════
   RESPONSIVE
══════════════════ */
@media (max-width: 700px) {
  #main-section { grid-template-columns: 1fr; }

  .cs-input-section  { grid-column: 1 / -1; grid-row: 1; }
  .cs-mode-section   { grid-column: 1 / -1; grid-row: 2; }
  .cs-output-section { grid-column: 1 / -1; grid-row: 3; }

  .cs-textarea { min-height: 160px; }
  .cs-output-box { max-width: 100%; }
  .cs-wrap-grid { grid-template-columns: repeat(2, 1fr); }
}