/* =============================================================
   Corporate Law Assistant — interface theme

   The look is meant to read like a professional practice tool, not a
   consumer chat app: a deep navy rail, a quiet off-white page, one
   restrained brass accent, and a serif reserved for headings and for
   the documents themselves.

   Conventions used throughout this file:
     · every colour, radius and shadow is a token in :root — do not
       hard-code a new colour further down, add a token
     · spacing follows a 4px rhythm
     · every interactive element gets a visible :focus-visible ring,
       because this is a tool people will drive from the keyboard
   ============================================================= */

:root {
  /* --- surfaces --- */
  --navy:        #111c2e;   /* sidebar / primary dark */
  --navy-800:    #1b2a44;
  --navy-700:    #26395a;
  --paper:       #f6f5f2;   /* app background */
  --paper-2:     #fbfaf8;   /* raised panels on the page */
  --card:        #ffffff;

  /* --- accent (brass) --- */
  --gold:        #a37c3c;
  --gold-strong: #8a6529;
  --gold-soft:   #e0cca7;
  --gold-tint:   #f6f0e3;

  /* --- text --- */
  --ink:         #1b2330;
  --ink-soft:    #5c6675;
  --ink-faint:   #8a94a2;

  /* --- lines --- */
  --line:        #e7e3d9;   /* warm hairline, on the paper background */
  --line-cool:   #e3e7ed;   /* cool hairline, inside white cards */

  /* --- sidebar text --- */
  --rail-text:   #c5cede;
  --rail-dim:    #8794ab;
  --rail-faint:  #6c7a92;

  /* --- semantic --- */
  --user-bubble: #1b2a44;
  --danger:      #96552a;
  --danger-bg:   #f7ebe1;
  --ok:          #2f6a4a;
  --ok-bg:       #edf5f0;
  --ok-line:     #c6dfd0;

  /* --- type --- */
  --font-serif: "Source Serif 4", "Lora", Georgia, "Times New Roman", serif;
  --font-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                Arial, sans-serif;
  --font-mono:  "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* --- shape --- */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  --shadow-xs: 0 1px 2px rgba(17, 28, 46, 0.05);
  --shadow-sm: 0 1px 2px rgba(17, 28, 46, 0.05), 0 1px 3px rgba(17, 28, 46, 0.04);
  --shadow-md: 0 10px 28px -8px rgba(17, 28, 46, 0.16), 0 2px 6px rgba(17, 28, 46, 0.05);
  --shadow-lg: 0 24px 56px -16px rgba(17, 28, 46, 0.28);

  --ring: 0 0 0 3px rgba(163, 124, 60, 0.22);
  --ring-dark: 0 0 0 3px rgba(224, 204, 167, 0.28);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* The column width every reading surface lines up to. */
  --measure: 880px;
}

* { box-sizing: border-box; }

/* IMPORTANT: several elements below set `display: flex`, which silently beats
   the browser's built-in `[hidden] { display: none }` rule. Without this line,
   anything the HTML or JavaScript marks as hidden (the attached-document chip,
   the Download/Export dropdown menus) stays on screen permanently. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  text-rendering: optimizeLegibility;
}

/* One focus treatment for the whole interface. */
:where(button, a, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Quiet scrollbars — the default Windows ones are heavy and undo a lot of
   the calm the rest of the page is going for. */
* { scrollbar-width: thin; scrollbar-color: rgba(17, 28, 46, 0.22) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(17, 28, 46, 0.16);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(17, 28, 46, 0.3); background-clip: content-box; }

::selection { background: rgba(163, 124, 60, 0.22); }

/* ===================== Layout shell ===================== */

.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ===================== Sidebar ===================== */

.sidebar {
  width: 288px;
  flex-shrink: 0;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(163, 124, 60, 0.10) 0%, transparent 62%),
    linear-gradient(180deg, #16223a 0%, var(--navy) 42%, #0d1725 100%);
  color: var(--rail-text);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  gap: 24px;
  overflow-y: auto;
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.04) inset;
}

