@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@300;400;500;600&display=swap');

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

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.06);
  --border-hover: rgba(0,0,0,0.12);
  --text: #171717;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  --accent: #4a7c59;
  --accent-hover: #3d6a4b;
  --accent-subtle: rgba(74,124,89,0.08);
  --accent-border: rgba(74,124,89,0.2);
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --success: #4a7c59;
  --success-bg: rgba(74,124,89,0.06);
  --radius: 10px;
  --radius-sm: 8px;
  --transition: 0.12s ease;
}

body {
  font-family: 'Source Sans 3', -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== AUTH LAYOUT ===== */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-card { width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .logo { font-size: 1.4rem; }

.auth-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.auth-footer { text-align: center; margin-top: 20px; }

/* ===== HEADER ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  background: rgba(250,250,249,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.04em; }
.logo a { color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }

nav { display: flex; gap: 2px; }

nav button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  font-family: inherit;
  font-weight: 400;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all var(--transition);
}

nav button:hover { color: var(--text-secondary); background: rgba(0,0,0,0.04); }

/* ===== LAYOUT ===== */
main {
  max-width: 540px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 16px;
}

/* ===== TYPOGRAPHY ===== */
h2 {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 4px;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 24px;
  font-weight: 400;
}

/* ===== FORMS ===== */
label {
  display: block;
  font-weight: 500;
  font-size: 16px;
  margin-bottom: 5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.helper {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 6px;
  line-height: 1.5;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  margin-bottom: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  height: 44px;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

textarea {
  min-height: 120px;
  height: auto;
  resize: vertical;
  line-height: 1.6;
}

.field-group { margin-bottom: 2px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 22px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: -0.01em;
}

.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

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

.btn-secondary:hover { border-color: var(--border-hover); background: rgba(0,0,0,0.02); }

.btn-full { width: 100%; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== LINK BUTTONS ===== */
.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  font-family: inherit;
  font-weight: 400;
  padding: 0;
}

.link-btn:hover { color: var(--accent); }

/* ===== ALERTS ===== */
.error {
  color: var(--error);
  font-size: 16px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  display: none;
}

.error:not(:empty) { display: block; }

.success {
  color: var(--success);
  font-size: 16px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--success-bg);
  border-radius: var(--radius-sm);
  display: none;
}

.success:not(:empty) { display: block; }

.muted { color: var(--text-muted); font-size: 14px; }

/* ===== DRAFT TEXTAREA ===== */
.draft-textarea {
  width: 100%;
  min-height: 340px;
  height: auto;
  font-family: inherit;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  margin-bottom: 16px;
}

.draft-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ===== LISTING CONTEXT ===== */
.listing-context {
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-muted);
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-free { background: rgba(0,0,0,0.05); color: var(--text-muted); }
.badge-pro { background: var(--accent-subtle); color: var(--accent); }

/* ===== PROGRESS ===== */
.progress-track {
  background: rgba(0,0,0,0.05);
  border-radius: 2px;
  height: 3px;
  overflow: hidden;
}

.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 2px;
}

/* ===== USAGE / METER ===== */
.usage-meter {
  padding: 14px 16px;
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
}

/* ===== STYLE PICKER ===== */
.style-btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.style-btn:hover { border-color: var(--border-hover); color: var(--text-secondary); }

.style-btn-active {
  border-color: var(--accent-border);
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 500;
}

.style-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== FETCH ROW ===== */
.fetch-row { display: flex; gap: 8px; }
.fetch-row input { margin-bottom: 0 !important; }

/* ===== DIVIDER ===== */
.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== UPGRADE / PRO CARDS ===== */
.upgrade-card {
  border: 1px solid rgba(196,138,82,0.25);
  background: rgba(253,246,239,0.5);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 16px;
}

.upgrade-card .btn { background: #b8864a; margin-top: 12px; }
.upgrade-card .btn:hover { background: #a57840; }

.pro-card {
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 16px;
}

/* ===== MOBILE ===== */
@media (max-width: 480px) {
  header { padding: 0 16px; height: 52px; }
  main { padding: 20px 12px 48px; }
  .card { padding: 20px; }
  .auth-form { padding: 24px; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
  .fetch-row { flex-direction: column; }
  .fetch-row .btn { width: 100%; }
  #style-picker, #regen-styles { flex-direction: column; }
  .style-btn { width: 100%; text-align: center; }
}
