/* ─── Base Reset ─── */
html, body {
  height: 100%;
  margin: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
}

:root {
  --bg-primary: #333;
  --bg-surface: #333;
  --text-primary: #fff;
  --accent: #ff3333;
  --gray-light: #000;
}

body.theme-red {
  --bg-primary: #ff3333;
  --bg-surface: #ff3333;
  --text-primary: #fff;
  --accent: #1C1C1E;
}

/* ─── Header & Footer ─── */
.site-header,
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--gray-light);
  height: 50px;
  padding: 0 2rem;
}

.site-header .logo a,
.footer-nav a,
.top-nav a {
  color: var(--text-primary);
  font-weight: 700;
  text-decoration: none;
}

.main-content {
  flex: 1 0 auto;
  overflow-y: auto;
  scrollbar-width: none;
}
.main-content::-webkit-scrollbar {
  display: none;
}

#theme-toggle-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

/* ─── Hub / Generator ─── */
.hub.formula-generator {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0;
}

.formula-wrapper {
  background: var(--bg-surface);
  border: 1px solid #666;
  padding: 1.5rem 1rem;
  width: 90%;
  max-width: 800px;
  box-sizing: border-box;
}
.formula-wrapper > * {
  width: 100%;
  box-sizing: border-box;
}

.formula-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}
.formula-link {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: underline;
}
.formula-link.active {
  color: var(--accent);
}

.random-btn {
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  padding: 0.5rem 0.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  width: 200px;
}

.input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.subject-input,
.aspect-select {
  height: 30px;
  width: 100%;
  padding: 0 0.5rem;
  font-size: 0.9rem;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
}
.subject-input::placeholder {
  color: rgba(255,255,255,0.7);
}

.outputs {
  margin-bottom: 1.5rem;
}
.output-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.output-row label {
  display: flex;
  align-items: center;
  min-width: 160px;
  color: var(--text-primary);
}
.output-checkbox {
  accent-color: yellow;
  margin-right: 0.5rem;
}
.label-input {
  background: #fff;
  color: #000;
  border: 1px solid #ccc;
  padding: 0.25rem 0.5rem;
  flex: 1;
  min-width: 120px;
  font-size: 0.9rem;
}
.clear-label-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.75rem;
}
.random-label-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  cursor: pointer;
  margin-left: 0.5rem;
}
.random-label-btn:hover {
  transform: scale(1.1);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.action-btn,
#generate-btn {
  height: 30px;
  line-height: 30px;
  padding: 0 0.75rem;
  font-size: 0.8rem;
  border: none;
  border-radius: 0;
  cursor: pointer;
  background: var(--accent);
  color: var(--bg-primary);
}
#generate-btn {
  background: #fff;
  color: var(--accent);
  font-weight: bold;
}

.prompt-output-container,
.inspiration-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.prompt-output,
.inspiration-output {
  flex: 1;
  padding: 0.25rem 0.5rem;
  border: none;
  background: var(--accent);
  color: var(--bg-primary);
  resize: vertical;
  overflow-y: hidden;
  width: 100%;
  box-sizing: border-box;
}
.prompt-output-container label,
.inspiration-row label {
  flex: 0 0 6rem;
  white-space: nowrap;
  margin-bottom: 0.25rem;
}

.result-sections {
  width: 100%;
  max-width: 800px;
  margin-top: 2rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--bg-surface);
  padding: 0.5rem 0.5rem 2.5rem;
  font-size: 0.65rem;
  border: 1px solid #666;
  position: relative;
}
.card-title {
  font-size: 0.75rem;
  font-weight: bold;
}
.btn-group {
  position: absolute;
  bottom: 0.25rem;
  right: 0.25rem;
  display: flex;
  gap: 0.25rem;
}
.btn-group button {
  background: none;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  color: #fff;
}
.favorite-toggle {
  color: var(--accent);
  position: absolute;
  bottom: 0.25rem;
  left: 0.25rem;
  font-size: 1rem;
  cursor: pointer;
}

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  z-index: 100;
  padding-right: 2rem;
}
.modal-content {
  background: var(--accent);
  padding: 2rem;
  border-radius: 8px;
  width: 300px;
}
.hidden {
  display: none;
}

#info-btn {
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  height: 30px;
  padding: 0;
  font-size: 1rem;
  cursor: pointer;
  margin-left: auto;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

@media (max-width: 600px) {
  .input-row,
  .controls-row,
  .prompt-output-container,
  .inspiration-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  .output-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .output-row label,
  .output-row span,
  .clear-label-btn {
    margin: 0.25rem 0;
  }
  .action-btn,
  #generate-btn,
  .subject-input,
  .aspect-select,
  .label-input {
    width: 100%;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .formula-link {
    flex: 1;
    text-align: center;
  }
}
