:root {
  --soft-linen: #f6f1e9;
  --gunmetal: #1d1f21;
  --linen-mid: #efe7dc;
  --linen-deep: #e8ded0;
  --bg: var(--soft-linen);
  --panel: #fffaf6;
  --panel-soft: var(--linen-mid);
  --ink: var(--gunmetal);
  --muted: #6b6660;
  --accent: var(--gunmetal);
  --accent-dark: var(--gunmetal);
  --accent-soft: var(--linen-deep);
  --line: #d8cdbc;
  --danger: #a53d3d;
  --shadow: 0 18px 44px rgb(35 31 26 / 10%);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Montserrat, Aptos, "Segoe UI", Arial, sans-serif; }
button, input, textarea { font: inherit; }
button { min-height: 48px; border: 0; border-radius: 14px; padding: 0 18px; cursor: pointer; font-weight: 700; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.page { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.app { width: min(100%, 980px); min-width: 0; display: grid; gap: 18px; }
.screen { display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.screen.active { display: block; }
.split { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); min-height: 620px; }
.brand { display: grid; place-items: center; padding: 40px; background: var(--soft-linen); border-right: 1px solid var(--line); }
/* MEDC's own wordmark. The teal asset is drawn for light backgrounds; the
   linen one is for dark, and would be invisible here - see public/brand/README.md. */
.brand-logo { width: min(100%, 420px); height: auto; display: block; }
.submitted-logo { width: min(100%, 340px); height: auto; display: block; }
.content { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr); align-content: center; gap: 22px; padding: 42px; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: "Trade Gothic Heavy Condensed", "Arial Narrow", Impact, sans-serif; font-size: clamp(2rem, 6vw, 3.3rem); line-height: 1; text-transform: uppercase; }
.copy { color: var(--muted); font-size: 1rem; line-height: 1.6; max-width: 46rem; }
.dropzone { display: grid; justify-items: center; gap: 14px; min-height: 260px; padding: 28px; border: 2px dashed #aaa49b; border-radius: 18px; background: rgb(255 255 255 / 45%); text-align: center; transition: border-color 160ms ease, background 160ms ease, transform 160ms ease; }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.primary { background: var(--accent); color: #fff; }
.plain { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.file-row { display: none; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.file-row.visible { display: flex; }
.file-info { flex: 1; min-width: 0; max-width: 100%; }
.file-row button { flex-shrink: 0; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.status { min-height: 22px; color: var(--accent-dark); font-size: 0.95rem; line-height: 1.45; }
.status.error { color: var(--danger); }
.center-screen { min-height: 560px; display: grid; place-items: center; padding: 34px; text-align: center; }
.loader { width: 62px; height: 62px; border-radius: 50%; border: 5px solid #d7d1c8; border-top-color: var(--accent); animation: spin 900ms linear infinite; margin: 0 auto 24px; }
.chat-screen { display: none; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 14px; height: min(620px, calc(100dvh - 46px)); min-height: 0; padding: 28px; }
.chat-screen.active { display: grid; }
.chat-log { min-height: 0; overflow: auto; overscroll-behavior-y: contain; scrollbar-gutter: stable; display: grid; align-content: start; gap: 14px; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel-soft); }
.message { max-width: min(78%, 620px); padding: 14px 16px; border-radius: 18px 18px 18px 6px; background: #fff; border: 1px solid var(--line); line-height: 1.5; justify-self: start; overflow-wrap: anywhere; box-shadow: 0 1px 0 rgb(35 31 26 / 5%); white-space: pre-wrap; }
.message.user { justify-self: end; background: var(--ink); border-color: var(--ink); border-radius: 18px 18px 6px 18px; color: #fff; }
.message.user .label { color: rgb(255 255 255 / 72%); }
.message.thinking-message { font-weight: 800; }
.thinking-row { display: inline-flex; align-items: center; gap: 9px; }
.thinking-dots { display: inline-flex; align-items: center; gap: 4px; padding-top: 2px; }
.thinking-dots i { width: 5px; height: 5px; display: block; border-radius: 50%; background: var(--accent); animation: thinking-dot 1s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: 140ms; }
.thinking-dots i:nth-child(3) { animation-delay: 280ms; }
.label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
textarea { width: 100%; min-height: 58px; max-height: 180px; resize: vertical; border-radius: 14px; border: 1px solid var(--line); padding: 14px; background: #fff; color: var(--ink); outline: none; }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(32 34 38 / 14%); }
.composer textarea { min-height: 52px; max-height: 132px; resize: none; border: 0; padding: 12px; }
.composer textarea:focus { border-color: transparent; box-shadow: none; }
.composer button { min-height: 44px; border-radius: 12px; padding: 0 18px; }
/* The review step: the same answers, grouped and editable, before submitting. */
.review-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 16px; height: min(760px, calc(100dvh - 46px)); min-height: 0; padding: 28px; }
.review-head { display: grid; gap: 10px; }
.review-summary { display: flex; flex-wrap: wrap; gap: 10px; }
.review-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); font-size: 0.85rem; font-weight: 700; }
.review-pill.warn { background: #f6e3dd; color: #7d3620; }
.review-body { min-height: 0; overflow: auto; overscroll-behavior-y: contain; display: grid; align-content: start; gap: 20px; padding-right: 6px; }
.review-section { display: grid; gap: 10px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.review-section h3 { font-family: inherit; font-size: 1.05rem; font-weight: 800; text-transform: none; }
.review-section .section-blurb { color: var(--muted); font-size: 0.9rem; }
.review-row { display: grid; grid-template-columns: minmax(0, 0.42fr) minmax(0, 0.58fr); gap: 12px; align-items: start; padding: 10px 0; border-top: 1px solid rgb(216 205 188 / 55%); }
.review-row:first-of-type { border-top: 0; }
.review-label { font-weight: 700; font-size: 0.92rem; overflow-wrap: anywhere; }
.review-value { display: grid; gap: 6px; }
.review-value textarea { min-height: 42px; max-height: none; resize: vertical; font-size: 0.95rem; padding: 10px 12px; }
.review-value .empty-note { font-size: 0.82rem; color: var(--muted); }
.review-row.unanswered .review-value textarea { border-color: #d9a08c; background: #fff8f5; }
.review-row.unavailable .review-value textarea { background: #fffdf5; }
.review-row.locked { opacity: 0.7; }
.review-foot { display: grid; gap: 10px; }
.review-foot .actions { justify-content: flex-end; }
.review-prompt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.review-prompt .copy { font-size: 0.87rem; }

.submitted { display: grid; justify-items: center; gap: 20px; }
.submitted-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.manager-link { min-height: 54px; display: inline-grid; place-items: center; border-radius: 18px; padding: 0 24px; border: 1px solid var(--ink); color: var(--ink); text-decoration: none; font-weight: 800; background: transparent; }
.finalize-backdrop { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 22px; background: rgb(29 31 33 / 72%); backdrop-filter: blur(5px); }
.finalize-modal { width: min(100%, 520px); display: grid; justify-items: center; gap: 18px; padding: 38px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 26px 80px rgb(0 0 0 / 28%); text-align: center; }
.finalize-modal .copy { text-align: center; }
.finalize-loader { width: 54px; height: 54px; margin-bottom: 2px; }
.finalize-error { color: var(--danger); }
.hidden { display: none !important; }

/* The issue-report button and its dialog.
   Pinned to the bottom-right corner of the viewport, not to a screen: an upload
   that will not go through is the first thing someone needs to report. */
.report-trigger { position: fixed; right: 18px; bottom: 18px; z-index: 900; min-height: 44px; border-radius: 999px; padding: 0 20px; border: 1px solid var(--ink); background: var(--panel); color: var(--ink); font-size: 0.92rem; box-shadow: var(--shadow); }
.report-trigger:hover { background: var(--linen-mid); }
.report-trigger:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
body.report-open { overflow: hidden; }
.report-modal { width: min(100%, 620px); max-height: calc(100dvh - 44px); overflow: auto; display: grid; gap: 18px; padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 26px 80px rgb(0 0 0 / 28%); }
.report-head { display: grid; gap: 10px; }
.report-head h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.report-form { display: grid; gap: 14px; }
.report-field { display: grid; gap: 6px; min-width: 0; }
.report-label { font-weight: 700; font-size: 0.9rem; }
.report-field input { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); padding: 12px; background: #fff; color: var(--ink); outline: none; }
.report-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(32 34 38 / 14%); }
.report-field textarea { min-height: 108px; }
.report-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.report-note { font-size: 0.85rem; }
.report-actions { justify-content: flex-end; }
.report-done { display: grid; gap: 16px; }

/* State viewer — test tooling, not part of the applicant journey. It has no
   on-page toggle; the probes reveal it directly. */
.state-panel { position: fixed; right: 14px; bottom: 62px; z-index: 1100; width: min(92vw, 430px); max-height: 70vh; overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); font-size: 0.82rem; }
.state-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.state-count { color: var(--muted); }
.state-missing { margin-bottom: 10px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); line-height: 1.4; overflow-wrap: anywhere; }
.state-grid { display: grid; gap: 4px; }
.state-row { display: grid; grid-template-columns: minmax(0, 0.5fr) minmax(0, 0.5fr); gap: 8px; padding: 4px 0; border-bottom: 1px solid rgb(216 205 188 / 55%); }
.state-row span:first-child { color: var(--muted); overflow-wrap: anywhere; }
.state-row span:last-child { overflow-wrap: anywhere; }
.state-row.filled span:last-child { font-weight: 700; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes thinking-dot { 0%, 80%, 100% { transform: translateY(0); opacity: 0.42; } 40% { transform: translateY(-4px); opacity: 1; } }

@media (max-width: 760px) {
  .page { min-height: 100svh; padding: 12px; place-items: stretch; }
  .app, .screen { min-height: calc(100svh - 24px); }
  .split { grid-template-columns: 1fr; min-height: 0; }
  .brand { min-height: 190px; padding: 26px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .content { padding: 22px; }
  .chat-screen { height: calc(100dvh - 26px); padding: 18px; }
  .dropzone { min-height: 220px; padding: 22px 16px; }
  .actions { display: grid; grid-template-columns: 1fr; }
  .composer { grid-template-columns: minmax(0, 1fr) auto; padding: 7px; }
  button, .manager-link { width: 100%; }
  .composer button { width: auto; min-width: 76px; padding: 0 14px; }
  .file-row { align-items: flex-start; flex-direction: column; }
  .review-screen { height: calc(100dvh - 26px); padding: 18px; }
  .review-row { grid-template-columns: 1fr; gap: 6px; }
  .review-foot .actions { display: grid; grid-template-columns: 1fr; }
  .chat-log { min-height: 0; padding: 14px; }
  .message { max-width: 92%; font-size: 0.96rem; }
  .message.user { max-width: 88%; }
  .finalize-modal { padding: 28px 22px; }
  /* The corner button must not land on top of the composer or the review footer,
     so on a phone it is pinned above the bottom of the screen and the screens get
     room underneath it. */
  .report-trigger { right: 12px; bottom: 12px; left: 12px; width: auto; padding: 0 14px; }
  .chat-screen, .review-screen { padding-bottom: 68px; }
  .report-modal { padding: 22px 18px; }
  .report-pair { grid-template-columns: 1fr; }
  .report-actions { display: grid; grid-template-columns: 1fr; }
}