.sidebar { scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
.sidebar *::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); background-clip: content-box; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(155deg, #c79a52 0%, var(--gold) 46%, #7d5a26 100%);
  color: #fffdf8;
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.brand-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 16.5px;
  letter-spacing: -0.005em;
  color: #ffffff;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--rail-dim);
  margin-top: 3px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.05);
  color: #eef2f8;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
              transform 0.06s var(--ease);
}

.new-chat-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(224, 204, 167, 0.5);
}
.new-chat-btn:active { transform: translateY(1px); }
.new-chat-btn:focus-visible { outline-color: var(--gold-soft); }

.new-chat-btn .plus {
  font-size: 16px;
  line-height: 0;
  color: var(--gold-soft);
  transform: translateY(-0.5px);
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }

.side-heading {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rail-faint);
  margin: 0 10px 8px;
  font-weight: 600;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--rail-text);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.3;
  position: relative;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-link:focus-visible { outline-color: var(--gold-soft); }

/* The two working section buttons are <button>s, so reset the default
   button look and make them fill the sidebar like the old links did. */
.mode-btn,
#docs-nav-btn {
  width: 100%;
  background: none;
  border: 0;
  font-family: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

/* How many documents are saved, shown on the sidebar button. */
.count-tag {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gold-soft);
  background: rgba(163, 124, 60, 0.2);
  border: 1px solid rgba(224, 204, 167, 0.3);
  border-radius: 999px;
  padding: 1px 8px;
}

.side-link.active {
  background: linear-gradient(90deg, rgba(163, 124, 60, 0.22) 0%, rgba(163, 124, 60, 0.07) 100%);
  color: #fff;
  font-weight: 500;
}
.side-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 2.5px;
  border-radius: 0 3px 3px 0;
  background: var(--gold-soft);
}

.side-ic {
  width: 18px;
  flex: none;
  text-align: center;
  font-size: 13px;
  color: var(--gold-soft);
  opacity: 0.9;
}

.side-link.recent { color: #a9b4c8; font-size: 13px; }
.side-link.recent.muted { color: var(--rail-faint); }

/* ---- Saved chat history list ---- */

.recent-list { display: flex; flex-direction: column; gap: 1px; }

/* "Pinned" / "Recent" group labels inside the list. */
.recent-group {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rail-faint);
  font-weight: 600;
  padding: 10px 10px 4px;
}
.recent-group:first-child { padding-top: 0; }

/* A row holds the chat title (a button) plus a "⋯" menu button that only
   appears on hover, so the list stays clean. */
.recent-row {
  display: flex;
  align-items: center;
  border-radius: 8px;
  position: relative;
  transition: background 0.15s var(--ease);
}

/* The pin marker sits inside the title button, before the text. */
.pin-mark { font-size: 9.5px; margin-right: 6px; opacity: 0.8; color: var(--gold-soft); }

.recent-row:hover { background: rgba(255, 255, 255, 0.07); }

.recent-row.active {
  background: linear-gradient(90deg, rgba(163, 124, 60, 0.22) 0%, rgba(163, 124, 60, 0.07) 100%);
}
.recent-row.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 2.5px;
  border-radius: 0 3px 3px 0;
  background: var(--gold-soft);
}

.recent-item {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 9px 4px 9px 10px;
  color: #a9b4c8;
  font-family: inherit;
  font-size: 12.8px;
  line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s var(--ease);
}
.recent-item:focus-visible { outline-color: var(--gold-soft); }

