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

/* ── Design tokens ────────────────────────────────────────────────── */
:root {
  --bg:            #f8f9fa;
  --surface:       #ffffff;
  --ink:           #111827;
  --muted:         #6b7280;
  --subtle:        #9ca3af;
  --border:        #e5e7eb;
  --border-mid:    #d1d5db;
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-light:  #eff6ff;
  --error:         #dc2626;
  --error-bg:      #fef2f2;
  --error-border:  #fecaca;
  --success:       #16a34a;
  --success-bg:    #f0fdf4;
  --success-border:#bbf7d0;
  --warn:          #d97706;
  --warn-bg:       #fffbeb;
  --warn-border:   #fde68a;
  --r:             12px;   /* card radius */
  --r-sm:          8px;    /* input / small element radius */
  --shadow:        0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
}

/* ── Base ─────────────────────────────────────────────────────────── */
html  { scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────────── */
.container {
  width: min(680px, 100% - 32px);
  margin: 0 auto;
}

.view          { min-height: 100vh; }
.view.hidden   { display: none !important; }
.hidden        { display: none !important; }

/* ── Wordmark ─────────────────────────────────────────────────────── */
.wordmark {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ══════════════════════════════════════════════════════════════════
   VIEW 1: INTAKE
══════════════════════════════════════════════════════════════════ */

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

.site-header .wordmark { margin-bottom: 22px; display: block; }

h1 {
  font-size: clamp(1.875rem, 5.5vw, 2.875rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
}

.lead {
  color: var(--muted);
  font-size: 1rem;
  max-width: 48ch;
  margin: 0 auto;
  line-height: 1.65;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card-header { margin-bottom: 18px; }

.card-header h2 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.card-hint {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Form */
#intake-form { padding-bottom: 80px; }

textarea {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea::placeholder { color: var(--subtle); }

/* Tabs */
.tab-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: var(--r-sm);
  width: fit-content;
}

.tab {
  padding: 5px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover { color: var(--ink); }

.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.tab-panel.hidden { display: none !important; }

/* Drop zone */
.drop-zone {
  display: block;
  cursor: pointer;
  position: relative;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.drop-zone-inner {
  border: 2px dashed var(--border);
  border-radius: var(--r-sm);
  padding: 36px 24px;
  text-align: center;
  color: var(--muted);
  transition: all 0.15s;
  user-select: none;
}

.drop-zone:hover .drop-zone-inner,
.drop-zone.drag-over .drop-zone-inner {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.drop-zone-inner svg  { display: block; margin: 0 auto 12px; opacity: 0.55; }
.drop-zone-label      { font-size: 0.875rem; font-weight: 600; margin-bottom: 4px; }
.drop-zone-hint       { font-size: 0.775rem; }

.file-status {
  margin-top: 10px;
  font-size: 0.8125rem;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
  font-weight: 500;
}

.file-status.error { background: var(--error-bg); color: var(--error); border-color: var(--error-border); }

/* Collapsible */
.collapsible summary          { list-style: none; cursor: pointer; user-select: none; }
.collapsible summary::-webkit-details-marker { display: none; }

.collapsible-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.collapsible-summary-text h2 { font-size: 0.9375rem; font-weight: 700; margin-bottom: 4px; }

.badge {
  display: inline-block;
  font-size: 0.675rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-left: 6px;
  letter-spacing: 0.03em;
}

.chevron {
  flex-shrink: 0;
  color: var(--muted);
  margin-top: 2px;
  transition: transform 0.2s;
}

details[open] .chevron { transform: rotate(180deg); }

.collapsible-body {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* Form error */
.form-error {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 12px;
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

/* ══════════════════════════════════════════════════════════════════
   SHARED: BUTTONS
══════════════════════════════════════════════════════════════════ */
button { cursor: pointer; font: inherit; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled)  { background: var(--accent-hover); }
.btn-primary:disabled              { opacity: 0.55; cursor: not-allowed; }
.btn-primary.btn-block             { width: 100%; padding: 14px; margin-top: 4px; border-radius: var(--r); font-size: 1rem; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-secondary:hover { background: var(--bg); border-color: var(--border-mid); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8125rem;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s;
  font-weight: 500;
}

.btn-ghost:hover { color: var(--ink); }

/* ══════════════════════════════════════════════════════════════════
   SHARED: APP NAV (sticky top bar on editor + final views)
══════════════════════════════════════════════════════════════════ */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(248, 249, 250, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 11px 0;
}

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

.step-counter {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════
   SHARED: LOADING STATE
══════════════════════════════════════════════════════════════════ */
.loading-state { text-align: center; padding: 80px 0; }

.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.75s linear infinite;
}

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

.loading-msg { color: var(--muted); font-size: 0.875rem; }

/* ══════════════════════════════════════════════════════════════════
   VIEW 2: SECTION EDITOR
══════════════════════════════════════════════════════════════════ */
.editor-body { padding: 24px 0 80px; }

/* Progress bar */
.progress-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  margin-bottom: 32px;
  overflow: hidden;
}

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

/* Section panel */
.editor-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* Section panel header */
.section-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.section-panel-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Status badges */
.status-badge {
  font-size: 0.675rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.status-badge.ok          { background: var(--success-bg); color: var(--success); }
.status-badge.needs-work  { background: var(--warn-bg);    color: var(--warn); }
.status-badge.missing     { background: var(--error-bg);   color: var(--error); }

/* Current content block (read-only) */
.current-block {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.field-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 8px;
}

.current-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78125rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  max-height: 180px;
  overflow-y: auto;
}

/* Critique bar */
.critique-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--warn-bg);
}

.critique-bar.ok      { background: var(--success-bg); }
.critique-bar.missing { background: var(--error-bg); }

.critique-icon {
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--warn);
}

.critique-icon.ok      { color: var(--success); }
.critique-icon.missing { color: var(--error); }

.critique-text {
  font-size: 0.8125rem;
  color: var(--ink);
  line-height: 1.5;
}

/* Proposed textarea block */
.proposed-block {
  padding: 18px 24px;
}

.editor-textarea {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78125rem;
  line-height: 1.65;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.editor-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Editor action row */
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ══════════════════════════════════════════════════════════════════
   VIEW 3: FINAL REVIEW
══════════════════════════════════════════════════════════════════ */
.final-body   { padding: 40px 0 80px; }

.final-block  { margin-bottom: 40px; }

.final-block h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.block-head h2  { border: none; padding: 0; margin: 0; }
.block-head-sm  { margin-top: 20px; }

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

/* Resume pre */
.resume-pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, "Cascadia Code", monospace;
  font-size: 0.78125rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 20px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* Notes list */
.notes-list { display: grid; gap: 10px; }

.note-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.note-priority {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.note-priority.high   { color: var(--error); }
.note-priority.medium { color: var(--warn); }
.note-priority.low    { color: var(--success); }

.note-title  { font-size: 0.875rem; font-weight: 600; margin-bottom: 3px; }
.note-detail { font-size: 0.8125rem; color: var(--muted); line-height: 1.5; }

/* ── Parsing confidence warning ──────────────────────────────────── */
.parse-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
}

.parse-warning-icon {
  font-size: 0.9rem;
  color: var(--warn);
  flex-shrink: 0;
  margin-top: 1px;
}

.parse-warning-text {
  font-size: 0.8125rem;
  color: #92400e;
  line-height: 1.5;
}

/* ── Change log (before/after bullet explanations) ───────────────── */
.change-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 16px 18px;
  margin-top: 12px;
}

.change-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.change-item:last-child { border-bottom: none; }

.change-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}

.change-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.change-badge.before {
  background: #fee2e2;
  color: #991b1b;
}

.change-badge.after {
  background: #dcfce7;
  color: #166534;
}

.change-text {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink);
}

.change-reason {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
  font-style: italic;
}

/* ── Editable resume pre ─────────────────────────────────────────── */
.resume-pre-editable {
  cursor: text;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.resume-pre-editable:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* ── AI actions grid ─────────────────────────────────────────────── */
.ai-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.ai-action-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  min-height: 60px;
  transition: border-color 0.15s, background 0.15s;
}

.ai-action-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.ai-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ai-action-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.ai-action-desc {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.ai-block .card-hint { margin-bottom: 16px; }
.ai-block .block-head { margin-bottom: 8px; }

.ai-idle {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* "Run another pass:" label shown after first AI result */
.ai-next-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.hint-text   { font-size: 0.8125rem; color: var(--muted); }
.label-muted { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* AI result header row */
.ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.ai-result-header-left { display: flex; flex-direction: column; gap: 2px; }

#ai-result { margin-bottom: 20px; }

/* ── AI notes — grouped categories ──────────────────────────────── */
.ai-notes {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-note-group {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.ai-note-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.ai-note-group-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.ai-note-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.ai-note-item {
  font-size: 0.8125rem;
  color: var(--ink);
  line-height: 1.55;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.ai-note-item:last-child { border-bottom: none; }

.ai-note-item.summary-item {
  font-weight: 500;
  color: var(--ink);
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
}

.ai-note-item.muted { color: var(--muted); }

/* Final footer */
.final-footer {
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .site-header { padding: 48px 0 36px; text-align: left; }
  .site-header .wordmark { text-align: left; }
  h1   { font-size: 1.875rem; }
  .lead { font-size: 0.9375rem; max-width: none; }
  .card { padding: 18px; }
  .btn-block { font-size: 0.9375rem; }
  .section-panel-header { padding: 14px 18px; }
  .current-block  { padding: 14px 18px; }
  .critique-bar   { padding: 10px 18px; }
  .proposed-block { padding: 14px 18px; }
  .editor-actions { flex-direction: column-reverse; align-items: stretch; }
  .editor-actions .btn-primary { text-align: center; }
  .block-head { flex-direction: column; align-items: flex-start; }
  .ai-idle    { flex-direction: column; align-items: flex-start; }
}
