:root {
  --primary: #6366f1;
  /* Indigo 500 */
  --primary-hover: #4f46e5;
  /* Indigo 600 */
  --bg: #f8fafc;
  /* Slate 50 */
  --surface: #ffffff;
  --text-main: #0f172a;
  /* Slate 900 */
  --text-muted: #64748b;
  /* Slate 500 */
  --border: #e2e8f0;
  /* Slate 200 */
  --danger: #ef4444;
  --success: #22c55e;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.2;
  font-weight: 700;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.25rem;
  letter-spacing: -0.025em;
  text-align: center;
}

h2 {
  font-size: 1.8rem;
  letter-spacing: -0.025em;
  margin-top: 2rem;
}

h3 {
  font-size: 1.5rem;
  margin-top: 1.5rem;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 1rem;
}

.logo-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 0.5rem;
  fill: var(--primary);
}

/* Ad Slots */
.ad-slot {
  background-color: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  margin: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}

.ad-slot span {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

/* Controls */
.control-group {
  margin-bottom: 1rem;
}

.label-text {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

/* Drag Drop */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: var(--bg);
}

.drop-zone.drag-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, var(--bg));
}

.drop-zone input {
  display: none;
}

.drop-btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-feature-settings: "tnum";
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  font-size: 1rem;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  width: 100%;
  border: 1px solid var(--primary);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  text-decoration: none;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--border);
  text-decoration: none;
}

/* Toggles */
.options-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  margin: 2rem 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.toggle-label:hover {
  background: var(--surface);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Custom Checkbox */
.toggle-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid #cbd5e1;
  /* Slightly darker than generic border for visibility */
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: all 0.2s ease-in-out;
  flex-shrink: 0;
  margin: 0;
}

.toggle-label:hover input[type="checkbox"] {
  border-color: var(--primary);
}

.toggle-label input[type="checkbox"]:checked {
  background-color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.toggle-label input[type="checkbox"]::before {
  content: "";
  width: 0.4em;
  height: 0.75em;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  opacity: 0;
  transition: all 0.2s cubic-bezier(0.12, 0.4, 0.29, 1.46);
  margin-top: -2px;
  /* Visual correction */
}

.toggle-label input[type="checkbox"]:checked::before {
  transform: rotate(45deg) scale(1);
  opacity: 1;
}

/* Stats */
.stats {
  text-align: center;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.error-msg {
  color: var(--danger);
  margin-top: 0.5rem;
  font-size: 0.9rem;
  text-align: center;
}

/* Quick Entry Section */
.quick-entry-section {
  margin-top: 2rem;
}

.quick-entry-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
}

.quick-entry-container.open {
  max-height: 800px;
  overflow-y: auto;
  padding: 1rem;
  margin-top: 0.5rem;
}

.quick-entry-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.quick-entry-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-main);
  font-size: 0.9rem;
}

.quick-entry-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.quick-entry-remove {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--danger);
  border-radius: var(--radius);
  width: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.quick-entry-remove:hover {
  background: var(--danger);
  color: white;
}

/* Preview */
.preview-section {
  margin-top: 2rem;
}

.preview-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease-out;
}

.preview-list.open {
  max-height: 500px;
  overflow-y: auto;
}

.preview-list li {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.preview-list li:last-child {
  border-bottom: none;
}

.preview-toggle {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}

/* Generator Table */
.gen-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.gen-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-main);
}

.gen-remove {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--danger);
  border-radius: var(--radius);
  width: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--surface);
  padding: 3rem;
  border-radius: 1.5rem;
  text-align: center;
  position: relative;
  max-width: 90%;
  width: 500px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.active .modal-content {
  transform: scale(1);
}

.result-display {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 2rem;
  word-break: break-word;
  color: var(--primary);
}

.close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.close-modal:hover {
  background: var(--text-muted);
  color: var(--surface);
}

/* Confetti details */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* Content Section (Article) */
article {
  margin-top: 3rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}

article p {
  margin-bottom: 1.25rem;
  color: var(--text-main);
  opacity: 0.9;
}

article ul,
article ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

article li {
  margin-bottom: 0.5rem;
}

.faq-item {
  margin-bottom: 2rem;
}

.faq-question {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  display: block;
}

/* Footer */
footer {
  margin-top: 4rem;
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--text-muted);
}

footer a:hover {
  color: var(--primary);
}

/* Cookie Notice */
.cookie-notice {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  z-index: 2000;
  transform: translateY(100%);
  transition: transform 0.3s;
}

.cookie-notice.show {
  transform: translateY(0);
}

.cookie-text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.cookie-btn {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
}

@media (max-width: 600px) {
  h1 {
    font-size: 1.8rem;
  }

  .modal-content {
    padding: 2rem 1.5rem;
  }

  .result-display {
    font-size: 1.8rem;
  }
}