.recent-row:hover .recent-item,
.recent-row.active .recent-item { color: #fff; }

/* ---- "⋯" row menu (used by the chat list and the document cards) ---- */

.row-menu-wrap { position: relative; flex-shrink: 0; }

.row-menu-btn {
  background: none;
  border: 0;
  color: var(--ink-faint);
  font-size: 15px;
  line-height: 1;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.row-menu-btn:hover { background: rgba(17, 28, 46, 0.06); color: var(--navy); }

.row-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  z-index: 30;
  min-width: 154px;
  background: var(--card);
  border: 1px solid var(--line-cool);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  padding: 5px;
  display: flex;
  flex-direction: column;
  animation: pop-in 0.13s var(--ease);
}

.row-menu-item {
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.row-menu-item:hover { background: var(--gold-tint); color: var(--navy); }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { background: var(--danger-bg); }

/* In the dark sidebar the "⋯" button stays hidden until you hover the row. */
.recent-menu .row-menu-btn {
  color: var(--rail-faint);
  opacity: 0;
  transition: opacity 0.12s var(--ease), color 0.12s var(--ease), background 0.12s var(--ease);
}
.recent-row:hover .recent-menu .row-menu-btn,
.recent-menu .row-menu-btn:focus-visible { opacity: 1; }
.recent-menu .row-menu-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
/* Keep it visible while its menu is open, so it doesn't vanish mid-click. */
.recent-menu:has(.row-menu:not([hidden])) .row-menu-btn { opacity: 1; }

.recent-empty {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--rail-faint);
  padding: 2px 10px;
}

.side-foot {
  margin-top: auto;
  font-size: 11px;
  line-height: 1.55;
  color: var(--rail-dim);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 11px;
  padding: 12px 13px;
}

.side-foot-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gold-soft);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.side-foot-title::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  flex: none;
}

/* ===================== Main column ===================== */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
  position: relative;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 248, 0.85);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  z-index: 10;
}

.main-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--navy);
  line-height: 1.2;
}

.main-sub {
  margin: 4px 0 0;
  font-size: 12px;
  letter-spacing: 0.005em;
  color: var(--ink-soft);
}

.header-actions { display: flex; align-items: center; gap: 10px; }

/* Kept for anything that still wants a small pill in the header. */
.header-badge {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gold-strong);
  border: 1px solid var(--gold-soft);
  background: var(--gold-tint);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ===================== Buttons & dropdowns ===================== */

.dl { position: relative; display: inline-block; }

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--navy);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 12px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease),
              box-shadow 0.15s var(--ease), transform 0.06s var(--ease);
}
.dl-btn:hover {
  border-color: var(--gold-soft);
  background: var(--gold-tint);
  box-shadow: var(--shadow-sm);
}
.dl-btn:active { transform: translateY(1px); }
.dl-caret { font-size: 9px; opacity: 0.6; transform: translateY(1px); }

/* The filled variant, for the one action a panel actually wants you to take. */
.dl-btn.primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.dl-btn.primary:hover {
  background: var(--navy-800);
  border-color: var(--navy-800);
  box-shadow: var(--shadow-md);
}

.dl-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 158px;
  background: var(--card);
  border: 1px solid var(--line-cool);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  padding: 5px;
  display: flex;
  flex-direction: column;
  animation: pop-in 0.13s var(--ease);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.dl-item {
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.dl-item:hover { background: var(--gold-tint); color: var(--navy); }

/* Divider before the non-download actions at the bottom of a menu
   (e.g. "Save chat to My Documents"), so they don't read as a file format. */
.dl-sep {
  height: 1px;
  background: var(--line);
  margin: 5px 4px;
}
.dl-item-alt { color: var(--navy); font-weight: 500; }

/* Action row under an AI answer */
.msg-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.msg-actions .dl-btn { font-size: 12px; padding: 6px 11px; }

/* ===================== Chat window ===================== */

.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 30px 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 14px;
  max-width: var(--measure);
  width: 100%;
  animation: msg-in 0.26s var(--ease) both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.ai { align-self: flex-start; }

.avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  background: linear-gradient(155deg, #c79a52 0%, var(--gold) 46%, #7d5a26 100%);
  color: #fffdf8;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Bubbles */
.bubble {
  padding: 4px 2px;
  line-height: 1.65;
  font-size: 14.5px;
  min-width: 0;
}

.message.ai .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  max-width: 780px;
}

.message.user .bubble {
  background: var(--user-bubble);
  color: #eef2f8;
  border-radius: 14px 4px 14px 14px;
  padding: 12px 16px;
  max-width: 620px;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}

.message.user .avatar {
  background: linear-gradient(155deg, var(--navy-700) 0%, var(--navy-800) 100%);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ===================== Rendered answer content ===================== */

.answer > *:first-child { margin-top: 0; }
.answer > *:last-child { margin-bottom: 0; }

.answer p { margin: 0 0 11px; }

.answer h1, .answer h2, .answer h3, .answer h4 {
  font-family: var(--font-serif);
  color: var(--navy);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 20px 0 8px;
}
.answer h1 { font-size: 19.5px; }
.answer h2 { font-size: 17.5px; }
.answer h3 { font-size: 15.5px; }
.answer h4 { font-size: 14.5px; }

/* A top-level heading in an answer earns a hairline above it — it makes a
   long compliance answer scannable without adding any chrome. */
.answer h2:not(:first-child) {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.answer ul, .answer ol { margin: 4px 0 13px; padding-left: 22px; }
.answer li { margin: 5px 0; }
.answer li::marker { color: var(--gold); }

.answer strong { color: var(--navy); font-weight: 600; }

.answer hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.answer blockquote {
  margin: 10px 0 14px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--gold-soft);
  color: var(--ink-soft);
}

/* Tables in an answer (e.g. compliance checklists, due-date charts).
   The wrapper scrolls sideways on its own so a wide table never forces the
   whole page to scroll horizontally on a small screen. */
.answer .table-wrap {
  overflow-x: auto;
  margin: 8px 0 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-xs);
}

.answer table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
}

