/* FS Fixer design system. Tokens and names from docs/DESIGN.md, exactly.
   No build step, no CDN: this file is the whole stylesheet, vendored like htmx. */

:root {
  --paper: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --bubble: #eeeae2;
  --ink: #24211d;
  --muted: #6f6961;
  --faint: #8a847b;
  --hair: #e7e2d9;
  --hair-strong: #d7d1c6;
  --accent: #1f6b4a;
  --accent-soft: #e6f1eb;
  --inserted: #e3f0d6;
  --bad: #b23a2e;
  --advisory: #b7791f;
  --advisory-soft: #fbf1df;
  --pill: #f1eee7;
  --doc-ink: #111111;
}

/* Self-hosted (SIL OFL, licence alongside): app/static/fonts/LICENSE.txt.
   font-display: swap lets the fallback stack paint immediately and Inter
   swap in once it loads, rather than holding text invisible. */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #174f37; }

:focus-visible { outline: 3px solid var(--advisory); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1, h2, h3 { margin: 0; }

.doc, .doc-face {
  font-family: Georgia, "DejaVu Serif", serif;
  color: var(--doc-ink);
}

.num, [class*="tabular"] { font-variant-numeric: tabular-nums; }

/* Section labels: 11.5px 600 uppercase .08em --faint */
.section-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}

/* --- Buttons -------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-color: var(--accent);
}
.btn-primary:hover { background: #174f37; border-color: #174f37; color: #fff; }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--hair-strong);
}
.btn-secondary:hover { border-color: var(--faint); }

.btn-tertiary {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 0 10px;
}

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

/* --- Status dots and pills ------------------------------------------ */

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 9px;
}
.dot--accent { background: var(--accent); }
.dot--bad { background: var(--bad); }
.dot--progress { background: transparent; border: 1.5px solid var(--faint); width: 7px; height: 7px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}
.pill--issued { background: var(--accent-soft); color: var(--accent); }

/* --- Cards ------------------------------------------------------------ */

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--hair);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card-title { font-weight: 600; font-size: 13.5px; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-meta--bad { color: var(--bad); font-weight: 500; }
.card-provenance { font-size: 12.5px; color: var(--muted); }

.card-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 19px;
}
.check-row { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13.5px; line-height: 1.45; }
.check-ref {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--bad);
  font-variant-numeric: tabular-nums;
}
.check-body { display: flex; flex: 1 1 220px; flex-direction: column; min-width: 0; }
.check-code {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.check-detail { display: block; color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.check-technical-details { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
.check-technical-details dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 8px; margin: 6px 0 0; }
.check-technical-details dt { color: var(--muted); }
.check-technical-details dd { margin: 0; overflow-wrap: anywhere; }

.card-actions {
  display: flex;
  gap: 8px;
  padding-left: 19px;
  flex-wrap: wrap;
}
.card-actions--flush { padding-left: 0; justify-content: flex-end; }

.card details > summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  padding-left: 19px;
}
.engine-output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 6px 0 0 19px;
}

.app-notice { color: var(--advisory); font-size: 13px; margin: 0; }
.journal-waiting-notice p { margin: 0; }
.journal-waiting-notice .journal-waiting-line { margin-top: 4px; }

/* Item E5: the advisory is one clamped line by default so the run strip's
   own scroll boundary can never land mid-glyph through it (the failure the
   34vh strip produced -- "acceptable for a fi[rst review]", cut vertically
   at whatever pixel the strip's max-height happened to end on). A person
   opts into the full text with "Show more" instead of it being sized to
   however tall this run's wording happens to be. */
.engine-advisory-wrap {
  margin: 0;
  background: var(--advisory-soft);
  border-left: 2px solid var(--advisory);
  padding: 8px 10px;
  border-radius: 4px;
}
.engine-advisory-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
/* Item 4: the check id reads as its own small label (the .section-label
   treatment, in --advisory rather than --faint) instead of being the first
   word of a monospace <pre> line the engine happened to print. */
.engine-advisory-check {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--advisory);
}
.engine-advisory {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-size: 13px;
  color: var(--ink);
  margin: 0;
}
.engine-advisory.expanded {
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-overflow: clip;
}
.engine-advisory-toggle {
  display: block;
  margin: 4px 0 0;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--advisory);
  cursor: pointer;
  text-decoration: underline;
}

/* --- Layout: the whole window never scrolls, only its panels do ----- */

