/* TailorFit — the tool UI. Navy + gold brand, matches the Magellan landing page.
   Vanilla CSS, no frameworks/fonts — fast, and one thing on screen at a time. */

:root {
  --navy: #0E1F3D;
  --navy-2: #16294d;
  --gold: #E0A838;
  --gold-deep: #B07A1C;
  --gold-soft: #fbedcf;
  --ink: #14171a;
  --muted: #5b646e;
  --line: #e3e7ec;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ok: #1f9d55;
  --err: #c0392b;
  --radius: 14px;
  --maxw: 720px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over any class that sets `display`
   (e.g. .btn-mic uses inline-flex). Without this, those elements would
   show even while carrying `hidden`. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ─────────────────────────────────────────────────────────────── */
.tf-header { background: var(--navy); color: #fff; }
.tf-header-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 18px 8px;
}
.tf-brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.tf-mark { display: block; flex: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.tf-wordmark {
  font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: #fff; line-height: 1;
}
.tf-wordmark .accent { color: var(--gold); }
.tf-titlebar { max-width: var(--maxw); margin: 0 auto; padding: 4px 18px 20px; }
.tf-tagline { margin: 6px 0 0; color: #b9c4d6; font-size: 15px; }

/* preview-mode banner (?mock=1 only) */
.mock-banner {
  max-width: var(--maxw); margin: 14px auto 0; padding: 10px 16px;
  background: var(--gold-soft); border: 1px solid var(--gold);
  border-radius: 10px; color: var(--gold-deep); font-size: 13.5px; text-align: center;
}
.mock-banner strong { color: var(--gold-deep); }

/* ── LAYOUT ─────────────────────────────────────────────────────────────── */
.card {
  max-width: var(--maxw); margin: 20px auto; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; box-shadow: 0 1px 2px rgba(14, 31, 61, .05);
}
.app { padding-bottom: 40px; }
.muted { color: var(--muted); }
.fine { font-size: 13px; color: var(--muted); }
.rule { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }

h1 { font-size: 28px; margin: 0; }
h2 { font-size: 21px; margin: 0 0 6px; }
h3 { font-size: 17px; margin: 0 0 12px; }

.lbl { display: block; font-weight: 700; font-size: 14px; margin: 18px 0 7px; }
.lbl:first-child { margin-top: 0; }

textarea, input[type="text"] {
  width: 100%; font: inherit; font-size: 16px; /* >=16px stops iOS zoom */
  color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px;
  outline: none; resize: vertical;
}
textarea { line-height: 1.5; min-height: 120px; }
textarea:focus, input[type="text"]:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(224, 168, 56, .18);
}

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 16px;
  border-radius: 12px; padding: 13px 18px; cursor: pointer;
  border: 1px solid transparent; transition: transform .04s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { width: 100%; margin-top: 18px; background: var(--gold); color: var(--navy); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.04); }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: var(--navy-2); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: #c7ccd2; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; color: var(--navy);
}
@keyframes spin { to { transform: rotate(360deg); } }

.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--gold); font: inherit; font-size: 13px; text-decoration: underline;
}
.back-link {
  display: inline-block; max-width: var(--maxw); margin: 18px auto 0; padding: 0 18px;
  width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-weight: 700; font-size: 14px;
}
.back-link:hover { color: var(--navy); }

/* ── MIC ────────────────────────────────────────────────────────────────── */
.mic-wrap { position: relative; }
.btn-mic {
  position: absolute; right: 10px; bottom: 10px;
  background: #fff; color: var(--navy); border: 1px solid var(--line);
  font-size: 14px; padding: 8px 12px;
}
.btn-mic .mic-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block;
}
.btn-mic.is-listening { border-color: var(--err); color: var(--err); }
.btn-mic.is-listening .mic-dot { background: var(--err); animation: pulse 1s ease-in-out infinite; }
.btn-mic.mic-blocked { border-color: var(--err); opacity: .7; }
@keyframes pulse { 50% { opacity: .3; } }
.mic-note { margin: 8px 2px 0; }
.mic-note.is-err { color: var(--err); font-weight: 600; }

/* inline mic (chat inputs) */
.mic-inline {
  flex: 0 0 auto; width: 46px; align-self: stretch;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.mic-inline:hover { border-color: var(--gold); }
.mic-inline:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.mic-inline .mic-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); display: inline-block; }
.mic-inline.is-listening { border-color: var(--err); }
.mic-inline.is-listening .mic-dot { background: var(--err); animation: pulse 1s ease-in-out infinite; }
.mic-inline.mic-blocked { border-color: var(--err); opacity: .7; }

