/* Minimal neutral theme. Light by default; dark follows the system unless the user picks one. */
:root {
  color-scheme: light;
  --bg: #fafafa; --fg: #18181b; --ink: #18181b; --on-ink: #fafafa; --ink-hover: #3f3f46;
  --card: #ffffff; --side: #fafafa; --muted: #f4f4f5; --muted-fg: #71717a; --soft-fg: #a1a1aa;
  --border: #e4e4e7; --border-soft: #f0f0f2; --canvas: #f4f4f5;
  --emerald: #10a36e; --emerald-dark: #0a7a52; --emerald-light: #c9f2df; --emerald-soft: #edf9f3;
  --warn: #8a5a0b; --warn-soft: #fdf4e3; --warn-line: #e6b85c; --danger: #dc2626;
  --scrim: rgba(9, 9, 11, .35);
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, .04);
  --shadow: 0 1px 2px rgba(9, 9, 11, .04);
  --shadow-pop: 0 16px 40px -12px rgba(9, 9, 11, .22);
  --page-shadow: 0 1px 2px rgba(9, 9, 11, .06), 0 0 0 1px rgba(9, 9, 11, .04);
  --ring: 0 0 0 3px rgba(16, 163, 110, .18);
  --pad-bg: #fcfcfb;
  --font: 'Anuphan', -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Anuphan', -apple-system, sans-serif;
  --pen: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark;
  --bg: #0e0e10; --fg: #ececee; --ink: #ececee; --on-ink: #111113; --ink-hover: #d4d4d8;
  --card: #18181b; --side: #111113; --muted: #232327; --muted-fg: #a1a1aa; --soft-fg: #71717a;
  --border: #2c2c31; --border-soft: #222226; --canvas: #0a0a0b;
  --emerald: #2bc48a; --emerald-dark: #4ade9f; --emerald-light: #164a35; --emerald-soft: #10251c;
  --warn: #f5c56b; --warn-soft: #2e230f; --warn-line: #a7792a; --danger: #f87171;
  --scrim: rgba(0, 0, 0, .55); --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, .7);
  --page-shadow: 0 0 0 1px rgba(255, 255, 255, .06); --pad-bg: #1f1f23; } }
:root[data-theme="dark"] { color-scheme: dark;
  --bg: #0e0e10; --fg: #ececee; --ink: #ececee; --on-ink: #111113; --ink-hover: #d4d4d8;
  --card: #18181b; --side: #111113; --muted: #232327; --muted-fg: #a1a1aa; --soft-fg: #71717a;
  --border: #2c2c31; --border-soft: #222226; --canvas: #0a0a0b;
  --emerald: #2bc48a; --emerald-dark: #4ade9f; --emerald-light: #164a35; --emerald-soft: #10251c;
  --warn: #f5c56b; --warn-soft: #2e230f; --warn-line: #a7792a; --danger: #f87171;
  --scrim: rgba(0, 0, 0, .55); --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, .7);
  --page-shadow: 0 0 0 1px rgba(255, 255, 255, .06); --pad-bg: #1f1f23; }

/* TH SarabunPSK ships with the site so the preview matches the Word file exactly. */
@font-face { font-family: 'TH SarabunPSK'; src: local('TH SarabunPSK'), url('fonts/THSarabun.ttf') format('truetype'); font-weight: 400; font-style: normal; }
@font-face { font-family: 'TH SarabunPSK'; src: local('TH SarabunPSK Bold'), url('fonts/THSarabun-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; }
@font-face { font-family: 'TH SarabunPSK'; src: local('TH SarabunPSK Italic'), url('fonts/THSarabun-Italic.ttf') format('truetype'); font-weight: 400; font-style: italic; }
@font-face { font-family: 'TH SarabunPSK'; src: local('TH SarabunPSK Bold Italic'), url('fonts/THSarabun-BoldItalic.ttf') format('truetype'); font-weight: 700; font-style: italic; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: var(--font); font-weight: 400; background: var(--bg); color: var(--fg); font-size: 15px; line-height: 1.55; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.grow { flex: 1; }
[hidden] { display: none !important; }
html[data-lang="en"] .i18n-th, html[data-lang="th"] .i18n-en { display: none !important; }
:focus-visible { outline: 0; box-shadow: var(--ring); }

.app { display: flex; height: 100vh; }

/* ================= Sidebar ================= */
.sidebar { width: 300px; flex-shrink: 0; background: var(--side); border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 10px; padding: 14px 10px 10px; height: 100vh; }
.brand { font-size: 19px; font-weight: 500; padding: 4px 12px 6px; letter-spacing: -.2px; }
.new-chat { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--on-ink); transition: transform .15s, box-shadow .15s; }
.new-chat:hover { background: var(--ink-hover); }
.new-chat > span { display: flex; flex-direction: column; line-height: 1.25; }
.new-chat b { font-weight: 600; font-size: 16px; }
.new-chat small { font-size: 12px; opacity: .75; font-weight: 400; }
.side-card { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--border-soft); font-weight: 600; }
.side-card > svg:first-child { color: var(--emerald-dark); }
.side-card .arrow { color: var(--soft-fg); }
.side-card:hover { border-color: var(--border); }
.pill-new { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--emerald-soft); color: var(--emerald-dark); }
.side-search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--muted); color: var(--muted-fg); }
.side-search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 14px; color: var(--fg); }
.side-search:focus-within { box-shadow: var(--ring); }
.history { list-style: none; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 2px; }
.history a { display: block; padding: 8px 12px; border-radius: 10px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted-fg); }
.history a:hover { background: var(--muted); color: var(--fg); }
.history a.active { background: var(--card); color: var(--fg); box-shadow: var(--shadow-sm); }
.history .empty { color: var(--soft-fg); font-size: 14px; padding: 4px 12px; }
.side-links { display: flex; flex-direction: column; border-top: 1px solid var(--border-soft); padding-top: 6px; }
.side-links a, .side-links button { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 10px;
  border: 0; background: transparent; font-weight: 600; font-size: 15px; cursor: pointer; text-align: left; }
