/* VYRAETH web client — flat, neutral, no external assets. */
:root {
  --bg: #f8f7f4;
  --panel: #f0eee9;
  --surface: #ffffff;
  --hover: #e7e4dc;
  --border: #e2dfd7;
  --text: #1f1e1b;
  --muted: #6c6961;
  --accent: #5b5bd6;
  --accent-ink: #4a4ac0;
  --on-accent: #ffffff;
  --user: #ebe8e0;
  --code-bg: #f2f0ea;
  --danger: #c2412d;
  --ok: #2f7d4f;
  --warn: #9a6b12;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 10, .06), 0 6px 18px rgba(20, 20, 10, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] {
  --bg: #1c1c1b; --panel: #161615; --surface: #262625; --hover: #2f2f2d; --border: #363633;
  --text: #ecebe6; --muted: #a29f95; --accent-ink: #a5a5f5; --user: #2c2c2a; --code-bg: #1a1a19;
  --danger: #ee7d69; --ok: #6cc28b; --warn: #e0b45c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1b; --panel: #161615; --surface: #262625; --hover: #2f2f2d; --border: #363633;
    --text: #ecebe6; --muted: #a29f95; --accent-ink: #a5a5f5; --user: #2c2c2a; --code-bg: #1a1a19;
    --danger: #ee7d69; --ok: #6cc28b; --warn: #e0b45c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.logo { color: var(--accent); flex: none; }
.logo.sm { width: 24px; height: 24px; }
.logo.lg { width: 44px; height: 44px; }
.logo.xl { width: 40px; height: 40px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 500;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-secondary:hover { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--text); padding: 7px 10px; }
.btn-ghost:hover { background: var(--hover); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-ink); text-decoration: underline; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-content: center; justify-items: center; gap: 18px; padding: 24px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 32px 28px 26px; box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { font-size: 22px; font-weight: 600; margin: 14px 0 4px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 20px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.login-card input {
  width: 100%; padding: 10px 12px; margin-bottom: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
}
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-error { color: var(--danger); margin: 12px 0 0 !important; font-size: 13.5px; }
.login-note { color: var(--muted); font-size: 12.5px; margin: 14px 0 0 !important; }
.login-foot { color: var(--muted); font-size: 12.5px; margin: 0; }

/* ---------- app shell ---------- */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 288px; flex: none; display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border-right: 1px solid var(--border); padding: 10px 10px 8px;
  transition: margin-left .2s ease;
}
.app.collapsed .sidebar { margin-left: -288px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 8px 6px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.side-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 10px; background: transparent;
}
.side-btn:hover { background: var(--hover); }
.side-new { font-weight: 500; }
.side-new .i { color: var(--accent-ink); }
.search {
  display: flex; align-items: center; gap: 8px; margin: 2px 0 4px; padding: 0 10px; height: 36px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.search input::-webkit-search-cancel-button { display: none; }
kbd { font: 11px var(--font); padding: 2px 5px; border: 1px solid var(--border); border-radius: 5px; color: var(--muted); }

.chat-list { flex: 1; overflow-y: auto; overflow-x: hidden; margin: 6px -4px 0 0; padding-right: 4px; }
.group-label { padding: 12px 10px 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 10px; }
.chat-item:hover, .chat-item.active { background: var(--hover); }
.chat-link {
  flex: 1; min-width: 0; text-align: left; padding: 7px 10px; border: 0; background: transparent;
  display: flex; flex-direction: column;
}
.chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-snip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.chat-more { opacity: 0; margin-right: 4px; width: 28px; height: 28px; }
.chat-item:hover .chat-more, .chat-item.active .chat-more, .chat-more:focus-visible { opacity: 1; }
.chat-rename { flex: 1; min-width: 0; margin: 3px 6px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--accent); background: var(--surface); }
.list-empty { padding: 14px 10px; color: var(--muted); font-size: 13.5px; }

.side-foot { position: relative; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.user-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: 10px; background: transparent; text-align: left; }
.user-btn:hover { background: var(--hover); }
.avatar { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13px; }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 8px; height: 52px; flex: none; padding: 0 12px; }
#btn-open { display: none; }
.app.collapsed #btn-open { display: inline-grid; }
.top-title { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- chat ---------- */
.messages { flex: 1; overflow-y: auto; }
.thread { max-width: 760px; margin: 0 auto; padding: 8px 20px 12px; }
.msg { display: flex; gap: 12px; margin: 0 0 24px; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 86%; background: var(--user); padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.utext { white-space: pre-wrap; }
.msg-ai-mark { width: 28px; height: 28px; margin-top: 2px; }
.abody { flex: 1; min-width: 0; }
.msg-actions { display: flex; gap: 2px; margin: 6px 0 0 -8px; }
.msg-actions .btn-ghost { font-size: 13px; color: var(--muted); padding: 4px 8px; }
.msg-actions .btn-ghost:hover { color: var(--text); }
.msg-error { margin-top: 8px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--danger); color: var(--danger); font-size: 14px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.empty { max-width: 720px; margin: 0 auto; padding: 12vh 20px 24px; text-align: center; }
.greeting { font-size: 30px; font-weight: 500; letter-spacing: -.015em; margin: 14px 0 26px; }
.slot-empty { text-align: left; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 13.5px; }
.chip:hover { background: var(--hover); color: var(--text); }

.composer-wrap { max-width: 760px; width: 100%; margin: 0 auto; padding: 0 20px 14px; flex: none; }
.view-chat.is-empty .composer-wrap { display: none; }
.composer {
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px;
  padding: 12px 12px 8px 16px; box-shadow: var(--shadow); text-align: left;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.composer textarea {
  display: block; width: 100%; min-height: 26px; max-height: 240px; resize: none; border: 0; outline: 0;
  background: transparent; padding: 2px 0 6px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-row { display: flex; align-items: center; gap: 6px; }
.model { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 6px 4px; border-radius: 8px; }
.model:hover { background: var(--hover); color: var(--text); }
.send { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: var(--on-accent); }
.send:disabled { opacity: .3; cursor: default; }
.disclaimer { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attach {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px; padding: 6px 8px 6px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 13px;
}
.attach img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.attach .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach .size { color: var(--muted); font-size: 12px; }
.attach button { width: 22px; height: 22px; }
.bubble .attach-list { margin: 0 0 8px; }
.bubble .attach { background: var(--surface); }

.dropzone { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 82%, transparent); }
.dropzone > div { padding: 36px 56px; border: 2px dashed var(--accent); border-radius: 20px; font-size: 18px; font-weight: 500; color: var(--accent-ink); background: var(--surface); }

/* ---------- markdown ---------- */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { line-height: 1.3; margin: 20px 0 8px; font-weight: 600; letter-spacing: -.01em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; }
.md h4, .md h5, .md h6 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 1.5em; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md a { color: var(--accent-ink); text-underline-offset: 2px; }
.md blockquote { margin: 0 0 12px; padding: 2px 0 2px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.md code { font-family: var(--mono); font-size: .9em; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.code { margin: 0 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--code-bg); overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 8px 5px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.copy-code { border: 0; background: transparent; color: var(--muted); padding: 3px 8px; border-radius: 6px; font-size: 12px; }
.copy-code:hover { background: var(--hover); color: var(--text); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; }
.tbl { overflow-x: auto; margin: 0 0 14px; }
.md table { border-collapse: collapse; min-width: 60%; font-size: .95em; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.md th { background: var(--code-bg); font-weight: 600; }
.md .al-c { text-align: center; } .md .al-r { text-align: right; }

/* ---------- documents ---------- */
.view-docs { overflow-y: auto; }
.docs-inner { width: 100%; max-width: 900px; margin: 0 auto; padding: 8px 24px 40px; }
.docs-inner h2 { font-size: 26px; font-weight: 500; letter-spacing: -.01em; margin: 6px 0 4px; }
.banner { margin: 14px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--code-bg); color: var(--muted); font-size: 13.5px; }
.tabs { display: flex; gap: 4px; margin: 22px 0 14px; border-bottom: 1px solid var(--border); }
.tab { padding: 9px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--muted); font-weight: 500; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.doc-drop {
  display: flex; align-items: center; gap: 14px; padding: 18px; margin-bottom: 14px; border: 1.5px dashed var(--border);
  border-radius: 14px; color: var(--muted);
}
.doc-drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.doc-drop.disabled { opacity: .55; }
.doc-drop .i { width: 24px; height: 24px; }
.doc-list { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.doc-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 90px 110px 36px; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--border); }
.doc-row:first-child { border-top: 0; }
.doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { color: var(--muted); font-size: 13px; }
.pill { display: inline-flex; align-items: center; justify-self: start; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--code-bg); color: var(--muted); }
.pill.indexed { color: var(--ok); }
.pill.processing, .pill.uploading { color: var(--warn); }
.pill.failed { color: var(--danger); }
.bar { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.doc-empty { padding: 26px; text-align: center; color: var(--muted); }
@media (max-width: 640px) { .doc-row { grid-template-columns: 24px minmax(0, 1fr) 100px 36px; } .doc-row .doc-size { display: none; } }

/* ---------- admin center ---------- */
.invite { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 130px auto; gap: 8px; }
.invite input, .invite select, .people-tools input, .field input, .field select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 0;
}
.invite input:focus, .invite select:focus, .people-tools input:focus, .field input:focus, .field select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.invite-note { margin: 8px 0 16px; }
.people-tools { margin: 0 0 10px; }
.people-tools input { width: 100%; max-width: 320px; }
.people-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 120px 96px 36px; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.people-row:first-child { border-top: 0; }
.people-row.off { opacity: .6; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--user); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.people-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.role-static { color: var(--muted); font-size: 13.5px; padding: 0 8px; }
.people-more { margin-top: 12px; text-align: center; }
.card { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 18px 20px; margin-bottom: 14px; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.card p { margin: 6px 0; }
.steps { margin: 10px 0 14px; padding-left: 20px; color: var(--text); }
.steps li { margin: 7px 0; }
.copy-line { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.copy-line code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); padding: 7px 10px; border-radius: 8px; }
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.field input, .field select { width: 100%; }
.field-row { display: flex; gap: 8px; align-items: flex-end; }
.field-row .field { flex: 1; margin: 12px 0 0; }
.form-error { color: var(--danger); font-size: 13.5px; margin: 8px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; margin: 10px 0; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .invite { grid-template-columns: 1fr 1fr; }
  .invite input:first-child { grid-column: 1 / -1; }
  .people-row { grid-template-columns: 30px minmax(0, 1fr) 36px; }
  .people-row .role-select, .people-row .role-static, .people-row .pill { grid-column: 2 / 3; justify-self: start; }
  .kv { grid-template-columns: 1fr; }
}

/* ---------- menus, toast ---------- */
.menu {
  position: fixed; z-index: 70; min-width: 210px; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-item .i { color: var(--muted); }
.menu-item.danger .i { color: var(--danger); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80; max-width: min(92vw, 520px);
  padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
}

/* ---------- mobile ---------- */
.scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .38); }
@media (max-width: 820px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(86vw, 310px); margin-left: calc(-1 * min(86vw, 310px)); }
  .app.collapsed .sidebar { margin-left: calc(-1 * min(86vw, 310px)); }
  .app.side-open .sidebar { margin-left: 0; box-shadow: var(--shadow); }
  #btn-open { display: inline-grid; }
  .greeting { font-size: 24px; }
  .empty { padding-top: 7vh; }
  .chat-more { opacity: 1; }
}
/* Large screens: bigger type, wider reading column and sidebar. */
@media (min-width: 1440px) {
  body { font-size: 16px; }
  .sidebar { width: 312px; }
  .app.collapsed .sidebar { margin-left: -312px; }
  .thread, .composer-wrap { max-width: 820px; }
  .empty { max-width: 780px; }
  .docs-inner { max-width: 1000px; }
}
@media (min-width: 1920px) {
  body { font-size: 17px; }
  .sidebar { width: 340px; }
  .app.collapsed .sidebar { margin-left: -340px; }
  .thread, .composer-wrap { max-width: 900px; }
  .empty { max-width: 860px; }
  .docs-inner { max-width: 1100px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }


/* ---------- documents, tables, edit, overlays ---------- */
:root[data-size="s"] body { font-size: 14px; }
:root[data-size="l"] body { font-size: 17px; }
.code-acts { display: inline-flex; gap: 2px; }
.parts { min-width: 0; }
.tbl-wrap { position: relative; margin: 0 0 14px; }
.tbl-wrap .tbl { margin: 0; }
.tbl-tools { display: flex; gap: 2px; justify-content: flex-end; margin-bottom: 3px; opacity: 0; transition: opacity .12s; }
.tbl-wrap:hover .tbl-tools, .tbl-wrap:focus-within .tbl-tools { opacity: 1; }
@media (hover: none) { .tbl-tools { opacity: 1; } }
.tbl-act { border: 0; background: transparent; color: var(--muted); padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.tbl-act:hover { background: var(--hover); color: var(--text); }
.doc-card { display: flex; align-items: center; margin: 4px 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); max-width: 520px; }
.doc-card:hover { border-color: var(--accent); }
.doc-card-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px; border: 0; background: transparent; text-align: left; color: var(--text); border-radius: 12px; }
.doc-card-ic { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--code-bg); color: var(--accent-ink); }
.doc-card-meta { display: flex; flex-direction: column; min-width: 0; }
.doc-card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card-sub { font-size: 12.5px; color: var(--muted); }
.doc-card.writing .doc-card-sub { color: var(--accent-ink); }
.doc-card.writing .doc-card-ic { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.doc-card-dl { margin-right: 8px; }
.docpanel { width: min(46vw, 720px); flex: none; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); min-width: 0; }
.docpanel[hidden] { display: none; }
.dp-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.dp-titlewrap { flex: 1; min-width: 0; }
.dp-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-ver { max-width: 150px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 13px; }
.dp-head .btn:disabled { opacity: .5; }
.dp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dp-view { flex: 1; overflow-y: auto; padding: 28px clamp(18px, 4vw, 44px) 40px; }
.dp-view[hidden], .dp-editor[hidden] { display: none; }
.dp-editor { flex: 1; width: 100%; border: 0; outline: 0; resize: none; padding: 22px clamp(18px, 4vw, 44px); background: var(--surface); color: var(--text); font: 14px/1.6 var(--mono); }
.dp-editbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.dp-editbar[hidden] { display: none; }
@media (max-width: 1100px) { .docpanel { width: min(52vw, 560px); } }
@media (max-width: 820px) { .docpanel { position: fixed; inset: 0; width: auto; z-index: 40; border: 0; } .dp-head .btn span { display: none; } }
.user-actions { justify-content: flex-end; opacity: 0; transition: opacity .12s; margin-right: -4px; }
.msg.user:hover .user-actions, .msg.user:focus-within .user-actions { opacity: 1; }
@media (hover: none) { .user-actions { opacity: 1; } }
.msg.user { flex-direction: column; align-items: flex-end; }
.edit-box { width: min(100%, 640px); border: 1px solid var(--accent); border-radius: 14px; background: var(--surface); padding: 10px; }
.edit-input { width: 100%; border: 0; outline: 0; resize: vertical; background: transparent; color: var(--text); font: inherit; min-height: 80px; }
.edit-bar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0, 0, 0, .4); padding: 16px; }
.overlay[hidden] { display: none; }
.overlay-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; box-shadow: var(--shadow); }
.overlay-card h3 { margin: 0 0 12px; }
.sc-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.overlay-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

