* { box-sizing: border-box; }

/* ══════════════════
   LAYOUT
══════════════════ */
#main-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}

.ftg-input-section,
.ftg-filter-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.ftg-section-title,
.ftg-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.ftg-section-title svg,
.ftg-section-title svg { flex-shrink: 0; stroke: #6366f1; }

/* ══════════════════
   INPUT
══════════════════ */
.ftg-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ftg-textarea {
  flex: 1;
  width: 100%;
  min-height: 180px;
  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;
}

.ftg-textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

.ftg-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;
}

.ftg-clear-btn:hover { background: #e2e8f0; color: #ef4444; }

.ftg-input-meta {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
}

/* ══════════════════
   CATEGORY FILTER
══════════════════ */
.ftg-cat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.ftg-cat-btn {
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.ftg-cat-btn:hover { border-color: #a5b4fc; background: #ede9fe; color: #4338ca; }

.ftg-cat-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}

/* ══════════════════
   SEARCH
══════════════════ */
.ftg-search-wrap {
  position: relative;
  margin-bottom: 12px;
}

.ftg-search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  stroke: #94a3b8;
  pointer-events: none;
}

.ftg-search {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  font-size: 0.87rem;
  font-family: inherit;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  transition: border-color 0.18s;
}

.ftg-search:focus { border-color: #818cf8; }

.ftg-stats {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
}

/* ══════════════════
   GRID HEADER
══════════════════ */
.ftg-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 10px;
}

.ftg-grid-header h2 { margin: 0; }

.ftg-copy-all-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 18px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.18s;
  white-space: nowrap;
}

.ftg-copy-all-btn:hover { opacity: 0.85; }
.ftg-copy-all-btn.copied { background: linear-gradient(135deg, #22c55e, #16a34a); }

/* ══════════════════
   STYLE CARDS GRID
══════════════════ */
.ftg-all-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.ftg-card {
  background: #f8f9ff;
  border: 1.5px solid #e2e8f0;
  border-radius: 13px;
  padding: 14px 16px 12px;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ftg-card:hover {
  border-color: #a5b4fc;
  background: #ede9fe;
  box-shadow: 0 4px 16px rgba(99,102,241,0.10);
  transform: translateY(-1px);
}

.ftg-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ftg-card-name {
  font-size: 0.70rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ftg-card-cat {
  font-size: 0.65rem;
  font-weight: 600;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
}

.ftg-card-preview {
  font-size: 1.15rem;
  color: #1e293b;
  word-break: break-word;
  line-height: 1.5;
  min-height: 28px;
  flex: 1;
}

.ftg-card-preview.empty { color: #cbd5e1; font-size: 0.85rem; font-style: italic; }

.ftg-card-copy-btn {
  align-self: flex-end;
  background: #e0e7ff;
  border: none;
  border-radius: 7px;
  padding: 5px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #4338ca;
  cursor: pointer;
  transition: all 0.15s;
}

.ftg-card-copy-btn:hover { background: #c7d2fe; }
.ftg-card-copy-btn.copied { background: #dcfce7; color: #15803d; }

/* No results */
.ftg-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-size: 0.92rem;
}

/* ══════════════════
   DARK MODE
══════════════════ */
body.dark-mode .ftg-input-section,
body.dark-mode .ftg-filter-section {
  background: #0f172a;
  border-color: #1e293b;
}

body.dark-mode label.ftg-section-title,
body.dark-mode .ftg-section-title { color: #e2e8f0; }

body.dark-mode label.ftg-section-title svg,
body.dark-mode .ftg-section-title svg { stroke: #a5b4fc; }

body.dark-mode .ftg-textarea {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .ftg-textarea:focus { border-color: #818cf8; }

body.dark-mode .ftg-clear-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .ftg-clear-btn:hover { background: #334155; color: #ef4444; }

body.dark-mode .ftg-input-meta { color: #475569; }

body.dark-mode .ftg-cat-btn {
  background: #1e1b4b;
  border-color: #312e81;
  color: #94a3b8;
}

body.dark-mode .ftg-cat-btn:hover { background: #2e1b6b; color: #a5b4fc; }

body.dark-mode .ftg-cat-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
}

body.dark-mode .ftg-search {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .ftg-search:focus { border-color: #818cf8; }

body.dark-mode .ftg-search-wrap svg { stroke: #475569; }

body.dark-mode .ftg-stats { color: #475569; }

body.dark-mode .ftg-card {
  background: #1e1b4b;
  border-color: #312e81;
}

body.dark-mode .ftg-card:hover {
  background: #2e1b6b;
  border-color: #6366f1;
}

body.dark-mode .ftg-card-name { color: #475569; }

body.dark-mode .ftg-card-cat {
  background: #1e1b4b;
  color: #a5b4fc;
}

body.dark-mode .ftg-card-preview { color: #e2e8f0; }
body.dark-mode .ftg-card-preview.empty { color: #334155; }

body.dark-mode .ftg-card-copy-btn {
  background: #312e81;
  color: #a5b4fc;
}

body.dark-mode .ftg-card-copy-btn:hover { background: #3730a3; }
body.dark-mode .ftg-card-copy-btn.copied { background: #14532d; color: #4ade80; }

body.dark-mode .ftg-no-results { color: #475569; }

/* ══════════════════
   RESPONSIVE
══════════════════ */
@media (max-width: 700px) {
  #main-section { grid-template-columns: 1fr; }
  .ftg-textarea { min-height: 140px; }
  .ftg-all-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .ftg-all-grid { grid-template-columns: 1fr; }
}