.answer th, .answer td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
}

.answer th:last-child, .answer td:last-child { border-right: 0; }
.answer tbody tr:last-child td { border-bottom: 0; }
.answer tbody tr:nth-child(even) td { background: rgba(246, 240, 227, 0.35); }

.answer thead th {
  background: var(--gold-tint);
  color: var(--navy);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.answer code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: #f3f1ea;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

/* Detected legal references — Section / Rule / Regulation / SS-1 / Companies
   Act 2013. IMPORTANT: these are only *detected* by a text pattern; nothing
   verifies the section exists or says what the model claims. So we deliberately
   style them as a subtle dotted underline (a "look here" cue), NOT as a solid
   gold "verified" chip — we must not imply a citation has been checked. */
.citation {
  color: inherit;
  border-bottom: 1px dotted var(--gold);
  cursor: help;
  white-space: nowrap;
}

/* Disclaimer callout, pulled out of the answer body */
.disclaimer-callout {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.55;
  color: #6b5734;
  background: var(--gold-tint);
  border: 1px solid var(--gold-soft);
  border-left: 3px solid var(--gold);
  border-radius: 9px;
  padding: 11px 13px;
}

.disclaimer-callout .disc-ic { flex-shrink: 0; font-size: 13px; line-height: 1.45; }

/* ===================== Typing indicator ===================== */

.typing-dots { display: inline-flex; gap: 5px; padding: 6px 2px; }

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.4;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.32; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ===================== Composer ===================== */

.composer {
  padding: 14px 32px 18px;
  border-top: 1px solid var(--line);
  background: rgba(251, 250, 248, 0.9);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: var(--measure);
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 8px 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.composer-inner:focus-within {
  border-color: var(--gold);
  box-shadow: var(--ring), var(--shadow-sm);
}

.composer-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: transparent;
  max-height: 200px;
  padding: 7px 0;
}

.composer-input::placeholder { color: #a2abb8; }

.send-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease),
              transform 0.06s var(--ease);
  flex-shrink: 0;
}

.send-btn:hover { background: var(--navy-800); box-shadow: var(--shadow-md); }
.send-btn:active { transform: translateY(1px); }

.send-btn:disabled {
  background: #aab3bf;
  border-color: #aab3bf;
  box-shadow: none;
  cursor: not-allowed;
}

.send-arrow { font-size: 15px; transition: transform 0.15s var(--ease); }
.send-btn:hover .send-arrow { transform: translateX(2px); }