.side-links a:hover, .side-links button:hover { background: var(--muted); }
.side-links svg { color: var(--soft-fg); }
.side-user { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 14px; padding: 8px 10px; box-shadow: var(--shadow-sm); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--muted); color: var(--fg); font-weight: 600; flex-shrink: 0; }
.who { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.who b { font-size: 14px; font-weight: 600; }
.who small { font-size: 12px; color: var(--muted-fg); font-weight: 400; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; flex-shrink: 0; }
.lang-switch button { border: 0; background: transparent; padding: 5px 9px; font-size: 12px; font-weight: 600; color: var(--muted-fg); cursor: pointer; }
.lang-switch button.active { background: var(--ink); color: var(--on-ink); }
.menu-btn, .scrim { display: none; }

/* ================= Main / pages ================= */
.main { flex: 1; min-width: 0; height: 100vh; overflow: hidden; }
.page { display: none; height: 100%; overflow-y: auto; }
.page.active { display: block; animation: fadeIn .3s ease; }
#page-doc { overflow: hidden; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ================= Home ================= */
.home { max-width: 820px; margin: 0 auto; padding: 9vh 24px 48px; text-align: center; position: relative; }

.home-icon { display: inline-block; margin-bottom: 6px; }
.hello { font-family: var(--font-head); font-size: 52px; font-weight: 600; letter-spacing: -.5px; line-height: 1.2; }
.hello-sub { color: var(--muted-fg); font-size: 18px; margin: 10px 0 30px; }
.composer { background: var(--side); border-radius: 28px; padding: 18px 18px 12px; text-align: left; box-shadow: var(--shadow); border: 1px solid transparent; transition: border-color .2s, background .2s; }
.composer:focus-within { border-color: var(--border); background: var(--card); }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; font-size: 17px; line-height: 1.6; min-height: 56px; max-height: 220px; }
textarea::placeholder, input::placeholder { color: var(--soft-fg); }
.composer-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.doc-lang { display: flex; gap: 4px; flex-wrap: wrap; }
.doc-lang button, .quick button { border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; color: var(--muted-fg); cursor: pointer; }
.doc-lang button.active { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.quick button:hover { border-color: var(--emerald); color: var(--emerald-dark); }
.send { margin-left: auto; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; transition: opacity .2s; }
.send:disabled { opacity: .35; cursor: default; }
.starter-head { display: flex; justify-content: space-between; align-items: center; margin: 34px 0 12px; font-size: 16px; color: var(--muted-fg); }
.ghost-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--side); font-size: 14px; color: var(--muted-fg); }
.ghost-pill:hover { color: var(--fg); }
.starters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; text-align: left; }
.starter { background: var(--card); border: 1px solid var(--border-soft); border-radius: 18px; padding: 14px 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; text-align: left; transition: transform .15s, box-shadow .15s; min-height: 118px; }
.starter:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.starter small { font-size: 13px; color: var(--soft-fg); font-weight: 500; }
.starter b { font-size: 15.5px; font-weight: 600; line-height: 1.45; }
.all-link { display: inline-block; margin-top: 18px; color: var(--muted-fg); font-size: 15px; }
.all-link:hover { color: var(--fg); }