#topbar {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid var(--hair);
  background: var(--paper);
}
.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.wordmark {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.topbar-divider { width: 1px; height: 18px; background: var(--hair-strong); flex: 0 0 1px; }
.topbar-company { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-status { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-status-name { font-weight: 600; font-size: 15px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex: 0 0 30px;
}

#workspace {
  flex: 1 1 auto;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

body.window-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Left rail --------------------------------------------------------- */

#entity-list {
  width: 264px;
  flex: 0 0 264px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 12px 16px 16px;
  border-right: 1px solid var(--hair);
  background: var(--paper);
  overflow-y: auto;
  min-height: 0;
}
.rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-group-label { padding: 0 8px 6px; }
.rail-links { display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; list-style: none; }
.rail-links li { margin: 0; }
.rail-link {
  display: block;
  padding: 7px 10px;
  font-size: 13.5px;
  color: var(--ink);
  border-radius: 6px;
}
.rail-link:hover { background: var(--surface-2); color: var(--ink); }

.entities { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.entity {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}
.entity:hover { background: var(--surface-2); }
.entity[aria-current] {
  background: var(--surface);
  border-color: var(--hair);
}
.entity .dot { margin-top: 5px; }
.entity-name { font-weight: 500; font-size: 13.5px; display: block; }
.entity[aria-current] .entity-name { font-weight: 600; }
.status { font-size: 12px; color: var(--muted); display: block; }
.status--bad { color: var(--bad); }
.empty { color: var(--muted); padding: 0 8px; }

.rail-actions { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; font-size: 12.5px; }
.rail-actions a { color: var(--muted); }
.rail-actions a:hover { color: var(--accent); }

.sun-export {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px;
  border-radius: 8px;
  border: 1px dashed var(--hair-strong);
  font-size: 12px;
}
.sun-export-title { font-weight: 600; }
.sun-export-detail { color: var(--muted); }

/* --- Conversation column ------------------------------------------------ */

#stream {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
}

/* --- Chat header: "New chat" / history, above the scrolling area ------- */

.chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 40px 6px;
}
.chat-header-title { font-size: 13px; font-weight: 600; color: var(--muted); }
.chat-header-actions { display: flex; align-items: center; gap: 14px; }
.btn-chat-action {
  background: none;
  border: none;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 0;
}
.btn-chat-action:hover { text-decoration: underline; }

.chat-history-panel {
  flex: 0 0 auto;
  margin: 0 40px 8px;
  border: 1px solid var(--hair-strong);
  border-radius: 10px;
  background: var(--surface);
  max-height: 240px;
  overflow-y: auto;
}
.chat-history-panel[hidden] { display: none; }
.chat-history-empty { padding: 12px 14px; color: var(--muted); font-size: 13px; }
.chat-history-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hair);
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.chat-history-item:last-child { border-bottom: none; }
.chat-history-item:hover { background: var(--surface-2); }
.chat-history-title { display: block; font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-history-date { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* --- Run strip: one compact line above the conversation, always visible
   without scrolling (item 5). Draft cards themselves live in the thread. ---- */

.run-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 40px;
  border-bottom: 1px solid var(--hair);
}

.run-strip-status {
  flex: 1 1 auto;
  min-width: 0;
  /* The status text is the one thing here the user most needs to read
     (e.g. "Not issued: 3 checks failed"), so it wraps rather than
     truncating. Real status phrases are short enough to land on one or
     two lines at the widths the app supports; nothing here caps or
     clips it, so it is never hidden behind an ellipsis. */
  overflow: visible;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.35;
  font-size: 13px;
  color: var(--muted);
}

.run-strip-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.run-strip-actions form { margin: 0; }

.btn-compact { padding: 6px 12px; font-size: 12.5px; }

/* A run card interleaved into the conversation (item 5): same card, sized
   and aligned like an assistant bubble rather than a full-width strip. */
.card--timeline {
  align-self: flex-start;
  width: 100%;
  max-width: 640px;
}

/* --- The conversation's own scrolling region --------------------------- */

.stream-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 40px 8px;
}

#chat-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-user { align-self: flex-end; display: flex; justify-content: flex-end; }
.bubble {
  max-width: 520px;
  padding: 11px 15px;
  border-radius: 14px 14px 4px 14px;
  background: var(--bubble);
  font-size: 14.5px;
  line-height: 1.45;
}

