:root {
  --primary: #f44336;
  --background-light: #ffffff;
  --background-dark: #121212;
  --text-light: #000000;
  --text-dark: #ffffff;
  --accent: #f44336;
  --gray: #e0e0e0;
  --input-bg-light: #f9f9f9;
  --input-bg-dark: #1e1e1e;
  --border: #ccc;
}

[data-theme="dark"] {
  --bg: var(--background-dark);
  --text: var(--text-dark);
  --input-bg: var(--input-bg-dark);
}

[data-theme="light"] {
  --bg: var(--background-light);
  --text: var(--text-light);
  --input-bg: var(--input-bg-light);
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}

.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1rem;
  text-align: center;
}

h1 {
  margin-bottom: 0.5rem;
}

.subtitle {
  font-weight: 300;
  margin-bottom: 2rem;
}

.toggle-wrapper {
  margin: 1rem 0;
}

.theme-button {
  background: none;
  border: 2px solid var(--text);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  background-color: transparent;
}

#format-buttons {
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.format-button {
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 8px;
  background-color: #eee;
  color: #000;
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  margin-bottom: 0.5rem;
}

.format-button.active {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 0 12px rgba(244, 67, 54, 0.6);
}

#fields-container {
  margin-top: 1rem;
  text-align: left;
}

.field-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.user-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background-color: var(--input-bg);
  color: var(--text);
  box-sizing: border-box;
}

#generate {
  margin-top: 1rem;
  padding: 0.8rem 1.6rem;
  font-size: 1.1rem;
  font-weight: bold;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#generate:hover {
  background-color: #d32f2f;
}

#result {
  margin-top: 2rem;
  background-color: var(--input-bg);
  padding: 1rem;
  border-radius: 8px;
  text-align: left;
  white-space: pre-wrap;
  font-family: 'Courier New', monospace;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  box-sizing: border-box;
}

.result-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.copy-btn {
  margin-top: 1rem;
  background-color: #444;
  color: #fff;
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.copy-btn:hover {
  background-color: #222;
}

.back-link {
  display: inline-block;
  margin-top: 2.5rem;
  padding: 0.6rem 1.4rem;
  background-color: var(--gray);
  color: var(--text);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s ease;
  font-size: 1rem;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.05);
}

.back-link:hover {
  background-color: var(--primary);
  color: white;
}

[data-theme="dark"] .back-link {
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.error {
  color: var(--primary);
  font-weight: bold;
}

.loading {
  font-style: italic;
}

/* 📱 Mobile Responsive */
@media (max-width: 600px) {
  .format-button {
    flex: 1 1 100%;
    width: 100%;
  }

  .container {
    padding: 1rem;
  }

  .user-input {
    font-size: 1rem;
  }

  #generate {
    width: 100%;
    font-size: 1.1rem;
  }

  .field-group {
    margin-bottom: 1rem;
  }

  .copy-btn {
    width: 100%;
    text-align: center;
  }

  .back-link {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
  }
}
