/* ─────────────────────────────────────────
   Tokens
───────────────────────────────────────── */
:root {
  --bg:           #f7f5f2;
  --surface:      #ffffff;
  --border:       #e4e0d8;
  --border-focus: #b09070;
  --ink:          #1a1714;
  --ink-2:        #5a5450;
  --ink-3:        #9a9390;
  --accent:       #c47f3c;
  --accent-light: #fdf4ea;
  --error:        #c0392b;
  --error-bg:     #fdf1f0;
  --success:      #2d7a4f;

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  --radius:     8px;
  --radius-sm:  5px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);

  --max-w: 760px;
  --gap:   1.5rem;
}

/* ─────────────────────────────────────────
   Reset
───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* ─────────────────────────────────────────
   Layout
───────────────────────────────────────── */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* ─────────────────────────────────────────
   Header
───────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 2rem;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-mark {
  font-size: 1.5rem;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1;
}

.header-text h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.2;
}

.tagline {
  font-size: 0.8rem;
  color: var(--ink-3);
  margin-top: 0.2rem;
  letter-spacing: 0.03em;
  font-weight: 300;
}

/* ─────────────────────────────────────────
   Demo bar
───────────────────────────────────────── */
.demo-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--accent-light);
  border: 1px solid #e8d4b8;
  border-radius: var(--radius);
}

.demo-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-2);
  margin-right: 0.25rem;
}

.demo-btn {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--accent);
  background: transparent;
  border: 1px solid #dfc49a;
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.demo-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ─────────────────────────────────────────
   Form section
───────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--ink);
}

.req { color: var(--accent); }

.optional {
  font-weight: 300;
  font-size: 0.78rem;
  color: var(--ink-3);
}

input[type="text"],
input[type="number"],
textarea,
select {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(176,144,112,0.15);
  background: var(--surface);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
  font-weight: 300;
}

textarea { resize: vertical; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239a9390' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  cursor: pointer;
}

.input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 0.75rem;
  font-size: 0.9rem;
  color: var(--ink-2);
  pointer-events: none;
}

.input-prefix-wrap input {
  padding-left: 1.6rem;
}

.field-error {
  font-size: 0.75rem;
  color: var(--error);
  min-height: 1em;
}

/* Submit */
.form-footer {
  margin-top: 1.75rem;
  display: flex;
  justify-content: flex-end;
}

#generate-btn {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  background: var(--ink);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.01em;
}

#generate-btn:hover  { background: #2d2926; }
#generate-btn:active { transform: scale(0.98); }

#generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-icon { color: var(--accent); font-size: 0.85rem; }

/* ─────────────────────────────────────────
   Loading
───────────────────────────────────────── */
.loading-state {
  text-align: center;
  padding: 3rem 1rem;
}

.loading-inner {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state p {
  font-size: 0.88rem;
  color: var(--ink-2);
  font-weight: 300;
}

.loading-dots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* ─────────────────────────────────────────
   Error
───────────────────────────────────────── */
.error-banner {
  background: var(--error-bg);
  border: 1px solid #e8b9b5;
  color: var(--error);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* ─────────────────────────────────────────
   Output section
───────────────────────────────────────── */
.output-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.output-header h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--ink);
}

.output-meta {
  font-size: 0.78rem;
  color: var(--ink-3);
  font-weight: 300;
}

.output-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Output cards */
.output-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.3s ease both;
}

.output-card:nth-child(1) { animation-delay: 0.05s; }
.output-card:nth-child(2) { animation-delay: 0.10s; }
.output-card:nth-child(3) { animation-delay: 0.15s; }
.output-card:nth-child(4) { animation-delay: 0.20s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.char-count-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.char-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-2);
}

.char-limit {
  font-size: 0.72rem;
  color: var(--ink-3);
}

.char-count.over-limit { color: var(--error); }

.title-text {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--ink);
}

#output-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#output-bullets li {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
  padding-left: 1.1rem;
  position: relative;
}

#output-bullets li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--accent);
}

#output-description {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink);
}

.keywords-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.keyword-pill {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.7rem;
  display: inline-block;
  transition: background 0.12s, border-color 0.12s;
}

.keyword-pill:hover {
  background: var(--accent-light);
  border-color: #dfc49a;
}

.card-footer {
  margin-top: 1.1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.copy-btn {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.copy-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
  background: var(--bg);
}

.copy-btn.copied {
  color: var(--success);
  border-color: #a8d5bc;
  background: #f0faf5;
}

/* Regenerate */
.regenerate-bar {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
}

#regenerate-btn {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#regenerate-btn:hover { color: var(--ink); border-color: var(--ink-2); }

/* ─────────────────────────────────────────
   Footer
───────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem;
  text-align: center;
}

.site-footer p {
  font-size: 0.78rem;
  color: var(--ink-3);
  font-weight: 300;
}

.site-footer a {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: color 0.12s, border-color 0.12s;
}

.site-footer a:hover { color: var(--accent); border-color: var(--accent); }

/* ─────────────────────────────────────────
   Responsive
───────────────────────────────────────── */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .field.full-width { grid-column: 1; }
  .form-section { padding: 1.25rem; }
  .output-card { padding: 1.1rem; }
  .header-text h1 { font-size: 1.15rem; }
  .demo-bar { padding: 0.6rem 0.75rem; }
}