/* Item 1: on --paper the reply had no shape of its own and read as loose
   text sitting on the page background. A --surface card with its own hairline
   border, radius and a faint shadow gives it an edge against --paper the way
   the composer already has one; the label and the different radius/padding
   from .card keep it from reading as a run card. */
.chat-assistant {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 1px 2px rgba(36, 33, 29, .06);
}
.chat-assistant-label {
  margin: 0;
}
.chat-text {
  font-size: 15px;
  line-height: 1.6;
  max-width: 68ch;
  font-variant-numeric: tabular-nums;
}
.chat-text p { margin: 0 0 .6em; }
.chat-text p:last-child { margin-bottom: 0; }
.chat-text table { border-collapse: collapse; margin: .5em 0; }
.chat-text th, .chat-text td { border: 1px solid var(--hair); padding: .3em .6em; text-align: left; }
.chat-text code { background: var(--surface-2); padding: .1em .3em; border-radius: .2em; }
.chat-text--live { white-space: pre-wrap; }

.composer-wrap { flex: 0 0 auto; padding: 8px 40px 22px; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 10px 8px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--hair-strong);
  box-shadow: 0 1px 2px rgba(36, 33, 29, .05);
}
.composer label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.composer textarea {
  flex: 1 1 auto;
  border: 0;
  resize: none;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: transparent;
  padding: 6px 0;
  min-height: 24px;
  max-height: 120px;
}
.composer textarea::placeholder { color: var(--faint); }
.composer textarea:focus { outline: none; }
.composer .btn-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  cursor: pointer;
}
.composer .btn-send:hover { background: #174f37; }
.composer .btn-send[data-state="stop"] { background: var(--bad); }
.composer .btn-send[data-state="stop"]:hover { background: #9a3a30; }
.composer textarea:disabled { color: var(--muted); }

/* Attaching a file: a paperclip beside the text box (the click and keyboard route), and a dashed
   edge plus one line above the composer while a file is dragged over the chat. */
.composer .btn-attach {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  cursor: pointer;
}
.composer .btn-attach:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.composer .btn-attach:disabled { opacity: .45; cursor: default; }
.drop-hint {
  display: none;
  margin: 0 0 8px;
  font-size: 13.5px;
  color: var(--accent);
}
.composer-wrap--dropping .drop-hint { display: block; }
.composer-wrap--dropping .composer { border-style: dashed; border-color: var(--accent); }

/* Dictating: a microphone beside Send. While it listens it is a filled microphone on the accent
   colour that pulses, and a line above the composer says so in words (and is announced): the
   state is never carried by colour or motion alone. Where the browser has no speech recognition
   the button stays, dimmed, and says why when pressed. */
.composer .btn-voice {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  cursor: pointer;
}
.composer .btn-voice:hover:not(:disabled):not([aria-disabled="true"]):not([data-state="listening"]) {
  background: var(--surface-2);
  color: var(--ink);
}
.composer .btn-voice:disabled { opacity: .45; cursor: default; }
.composer .btn-voice[aria-disabled="true"] { opacity: .45; cursor: default; }
.composer .btn-voice[data-state="listening"] {
  background: var(--accent);
  color: #fff;
  animation: voice-pulse 1.4s ease-out infinite;
}
@keyframes voice-pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 107, 74, .45); }
  100% { box-shadow: 0 0 0 10px rgba(31, 107, 74, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .composer .btn-voice[data-state="listening"] { animation: none; }
}
/* The status line is a live region, so it stays in the page when empty (an element removed from
   the page announces nothing when it is filled) and simply takes no room. */
.voice-status { margin: 0; font-size: 13.5px; color: var(--accent); }
.voice-status:not(:empty) { margin: 0 0 8px; }
.voice-status[data-tone="problem"] { color: var(--bad); }
.voice-privacy { display: none; margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.composer-wrap[data-voice-state="listening"] .voice-privacy,
.composer-wrap[data-voice-state="finishing"] .voice-privacy { display: block; }

.chat-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
  padding: 9px 14px;
  border-radius: 10px;
  background: #fbebe9;
  border: 1px solid #e7b6ae;
  color: var(--bad);
  font-size: 13.5px;
}
.chat-error[hidden] { display: none; }
.chat-retry {
  flex: 0 0 auto;
  background: none;
  border: 1px solid var(--bad);
  color: var(--bad);
  border-radius: 6px;
  padding: 3px 10px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.chat-retry:hover { background: var(--bad); color: #fff; }

.chat-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  max-width: 640px;
}
.chat-status .dot--progress { flex: 0 0 auto; }

.chat-starters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-width: 420px;
}
.chat-starter {
  text-align: left;
  padding: 9px 13px;
  border-radius: 10px;
  border: 1px solid var(--hair-strong);
  background: var(--surface);
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
}
.chat-starter:hover { background: var(--surface-2); }

.chat-assistant-foot { display: flex; align-items: center; gap: 12px; }
.chat-stopped-note { font-size: 12px; color: var(--muted); font-style: italic; }
.chat-muted { color: var(--muted); font-style: italic; }
.chat-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.chat-copy:hover { color: var(--ink); }
.chat-copy[data-copied="true"] { color: var(--accent); }

/* --- Document panel ------------------------------------------------------ */

#document {
  width: var(--doc-width, 560px);
  flex: 0 0 var(--doc-width, 560px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Item 3: without this, a flex item's default min-width:auto lets an
     oversized descendant (the wide exception-report iframe) push #document
     itself past its flex-basis instead of staying put and handing the
     overflow to .doc-panel-body's own scrollbar -- the same reason #stream
     carries min-width: 0 already. */
  min-width: 0;
  position: relative;
  border-left: 1px solid var(--hair);
  background: var(--surface-2);
}

/* --- Panel divider (item 4: resizable document panel) ------------------- */

.panel-divider {
  flex: 0 0 6px;
  width: 6px;
  min-width: 6px;
  cursor: col-resize;
  background: var(--hair);
  touch-action: none;
}
.panel-divider:hover,
.panel-divider:focus-visible {
  background: var(--accent);
  outline: none;
}

body.panel-dragging {
  cursor: col-resize;
}
body.panel-dragging,
body.panel-dragging * {
  user-select: none;
}

.doc-drag-shield {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: transparent;
  cursor: col-resize;
}

.doc-tabbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hair);
  background: var(--paper);
  flex: 0 0 auto;
}
.doc-tabs { display: flex; align-items: center; gap: 14px; min-width: 0; }
.doc-tab {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
  font-family: inherit;
}
.doc-tab[aria-current="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.doc-tabbar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px 16px; }
.doc-pdf-link, .doc-word-link { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--accent); flex: 0 0 auto; }
.doc-word-note { flex: 1 1 100%; text-align: right; font-size: 12.5px; color: var(--muted); }

