:root {
  --bg: #f5f6fa;
  --text: #333;
  --card: #fff;
  --primary: #4f46e5;
  --secondary: #e5e7eb;
  --accent: #10b981;
  --danger: #f87171;
  --border: #ddd;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}

body.dark {
  --bg: #1e1e2f;
  --text: #f1f1f1;
  --card: #2c2c3f;
  --secondary: #44475a;
  --border: #393c50;
  --accent: #34d399;
  --danger: #ef4444;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

header {
  background-color: var(--primary);
  color: white;
  padding: 60px 20px 40px;
  text-align: center;
  border-radius: 0 0 10px 10px;
  position: relative;
}

header h1 {
  font-size: 2.7rem;
  margin-bottom: 10px;
}

header p {
  font-size: 1.15rem;
  opacity: 0.9;
}

header button#themeToggle {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
}

header button#themeToggle:hover {
  transform: rotate(20deg);
}

.tool-section {
  margin-top: 40px;
  background: var(--card);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.category-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.category-buttons button {
  padding: 10px 16px;
  background: var(--secondary);
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.category-buttons button:hover {
  background: #d1d5db;
}

.category-buttons button.active {
  background: var(--primary);
  color: white;
}

.tool-section textarea {
  width: 96%;
  height: 120px;
  padding: 15px;
  font-size: 1rem;
  margin-bottom: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  background-color: #fbfbfb;
}

.tool-section button {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.3s ease;
}

.tool-section button:hover {
  background-color: #3730a3;
}

.spinner {
  display: none;
  margin-top: 20px;
  text-align: center;
}

.spinner div {
  width: 28px;
  height: 28px;
  border: 4px solid #ccc;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#outputWrapper {
  margin-top: 25px;
  background: var(--card);
  padding: 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

#generatedPrompt {
  margin-top: 10px;
  font-weight: 500;
  font-size: 1.05rem;
  white-space: pre-wrap;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#generatedPrompt.visible {
  opacity: 1;
}

.copy-btn {
  margin-top: 10px;
  padding: 9px 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.copy-btn:hover {
  background: #059669;
}

footer {
  text-align: center;
  padding: 30px 20px;
  font-size: 0.9rem;
  background-color: var(--card);
  color: var(--text);
  margin-top: 40px;
  border-top: 1px solid var(--border);
  transition: background 0.3s, color 0.3s;
}


#historyWrapper {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.history-buttons {
  display: flex;
  gap: 10px;
}

#promptHistory {
  list-style: none;
  padding-left: 0;
  max-height: 240px;
  overflow-y: auto;
  transition: max-height 0.4s ease;
}

#promptHistory li {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: 10px;
  transition: background 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.prompt-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.prompt-text {
  flex: 1;
  cursor: pointer;
  white-space: pre-wrap;
  font-size: 0.95rem;
  color: var(--text);
}

.prompt-text:hover {
  text-decoration: underline;
}

.star {
  font-size: 1.2rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s ease;
}

.star:hover {
  transform: scale(1.1);
}

.star.filled {
  color: gold;
}

.mini-btn {
  font-size: 0.85rem;
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: var(--secondary);
  color: var(--text);
  transition: background 0.2s ease;
}

.mini-btn:hover {
  background: #d1d5db;
}

.mini-btn.danger {
  background: var(--danger);
  color: white;
}

.mini-btn.danger:hover {
  background: #dc2626;
}

@media (max-width: 600px) {
  header h1 {
    font-size: 2rem;
  }

  .tool-section {
    padding: 20px;
  }

  .category-buttons {
    flex-direction: column;
  }

  .prompt-item {
    flex-direction: column;
    gap: 6px;
  }

  .mini-btn {
    margin-left: 0;
    margin-top: 5px;
  }

  #promptHistory {
    max-height: 0;
    overflow: hidden;
  }

  #promptHistory.expanded {
    max-height: 300px;
  }

  .history-header h3 {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  
  .tool-section textarea {
    width: 89%;
  }
}

.mini-btn select {
  font-size: 0.9rem;
}

select.mini-btn {
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
}

.char-count {
  font-size: 0.85rem;
  color: #666;
  text-align: right;
  margin-top: -10px;
  margin-bottom: 10px;
}


.category-buttons button.active {
  background: var(--primary);
  color: white;
}

.category-buttons button {
  transition: background 0.2s ease, color 0.2s ease;
}

h1 a {text-decoration:none; color:#fff;}

.char-count.warning {
  color: var(--danger);
  font-weight: bold;
}