/* Attach button inside the composer */
.attach-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  font-size: 17px;
  line-height: 1;
  padding: 9px;
  border-radius: 9px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s var(--ease), background 0.15s var(--ease);
}
.attach-btn:hover { opacity: 1; background: #f2f0e9; }
.attach-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Active-document chip above the input */
.doc-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--measure);
  margin: 0 auto 10px;
  background: var(--gold-tint);
  border: 1px solid var(--gold-soft);
  border-radius: 10px;
  padding: 8px 10px 8px 12px;
  font-size: 12.5px;
  color: #6b5734;
}
.doc-chip .doc-ic { flex-shrink: 0; }
.doc-chip-text { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
#doc-chip-name { font-weight: 600; color: #5a4726; word-break: break-all; }
.doc-chip-note { font-size: 11.5px; color: #8a7a52; }
.doc-chip-note.warn { color: var(--danger); font-weight: 500; }
.doc-remove {
  margin-left: auto;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #8a7a52;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.doc-remove:hover { background: rgba(0, 0, 0, 0.06); color: #5a4726; }

/* "Answered using document" badge on an AI message */
.doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 11px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
  border-radius: 999px;
  padding: 3px 11px;
}

.composer-hint {
  max-width: var(--measure);
  margin: 9px auto 0;
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
  letter-spacing: 0.01em;
}

.composer-hint kbd {
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-soft);
  background: #efece4;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}

/* ===================== "My Documents" library ===================== */

.docs-view {
  flex: 1;
  overflow-y: auto;
  padding: 26px 32px 40px;
}

.docs-toolbar { max-width: 940px; margin: 0 auto 20px; }

.docs-search {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 15px;
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.docs-search::placeholder { color: #a2abb8; }
.docs-search:focus {
  border-color: var(--gold);
  box-shadow: var(--ring);
}

/* Empty state */
.docs-empty {
  max-width: 560px;
  margin: 48px auto;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.65;
}
.docs-empty-mark {
  font-size: 30px;
  color: var(--gold);
  opacity: 0.5;
  margin-bottom: 12px;
}
.docs-empty h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin: 0 0 10px;
}
.docs-empty p { margin: 0 0 10px; }
.docs-empty strong { color: var(--ink); font-weight: 600; }
.docs-empty-note {
  font-size: 12.5px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 18px;
}

.docs-no-match {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
  padding: 28px 0;
}

/* Card grid */
.docs-list {
  max-width: 940px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
  gap: 14px;
}

.doc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px 12px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease),
              transform 0.18s var(--ease);
}
.doc-card:hover {
  border-color: var(--gold-soft);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.doc-card-head { display: flex; align-items: flex-start; gap: 4px; }

.doc-card-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--navy);
  transition: color 0.15s var(--ease);
}
.doc-card-title:hover { color: var(--gold-strong); }

.doc-card-meta {
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.015em;
}

.doc-card-snippet {
  margin: 2px 0 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-card-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* One document, opened */
.doc-detail { max-width: 940px; margin: 0 auto; }

.doc-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  margin-bottom: 12px;
  transition: color 0.15s var(--ease);
}
.doc-back:hover { color: var(--gold-strong); }

.doc-detail-head h2 {
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--navy);
  margin: 0 0 5px;
  line-height: 1.25;
}
.doc-detail-meta { font-size: 12px; color: var(--ink-faint); }

.doc-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

/* The document itself, on a sheet of "paper". */
.doc-paper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 40px;
  box-shadow: var(--shadow-sm);
  font-size: 14.5px;
  line-height: 1.7;
}

.dl-btn.danger { color: var(--danger); }
.dl-btn.danger:hover { border-color: var(--danger); background: var(--danger-bg); }

/* ===================== Save-to-documents button ===================== */

.save-btn.primary {
  border-color: var(--gold);
  background: var(--gold-tint);
  color: var(--gold-strong);
  font-weight: 600;
}
.save-btn.primary:hover { background: var(--gold-soft); border-color: var(--gold); }

.save-btn.saved,
.save-btn:disabled {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-line);
  box-shadow: none;
  cursor: default;
}
.save-btn.saved:hover { background: var(--ok-bg); border-color: var(--ok-line); }

/* Appears next to the button once a draft has been saved, so the save is
   visibly real and the library is one click away. */
.save-goto {
  color: var(--gold-strong);
  border-color: var(--gold-soft);
  background: var(--gold-tint);
}
.save-goto:hover { background: var(--gold-soft); border-color: var(--gold); }