.doc-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: 22px 26px 0;
}
.doc-panel-body iframe {
  width: 100%;
  height: 100%;
  min-height: 900px;
  border: none;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(36, 33, 29, .10), 0 8px 24px rgba(36, 33, 29, .06);
}
/* "What was checked" carries a table wider than the panel. It must scroll
   here, not vanish mid-word behind the panel edge, so only this frame gets
   room to be wider than 100% and this container, not the frame, carries the
   horizontal scrollbar. The Accounts document is not this wide and must fit
   the panel with no horizontal scroll at all (item D5). */
.doc-panel-body iframe.doc-frame-wide {
  min-width: 760px;
}

.doc-empty {
  color: var(--muted);
  padding: 40px 14px;
  text-align: center;
}

.doc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  border-top: 1px solid var(--hair);
  background: var(--paper);
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.files-disclosure { padding: 10px 18px; border-top: 1px solid var(--hair); background: var(--paper); flex: 0 0 auto; }
.files-disclosure summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
.files-disclosure ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.files-disclosure a { font-size: 12.5px; }
.files-disclosure .file-note { font-size: 12.5px; color: var(--muted); }

.what-changed { display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 22px; }
.what-changed h3 { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.what-changed .section-label { display: block; margin-bottom: 6px; }
.what-changed ul { margin: 0; padding-left: 18px; }
.what-changed li { font-size: 13.5px; line-height: 1.5; margin-bottom: 4px; }
.what-changed .empty-note { color: var(--muted); font-size: 13.5px; }
.what-changed .comparison-note { color: var(--muted); font-size: 12.5px; margin: -4px 0 2px; }

/* Same "this to this, by who, when" table language as "What was checked":
   hairline borders, a shaded header row, one row per fact. */
.changed-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.changed-table th, .changed-table td { border: 1px solid var(--hair); padding: 6px 10px; text-align: left; vertical-align: top; }
.changed-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.changed-table .changed-muted { color: var(--muted); font-size: 12px; }

.what-checked-list { display: flex; flex-direction: column; gap: 0; }
.what-checked-row { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--hair); font-size: 13px; }
.what-checked-row:last-child { border-bottom: none; }
.what-checked-ref { flex: 0 0 34px; font-weight: 600; font-variant-numeric: tabular-nums; }
.what-checked-ref--fail { color: var(--bad); }
.what-checked-ref--pass { color: var(--accent); }

