/* ─── Reset & Base ─────────────────────────────────────────────────────────── */

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

:root {
  /* Brand */
  --navy:         #2F495E;
  --navy-dark:    #1E3349;
  --navy-hover:   #3B5A72;
  --gold:         #E4B83E;
  --gold-light:   #FEF5DC;
  --blue-light:   #E7F0F4;

  /* Neutrals */
  --bg:           #F8F6F2;
  --surface:      #FFFFFF;
  --border:       #E5E0D8;
  --border-soft:  #EDE9E3;
  --text:         #1A2830;
  --text-secondary: #5A7080;
  --text-muted:   #9AABB5;

  /* Feedback */
  --success:      #2D7A4F;
  --success-bg:   #EFF9F3;
  --warning-bg:   #FFFBEB;
  --warning-border: #FCE89A;
  --warning-text: #7A5A10;
  --error-bg:     #FFF0EF;
  --error-border: #FECACA;
  --error-text:   #7A2020;

  /* Tokens */
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --radius-xl:    20px;
  --shadow-sm:    0 1px 3px rgba(30, 51, 73, 0.07);
  --shadow:       0 2px 10px rgba(30, 51, 73, 0.09), 0 1px 3px rgba(30, 51, 73, 0.05);
  --shadow-md:    0 4px 20px rgba(30, 51, 73, 0.11), 0 2px 6px rgba(30, 51, 73, 0.06);
  --max-width:    760px;
  --card-padding-x: 60px;
  --card-padding-y: 48px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--blue-light);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding: 36px 20px 56px;
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */

.app {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--surface);
  border-radius: 18px;
  box-shadow:
    0 4px 32px rgba(30, 51, 73, 0.10),
    0 1px 6px  rgba(30, 51, 73, 0.05);
  padding: var(--card-padding-y) var(--card-padding-x);
}

/* ─── Header / Logo ────────────────────────────────────────────────────────── */

.site-header {
  text-align: center;
  padding: 0 0 36px;
}

/* Drop logo.png into the public/ folder and it will appear automatically.
   Adjust max-width / max-height below to match your logo's proportions. */
.site-logo {
  width: 240px;
  max-width: 80%;
  height: auto;
  display: block;
  margin: 0 auto 24px auto;
}

/* ─── Wizard ───────────────────────────────────────────────────────────────── */

.wizard {
  position: relative;
}

/* Progress bar */
.wizard-progress {
  margin-bottom: 28px;
}

.progress-track {
  display: flex;
  gap: 5px;
}

.progress-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border-soft);
  transition: background 0.35s ease;
}

.progress-seg.active {
  background: var(--gold);
}

.progress-seg.done {
  background: var(--navy);
}

/* Step card */
.step-card {
  background: #F9F8F6;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 36px 32px 28px;
  animation: stepEnter 0.28s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

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

.step-card.step-exit {
  animation: stepExit 0.16s ease-in both;
}

@keyframes stepExit {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-6px); }
}

/* Step question */
.step-q {
  font-size: 1.4375rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.step-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 26px;
  line-height: 1.5;
}

/* ─── Pills ────────────────────────────────────────────────────────────────── */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 32px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: var(--font);
  font-weight: 450;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.pill:hover {
  border-color: var(--gold);
  color: var(--navy);
}

.pill.selected {
  border-color: var(--gold);
  background: var(--gold-light);
  color: var(--navy);
  font-weight: 500;
}

/* ─── Mode Cards ───────────────────────────────────────────────────────────── */

.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 32px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px 18px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.2s ease, color 0.2s ease;
  background: var(--surface);
  font-family: var(--font);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.mode-card:hover {
  border-color: var(--gold);
}

.mode-card.selected {
  border-color: var(--navy);
  background: var(--navy);
  color: white;
}

.mode-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--blue-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.mode-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--navy);
  transition: stroke 0.2s ease;
}

.mode-card.selected .mode-icon {
  background: rgba(255,255,255,0.15);
}

.mode-card.selected .mode-icon svg {
  stroke: rgba(255,255,255,0.9);
}

.mode-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 5px;
  line-height: 1.3;
  transition: color 0.2s ease;
}

.mode-card.selected .mode-card-title {
  color: white;
}

.mode-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  transition: color 0.2s ease;
}

.mode-card.selected .mode-card-desc {
  color: rgba(255,255,255,0.65);
}

/* ─── Message Type Grid ────────────────────────────────────────────────────── */

.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 32px;
}

.type-tile {
  padding: 13px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: var(--font);
  font-weight: 450;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  text-align: left;
  line-height: 1.35;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.type-tile:hover {
  border-color: var(--gold);
  color: var(--navy);
}

.type-tile.selected {
  border-color: var(--gold);
  background: var(--gold-light);
  color: var(--navy);
  font-weight: 500;
}

/* ─── Textarea ─────────────────────────────────────────────────────────────── */

.message-textarea {
  width: 100%;
  min-height: 170px;
  padding: 15px;
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  line-height: 1.7;
  transition: border-color 0.15s ease;
  margin-bottom: 8px;
}

.message-textarea:focus {
  outline: none;
  border-color: var(--navy);
}

.message-textarea::placeholder {
  color: var(--text-muted);
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-bottom: 24px;
}

.char-count.warning {
  color: #C97A10;
}

.char-count.over-limit {
  color: var(--error-text);
  font-weight: 500;
}

.length-error {
  font-size: 0.8125rem;
  color: var(--error-text);
  margin-top: 4px;
  line-height: 1.4;
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 18px;
  line-height: 1.5;
}

/* ─── Step Navigation ──────────────────────────────────────────────────────── */

.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.step-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-nav-submit {
  margin-top: 0;
}

/* Back button */
.btn-back {
  font-size: 0.875rem;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s ease;
  letter-spacing: 0.01em;
}

.btn-back:hover {
  color: var(--navy);
}

/* Skip button */
.btn-skip {
  font-size: 0.875rem;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.btn-skip:hover {
  color: var(--navy);
  border-color: var(--navy);
}

/* Continue button */
.btn-continue {
  padding: 12px 26px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font);
  color: white;
  background: var(--navy);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
  letter-spacing: 0.01em;
}

.btn-continue:hover:not(:disabled) {
  background: var(--navy-hover);
}

.btn-continue:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Submit / AnchorIt button */
.btn-submit {
  padding: 12px 28px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font);
  color: white;
  background: var(--navy);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
  letter-spacing: 0.015em;
  position: relative;
}