/* Brief confirmation after an action that closes its own menu (saving a chat
   into My Documents). Purely informational — it never blocks anything. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 12px);
  z-index: 60;
  max-width: 90vw;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--navy);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 11px 18px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* In-place rename box in My Documents (replaces the old prompt() dialog). */
.rename-input {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 5px 9px;
  min-width: 220px;
  max-width: 100%;
  flex: 1;
}
.rename-input:focus { outline: none; box-shadow: var(--ring); }

/* "Draft v1: <document>" badge on an AI answer. Turns green once the document
   has been finalised, because "final" must be visible at a glance. */
.draft-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 11px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--gold-strong);
  background: var(--gold-tint);
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  padding: 3px 11px;
}
.draft-badge.draft-final {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-line);
}

/* ===================== The drafting wizard =====================
   The form the assistant puts up when it needs facts before it will
   draft: labelled boxes for what the document type requires, then a
   summary to confirm. Styled as a form on the page rather than as
   part of the conversation, because that is what it is. */

.wizard {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.wz-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 15px;
  background: var(--gold-tint);
  border-bottom: 1px solid var(--gold-soft);
}
.wz-name {
  font-family: var(--font-serif);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--navy);
}
.wz-step {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--gold-strong);
  white-space: nowrap;
}

/* One line saying what this document is for, so a misunderstanding is caught
   before the user answers eight questions about the wrong document. */
.wz-purpose {
  margin: 0;
  padding: 11px 15px 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.wz-body { padding: 15px; }

.wz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 13px;
}

/* --- a group of questions ("Company Details", "Party Details") ---
   The groups come from the server, which worked them out for this document,
   so nothing here knows their names. A group holding something still needed is
   open; a completed one is collapsed, so what is outstanding stands out. */

.wz-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  margin-bottom: 10px;
  overflow: hidden;
}
.wz-group:last-of-type { margin-bottom: 0; }
.wz-group > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  padding: 10px 13px;
  background: #faf9f6;
  border-bottom: 1px solid transparent;
  list-style: none;
  transition: background 0.15s var(--ease);
}
.wz-group[open] > summary { border-bottom-color: var(--line); }
.wz-group > summary::-webkit-details-marker { display: none; }
.wz-group > summary:hover { background: #f5f3ee; }
.wz-group > summary:hover .wz-group-name { color: var(--navy); }
.wz-group-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--ink);
}
.wz-group-count {
  font-size: 11px;
  color: var(--ink-faint);
  white-space: nowrap;
}
.wz-group-needed > summary { background: var(--gold-tint); }
.wz-group-needed > summary:hover { background: #f2e9d6; }
.wz-group-needed .wz-group-count { color: var(--gold-strong); font-weight: 500; }
.wz-group .wz-grid { padding: 13px; }

/* Why the document needs this fact — what makes the form read as a Company
   Secretary asking rather than a web form demanding. */
.wz-why {
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* The heading over each group of answers in the review step. */
.wz-sum-group {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 16px 0 7px;
}
.wz-sum-group:first-child { margin-top: 0; }

.wz-field { display: flex; flex-direction: column; gap: 5px; }
.wz-label {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.wz-req {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.wz-missing .wz-req { color: var(--danger); }

.wz-input {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  resize: vertical;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.wz-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--ring);
}
.wz-input:disabled { background: #f7f6f1; color: var(--ink-faint); }
.wz-missing .wz-input { border-color: var(--gold-soft); background: #fffdf7; }

.wz-error { font-size: 11.5px; color: var(--danger); }

.wz-more {
  margin-top: 15px;
  border-top: 1px solid var(--line);
  padding-top: 13px;
}
.wz-more > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 10px;
  transition: color 0.15s var(--ease);
}
.wz-more > summary:hover { color: var(--navy); }

.wz-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 8px;
}
.wz-check input { margin-top: 3px; flex: none; accent-color: var(--gold); }
.wz-check em { color: var(--ink-soft); font-style: normal; }

/* --- the review step --- */

.wz-summary {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 7px 18px;
  margin: 0;
  font-size: 13px;
}
.wz-summary dt { color: var(--ink-soft); }
.wz-summary dd { margin: 0; color: var(--ink); font-weight: 500; }
.wz-default {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--gold-strong);
}

.wz-legal {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.wz-legal-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.wz-legal-line {
  display: flex;
  gap: 12px;
  font-size: 12px;
  line-height: 1.65;
}
.wz-legal-line span:first-child { flex: none; width: 96px; color: var(--ink-faint); }

.wz-conflict {
  margin: 11px 0 0;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #e6d0bd;
  border-radius: 8px;
}

.wz-note {
  margin: 13px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-faint);
}

/* --- the buttons --- */

.wz-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 13px 15px;
  border-top: 1px solid var(--line);
  background: #f8f6f1;
}
/* Written as `.dl-btn.wz-go` on purpose: the wizard's go button carries
   `dl-btn primary wz-go`, and `.dl-btn.primary` above would otherwise out-rank
   a bare `.wz-go` and paint it navy. */
.dl-btn.wz-go {
  border-color: var(--gold);
  background: linear-gradient(180deg, #b98d45 0%, var(--gold) 100%);
  color: #fffdf8;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.dl-btn.wz-go:hover {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-strong) 100%);
  border-color: var(--gold-strong);
  box-shadow: var(--shadow-md);
}
.wz-cancel { margin-left: auto; color: var(--ink-soft); }
.wz-foot .dl-btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

.wz-hint {
  margin: 0;
  padding: 0 15px 13px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-faint);
  background: #f8f6f1;
}

/* ============ The draft panel: editing and finalisation ============
   Sits under a drafted document. Everything about it says "this is not
   finished yet": the version line, the editing box, and the Finalise
   button that locks it. Once locked, the panel becomes a green note
   and the controls go away entirely. */

.draft-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  padding: 13px 15px;
  box-shadow: var(--shadow-xs);
}