/* --- Upload card -------------------------------------------------------- */

.state[data-state="confirmed"] { color: var(--accent); font-weight: 500; }
.state[data-state="received"] { color: var(--muted); }
dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; }

form.inline-upload { display: flex; flex-direction: column; gap: 6px; }
form label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
input[type="file"], input[type="text"], textarea.plain { font: inherit; }
.refused { color: var(--bad); }
.preview-unavailable { color: var(--muted); font-size: 13px; }

/* --- Shared form chrome (configuration, login) -------------------------- */

.app-shell-header {
  background: var(--ink);
  color: var(--paper);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.app-shell-header a { color: var(--paper); opacity: .85; }
.app-shell-header a:hover { opacity: 1; color: var(--paper); }
.app-shell-header strong { letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  margin: 1rem 0;
}
.form-card label { display: block; font-weight: 600; font-size: 13px; margin: .6rem 0 .25rem; color: var(--ink); }
.form-card input, .form-card select, .form-card textarea {
  width: 100%;
  max-width: 100%;
  font: inherit;
  font-size: 14px;
  padding: .5rem .6rem;
  border: 1px solid var(--hair-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.form-card textarea { min-height: 6rem; }
.form-card .error-note { border-left: 3px solid var(--bad); padding: .7rem .9rem; background: #fdf1ef; border-radius: 0 6px 6px 0; }
.form-card .muted-note { color: var(--muted); }

/* --- Proposal cards (slice 3b): a wording chip and its before/after diff,
   in the chat window's own look, not the S3 editor's standalone page.
   Chip colours match app/templates/wording_editor.html's own palette so a
   figure or company detail reads the same wherever it is shown. --- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12.5px;
  font-weight: 600;
  margin: 0 1px;
  vertical-align: middle;
}
.chip-figure, .chip-direction { background: var(--surface-2); color: var(--ink); border: 1px solid var(--hair-strong); }
.chip-company_detail { background: #e2edf7; color: #1f4e7a; border: 1px solid #bcd4ea; }
.chip-note, .chip-computed, .chip-unknown { background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair); }

.diff-changed { background: var(--inserted); border-radius: 3px; }

.proposal-diff {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proposal-side { display: flex; flex-direction: column; gap: 2px; }
.proposal-diff-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.sentence-preview { margin: 0; line-height: 1.6; }

.preview {
  background: var(--surface-2);
  border-radius: 8px;
  padding: .8rem 1rem;
  margin: 0;
}

.proposal-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.proposal-table th, .proposal-table td { border: 1px solid var(--hair); padding: 4px 8px; text-align: left; }
.proposal-table th { background: var(--surface-2); font-weight: 600; }
.proposal-table-single { margin-top: 4px; }

.proposal-decided { font-style: normal; }
.proposal-notice { color: var(--advisory); font-style: normal; }
.proposal-reject-form { display: flex; align-items: center; gap: 6px; }
.proposal-reject-form input { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--hair-strong); border-radius: 6px; }

.markup-source { padding: 0 0 6px; }
.markup-quote {
  margin: 4px 0;
  padding: 6px 10px;
  border-left: 3px solid var(--hair-strong);
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The account menu behind the avatar.
   First cut put an underlined "Sign out" link beside the avatar and it looked
   like a mistake. The circle is where people expect their account to live, so
   the circle opens it. <details> rather than script: it keeps working with
   keyboard and without JavaScript, and closes on a second click. */
.account { position: relative; }
.account > summary { list-style: none; cursor: pointer; }
.account > summary::-webkit-details-marker { display: none; }
.account > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  padding: 10px;
  background: var(--paper);
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 40;
}
.account-email {
  margin: 0 0 8px;
  padding: 0 4px 8px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.account-menu form { margin: 0; }
.account-menu button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 6px 4px;
  color: inherit;
  font: inherit;
  border-radius: 4px;
  cursor: pointer;
}
.account-menu button:hover, .account-menu button:focus { background: rgba(0, 0, 0, 0.06); }
