* { box-sizing: border-box; }

#wfc-wrapper {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ══════════════════════════════
   TOP ROW — Input + Options
══════════════════════════════ */
#wfc-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.wfc-input-section,
.wfc-options-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.wfc-section-title,
.wfc-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.wfc-section-title svg,
.wfc-section-title svg { flex-shrink: 0; stroke: #6366f1; }

/* ══════════════════
   INPUT
══════════════════ */
.wfc-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.wfc-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;
}

.wfc-textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

.wfc-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;
}

.wfc-clear-btn:hover { background: #e2e8f0; color: #ef4444; }

.wfc-input-stats {
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
}

/* ══════════════════
   OPTIONS
══════════════════ */
.wfc-opts-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.wfc-opt-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wfc-opt-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Sort buttons */
.wfc-btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.wfc-opt-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.80rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.wfc-opt-btn:hover { border-color: #a5b4fc; color: #4338ca; background: #ede9fe; }

.wfc-opt-btn.active {
  border-color: #6366f1;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.22);
}

/* Toggle switches */
.wfc-toggle-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wfc-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 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;
}

.wfc-toggle:hover { border-color: #a5b4fc; background: #ede9fe; }

.wfc-toggle.active {
  border-color: #6366f1;
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  color: #4338ca;
}

.wfc-toggle-dot {
  width: 32px;
  height: 18px;
  background: #e2e8f0;
  border-radius: 9px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.18s;
}

.wfc-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);
}

.wfc-toggle.active .wfc-toggle-dot {
  background: #6366f1;
}

.wfc-toggle.active .wfc-toggle-dot::after {
  transform: translateX(14px);
}

/* Min count */
.wfc-count-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wfc-count-btn {
  width: 30px;
  height: 30px;
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  font-size: 1rem;
  font-weight: 700;
  color: #6366f1;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wfc-count-btn:hover { background: #ede9fe; }

.wfc-count-input {
  width: 52px;
  height: 30px;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  -moz-appearance: textfield;
}

.wfc-count-input::-webkit-inner-spin-button,
.wfc-count-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.wfc-count-hint {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 500;
}

/* ══════════════════════════════
   RESULTS SECTION
══════════════════════════════ */
.wfc-results-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 2px 12px rgba(99,102,241,0.07);
}

.wfc-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.wfc-results-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wfc-results-actions {
  display: flex;
  gap: 8px;
}

.wfc-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;
}

.wfc-action-btn svg { stroke: #6366f1; }
.wfc-action-btn:hover { border-color: #a5b4fc; color: #4338ca; background: #ede9fe; }
.wfc-action-btn.copied { border-color: #22c55e; background: #dcfce7; color: #16a34a; }

/* Results list */
.wfc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wfc-row {
  display: grid;
  grid-template-columns: 28px 1fr 80px 52px;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  transition: border-color 0.15s;
}

.wfc-row:hover { border-color: #a5b4fc; }

.wfc-row-rank {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.wfc-row-word {
  font-size: 0.92rem;
  font-weight: 700;
  color: #1e293b;
}

/* Bar */
.wfc-row-bar-wrap {
  position: relative;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.wfc-row-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.wfc-row-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6366f1;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Empty state */
.wfc-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
  color: #cbd5e1;
  gap: 12px;
  text-align: center;
}

.wfc-empty-state svg { stroke: #cbd5e1; }
.wfc-empty-state p { font-size: 0.92rem; color: #94a3b8; max-width: 32ch; }

/* ══════════════════
   DARK MODE
══════════════════ */
body.dark-mode .wfc-input-section,
body.dark-mode .wfc-options-section,
body.dark-mode .wfc-results-section {
  background: #0f172a;
  border-color: #1e293b;
}

body.dark-mode label.wfc-section-title,
body.dark-mode .wfc-section-title { color: #e2e8f0; }

body.dark-mode label.wfc-section-title svg,
body.dark-mode .wfc-section-title svg { stroke: #a5b4fc; }

body.dark-mode .wfc-textarea {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .wfc-textarea:focus { border-color: #818cf8; }

body.dark-mode .wfc-clear-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .wfc-clear-btn:hover { background: #334155; color: #ef4444; }

body.dark-mode .wfc-input-stats { color: #475569; }

body.dark-mode .wfc-opt-btn {
  background: #1e1b4b;
  border-color: #312e81;
  color: #94a3b8;
}

body.dark-mode .wfc-opt-btn:hover { background: #2e1b6b; border-color: #6366f1; color: #a5b4fc; }

body.dark-mode .wfc-opt-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: #6366f1;
  color: #fff;
}

body.dark-mode .wfc-toggle {
  background: #1e1b4b;
  border-color: #312e81;
  color: #94a3b8;
}

body.dark-mode .wfc-toggle:hover { background: #2e1b6b; border-color: #6366f1; }

body.dark-mode .wfc-toggle.active {
  background: linear-gradient(135deg, #1e1b4b, #2e1b6b);
  border-color: #6366f1;
  color: #a5b4fc;
}

body.dark-mode .wfc-count-btn {
  background: #1e1b4b;
  border-color: #312e81;
  color: #a5b4fc;
}

body.dark-mode .wfc-count-btn:hover { background: #2e1b6b; }

body.dark-mode .wfc-count-input {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .wfc-results-title { color: #a5b4fc; }

body.dark-mode .wfc-action-btn {
  background: #1e1b4b;
  border-color: #312e81;
  color: #94a3b8;
}

body.dark-mode .wfc-action-btn svg { stroke: #a5b4fc; }
body.dark-mode .wfc-action-btn:hover { background: #2e1b6b; border-color: #6366f1; color: #a5b4fc; }
body.dark-mode .wfc-action-btn.copied { border-color: #22c55e; background: #14532d; color: #86efac; }

body.dark-mode .wfc-row {
  background: #1e1b4b;
  border-color: #312e81;
}

body.dark-mode .wfc-row:hover { border-color: #6366f1; }
body.dark-mode .wfc-row-word { color: #e2e8f0; }
body.dark-mode .wfc-row-bar-wrap { background: #312e81; }
body.dark-mode .wfc-row-count { color: #a5b4fc; }
body.dark-mode .wfc-row-rank { color: #475569; }

body.dark-mode .wfc-empty-state svg { stroke: #334155; }
body.dark-mode .wfc-empty-state p { color: #475569; }

/* ══════════════════
   RESPONSIVE
══════════════════ */
@media (max-width: 768px) {
  #wfc-top { grid-template-columns: 1fr; }
  .wfc-textarea { min-height: 160px; }
  .wfc-row { grid-template-columns: 24px 1fr 60px 44px; gap: 8px; }
}