.dp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.dp-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--gold-strong);
}
.dp-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex: none;
}
.dp-status.dp-final { color: var(--ok); }
.dp-status.dp-final::before { background: var(--ok); }
.dp-versions { font-size: 11.5px; color: var(--ink-faint); }

.dp-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.dp-input,
.dp-editor {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
  resize: vertical;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.dp-input:focus,
.dp-editor:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--ring);
}
.dp-input:disabled { background: #f7f6f1; color: var(--ink-faint); }

/* The by-hand editor is the document itself, so it is set in the document's
   own face rather than the interface face. */
.dp-editor {
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.75;
  margin: 12px 0;
  min-height: 280px;
}

.dp-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
}
.dp-foot .dl-btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

/* Example instructions. They teach the user that an edit can be an instruction
   rather than retyping the clause themselves. */
.dp-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}
.dp-chip {
  font-family: inherit;
  font-size: 11px;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease),
              background 0.15s var(--ease);
}
.dp-chip:hover {
  color: var(--navy);
  border-color: var(--gold-soft);
  background: var(--gold-tint);
}

/* ===================== Responsive ===================== */

@media (max-width: 1080px) {
  .sidebar { width: 250px; }
  .main-header, .chat-window, .composer, .docs-view {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (max-width: 820px) {
  .sidebar { display: none; }
  .main-header, .chat-window, .composer, .docs-view {
    padding-left: 16px;
    padding-right: 16px;
  }
  .main-header { padding-top: 14px; padding-bottom: 14px; }
  .main-header h1 { font-size: 18px; }
  .message.ai .bubble { padding: 15px 16px; }
  .docs-list { grid-template-columns: 1fr; }
  .doc-paper { padding: 20px 18px; }
  .doc-detail-head h2 { font-size: 20px; }
  .wz-grid { grid-template-columns: 1fr; }
  .wz-summary { grid-template-columns: 1fr; gap: 0; }
  .wz-summary dt { margin-top: 9px; font-size: 11.5px; }
  .wz-legal-line { flex-direction: column; gap: 0; }
  .wz-legal-line span:first-child { width: auto; }
  .dp-foot .dl-btn { flex: 1 1 auto; justify-content: center; }
  .composer-hint { font-size: 10.5px; }
}

/* Respect a system-level preference for less movement. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===================== Print =====================
   Printing is aimed at one thing: the opened document in My Documents.
   Everything that is interface gets out of the way. */

@media print {
  .sidebar, .main-header, .composer, .doc-detail-actions, .doc-back,
  .docs-toolbar, .msg-actions, .draft-panel, .wizard, .toast { display: none !important; }
  html, body, .app-shell, .main, .docs-view { height: auto; overflow: visible; background: #fff; }
  .doc-paper { border: 0; box-shadow: none; padding: 0; font-size: 12pt; }
  .doc-detail { max-width: none; }
  .answer h1, .answer h2, .answer h3 { break-after: avoid; }
  .answer table, .answer .table-wrap { break-inside: avoid; border: 0; }
}

/* ===================== Signing in ===================== */

/* Nothing of the app shows until the server has confirmed a session. */
body.auth-pending .app-shell,
body.signed-out .app-shell { display: none; }

.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(90% 60% at 0% 0%, rgba(163, 124, 60, 0.10) 0%, transparent 62%),
    var(--paper);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 32px 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.auth-brand-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}
.auth-brand-sub { font-size: 12px; color: var(--ink-soft); }

.auth-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
}
.auth-sub {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 20px;
}

.auth-form { display: flex; flex-direction: column; }

.auth-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 12px 0 6px;
}
.auth-form > .auth-label:first-child { margin-top: 0; }

