:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #5d6b7a;
  --line: #d7dee6;
  --accent: #005eb8;
  --accent-ink: #ffffff;
  --warn-bg: #fff6e0;
  --warn-line: #e8c26a;
  --mark: #ffe58a;
  --error: #b42318;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 18px; margin: 0; }
.tab { font-size: 14px; padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.tab:hover { color: var(--accent); }
nav { display: flex; gap: 4px; }
.tab.active { background: #e8f1fb; color: var(--accent); font-weight: 600; }
.tab.soon { opacity: .6; }

.layout { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 20px; padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; padding: 16px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.panel h2:first-child { margin-top: 0; }

label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 10px; }
.hint { font-weight: 400; color: var(--muted); }
input, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; line-height: 1.45; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; margin: 0; }
details { margin: 10px 0; font-size: 13px; }
summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; }

button { font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.privacy { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.output-bar { display: flex; justify-content: space-between; align-items: center; }
.output-bar h2 { margin: 0; }
.output-bar div { display: flex; gap: 8px; }
.status { min-height: 20px; font-size: 13px; color: var(--muted); margin: 10px 0; }
.status.error { color: var(--error); }
.alert { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 10px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.letter { font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.55; max-width: 720px; margin: 0 auto; padding: 36px 44px; border: 1px solid var(--line); border-radius: 4px; background: #fff; min-height: 420px; }
.letter:focus { outline: 2px solid #b9d4f0; }
.letter.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-family: inherit; }
.letter p { margin: 0 0 12px; }
.letter-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.letter-head .date { text-align: right; white-space: nowrap; }
.letter .re { margin-bottom: 18px; }
.letter .signoff { margin-top: 18px; margin-bottom: 0; }
.letter .sig-space { height: 56px; }
.letter .sig-img + .sig-block, .letter .sig-space + .sig-block { margin-top: 0; }
.letter mark { background: var(--mark); padding: 0 2px; }

@media print {
  @page { size: A4; margin: 20mm 22mm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .layout { display: block; padding: 0; }
  .panel { border: 0; padding: 0; }
  .letter { border: 0; padding: 0; max-width: none; min-height: 0; font-size: 11.5pt; }
  .letter { color: #000; }
  .letter mark { background: none; padding: 0; }
  body.letterhead-space .letter { padding-top: 40mm; }
}

.who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.who label { margin: 0; color: var(--muted); font-weight: 400; }
select { font: inherit; font-size: 14px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
label select { display: block; width: 100%; margin-top: 4px; }
@media (max-width: 700px) { .topbar { flex-wrap: wrap; gap: 10px; } .who { margin-left: 0; width: 100%; } }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(560px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(20, 30, 40, .35); }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
dialog .hint { font-size: 13px; margin-top: 0; }
.sig-preview { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px; border: 1px dashed var(--line); border-radius: 6px; margin-bottom: 10px; }
.sig-preview img { max-height: 60px; max-width: 240px; }
.actions.spread { justify-content: space-between; }
.actions.spread span { display: flex; gap: 8px; }

.letter .sig-img { display: block; max-height: 56px; max-width: 220px; margin: 4px 0; }
.letter .sig-block p { margin: 0; }

.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .row, .row3 { grid-template-columns: 1fr; } }
select { width: 100%; }
.small { font-size: 12px; margin: -4px 0 10px; }
.wrap-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.output-bar { flex-wrap: wrap; gap: 8px; }
.dropzone { display: block; border: 1.5px dashed var(--line); border-radius: 8px; padding: 14px; text-align: center; cursor: pointer; font-weight: 400; color: var(--muted); }
.dropzone input { display: none; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: #f3f8fd; }
.filelist { list-style: none; padding: 0; margin: 6px 0 10px; font-size: 13px; }
.filelist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; }
.filelist button { font-size: 12px; padding: 2px 8px; }
.alert.check { background: #fdecea; border-color: #f0a39b; }

.report { max-width: 720px; margin: 0 auto; padding: 28px 36px; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 15px; line-height: 1.5; }
.report.empty { color: var(--muted); text-align: center; }
.report h3 { font-size: 22px; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.report h3 + ul { margin-top: 0; }
.report .sec + .sec { margin-top: 28px; }
.report ul { list-style: none; padding: 0; margin: 0 0 12px; }
.report li { display: grid; grid-template-columns: 24px 1fr; gap: 4px; margin-bottom: 6px; }
.report .mk { line-height: 1.5; }
.report [contenteditable]:focus { outline: 2px solid #b9d4f0; border-radius: 2px; }
.report .normal-heading { margin: 14px 0 6px; }
.report .caution { font-weight: 600; font-size: 13px; margin: -2px 0 12px 28px; }
.report .overall { margin-top: 14px; }
.report li.urgent .txt { font-weight: 600; }
@media (max-width: 560px) { .report { padding: 20px 16px; } }
@media print { [data-view="results"] { display: none !important; } }
[hidden] { display: none !important; }
/* Markers: the emoji stay in the text (for copying) but are drawn in the GPT's colours:
   red raised, blue low, dark green normal and recommendations. */
.report .mk { font-size: 0; display: flex; align-items: flex-start; padding-top: .42em; }
.report .mk::before { content: ""; display: block; width: 11px; height: 11px; font-size: 15px; }
.report .mk.up::before { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid #c62828; }
.report .mk.down::before { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 10px solid #1565c0; }
.report .mk.ok::before { width: 12px; height: 12px; border-radius: 3px; background: #1b6e3a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2l2 2.2 4-4.8' fill='none' stroke='white' stroke-width='1.6'/%3E%3C/svg%3E") center/12px no-repeat; }
.report .mk.rec::before { width: 11px; height: 11px; border-radius: 50%; background: #1b6e3a; }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(380px, 100%); }
.login h1 { font-size: 20px; margin: 0 0 16px; }
.me { font-size: 13px; color: var(--muted); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; }
legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.shots-hint { margin: 6px 0 6px; }
.linklike { display: inline; font-size: inherit; font-weight: 400; margin: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.linklike input { display: none; }
.thumbs { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs:empty { display: none; }
.thumbs li { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.thumbs img { width: 110px; height: 80px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.thumbs button { font-size: 12px; padding: 2px 8px; }
