* { box-sizing: border-box; }

#rwg-wrapper {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ══════════════════════════════
   CONTROLS SECTION
══════════════════════════════ */
.rwg-controls {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(99,102,241,0.07);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 20px;
  align-items: end;
}

.rwg-control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Label */
.rwg-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: default;
}

.rwg-label svg { stroke: #6366f1; flex-shrink: 0; }

.rwg-optional {
  font-weight: 400;
  text-transform: none;
  color: #94a3b8;
  letter-spacing: 0;
  font-size: 0.78rem;
}

/* ── Count ── */
.rwg-count-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  width: 130px;
}

.rwg-count-btn {
  width: 36px;
  height: 40px;
  background: #f8f9ff;
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  color: #6366f1;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.rwg-count-btn:hover { background: #ede9fe; }

.rwg-count-input {
  flex: 1;
  height: 40px;
  border: none;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  -moz-appearance: textfield;
}

.rwg-count-input::-webkit-inner-spin-button,
.rwg-count-input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── Type buttons ── */
.rwg-type-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rwg-type-btn {
  padding: 7px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #f8f9ff;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.rwg-type-btn:hover {
  border-color: #a5b4fc;
  color: #4338ca;
  background: #ede9fe;
}

.rwg-type-btn.active {
  border-color: #6366f1;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}

/* ── Letter select ── */
.rwg-select {
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  cursor: pointer;
  min-width: 140px;
  transition: border-color 0.15s;
  appearance: auto;
}

.rwg-select:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

/* ── Generate button ── */
.rwg-generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 0 24px;
  height: 44px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.18s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(99,102,241,0.30);
  letter-spacing: 0.02em;
}

.rwg-generate-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.rwg-generate-btn:active {
  transform: translateY(0);
}

/* ══════════════════════════════
   OUTPUT SECTION
══════════════════════════════ */
.rwg-output-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 2px 12px rgba(99,102,241,0.07);
  min-height: 200px;
}

/* Header */
.rwg-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.rwg-output-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rwg-output-actions {
  display: flex;
  gap: 8px;
}

.rwg-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #f8f9ff;
  font-size: 0.80rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}

.rwg-action-btn svg { stroke: #6366f1; }

.rwg-action-btn:hover {
  border-color: #a5b4fc;
  color: #4338ca;
  background: #ede9fe;
}

.rwg-action-btn.copied {
  border-color: #22c55e;
  background: #dcfce7;
  color: #16a34a;
}

/* Words grid */
.rwg-words-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Word chip */
.rwg-word {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #f8f9ff;
  border: 1.5px solid #e0e7ff;
  border-radius: 8px;
  font-size: 0.90rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.rwg-word:hover {
  border-color: #6366f1;
  background: #ede9fe;
  color: #4338ca;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99,102,241,0.12);
}

.rwg-word.copied-word {
  border-color: #22c55e;
  background: #dcfce7;
  color: #16a34a;
}

.rwg-word-num {
  font-size: 0.70rem;
  color: #a5b4fc;
  font-weight: 700;
}

/* Empty state */
.rwg-empty-state {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
  color: #cbd5e1;
  gap: 12px;
  text-align: center;
}

.rwg-empty-state svg { stroke: #cbd5e1; }

.rwg-empty-state p {
  font-size: 0.92rem;
  color: #94a3b8;
  max-width: 28ch;
}

.rwg-empty-state strong { color: #6366f1; }

/* ══════════════════
   DARK MODE
══════════════════ */
body.dark-mode .rwg-controls,
body.dark-mode .rwg-output-section {
  background: #0f172a;
  border-color: #1e293b;
}

body.dark-mode .rwg-label { color: #94a3b8; }

body.dark-mode .rwg-count-wrap {
  border-color: #334155;
}

body.dark-mode .rwg-count-btn {
  background: #1e293b;
  color: #a5b4fc;
}

body.dark-mode .rwg-count-btn:hover { background: #2e1b6b; }

body.dark-mode .rwg-count-input {
  background: #0f172a;
  color: #e2e8f0;
}

body.dark-mode .rwg-type-btn {
  background: #1e1b4b;
  border-color: #312e81;
  color: #94a3b8;
}

body.dark-mode .rwg-type-btn:hover {
  background: #2e1b6b;
  border-color: #6366f1;
  color: #a5b4fc;
}

body.dark-mode .rwg-type-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: #6366f1;
  color: #ffffff;
}

body.dark-mode .rwg-select {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .rwg-output-count { color: #a5b4fc; }

body.dark-mode .rwg-action-btn {
  background: #1e1b4b;
  border-color: #312e81;
  color: #94a3b8;
}

body.dark-mode .rwg-action-btn:hover {
  background: #2e1b6b;
  border-color: #6366f1;
  color: #a5b4fc;
}

body.dark-mode .rwg-word {
  background: #1e1b4b;
  border-color: #312e81;
  color: #e2e8f0;
}

body.dark-mode .rwg-word:hover {
  background: #2e1b6b;
  border-color: #6366f1;
  color: #a5b4fc;
}

body.dark-mode .rwg-empty-state svg { stroke: #334155; }
body.dark-mode .rwg-empty-state p { color: #475569; }

/* ══════════════════
   RESPONSIVE
══════════════════ */
@media (max-width: 900px) {
  .rwg-controls {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .rwg-generate-btn {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 600px) {
  .rwg-controls {
    grid-template-columns: 1fr;
  }

  .rwg-output-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}