/* ── UPLOAD DROPZONE + FILE CARD ────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 22px 18px; cursor: pointer;
  border: 2px dashed #cdd5df; border-radius: 14px; background: #fbfcfe;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--gold); background: var(--gold-soft); }
.dropzone:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.dz-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 50%; margin-bottom: 4px;
  background: var(--navy); color: var(--gold);
}
.dz-title { font-weight: 800; font-size: 16px; color: var(--navy); }
.dz-sub { font-size: 13px; color: var(--muted); max-width: 40ch; }
.upload-status { margin: 10px 2px 0; color: var(--ok); }
.upload-status.is-err { color: var(--err); }

.file-card {
  display: flex; align-items: center; gap: 12px; margin-top: 12px;
  padding: 12px 14px; border: 1px solid #cdebd8; border-radius: 12px; background: #eef7f1;
}
.file-card .fc-check {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ok); color: #fff; font-weight: 800; font-size: 14px;
}
.file-card .fc-body { display: flex; flex-direction: column; line-height: 1.3; flex: 1 1 auto; min-width: 0; }
.file-card .fc-body strong { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .linkish { color: var(--gold-deep); flex: none; }

/* ── MODE TABS ──────────────────────────────────────────────────────────── */
.mode-tabs {
  max-width: var(--maxw); margin: 20px auto 0; display: flex; gap: 8px; padding: 0 18px;
}
.mode-tab {
  flex: 1 1 0; font: inherit; font-weight: 700; font-size: 15px;
  padding: 12px; cursor: pointer; border-radius: 12px 12px 0 0;
  background: #e9edf2; color: var(--muted); border: 1px solid var(--line); border-bottom: 0;
}
.mode-tab.is-active { background: var(--card); color: var(--navy); box-shadow: 0 -2px 0 var(--gold) inset; }
.panel { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.panel-lead { margin: 0 0 6px; color: #33404f; }

/* ── RESULT VIEW ────────────────────────────────────────────────────────── */
.result-head { margin-bottom: 16px; }
.result-head h2 { margin-bottom: 4px; }
.result-head p { margin: 0; font-size: 14px; }
.ph-key { color: var(--gold-deep); font-weight: 700; }
.hl-key { background: var(--gold-soft); box-shadow: 0 0 0 2px var(--gold-soft); border-radius: 3px; font-weight: 700; color: var(--gold-deep); }
.doc-note { margin: 0 0 12px; font-size: 13px; color: var(--muted); }

.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
/* keep action buttons compact — override .btn-primary's full width + top margin */
.result-actions .btn { flex: 0 0 auto; width: auto; margin-top: 0; padding: 11px 16px; font-size: 15px; }

.edit-area { margin-top: 4px; font-size: 15px; }

/* ── DOCUMENT PREVIEW ("paper") ─────────────────────────────────────────── */
.doc {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 30px 34px; box-shadow: 0 1px 3px rgba(14,31,61,.06);
  font-size: 14.5px; line-height: 1.55; color: #23282e;
  max-height: 620px; overflow-y: auto;
}

/* ── template picker ── */
.tpl-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tpl-label { font-size: 11.5px; font-weight: 700; color: var(--muted); margin-right: 4px; text-transform: uppercase; letter-spacing: .05em; }
.tpl-pill {
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 13px; border-radius: 999px;
  cursor: pointer; background: #fff; color: var(--navy); border: 1px solid var(--line);
  transition: background .12s, border-color .12s, color .12s;
}
.tpl-pill:hover { border-color: var(--gold); }
.tpl-pill.is-active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tpl-pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ── PDF-canvas preview (the on-screen doc IS the real rendered template) ── */
.doc.doc-canvas { background: #eef1f5; padding: 16px; }
.doc.doc-canvas .doc-page {
  display: block; width: 100%; height: auto; border-radius: 3px; background: #fff;
  box-shadow: 0 2px 10px rgba(14,31,61,.18);
}
.doc.doc-canvas .doc-page + .doc-page { margin-top: 14px; }
.doc-loading { color: var(--muted); font-size: 13px; padding: 24px; text-align: center; }

/* ── Polish / proofread note ── */
.polish-note {
  margin: 10px 0 0; padding: 11px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.5;
  background: var(--gold-soft); border: 1px solid var(--gold); color: var(--ink);
}
.polish-note strong { color: var(--gold-deep); }
.polish-note.is-err { background: #fdecec; border-color: #e6a3a3; color: #7a1f1f; }
.polish-note .polish-tips { margin-top: 6px; font-size: 12.5px; color: var(--navy); }
.polish-note .polish-tips span { font-weight: 700; }
.doc .doc-name {
  font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--navy);
}
.doc .doc-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.doc .doc-rule { border: 0; border-top: 2px solid var(--gold); margin: 10px 0 4px; }
.doc .doc-h {
  font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--navy); margin: 20px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.doc .doc-p { margin: 7px 0; }
.doc .doc-ul { margin: 6px 0; padding-left: 20px; }
.doc .doc-ul li { margin: 4px 0; }
.doc mark.hl {
  background: var(--gold-soft); color: var(--gold-deep); font-weight: 700;
  padding: 0 2px; border-radius: 3px;
}
.doc mark.ph {
  background: #fdf0d6; color: var(--gold-deep); font-weight: 700; font-style: normal;
  padding: 0 3px; border-radius: 3px; border: 1px dashed var(--gold);
}
.doc-letter { font-size: 15px; }
.doc-letter .doc-p { margin: 10px 0; }

/* experience/education entry rows: bold title (left) + right-aligned dates */
.doc .doc-entry {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 10px 0 2px;
}
.doc .doc-entry-left { font-weight: 400; }
.doc .doc-entry-left strong { color: var(--navy); font-weight: 800; }
.doc .doc-entry-date { color: var(--muted); font-size: 13px; white-space: nowrap; flex: none; }
.doc .sep { color: #b6bec8; padding: 0 2px; }

/* ── INTAKE FIELDS ──────────────────────────────────────────────────────── */
.details-block { margin: 6px 0 4px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.details-block > summary {
  cursor: pointer; padding: 12px 14px; font-weight: 700; font-size: 14px; list-style: none;
}
.details-block > summary::-webkit-details-marker { display: none; }
.details-block > summary::before { content: "▸ "; color: var(--gold-deep); }
.details-block[open] > summary::before { content: "▾ "; }
.details-block[open] > summary { border-bottom: 1px solid var(--line); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px; }
.field-grid .lbl { margin: 0 0 5px; }
.field-grid .field-wide { grid-column: 1 / -1; }
@media (max-width: 520px) { .field-grid { grid-template-columns: 1fr; } }

.fix-summary {
  margin: 0 0 16px; padding: 11px 14px; border-radius: 10px;
  background: #eef7f1; border: 1px solid #cdebd8; color: #1c7a44; font-size: 14px; font-weight: 600;
}

/* ── REFINE CHAT ────────────────────────────────────────────────────────── */
.refine { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.refine-head { font-weight: 800; font-size: 15px; color: var(--navy); margin-bottom: 12px; }
.refine-head .fine { font-weight: 400; }
.refine-log { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.refine-log:empty { display: none; }
.refine-msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.refine-msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.refine-msg.ai { align-self: flex-start; background: #eef1f5; color: var(--ink); border-bottom-left-radius: 4px; }
.refine-msg.ai.is-busy { color: var(--muted); font-style: italic; }
.refine-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.mini-chip {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: #fff; color: var(--navy); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
}
.mini-chip:hover { border-color: var(--gold); }
.refine-input { display: flex; gap: 8px; }
.refine-input input { flex: 1 1 auto; }
.refine-input .btn { flex: 0 0 auto; width: auto; margin-top: 0; padding: 12px 18px; }

/* ── CHIPS ──────────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 0; }
.chip {
  font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  background: #eef7f1; color: #1c7a44; border: 1px solid #cdebd8;
}
.chip-new { background: var(--gold-soft); color: var(--gold-deep); border-color: var(--gold); }
.chips-muted .chip { background: #f3f5f7; color: var(--muted); border-color: var(--line); }
.chip.ph-chip { background: #fdf0d6; color: var(--gold-deep); border-color: var(--gold); }
.kw-group { margin-top: 18px; }
.kw-title { font-weight: 700; font-size: 13px; margin: 0; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

/* ── SCORE ──────────────────────────────────────────────────────────────── */
.score-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.score-head h2 { margin: 0; }
.delta-pill {
  font-size: 13px; font-weight: 800; padding: 4px 11px; border-radius: 999px;
  background: var(--gold-soft); color: var(--gold-deep); border: 1px solid var(--gold);
}
.score-block { margin-bottom: 4px; }
.score-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.score-name { width: 52px; font-size: 13px; font-weight: 700; color: var(--muted); }
.bar { flex: 1 1 auto; height: 14px; background: #edf0f4; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; transition: width .9s cubic-bezier(.2,.7,.2,1); }
.bar-before { background: #b9c2cd; }
.bar-after { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }
.score-num { width: 46px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-num-after { color: var(--gold-deep); }

/* ── RESULT TABS ────────────────────────────────────────────────────────── */
.result-tabs { display: flex; gap: 8px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.result-tab {
  font: inherit; font-weight: 700; font-size: 14px; color: var(--muted);
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 10px 4px; margin-bottom: -1px; cursor: pointer;
}
.result-tab.is-active { color: var(--navy); border-bottom-color: var(--gold); }

/* ── STATES ─────────────────────────────────────────────────────────────── */
.err { color: var(--err); font-size: 14px; margin: 12px 0 0; font-weight: 600; }
.copied { color: var(--ok) !important; }

/* ── FOOTER ─────────────────────────────────────────────────────────────── */
.tf-footer {
  max-width: var(--maxw); margin: 8px auto 0; padding: 20px 20px 0;
  color: var(--muted); font-size: 13px; text-align: center;
}
.tf-footer p { margin: 0 0 8px; }
.tf-footer strong { color: var(--ink); }
.tf-fineprint { font-size: 12px; }

@media (max-width: 560px) {
  .tf-wordmark { font-size: 20px; }
  .card { margin: 14px auto; border-radius: 12px; }
  .doc { padding: 22px 20px; }
  .result-actions .btn { flex: 1 1 auto; }
}
