/* ===== Design tokens ===== */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f5f5f6;
  --border: #e4e4e7;
  --text: #18181b;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-text: #ffffff;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 15, 0.06);
  --shadow-md: 0 2px 10px rgba(20, 20, 15, 0.07);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--space-2);
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

p { margin: 0 0 var(--space-3); }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }

/* ===== Layout ===== */
.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.container-narrow {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

main {
  flex: 1;
  padding: var(--space-7) 0 var(--space-8);
}

/* ===== Navbar ===== */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  font-size: 14px;
}

.nav-links a { color: var(--text-muted); }
.nav-links a:hover { color: var(--text); text-decoration: none; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.user-menu summary::-webkit-details-marker,
.user-menu summary::marker {
  display: none;
  content: "";
}

.user-menu .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 190px;
  padding: var(--space-2);
  z-index: 30;
}

.user-menu .menu-name {
  padding: var(--space-2) 10px 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.user-menu .menu a {
  display: block;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
}

.user-menu .menu a:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.user-menu .menu hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-2) 4px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

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

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

.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: var(--space-5); }

/* ===== Forms ===== */
.field {
  margin-bottom: var(--space-5);
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: var(--space-2);
  color: var(--text);
}

.field .hint {
  display: block;
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: var(--space-1);
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

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

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-6);
}

fieldset legend {
  font-weight: 650;
  font-size: 15px;
  padding: 0 0 var(--space-1);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.radio-option:hover { background: var(--surface-alt); }

.radio-option input { margin-top: 3px; }

.radio-option.checked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ===== Alerts / flash ===== */
.alert {
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: 14px;
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(179, 64, 47, 0.25);
}

.alert-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(61, 107, 79, 0.25);
}

/* ===== Auth pages ===== */
.auth-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-header .brand-mark {
  width: 44px;
  height: 44px;
  font-size: 18px;
  margin: 0 auto var(--space-4);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-5);
  font-size: 14px;
  color: var(--text-muted);
}

/* ===== Dashboard ===== */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-header p { margin: 0; }

.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  color: var(--text-muted);
}

.empty-state .brand-mark {
  width: 44px; height: 44px; font-size: 18px;
  margin: 0 auto var(--space-4);
  background: var(--surface-alt);
  color: var(--text-faint);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  transition: border-color 120ms ease;
}

.history-item:hover { border-color: var(--text-faint); }

.history-item-main a {
  font-weight: 600;
  color: var(--text);
}

.history-item-main a:hover { color: var(--accent); }

.history-meta {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-1);
}

/* ===== Score badge ===== */
.score-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.score-badge .max { font-weight: 500; color: var(--text-faint); font-size: 11.5px; }

/* ===== Results page ===== */
.result-hero {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.result-score {
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.result-score .num { font-size: 30px; font-weight: 700; line-height: 1; color: var(--accent-hover); }
.result-score .denom { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.result-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.result-section-title .icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pill {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  color: var(--text);
}

.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.suggestion-list li {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.suggestion-list li .marker {
  flex-shrink: 0;
  color: var(--text-faint);
  font-weight: 700;
  font-size: 12px;
  margin-top: 3px;
}

.headline-option {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: var(--space-2);
}
.headline-option:last-child { margin-bottom: 0; }

.rewrite-box {
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-4) var(--space-5);
  font-size: 14.5px;
  white-space: pre-wrap;
}

.gap-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.gap-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: 14px;
  color: var(--text);
}

.gap-list li::before {
  content: "!";
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.section-gap { margin-bottom: var(--space-5); }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}

.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(246, 246, 244, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-4);
  z-index: 50;
}

.spinner-overlay.active { display: flex; }

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

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

/* ===== Wizard / stepper ===== */
.stepper {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-6);
}

.step-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.step-item .step-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.step-item .step-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-faint);
  white-space: nowrap;
  transition: color 150ms ease;
}

.step-item.active .step-circle {
  border-color: var(--accent);
  color: var(--accent);
}
.step-item.active .step-label { color: var(--text); }

.step-item.done .step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.step-item.done .step-label { color: var(--text-muted); }

.step-connector {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 var(--space-3);
  transition: background-color 150ms ease;
}
.step-connector.done { background: var(--accent); }

.wizard-step h2 {
  margin-bottom: var(--space-1);
}

.wizard-step .step-intro {
  color: var(--text-muted);
  margin-bottom: var(--space-5);
  font-size: 14px;
}

.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.wizard-nav .spacer { flex: 1; }

.review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.review-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}

.review-list .review-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}

.review-list .review-value {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
}

.field-error {
  display: none;
  color: var(--danger);
  font-size: 12.5px;
  margin-top: var(--space-1);
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--danger);
}

.field.has-error .field-error { display: block; }

@media (max-width: 600px) {
  .step-item .step-label { display: none; }
}

/* ===== Profile / settings ===== */
.profile-hero {
  text-align: center;
}

.profile-hero .avatar {
  width: 64px;
  height: 64px;
  font-size: 22px;
  margin: 0 auto var(--space-4);
}

.stat-row {
  display: flex;
  gap: var(--space-6);
}

.stat-tile .stat-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-tile .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.card-danger {
  border-color: rgba(220, 38, 38, 0.35);
}

.card-danger h2 {
  color: var(--danger);
}

.settings-section-gap {
  margin-bottom: var(--space-3);
}

footer.site-footer {
  text-align: center;
  padding: var(--space-5);
  color: var(--text-faint);
  font-size: 12.5px;
}

@media (max-width: 600px) {
  .container, .container-narrow { padding: 0 var(--space-4); }
  main { padding: var(--space-6) 0 var(--space-7); }
  .card { padding: var(--space-5); }
  .result-hero { flex-direction: column; align-items: flex-start; gap: var(--space-4); }
  .page-header { flex-direction: column; align-items: flex-start; }
}