.btn-submit:hover:not(:disabled) {
  background: var(--navy-hover);
}

.btn-submit:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-submit:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ─── Loading ──────────────────────────────────────────────────────────────── */

.loading-card {
  background: #F9F8F6;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  margin-bottom: 16px;
}

.loading-state {
  text-align: center;
  padding: 52px 20px;
}

.loading-dots {
  display: inline-flex;
  gap: 7px;
  margin-bottom: 14px;
}

.loading-dots span {
  width: 7px;
  height: 7px;
  background: var(--gold);
  border-radius: 50%;
  animation: dotBounce 1.3s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.18s; }
.loading-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: translateY(0);   opacity: 0.35; }
  40%           { transform: translateY(-9px); opacity: 1; }
}

.loading-text {
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-style: italic;
  letter-spacing: 0.01em;
}

/* ─── Output Section ───────────────────────────────────────────────────────── */

.output-section {
  margin-top: 0;
}

.output-card {
  background: #F9F8F6;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
}

.output-card-header {
  padding: 13px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--blue-light);
}

.output-card-header h3 {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  opacity: 0.7;
}

.output-card-body {
  padding: 22px;
}

.rewrite-text {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.possible-response-text {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.composure-note-text {
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.6;
}

.output-acknowledgment {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.55;
  padding: 0 2px 14px;
}

.output-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.output-list li {
  display: flex;
  gap: 11px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.output-list li::before {
  content: '—';
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 1px;
}

.coaching-list li {
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--text);
}

.coaching-list li::before {
  content: '·';
  color: var(--gold);
  font-style: normal;
  font-size: 1.1rem;
}

/* Status cards (unsafe / not_supported) */
.status-card {
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.status-card.warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
}

.status-card.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
}

.status-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--warning-text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.status-card.error h3 {
  color: var(--error-text);
}

.status-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* Redirect card (composure-based, not an error state) */
.redirect-card {
  background: #F9F8F6;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 12px;
}

.redirect-line1 {
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 10px;
}

.redirect-line2 {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.65;
}

/* Analyze no-action */
.no-action-block {
  padding: 22px;
}

.no-action-block p {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.65;
}

.optional-note {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ─── Copy Button ──────────────────────────────────────────────────────────── */

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  padding: 9px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  border-color: var(--navy);
  color: var(--navy);
}

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

.copy-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* ─── Refinement ───────────────────────────────────────────────────────────── */

.refinement-card {
  background: #F9F8F6;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 12px;
}

.refinement-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  opacity: 0.6;
  margin-bottom: 14px;
}

.quick-refine {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.refine-pill {
  padding: 7px 15px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.refine-pill:hover {
  border-color: var(--gold);
  color: var(--navy);
  background: var(--gold-light);
}

.custom-refine-row {
  display: flex;
  gap: 8px;
}

.refine-input {
  flex: 1;
  padding: 10px 13px;
  font-size: 0.875rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease;
}

.refine-input:focus {
  outline: none;
  border-color: var(--navy);
}

.refine-input::placeholder {
  color: var(--text-muted);
}

.btn-refine {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font);
  color: white;
  background: var(--navy);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.btn-refine:hover:not(:disabled) {
  background: var(--navy-hover);
}

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

/* ─── Start Over ───────────────────────────────────────────────────────────── */

.btn-start-over {
  display: block;
  width: 100%;
  padding: 13px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  margin-bottom: 4px;
}

.btn-start-over:hover {
  border-color: var(--navy);
  color: var(--navy);
}

/* ─── Footer ───────────────────────────────────────────────────────────────── */

.site-footer {
  text-align: center;
  padding: 24px 0 0;
  border-top: 1px solid var(--border-soft);
  margin-top: 36px;
}

.footer-brand {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

.footer-privacy {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ─── Utility ──────────────────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

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

/* ─── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  body {
    padding: 16px 12px 40px;
  }

  .app {
    border-radius: 12px;
    padding: 32px 24px 40px;
    --card-padding-x: 24px;
  }

  .site-header {
    padding: 0 0 28px;
  }

  .site-logo {
    width: 200px;
  }

  .step-card {
    padding: 28px 22px 22px;
    border-radius: var(--radius-lg);
  }

  .step-q {
    font-size: 1.25rem;
  }

  .mode-cards {
    grid-template-columns: 1fr;
  }

  .type-grid {
    grid-template-columns: 1fr;
  }

  .output-card-body {
    padding: 18px;
  }

  .refinement-card {
    padding: 18px;
  }

  .btn-continue,
  .btn-submit {
    padding: 12px 20px;
  }
}