.auth-input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.auth-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--ring);
}

.auth-hint {
  font-size: 12px;
  color: var(--ink-faint);
  margin: 6px 0 0;
}

.auth-error {
  min-height: 20px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--danger);
  margin: 12px 0 4px;
}
.auth-error:empty { margin: 8px 0 0; }

.auth-submit {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--navy-800);
  border: 1px solid var(--navy-800);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-top: 8px;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}
.auth-submit:hover { background: var(--navy-700); }
.auth-submit:focus-visible { outline: none; box-shadow: var(--ring); }
.auth-submit:disabled { opacity: 0.6; cursor: progress; }

.auth-switch {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  margin: 20px 0 0;
}
.auth-switch-btn {
  font: inherit;
  font-weight: 600;
  color: var(--gold-strong);
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 4px;
}
.auth-switch-btn:hover { text-decoration: underline; }
.auth-switch-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* --- "Continue with Google" (Google's sign-in button branding: white,
   grey outline, the four-colour G) --- */
.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  font-size: 14px;
  font-weight: 500;
  color: #1f1f1f;
  text-decoration: none;
  background: #fff;
  border: 1px solid #747775;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: background 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.auth-google:hover { background: #f8f9fa; box-shadow: var(--shadow-xs); }
.auth-google:focus-visible { outline: none; box-shadow: var(--ring); }
.auth-google-g { width: 18px; height: 18px; flex: none; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  font-size: 12px;
  color: var(--ink-faint);
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* --- who is signed in (sidebar) --- */
.side-account {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: var(--rail-text);
}
/* The account block now takes the bottom slot the note used to push to. */
.side-account + .side-foot { margin-top: 0; }
.side-account-ic { color: var(--gold-soft); font-size: 11px; flex: none; }
.side-account-email {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-account-out {
  flex: none;
  font: inherit;
  font-size: 11.5px;
  color: var(--rail-text);
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  padding: 4px 8px;
  cursor: pointer;
}
.side-account-out:hover { border-color: rgba(224, 204, 167, 0.5); color: #fff; }
.side-account-out:focus-visible { outline: none; box-shadow: var(--ring-dark); }

/* --- Sign out in the header: only where the sidebar is hidden --- */
.header-sign-out {
  display: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
}
.header-sign-out:focus-visible { outline: none; box-shadow: var(--ring); }

@media (max-width: 820px) {
  .header-sign-out { display: inline-block; }
  .auth-card { padding: 24px 20px 20px; }
}

@media print {
  .auth-screen, .header-sign-out { display: none !important; }
}