/* ---------- print (Save as PDF) ---------- */
.print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing { background: #fff; color: #111; font-size: 12pt; }
  body.printing #print-root { display: block; }
  .print-root h1.pr-title { font-size: 20pt; margin: 0 0 14pt; }
  .print-root .pr-msg { margin: 0 0 14pt; break-inside: auto; }
  .print-root .pr-role { font-size: 9pt; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #555; margin: 0 0 3pt; }
  .print-root .pr-user { white-space: pre-wrap; }
  .print-root .code, .print-root .md code { background: #f3f3f3; }
  .print-root .code { break-inside: avoid; border-color: #ddd; }
  .print-root .copy-code, .print-root .dl-code, .print-root .tbl-tools { display: none; }
  .print-root a { color: #111; }
}
.msg.user { gap: 0; margin-bottom: 20px; }
.user-actions { margin: 2px -4px 0 0; }
.dp-view .tbl-tools { display: none; }
.dp-view .tbl-wrap { margin-bottom: 18px; }

.plan-pill { margin: 0 4px 8px; padding: 7px 10px; border-radius: 10px; background: var(--hover); color: var(--muted, #6b6b6b); font-size: 12px; line-height: 1.35; }
.plan-pill.warn { background: #fdf0d8; color: #7a4b00; }
@media (prefers-color-scheme: dark) { .plan-pill.warn { background: #3a2c12; color: #f0c776; } }

.msg-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.msg-sources-label { font-size: 12px; color: var(--muted, #6b6b6b); margin-right: 2px; }
.src-chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--hover); border: 1px solid var(--line, rgba(0,0,0,.08)); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-notice { margin-top: 8px; padding: 7px 11px; border-radius: 10px; background: #fdf0d8; color: #7a4b00; font-size: 13px; }
@media (prefers-color-scheme: dark) { .msg-notice { background: #3a2c12; color: #f0c776; } }

.about-help{margin:0 0 10px;color:var(--muted,#666);font-size:14px}.about-text{width:100%;box-sizing:border-box;padding:10px;border:1px solid var(--border,#ccc);border-radius:8px;font:inherit;background:transparent;color:inherit;resize:vertical}.about-count{text-align:right;font-size:12px;color:var(--muted,#666);margin-top:4px}

.doc-batch{margin:10px 0;padding:10px 12px;border:1px solid var(--line,#e3e2dc);border-radius:10px;background:var(--panel,transparent);font-size:14px}.doc-batch .small{margin-top:4px;opacity:.8}.doc-batch .link-btn{margin-top:6px}.pill.queued{color:var(--muted,#666)}

.radio-row{display:flex;gap:10px;align-items:flex-start;padding:10px 0;cursor:pointer}.radio-row input{margin-top:4px}

.terms-row { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 6px; font-size: 14px; }
.terms-row input { margin-top: 3px; flex: none; }
#terms-gate .overlay-foot { gap: 8px; }

.usage-plan { margin: 0 0 14px; font-size: 15px; }
.meter-row { margin: 14px 0; }
.meter-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 6px; }
.meter-bar { height: 10px; border-radius: 999px; background: var(--hover); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.meter-fill.warn { background: var(--warn); }
.meter-fill.full { background: var(--danger); }
.meter-note { margin-top: 5px; }
.usage-help { margin: 18px 0 0; }
.usage-alert { margin: 14px 0 4px; padding: 10px 12px; border-radius: 10px; background: #fdf0d8; color: #7a4b00; font-size: 14px; }
.usage-alert.full { background: #fbe3df; color: #8a2a1b; }
@media (prefers-color-scheme: dark) { .usage-alert { background: #3a2c12; color: #f0c776; } .usage-alert.full { background: #3c1f1a; color: #f4a496; } }
.usage-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
.usage-table th, .usage-table td { text-align: left; padding: 8px 4px; border-top: 1px solid var(--border); }
.usage-table th { font-weight: 600; color: var(--muted); border-top: 0; }

/* download card under an answer */
.file-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 2px; padding: 12px 14px; border: 1px solid var(--border, #e2dfd7); border-radius: 12px; background: var(--surface, #fff); }
.file-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); flex: none; }
.file-ic svg { width: 20px; height: 20px; }
.file-meta { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.file-meta strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.chart-wrap { margin: 0 0 14px; max-width: 640px; }
.diagram-wrap { max-width: 720px; }
.diagram-wrap .vy-diagram { display: block; width: 100%; height: auto; color: var(--text); }
.chart-wrap .vy-chart { display: block; width: 100%; height: auto; color: var(--text); }

.import-step { display: flex; align-items: center; gap: 10px; margin: 20px 0 8px; }
.import-step h4 { margin: 0; font-size: 15px; }
.step-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent, #5b5bd6); color: #fff; font-size: 13px; font-weight: 600; }
.import-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.import-warn { color: var(--danger, #b42318); margin: 8px 0; }
.cmd-box { border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; overflow: hidden; }
.cmd-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 12px; background: var(--code-bg); font-size: 13px; }
.cmd { margin: 0; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.import-sample { margin: 6px 0 6px 18px; padding: 0; font-size: 13px; }
.consent-note { margin: 12px 0; font-size: 14px; } .consent-note p { margin: 0 0 6px; } .consent-note a { font-weight: 600; }

.doc-access{display:flex;gap:10px;align-items:center;margin:10px 0;font-size:14px;color:var(--muted)}.doc-access select{max-width:260px}
.doc-access-label{color:var(--muted);font-size:13px}.link-btn.small{font-size:13px;margin-left:8px}
.chooser-list{display:flex;flex-direction:column;gap:2px;max-height:300px;overflow:auto;margin:6px 0 4px}.chooser-list label{display:flex;gap:10px;align-items:center;padding:7px 4px;cursor:pointer}
#chooser .overlay-foot{gap:8px}
.group-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;padding:10px 0;border-top:1px solid var(--border)}.group-row:first-of-type{border-top:0}.group-row .grow{flex:1;min-width:140px}.group-row .gname{font-weight:600}
.group-members{flex-basis:100%;margin:2px 0 2px 2px;font-size:13px;color:var(--muted)}.group-add{display:flex;gap:8px;margin:12px 0}.group-add input{flex:1;min-width:0}
.topic{border:1px solid var(--border);border-radius:12px;padding:12px;margin:10px 0}.topic label{display:block;font-size:13px;color:var(--muted);margin:8px 0 4px}.topic input,.topic textarea{width:100%}.topic .topic-head{display:flex;justify-content:space-between;align-items:center;gap:8px}
.chips-row{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}.chip-btn{border:1px solid var(--border);background:transparent;color:inherit;border-radius:999px;padding:4px 12px;font-size:13px;cursor:pointer}.chip-btn:hover{background:var(--code-bg)}
.guard-status{margin:10px 0;font-size:14px}.guard-status.warn{color:var(--warn)}

.sp-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 10px 0 6px; }
.sp-list { border: 1px solid var(--line, #d8dde6); border-radius: 10px; max-height: 320px; overflow: auto; }
.sp-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line, #e5e8ee); }
.sp-row:last-child { border-bottom: 0; }
.sp-name { overflow-wrap: anywhere; }
.sp-setup { margin: 10px 0 14px; }
.sp-setup summary { cursor: pointer; font-weight: 600; }
#sp-card .import-row { margin: 10px 0; }

/* company profile, letterheads, setup prompt */
.menu-heading{padding:8px 10px 4px;font-size:12px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}
.menu-check{display:inline-block;width:16px;text-align:center;color:var(--accent)}
.setup-banner{margin:22px auto 0;max-width:520px;padding:14px 16px;border:1px solid var(--border);border-radius:14px;background:var(--surface);text-align:left}
.setup-banner p{margin:4px 0 10px}.setup-actions{display:flex;gap:8px;flex-wrap:wrap}
.profile-assist{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0 6px}.profile-assist input{flex:1 1 240px;min-width:0}
.profile-status{min-height:20px;margin:2px 0 8px}
.field{display:block;margin:12px 0}.field-label{display:block;font-weight:600;margin-bottom:4px}
.field input,.field textarea{width:100%;box-sizing:border-box;padding:9px 11px;border:1px solid var(--border);border-radius:10px;background:var(--bg);color:inherit;font:inherit;resize:vertical}
.field input:focus,.field textarea:focus,.profile-assist input:focus{outline:2px solid var(--accent);outline-offset:1px}
.profile-assist input{padding:9px 11px;border:1px solid var(--border);border-radius:10px;background:var(--bg);color:inherit;font:inherit}
.profile-actions{margin-top:14px}
.lh-row{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:12px 0;border-top:1px solid var(--border)}
.lh-name{display:flex;align-items:center;gap:8px}.lh-acts{display:flex;gap:4px;flex-wrap:wrap}
.lh-upload{margin-top:14px;padding-top:14px;border-top:1px solid var(--border)}
.btn.danger{color:var(--danger)}

.tabs{flex-wrap:wrap}.tab{white-space:nowrap}

.dp-ask { border-top: 1px solid var(--border); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.dp-ask[hidden] { display: none; }
.dp-ask-row { display: flex; gap: 8px; }
.dp-ask-input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg, var(--surface)); color: inherit; font: inherit; }
.dp-ask-input:focus { outline: 2px solid var(--accent, #5b5bd6); outline-offset: 1px; }
.dp-ask-sel { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted, #666); background: var(--hover, rgba(0,0,0,.05)); border-radius: 8px; padding: 4px 6px 4px 10px; }
.dp-ask-sel[hidden] { display: none; }
.dp-ask-sel span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#btn-web.on { background: var(--accent-soft, rgba(91,91,214,.14)); color: var(--accent, #5b5bd6); }
.msg-web { margin-top: 8px; }
.src-link { text-decoration: none; color: inherit; }
.src-link:hover { background: var(--hover-strong, rgba(0,0,0,.09)); text-decoration: underline; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; }
.code-sample { background: var(--hover, rgba(0,0,0,.05)); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; user-select: all; }
#web-domains { width: 100%; box-sizing: border-box; font: inherit; padding: 8px 10px; border: 1px solid var(--border, rgba(0,0,0,.15)); border-radius: 10px; background: transparent; color: inherit; }
.disclaimer-home { margin-top: 22px; }

.dp-view.dp-styled { background: #e9e7e2; padding: 18px; }
.dp-page-wrap { margin: 0 auto; box-shadow: 0 2px 14px rgba(0,0,0,.18); background: #fff; overflow: hidden; }
.dp-page { display: block; border: 0; background: #fff; }
.dp-designing { padding: 40px 12px; text-align: center; color: var(--muted); }

.conn-item{border:1px solid var(--border);border-radius:12px;padding:12px 14px;margin:10px 0}
.conn-top{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.conn-add{margin-top:18px}
.conn-add select{min-width:220px}
.conn-tools{display:grid;gap:12px}
.conn-tool{border:1px solid var(--border);border-radius:12px;padding:6px 14px 12px}
.conn-tool textarea{width:100%}
.conn-tool .field input{width:100%}
.conn-param{display:grid;grid-template-columns:minmax(90px,1fr) minmax(140px,2fr) minmax(130px,1fr) auto auto;gap:8px;align-items:center;margin:6px 0}
@media (max-width:720px){.conn-param{grid-template-columns:1fr 1fr}}
.msg-conn .msg-sources-label{font-weight:500}
.conn-add select{padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:inherit;font:inherit;min-width:260px}
.conn-add .field-row{align-items:center}
.conn-item .card-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}

.btn.danger{color:var(--danger)}
details.conn-item summary{cursor:pointer;list-style:revert}
.task-result{margin-top:10px;line-height:1.6}
#tasks-body .card-actions{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}
#tasks-body h3{margin:22px 0 4px;font-size:16px}
#tasks-body textarea{width:100%}

/* Word templates */
.tpl-notes{border:1px solid var(--border);border-radius:10px;padding:10px 14px;margin:8px 0 14px;background:var(--surface)}
.tpl-notes ul{margin:6px 0 0;padding-left:20px}.tpl-notes li{margin:3px 0}
.tpl-err{border-color:#d9534f;background:rgba(217,83,79,.07)}
.tpl-managers{margin-top:22px;padding-top:12px;border-top:1px solid var(--border)}
.tpl-mgr{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:4px 0}
.tpl-mgr-add{display:flex;gap:8px;margin-top:6px}.tpl-mgr-add input{flex:1;min-width:0}
.fill-card{flex-direction:column;align-items:stretch}
.fill-card .doc-card-main{display:flex;align-items:center;gap:10px;padding:12px 14px}
.fill-dl{margin:0 14px 12px;align-self:flex-start;display:inline-flex;align-items:center;gap:6px}
.fill-problems{margin:0 14px 12px;padding:10px 12px;border-radius:8px;background:rgba(217,83,79,.07);border:1px solid rgba(217,83,79,.35)}
.fill-problems ul{margin:6px 0;padding-left:20px}.fill-problems p{margin:4px 0 0}
.attach button.attach-tpl{width:auto;height:auto;padding:0 2px;font-size:12px;margin-left:4px;white-space:nowrap}