/* ================= Forms ================= */
.forms-wrap { max-width: 1080px; margin: 0 auto; padding: 44px 28px 60px; }
.page-title { font-family: var(--font-head); font-size: 44px; font-weight: 600; line-height: 1.2; }
.page-sub { color: var(--muted-fg); margin: 4px 0 18px; }
.search-box { display: flex; align-items: center; gap: 8px; max-width: 460px; padding: 10px 14px; border-radius: 12px; background: var(--muted); color: var(--muted-fg); margin-bottom: 26px; }
.search-box input { border: 0; outline: 0; flex: 1; background: transparent; color: var(--fg); }
.search-box:focus-within { box-shadow: var(--ring); }
.forms-grid { display: grid; grid-template-columns: 280px 1fr; gap: 26px; align-items: start; }
.cat-head { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.cats { display: flex; flex-direction: column; gap: 8px; }
.cat { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-radius: 18px; border: 1px solid var(--border-soft); background: var(--card); cursor: pointer; font-weight: 600; font-size: 16px; text-align: left; }
.cat em { font-style: normal; font-weight: 500; color: var(--soft-fg); font-size: 14px; }
.cat.active { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.cat.active em { color: var(--on-ink); opacity: .7; }
.cat-label { font-size: 14px; font-weight: 600; color: var(--muted-fg); margin: 2px 0 10px; }
.form-list { display: flex; flex-direction: column; gap: 12px; }
.form-card { background: var(--card); border: 1px solid var(--border-soft); border-radius: 18px; padding: 18px 20px; }
.form-card h3 { font-size: 17px; font-weight: 600; }
.form-card p { font-size: 14px; color: var(--muted-fg); margin-top: 6px; font-weight: 400; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { padding: 2px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--muted); color: var(--muted-fg); }
.badge-word { background: var(--muted); color: var(--muted-fg); }
.card-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.no-result { padding: 30px; text-align: center; color: var(--soft-fg); background: var(--card); border-radius: 18px; }

/* ================= Buttons ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-green { background: var(--ink); color: var(--on-ink); }
.btn-green:hover { background: var(--ink-hover); }
.btn-dark { background: var(--ink); color: var(--on-ink); }
.btn-dark:hover { background: var(--ink-hover); }
.btn-dark:disabled { opacity: .4; cursor: default; }
.btn-light { background: var(--card); border-color: var(--border); color: var(--fg); }
.btn-light:hover { background: var(--muted); }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--muted-fg); font-size: 15px; }
.icon-btn:hover { background: var(--muted); color: var(--fg); }

/* ================= Workspace ================= */
.ws { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(460px, 1.08fr); grid-template-rows: minmax(0, 1fr); height: 100%; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; height: 100%; background: var(--card); }
.chat-top { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--border-soft); min-height: 58px; }
.chat-top h2 { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; color: var(--muted-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { font-size: 14px; font-weight: 600; padding: 4px 14px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); white-space: nowrap; }
.status.ready { background: var(--emerald-soft); color: var(--emerald-dark); border: 1px solid var(--emerald-light); }
.top-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-fg); font-size: 15px; white-space: nowrap; }
.top-link:hover { color: var(--fg); }
.ws-tabs { display: none; }
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 26px 12px; display: flex; flex-direction: column; gap: 22px; }
.msg-user { align-self: flex-end; max-width: 82%; background: var(--muted); border-radius: 20px 20px 6px 20px; padding: 10px 18px; font-size: 16px; white-space: pre-wrap; box-shadow: var(--shadow-sm); }
.msg-bot { display: grid; grid-template-columns: 30px 1fr; gap: 0 10px; max-width: 100%; }
.bot-icon { width: 26px; height: 26px; color: var(--emerald); margin-top: 2px; grid-row: span 2; }
.bot-name { font-size: 13px; color: var(--muted-fg); grid-column: 2; }
.bot-body { grid-column: 2; font-size: 16px; display: flex; flex-direction: column; gap: 8px; }
.bot-body p { white-space: pre-wrap; }
.bot-body .lead { font-weight: 600; font-size: 17px; }
.bot-body .soft { color: var(--muted-fg); }
.bot-body ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.bot-body ul li::before { content: '•'; margin-right: 8px; color: var(--muted-fg); }
.bot-body .kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 15px; background: var(--side); border-radius: 12px; padding: 10px 14px; }
.bot-body .kv dt { color: var(--muted-fg); }
.bot-body .kv dd { font-weight: 600; word-break: break-word; }
.doc-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 18px; border: 2px solid var(--emerald-dark); background: var(--card); cursor: pointer; text-align: left; width: 100%; }
.doc-card .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.doc-card .t { flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.doc-card .t small { color: var(--emerald-dark); font-weight: 600; font-size: 14px; }
.doc-card .t b { font-weight: 600; font-size: 16px; }
.composer-chat { margin: 6px 22px 6px; padding: 12px 14px 10px; border-radius: 24px; }
.composer-chat textarea { font-size: 16px; min-height: 48px; }
.fineprint { text-align: center; font-size: 12.5px; color: var(--soft-fg); padding: 2px 16px 10px; font-weight: 400; }

/* Document pane */
.doc-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; background: var(--canvas); border-left: 1px solid var(--border-soft); overflow: hidden; }
.doc-pane { container-type: inline-size; }
.doc-head { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--border-soft); min-height: 58px; }
.doc-head b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@container (max-width: 760px) { .doc-head .made { display: none; } }
@container (max-width: 680px) { .doc-head .tb:not(.tb-dark) > span:not(.count) { display: none; } .doc-head .tb { padding: 7px 10px; } }
.doc-head > svg { color: var(--muted-fg); flex-shrink: 0; }
.doc-head b { font-size: 17px; font-weight: 600; }
.made { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; padding: 3px 12px; border-radius: 999px; background: var(--emerald-soft); color: var(--emerald-dark); border: 1px solid var(--emerald-light); }
.tb { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; white-space: nowrap; flex-shrink: 0; border-radius: 999px; border: 1px solid var(--border); background: var(--card); cursor: pointer; font-weight: 600; font-size: 14px; }
.tb:hover { background: var(--muted); }
.tb[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.tb-dark { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.tb-dark:hover { background: var(--ink-hover); }
.tb .count { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--emerald-soft); color: var(--emerald-dark); }
.tb .count:empty { display: none; }
.paper-scroll { flex: 1; min-height: 0; overflow: auto; padding: 18px 0; }
#preview .docx-wrapper { background: transparent !important; padding: 0 !important; display: flex; flex-direction: column; align-items: center; gap: 18px; }
#preview .docx-wrapper > section.docx { box-shadow: var(--page-shadow) !important; margin: 0 !important; }
/* Document defaults: keep the app's UI font/weight from leaking into the page (Word's base is 11pt, regular). */
#preview section.docx { font-weight: 400; font-size: 11pt; color: #000; }
#preview[data-doclang="th"] section.docx { font-family: 'TH SarabunPSK', sans-serif; }
#preview[data-doclang="en"] section.docx { font-family: 'Times New Roman', Times, serif; }
/* Tabbed header/footer lines laid out like Word's left-margin text + right tab stop. */
#preview p.hf-tabbed { display: flex !important; align-items: baseline; text-align: left !important; }
#preview p.hf-tabbed .hf-col { white-space: nowrap; }
#preview p.hf-tabbed .hf-col:nth-child(2) { flex: 1; }
/* The template's only body table (signatures) overrides TableGrid with no borders; docx-preview ignores that override. */
#preview.nda-doc article table, #preview.nda-doc article table td { border-color: transparent !important; border-style: none !important; }
.doc-foot { text-align: center; font-size: 12.5px; color: var(--soft-fg); padding: 8px 16px; background: var(--card); border-top: 1px solid var(--border-soft); font-weight: 400; }
.preview-msg { padding: 60px 20px; text-align: center; color: var(--soft-fg); }

/* Inline fields inside the rendered document */
.fld { cursor: pointer; border-radius: 3px; transition: background .15s; }
.fld.filled:hover { background: var(--emerald-light); box-shadow: 0 0 0 2px var(--emerald-light); }
.fld.empty { padding: 1px 6px 1px 4px; margin: 0 1px; border: 1.5px dashed var(--warn-line); background: var(--warn-soft);
  color: var(--warn); font-family: var(--font); font-size: .78em; font-weight: 500; font-style: normal; border-radius: 7px; white-space: nowrap; display: inline-block; line-height: 1.5; vertical-align: baseline; }
.fld.empty::before { content: ''; display: inline-block; width: .95em; height: .95em; margin-right: 3px; vertical-align: -.12em;
  background: currentColor; -webkit-mask: var(--pen) center / contain no-repeat; mask: var(--pen) center / contain no-repeat; }
.fld.empty:hover { background: #fbe6b8; }
.fld.flash { animation: fldFlash 1.6s ease; }
@keyframes fldFlash { 0%, 50% { background: var(--emerald-light); box-shadow: 0 0 0 3px var(--emerald-light); } 100% { box-shadow: none; } }
.sigslot { display: inline-block; vertical-align: bottom; cursor: pointer; width: 100%; min-width: 8em; height: 2.7em; position: relative; border-bottom: 1.3px dotted #222; text-align: center; }
.sigslot .sig-ask { position: absolute; left: 50%; bottom: .3em; transform: translateX(-50%); white-space: nowrap; font-family: var(--font); font-size: .7em; font-weight: 600;
  color: var(--emerald-dark); background: var(--emerald-soft); border: 1.5px dashed var(--emerald); padding: 0 9px; border-radius: 7px; line-height: 1.7; }
.sigslot:hover .sig-ask { background: var(--emerald-light); }
.sigslot img { height: 2.6em; max-width: 100%; object-fit: contain; display: block; margin: 0 auto; }
.sigslot.signed:hover { background: var(--emerald-soft); }

/* Edit drawer */
.edit-drawer { position: absolute; top: 58px; right: 0; bottom: 0; width: min(420px, 100%); background: var(--card); box-shadow: -16px 0 40px -24px rgba(16, 25, 36, .45);
  transform: translateX(105%); visibility: hidden; transition: transform .25s ease, visibility .25s; display: flex; flex-direction: column; z-index: 5; }
.edit-drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
#ndaForm { flex: 1; overflow-y: auto; padding: 4px 18px 24px; }
.group-title { font-size: 13px; font-weight: 600; color: var(--muted-fg); letter-spacing: .3px; margin: 16px 0 8px; display: flex; gap: 8px; align-items: baseline; }
.group-title small { font-weight: 400; color: var(--soft-fg); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span:first-child { font-size: 14px; font-weight: 600; }
.req { color: var(--danger); margin-left: 2px; }
.field input, .field textarea, .pop input, .pop textarea, .type-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); outline: 0; font-weight: 500; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .pop input:focus, .pop textarea:focus, .type-input:focus { border-color: var(--emerald); box-shadow: var(--ring); }
.field.missing input, .field.missing textarea { background: var(--warn-soft); border-color: var(--warn-line); border-style: dashed; }
.note { font-size: 12.5px; color: var(--muted-fg); font-weight: 400; }
.note:empty { display: none; }
.note.warn { color: var(--warn); }
.note.ok { color: var(--emerald-dark); }

/* Inline editor popover */
.pop { position: fixed; z-index: 60; width: min(360px, calc(100vw - 24px)); background: var(--card); border-radius: 16px; box-shadow: var(--shadow-pop); border: 1px solid var(--border-soft); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.pop[hidden] { display: none; }
.pop-label { font-size: 14px; font-weight: 600; }
.pop-note { font-size: 12.5px; color: var(--muted-fg); font-weight: 400; }
.pop-note:empty { display: none; }
.pop-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ================= Modals ================= */
.modal { border: 0; border-radius: 22px; padding: 0; margin: auto; width: min(640px, calc(100% - 24px)); box-shadow: var(--shadow-pop); background: var(--card); color: var(--fg); }
.modal::backdrop { background: var(--scrim); }
.modal-card { padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-family: var(--font-head); font-size: 22px; font-weight: 600; }
.modal-actions { display: flex; align-items: center; gap: 8px; }
.signers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.signer { border: 1px solid var(--border); background: var(--card); border-radius: 14px; padding: 8px 10px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.signer small { font-size: 12px; color: var(--muted-fg); font-weight: 500; }
.signer b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signer .st { font-size: 11.5px; font-weight: 600; color: var(--soft-fg); }
.signer .st.done { color: var(--emerald-dark); }
.signer.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.sign-modes { display: inline-flex; background: var(--muted); border-radius: 999px; padding: 3px; align-self: flex-start; }
.sign-modes button { border: 0; background: transparent; padding: 6px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted-fg); cursor: pointer; }
.sign-modes button.active { background: var(--card); color: var(--fg); box-shadow: var(--shadow-sm); }
.pad-wrap { position: relative; height: 210px; border-radius: 16px; border: 1px solid var(--border); background: var(--pad-bg); overflow: hidden; touch-action: none; }
#pad { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.pad-line { position: absolute; left: 8%; right: 8%; bottom: 52px; border-bottom: 1.5px dashed var(--border); pointer-events: none; }
.pad-hint { position: absolute; left: 0; right: 0; bottom: 20px; text-align: center; font-size: 13px; color: var(--soft-fg); pointer-events: none; font-weight: 400; }
.pad-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.inks { display: flex; gap: 8px; }
.ink { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--card); background: var(--ink); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.ink.active { box-shadow: 0 0 0 2px var(--emerald); }
.type-preview { height: 150px; margin-top: 10px; border-radius: 16px; border: 1px solid var(--border); background: var(--pad-bg); display: grid; place-items: center; overflow: hidden;
  font-family: 'Charmonman', cursive; font-size: 46px; color: var(--fg); padding: 0 16px; white-space: nowrap; }
.upload-zone { display: block; border: 2px dashed var(--border); border-radius: 16px; padding: 34px 20px; text-align: center; color: var(--muted-fg); cursor: pointer; background: var(--side); font-weight: 500; }
.upload-zone:hover { border-color: var(--emerald); color: var(--emerald-dark); }
.upload-preview { display: block; max-height: 140px; max-width: 100%; margin: 12px auto 0; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px; border-radius: 8px; }
.help-list { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.help-note { font-size: 14px; color: var(--muted-fg); background: var(--emerald-soft); padding: 10px 14px; border-radius: 12px; font-weight: 400; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--on-ink);
  padding: 10px 20px; border-radius: 999px; font-size: 14px; transition: all .25s; z-index: 80; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= Responsive ================= */
@media (max-width: 1180px) {
  .ws { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .ws-tabs { display: flex; gap: 4px; margin: 10px 22px 0; background: var(--muted); border-radius: 999px; padding: 3px; align-self: flex-start; }
  .ws-tabs button { border: 0; background: transparent; padding: 5px 18px; border-radius: 999px; font-weight: 600; cursor: pointer; color: var(--muted-fg); }
  .ws-tabs button.active { background: var(--card); color: var(--fg); box-shadow: var(--shadow-sm); }
  .ws[data-pane="chat"] .doc-pane { display: none; }
  .ws[data-pane="doc"] .chat-pane .thread, .ws[data-pane="doc"] .chat-pane .composer-chat, .ws[data-pane="doc"] .chat-pane .fineprint { display: none; }
  .ws[data-pane="doc"] { grid-template-rows: auto minmax(0, 1fr); }
  .ws[data-pane="doc"] .chat-pane { height: auto; padding-bottom: 10px; }
  .ws[data-pane="doc"] .doc-pane { border-left: 0; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 45; background: var(--scrim); }
  .menu-btn { display: grid; place-items: center; position: fixed; top: 9px; left: 10px; z-index: 40; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); cursor: pointer; }
  .chat-top { padding-left: 60px; }
  .chat-top .top-link span { display: none; }
  .home { padding: 70px 16px 40px; }
  .hello { font-size: 36px; }
  .hello-sub { font-size: 16px; }
  .starters { grid-template-columns: 1fr 1fr; }
  .forms-wrap { padding: 64px 16px 40px; }
  .page-title { font-size: 32px; }
  .forms-grid { grid-template-columns: 1fr; }
  .cats { flex-direction: row; overflow-x: auto; }
  .cat { flex-shrink: 0; }
  .thread { padding: 16px 16px 8px; }
  .composer-chat { margin: 6px 12px; }
  .doc-head .tb span:not(.count) { display: none; }
  .signers { grid-template-columns: repeat(2, 1fr); }
  .msg-user { max-width: 92%; }
}
@media (max-width: 480px) {
  .starters { grid-template-columns: 1fr; }
  .status { display: none; }
}

/* ================= Print: the document only ================= */
@media print {
  @page { size: A4; margin: 0; }
  html, body, .app, .main, .page, .ws, .doc-pane, .paper-scroll { height: auto !important; overflow: visible !important; display: block !important; background: #fff !important; }
  .sidebar, .menu-btn, .scrim, .chat-pane, .doc-head, .doc-foot, .edit-drawer, .toast, .pop, .page:not(#page-doc) { display: none !important; }
  .paper-scroll { padding: 0 !important; }
  #preview { zoom: 1 !important; }
  #preview .docx-wrapper { gap: 0 !important; }
  #preview .docx-wrapper > section.docx { box-shadow: none !important; break-after: page; }
}

/* ================= Multi-template additions ================= */
.home-hint { margin-top: 12px; text-align: left; font-size: 14px; color: var(--muted-fg); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-tpl { border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip-tpl:hover { border-color: var(--emerald); color: var(--emerald-dark); }
.badge-docx { background: var(--muted); color: var(--muted-fg); }
.badge-pdf { background: var(--muted); color: var(--muted-fg); }
.badge-xlsx { background: var(--muted); color: var(--muted-fg); }
.check-row, .yn { display: flex; gap: 14px; align-items: center; font-weight: 500; }
.yn label { display: inline-flex; gap: 6px; align-items: center; }
.field select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }

/* Word check boxes in the preview */
.chk { cursor: pointer; font-family: 'Segoe UI Symbol', 'Apple Symbols', sans-serif; font-size: 1.05em; padding: 0 2px; border-radius: 4px; color: var(--warn); background: var(--warn-soft); outline: 1.5px dashed var(--warn-line); }
.chk.on { color: var(--emerald-dark); background: var(--emerald-soft); outline-color: var(--emerald); }

/* Pages shared by the PDF and Excel engines */
#preview .pdf-doc, #preview .xl-doc { display: flex; flex-direction: column; align-items: center; gap: 18px; }
#preview .hd-page { position: relative; background: #fff; box-shadow: var(--page-shadow); flex-shrink: 0; }
.pdf-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pdf-layer { position: absolute; inset: 0; }
.pf { position: absolute; box-sizing: border-box; margin: 0; border: 1px solid transparent; border-radius: 3px; background: rgba(0, 164, 105, .07);
  font-family: 'TH SarabunPSK', sans-serif; color: #000; padding: 0 3px; line-height: 1.15; outline: 0; resize: none; overflow: hidden; }
.pf.empty, .pf-text:placeholder-shown { background: rgba(253, 241, 216, .85); border: 1px dashed var(--warn-line); }
.pf:hover { border-color: var(--emerald); }
.pf:focus { border: 1.5px solid var(--emerald); background: #fff; box-shadow: var(--ring); z-index: 2; }
.pf-text.multi { padding-top: 2px; white-space: pre-wrap; }
.pf-chk { cursor: pointer; display: grid; place-items: center; padding: 0; font-weight: 700; color: var(--emerald-dark); font-family: system-ui, sans-serif; font-size: 11px !important; background: rgba(253, 241, 216, .85); border: 1px dashed var(--warn-line); }
.pf-chk.on { background: var(--emerald-soft); border: 1.5px solid var(--emerald); }
.pf-sel { cursor: pointer; padding: 0 1px; appearance: auto; }
.pf-calc { display: flex; align-items: center; justify-content: flex-end; background: rgba(231, 236, 242, .55); border: 1px solid transparent; pointer-events: none; }
.pf-date { cursor: pointer; text-align: left; display: flex; align-items: center; white-space: nowrap; }
.pf-date.empty::before, .xi-date.empty::before { content: '📅'; font-size: 11px; opacity: .6; }
.pf-sig { position: absolute; border: 0; background: transparent; cursor: pointer; display: flex; align-items: flex-end; justify-content: center; padding: 0; z-index: 1; }
.pf-sig .sig-ask { font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--emerald-dark); background: var(--emerald-soft); border: 1.5px dashed var(--emerald); padding: 0 8px; border-radius: 7px; line-height: 1.7; white-space: nowrap; }
.pf-sig:hover .sig-ask { background: var(--emerald-light); }
.pf-sig img { max-height: 100%; max-width: 100%; object-fit: contain; }
.pf-sig.signed:hover { background: rgba(0, 164, 105, .08); border-radius: 6px; }

/* Excel sheets */
.xl-page { padding: 34px 0 0; }
.xl-tab { position: absolute; top: 8px; left: 10px; font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--muted-fg); background: var(--muted); padding: 2px 10px; border-radius: 999px; }
.xl-grid { position: relative; }
table.xl { border-collapse: collapse; table-layout: fixed; background: #fff; }
table.xl td { padding: 0 2px; overflow: visible; white-space: nowrap; line-height: 1.15; position: relative; }
table.xl td.wrap { white-space: normal; overflow: hidden; word-break: break-word; }
table.xl td .xl-v { position: relative; z-index: 1; }
table.xl td.xl-input { padding: 0; }
table.xl td.xl-input { background-image: linear-gradient(rgba(0, 164, 105, .06), rgba(0, 164, 105, .06)); cursor: text; }
table.xl td.xl-input.empty { background-image: linear-gradient(rgba(253, 241, 216, .75), rgba(253, 241, 216, .75)); }
table.xl td.xl-input:hover { outline: 1px solid var(--emerald); outline-offset: -1px; }
.xi-view { padding: 0 3px; pointer-events: none; }
.xi { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 18px; border: 1px solid transparent; background: transparent; font: inherit; color: inherit; padding: 0 3px; outline: 0; text-align: inherit; opacity: 0; cursor: text; }
.xi:focus { opacity: 1; border: 1.5px solid var(--emerald); background: #fff; box-shadow: var(--ring); z-index: 5; min-width: 220px; }
.xi-date { cursor: pointer; text-align: left; white-space: nowrap; }
.xl-img { position: absolute; pointer-events: none; z-index: 2; }
.xl-sig { z-index: 4; }

@media print {
  #preview .hd-page { box-shadow: none !important; break-after: page; }
  .pf, .xi { background: transparent !important; border-color: transparent !important; }
  .pf-sig .sig-ask, .xl-tab, .chk { display: none !important; }
}

/* ================= Account (Supabase) ================= */
.account { display: flex; }
.auth-btn { flex: 1; border: 1px solid var(--border); background: var(--card); border-radius: 12px; padding: 9px 12px; font-weight: 600; cursor: pointer; }
.auth-btn:hover { border-color: var(--emerald); color: var(--emerald-dark); }
.auth-btn[data-mode="out"] { font-weight: 500; color: var(--muted-fg); }
#whoName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#whoSub { cursor: default; }
.modal-sm { width: min(440px, calc(100% - 24px)); }

/* ================= Minimal pass ================= */
.sidebar { background: var(--side); border-right: 1px solid var(--border-soft); gap: 8px; }
.brand { font-weight: 600; font-size: 16px; letter-spacing: -.2px; }
.new-chat b { font-size: 15px; }
.side-card { border-radius: 10px; border-color: var(--border-soft); font-weight: 500; }
.side-card > svg:first-child { color: var(--muted-fg); }
.side-search { border-radius: 10px; }
.side-links a, .side-links button { font-weight: 500; font-size: 14px; }
.side-user { box-shadow: none; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--card); }
.avatar { width: 32px; height: 32px; font-size: 14px; }
.home { padding-top: 13vh; }
.home-icon { display: none; }
.hello { font-size: 40px; font-weight: 600; letter-spacing: -.8px; }
.hello-sub { font-size: 16px; margin-bottom: 26px; }
.composer { background: var(--card); border: 1px solid var(--border); box-shadow: none; border-radius: 16px; }
.composer:focus-within { border-color: var(--soft-fg); background: var(--card); }
.doc-lang button, .quick button { background: transparent; }
.send { border-radius: 10px; width: 36px; height: 36px; }
.starter-head { font-size: 14px; }
.ghost-pill { background: transparent; border: 1px solid var(--border); }
.starter { border-radius: 12px; min-height: 92px; border-color: var(--border); box-shadow: none; }
.starter:hover { transform: none; box-shadow: none; border-color: var(--soft-fg); }
.starter b { font-weight: 500; font-size: 15px; }
.page-title { font-size: 34px; letter-spacing: -.6px; }
.search-box { background: var(--card); border: 1px solid var(--border); }
.cat, .form-card { border-radius: 12px; border-color: var(--border); }
.form-card h3 { font-weight: 500; }
.btn { border-radius: 10px; }
.tb { border-radius: 10px; }
.chat-top, .doc-head { background: var(--card); }
.chat-top h2 { font-weight: 500; font-size: 15px; }
.status { font-weight: 500; font-size: 13px; border: 1px solid transparent; }
.made { border: 0; font-weight: 500; }
.msg-user { box-shadow: none; border-radius: 16px 16px 4px 16px; }
.doc-card { border: 1px solid var(--border); border-radius: 12px; }
.doc-card .t small { color: var(--muted-fg); font-weight: 500; }
.bot-icon { color: var(--muted-fg); }
.modal { border-radius: 16px; border: 1px solid var(--border-soft); }
.signer.active { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }
.help-note { background: var(--muted); }
.theme-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted-fg); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.theme-btn:hover { color: var(--fg); border-color: var(--soft-fg); }
.theme-btn svg { display: none; }
:root:not([data-theme]) .theme-btn .ic-system, :root[data-theme="light"] .theme-btn .ic-light, :root[data-theme="dark"] .theme-btn .ic-dark { display: block; }
.side-user { flex-wrap: wrap; }
.side-user .who { min-width: 120px; }

/* ================= Admin ================= */
.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 44px 28px 80px; }
.admin-empty { padding: 80px 20px; text-align: center; color: var(--muted-fg); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--muted); margin-bottom: 18px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--muted-fg); font-weight: 500; }
.seg button.active { background: var(--card); color: var(--fg); box-shadow: var(--shadow-sm); }
.seg.small { margin-bottom: 8px; }
.admin-table, .df-table { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.at-head, .at-row { display: grid; grid-template-columns: 1fr 80px 90px 80px 170px; gap: 12px; align-items: center; padding: 10px 16px; }
.at-head, .df-head { font-size: 12px; color: var(--muted-fg); background: var(--muted); font-weight: 500; }
.at-row + .at-row, .df-row + .df-row { border-top: 1px solid var(--border-soft); }
.at-row.is-hidden { opacity: .55; }
.at-title { display: flex; flex-direction: column; min-width: 0; }
.at-title b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-title small, .muted { color: var(--muted-fg); font-size: 13px; }
.at-actions { display: flex; gap: 6px; justify-content: flex-end; }
.btn-danger { background: transparent; border-color: var(--border); color: var(--danger); }
.btn-danger:hover { background: var(--muted); }
.admin-card { border: 1px solid var(--border); border-radius: 12px; background: var(--card); padding: 18px 20px; margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.admin-card h3 { font-size: 15px; font-weight: 600; }
.admin-card .field select, .admin-card .field input[type=file] { padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.admin-actions { display: flex; justify-content: flex-end; gap: 8px; }
.admin-actions.sticky { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); margin-top: 8px; }
.admin-warn { color: var(--warn); background: var(--warn-soft); padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.df-head, .df-row { display: grid; grid-template-columns: 1fr 110px 120px 44px 36px; gap: 10px; align-items: center; padding: 8px 12px; }
.df-row input:not([type=checkbox]), .df-row select { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.df-row input[type=checkbox] { width: 18px; height: 18px; justify-self: center; accent-color: var(--fg); }
.admin-inline { display: flex; gap: 8px; }
.admin-inline input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.admin-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 14px; overflow-x: auto; padding: 8px; background: var(--canvas); border-radius: 10px; }
.place-page { position: relative; background: #fff; cursor: crosshair; flex-shrink: 0; box-shadow: var(--page-shadow); }
.place-page canvas { position: absolute; inset: 0; }
.place-box { position: absolute; border: 1.5px solid; border-radius: 3px; pointer-events: none; }
.place-box.acro { border-color: rgba(113, 113, 122, .55); background: rgba(113, 113, 122, .08); }
.place-box.ov { border-color: #d99a1e; background: rgba(253, 241, 216, .6); }
.place-box.sig { border-color: #10a36e; background: rgba(16, 163, 110, .12); }
@media (max-width: 760px) {
  .at-head { display: none; }
  .at-row { grid-template-columns: 1fr auto; }
  .at-row > span:nth-child(2), .at-row > span:nth-child(3), .at-row > span:nth-child(4) { display: none; }
  .df-head { display: none; }
  .df-row { grid-template-columns: 1fr 1fr; }
}

/* ---- Chat-style composer: flat, no hover/focus highlight, auto-growing input ---- */
.composer, .composer:hover, .composer:focus-within { background: var(--card); border: 1px solid var(--border); box-shadow: none; border-radius: 24px; transition: none; }
.composer { padding: 12px 12px 10px 18px; }
.composer textarea, .composer textarea:focus, .composer textarea:focus-visible { box-shadow: none; outline: 0; }
.composer textarea { min-height: 28px; max-height: 200px; padding: 4px 0; font-size: 16px; line-height: 1.6; overflow-y: auto; }
.composer-chat textarea { min-height: 28px; }
.composer-bar { margin-top: 6px; }
.composer .doc-lang button, .composer .quick button, .composer .doc-lang button:hover, .composer .quick button:hover { border-color: var(--border); color: var(--muted-fg); transition: none; }
.composer .doc-lang button.active, .composer .doc-lang button.active:hover { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.composer .doc-lang button:focus-visible, .composer .quick button:focus-visible { box-shadow: none; }
.send, .send:hover { width: 34px; height: 34px; border-radius: 50%; }
.send:focus-visible { box-shadow: none; }

/* ---- Admin password gate ---- */
.admin-gate { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.admin-gate h1 { font-size: 26px; font-weight: 600; letter-spacing: -.4px; }
.admin-gate p { color: var(--muted-fg); margin: 6px 0 22px; font-size: 14px; }
.admin-gate form { display: flex; gap: 8px; }
.admin-gate input { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; background: var(--card); outline: 0; }
.admin-gate input:focus { border-color: var(--soft-fg); box-shadow: none; }
.admin-gate .err { color: #dc2626; font-size: 13px; min-height: 20px; margin-top: 10px; }
.admin-gate .muted-link { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--muted-fg); background: none; border: 0; cursor: pointer; }

/* ---- Composer type scale: match body text (15px) ---- */
.composer { padding: 10px 10px 8px 16px; }
.composer textarea, .composer-chat textarea { font-size: 15px; line-height: 1.6; min-height: 26px; padding: 3px 0; }
.composer .doc-lang button, .composer .quick button { font-size: 12.5px; padding: 3px 11px; }
.send, .send:hover { width: 32px; height: 32px; }
.send svg { width: 16px; height: 16px; }
.msg-user { font-size: 15px; }
.bot-body { font-size: 15px; }
.bot-body .lead { font-size: 15.5px; }
.bot-body .kv { font-size: 14px; }
.doc-card .t b { font-size: 15px; }

/* ---- Microsoft 365 sign-in ---- */
.ms-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 44px; margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--fg); font-weight: 500; cursor: pointer; }
.ms-btn:hover { border-color: var(--soft-fg); }
.ms-btn:disabled { opacity: .6; cursor: default; }
