/* ============================ Design tokens ============================ */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --warn: #d97706;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .1), 0 2px 4px -2px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, .18), 0 8px 10px -6px rgba(15, 23, 42, .1);
  --radius: 10px;
  --radius-sm: 7px;
  --topbar-h: 56px;
  --sidebar-w: 250px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Surfaces/chrome that themes (esp. dark) override; light defaults below. */
  --input-bg: #ffffff;
  --toolbar-bg: #f8fafc;
  --toolbar-ink: #334155;
  --toolbar-hover: #e9eef5;
  --canvas-bg: #525659;
  --thumbs-bg: #404245;
  --hover: rgba(15, 23, 42, .07);   /* subtle hover overlay (light); dark themes invert it */
}

/* ============================ Themes ============================ */
/* Light accent themes — recolour the primary family + page background. */
[data-theme="ocean"] {
  --primary: #0284c7; --primary-hover: #0369a1; --primary-soft: #e0f2fe;
  --bg: #eef5fb;
}
[data-theme="emerald"] {
  --primary: #059669; --primary-hover: #047857; --primary-soft: #d1fae5;
  --bg: #eef7f2;
}
[data-theme="rose"] {
  --primary: #e11d48; --primary-hover: #be123c; --primary-soft: #ffe4e6;
  --bg: #fbeef1;
}
/* Dark themes — override the neutral surface/text tokens too. */
[data-theme="dark"] {
  --bg: #0b1220; --surface: #111827; --surface-2: #0f1a2e;
  --border: #243049; --border-strong: #334155;
  --text: #e5e7eb; --text-muted: #9aa7bd; --text-faint: #6b7a93;
  --primary: #6366f1; --primary-hover: #818cf8; --primary-soft: #1f2547;
  --danger: #f05252; --danger-soft: #2a1518; --success: #22c55e; --warn: #f59e0b;
  --input-bg: #0e1830; --toolbar-bg: #0f1a2e; --toolbar-ink: #cbd5e1; --toolbar-hover: #1b2742;
  --canvas-bg: #1b2233; --thumbs-bg: #151c2c; --hover: rgba(255, 255, 255, .08);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 4px 10px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 30px rgba(0,0,0,.55);
}
[data-theme="midnight"] {
  --bg: #04111b; --surface: #0a1a26; --surface-2: #07151f;
  --border: #16323f; --border-strong: #1f4a5a;
  --text: #e2f1f6; --text-muted: #8fb3bf; --text-faint: #5d8593;
  --primary: #22d3ee; --primary-hover: #67e8f9; --primary-soft: #0b3a44;
  --danger: #fb7185; --danger-soft: #2a1418; --success: #2dd4bf; --warn: #fbbf24;
  --input-bg: #07171f; --toolbar-bg: #07151f; --toolbar-ink: #b6dde6; --toolbar-hover: #0e2a33;
  --canvas-bg: #0a1722; --thumbs-bg: #08131c; --hover: rgba(255, 255, 255, .08);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5); --shadow-md: 0 4px 10px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 30px rgba(0,0,0,.6);
}
/* True black (ChatGPT-style): neutral near-black greys, no blue tint. */
[data-theme="black"] {
  --bg: #0a0a0a; --surface: #171717; --surface-2: #232323;
  --border: #2a2a2a; --border-strong: #3d3d3d;
  --text: #ececec; --text-muted: #a3a3a3; --text-faint: #6e6e6e;
  --primary: #3b82f6; --primary-hover: #60a5fa; --primary-soft: #16233b;
  --danger: #f05252; --danger-soft: #2a1516; --success: #22c55e; --warn: #f59e0b;
  --input-bg: #1c1c1c; --toolbar-bg: #141414; --toolbar-ink: #d4d4d4; --toolbar-hover: #262626;
  --canvas-bg: #0a0a0a; --thumbs-bg: #0f0f0f; --hover: rgba(255, 255, 255, .07);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.6); --shadow-md: 0 6px 14px rgba(0,0,0,.65);
  --shadow-lg: 0 14px 34px rgba(0,0,0,.75);
}

* { box-sizing: border-box; }
/* The `hidden` attribute must always win — component rules that set `display`
   (e.g. .admin-gate, .chat-badge) would otherwise keep [hidden] elements visible. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ============================ Buttons ============================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .04s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn .ic { width: 18px; height: 18px; display: inline-block; }
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { background: var(--primary-soft); color: var(--primary); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn:disabled:hover { background: transparent; color: var(--text-muted); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; opacity: 1; }
.icon-btn svg { width: 20px; height: 20px; }

/* ============================ Inputs ============================ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 14px; color: var(--text); background: var(--input-bg);
  font-family: inherit; transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ============================ Auth page ============================ */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 70% -10%, #e0e7ff 0%, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 34px 32px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -.4px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary);
  display: grid; place-items: center; color: #fff; }
.brand .logo svg { width: 20px; height: 20px; }
.auth-card h1 { font-size: 21px; margin: 22px 0 4px; }
.auth-card .sub { color: var(--text-muted); margin: 0 0 22px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 9px; margin-bottom: 22px; }
.tabs button { flex: 1; padding: 8px; border: none; background: transparent; border-radius: 7px;
  font-weight: 600; color: var(--text-muted); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.form-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca;
  padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: none; }
.form-error.show { display: block; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

/* ============================ App shell ============================ */
.app { display: grid; grid-template-rows: var(--topbar-h) 1fr; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .brand { font-size: 18px; }
.topbar .brand .logo { width: 30px; height: 30px; }
.search { flex: 1; max-width: 520px; position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--text-faint); }
.search input { padding-left: 36px; background: var(--surface-2); border-color: transparent; }
.search input:focus { background: var(--input-bg); }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 380px; overflow: auto; z-index: 40; display: none; padding: 6px; }
.search-results.show { display: block; }
.search-results .res { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.search-results .res:hover { background: var(--surface-2); }
.spacer { flex: 1; }
.usermenu { position: relative; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; cursor: pointer; user-select: none; }
.dropdown { position: absolute; right: 0; top: 46px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; z-index: 50; display: none; }
.dropdown.show { display: block; }
.dropdown .info { padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown .info .nm { font-weight: 700; }
.dropdown .info .em { color: var(--text-muted); font-size: 12px; }
.dropdown .item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 7px;
  cursor: pointer; color: var(--text); }
.dropdown .item:hover { background: var(--surface-2); }
.dropdown .item.danger { color: var(--danger); }

.body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 0; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; padding: 14px 10px; }
.sidebar .nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  cursor: pointer; color: var(--text); font-weight: 500; }
.sidebar .nav-item:hover { background: var(--surface-2); }
.sidebar .nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar .nav-item svg { width: 19px; height: 19px; }
.sidebar .sec-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-faint); padding: 16px 12px 6px; }
.tree { margin-left: 2px; }
.tree-node .row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 7px; cursor: pointer; color: var(--text); }
.tree-node .row:hover { background: var(--surface-2); }
.tree-node .row.active { background: var(--primary-soft); color: var(--primary); }
.tree-node .row .twisty { width: 16px; height: 16px; display: grid; place-items: center; color: var(--text-faint);
  transition: transform .12s; flex: none; }
.tree-node .row .twisty.open { transform: rotate(90deg); }
.tree-node .row .twisty.leaf { visibility: hidden; }
.tree-node .row svg.fold { width: 17px; height: 17px; color: var(--warn); flex: none; }
.tree-node .row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-children { margin-left: 16px; }

/* ============================ Content area ============================ */
.content { overflow-y: auto; padding: 22px 28px; position: relative; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; color: var(--text-muted); }
.crumbs .c { padding: 4px 8px; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--text); }
.crumbs .c:hover { background: var(--surface-2); }
.crumbs .sep { color: var(--text-faint); }
.content-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 20px; }
.content-head h2 { margin: 0; font-size: 22px; letter-spacing: -.3px; }
.content-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* View toggle (tiles / list) */
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); }
.seg-btn { width: 32px; height: 30px; display: grid; place-items: center; border: none; cursor: pointer;
  background: transparent; color: var(--text-muted); border-radius: 6px; transition: background .12s, color .12s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.seg-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.seg-btn svg { width: 18px; height: 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: box-shadow .12s, border-color .12s, transform .06s; position: relative; }
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card.sel { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.card .thumb { height: 96px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 8px; }
.card .thumb.folder { color: var(--warn); }
.card .thumb.doc { background: var(--surface-2); color: var(--danger); }
.card .thumb.textdoc { background: var(--surface-2); color: #2563eb; }
.list-row .col-name .ic.textdoc { color: #2563eb; }
.card .thumb.image { background: var(--surface-2); color: var(--primary); overflow: hidden; padding: 0; }
.card .thumb.image img.img-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb.image svg { width: 48px; height: 48px; }
/* PDF first-page preview: show the top of the page filling the tile, on white. */
.card .thumb.pdfthumb { background: #fff; overflow: hidden; padding: 0; border: 1px solid var(--border); }
.card .thumb.pdfthumb img.img-thumb { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.card .thumb svg { width: 56px; height: 56px; }
.card .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { color: var(--text-faint); font-size: 12px; margin-top: 3px; }
.card .kebab { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .12s; }
.card:hover .kebab { opacity: 1; }

.empty { text-align: center; color: var(--text-muted); padding: 70px 20px; }
.empty svg { width: 64px; height: 64px; color: var(--border-strong); margin-bottom: 14px; }
.empty h3 { margin: 0 0 6px; color: var(--text); }

/* List (table) view */
.list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.list-head, .list-row { display: grid; grid-template-columns: minmax(0,1fr) 90px 150px 170px 44px;
  align-items: center; gap: 10px; padding: 0 14px; }
.list-head { height: 40px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-faint); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.list-row { height: 48px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-row .col-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list-row .col-name .ic { width: 22px; height: 22px; display: grid; place-items: center; flex: none; }
.list-row .col-name .ic.folder { color: var(--warn); }
.list-row .col-name .ic.doc { color: var(--danger); }
.list-row .col-name .ic svg { width: 20px; height: 20px; }
.list-row .col-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list-row .col-type, .list-row .col-size, .list-row .col-date { color: var(--text-muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .col-act { display: flex; justify-content: flex-end; }
.list-row .kebab { opacity: 0; }
.list-row:hover .kebab, .list-row .kebab:focus-visible { opacity: 1; }
@media (max-width: 760px) {
  .list-head .col-type, .list-row .col-type, .list-head .col-date, .list-row .col-date { display: none; }
  .list-head, .list-row { grid-template-columns: minmax(0,1fr) 130px 44px; }
}

.dropzone-hint { position: absolute; inset: 14px; border: 2.5px dashed var(--primary); border-radius: 16px;
  background: rgba(79, 70, 229, .06); display: none; place-items: center; z-index: 30; pointer-events: none; }
.dropzone-hint.show { display: grid; }
.dropzone-hint span { font-size: 19px; font-weight: 700; color: var(--primary); }

/* ============================ Context menu ============================ */
.ctxmenu { position: fixed; z-index: 1000; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 192px; display: none; }
.ctxmenu.show { display: block; }
.ctxmenu .mi { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 7px;
  cursor: pointer; font-size: 14px; }
.ctxmenu .mi:hover { background: var(--surface-2); }
.ctxmenu .mi.danger { color: var(--danger); }
.ctxmenu .mi svg { width: 17px; height: 17px; color: var(--text-muted); }
.ctxmenu .mi.danger svg { color: var(--danger); }
.ctxmenu .sep { height: 1px; background: var(--border); margin: 5px 2px; }

/* ============================ Modal + toast ============================ */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: none;
  align-items: center; justify-content: center; z-index: 1100; padding: 20px; }
.overlay.show { display: flex; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; padding: 24px; }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 16px; color: var(--text-muted); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1200;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 14px; animation: toastin .2s ease; max-width: 80vw; }
.toast.success { background: #15803d; } .toast.error { background: #b91c1c; } .toast.warn { background: #b45309; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================ Settings / theme picker ============================ */
.settings-section { margin: 18px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.theme-card { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 1.5px solid var(--border);
  border-radius: 11px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
  transition: border-color .12s, box-shadow .12s, transform .04s; }
.theme-card:hover { border-color: var(--border-strong); }
.theme-card:active { transform: translateY(1px); }
.theme-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.theme-prev { position: relative; height: 50px; border-radius: 7px; border: 1px solid var(--border); overflow: hidden; }
.theme-prev .theme-bar { position: absolute; top: 0; left: 0; right: 0; height: 17px; }
.theme-prev .theme-chip { position: absolute; left: 8px; bottom: 8px; width: 26px; height: 17px; border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.theme-name { font-size: 13px; font-weight: 600; text-align: center; }
@media (max-width: 480px) { .theme-grid { grid-template-columns: repeat(2, 1fr); } }
/* KI-Funktionen toggle in settings */
.ai-setting { display: flex; gap: 11px; align-items: flex-start; cursor: pointer;
  padding: 12px; border: 1.5px solid var(--border); border-radius: 11px; background: var(--surface); }
.ai-setting input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; flex: none; }
.ai-setting input:disabled { cursor: not-allowed; }
.ai-setting-text strong { display: block; font-size: 14px; }
.ai-setting-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.45; }
.ai-setting code { background: var(--surface-2); border: 1px solid var(--border); padding: 0 5px;
  border-radius: 4px; font-size: 11px; }

/* ============================ Import / merge preview ============================ */
.modal.import-modal { max-width: 580px; }
.import-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; padding: 2px; }
.import-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); }
.import-item.dragging { opacity: .45; }
.import-item .grip { display: flex; color: var(--text-faint); cursor: grab; flex: none; }
.import-item .grip svg { width: 18px; height: 18px; }
.import-item .ord { width: 16px; text-align: center; font-weight: 700; color: var(--text-muted); flex: none; }
.import-item .thumb { width: 42px; height: 50px; border-radius: 6px; overflow: hidden; flex: none;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--danger); }
.import-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.import-item .thumb svg { width: 22px; height: 22px; }
.import-item .info { flex: 1; min-width: 0; }
.import-item .info .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-item .info .meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.import-item .reorder { display: flex; flex-direction: column; gap: 2px; flex: none; }
.import-item .reorder .icon-btn { width: 26px; height: 20px; }
.import-item .reorder .icon-btn svg, .import-item [data-remove] svg { width: 15px; height: 15px; }
.import-item [data-remove] { flex: none; width: 30px; height: 30px; color: var(--text-muted); }
.import-item [data-remove]:hover { color: var(--danger); }

/* ============================ Workspaces / notifications ============================ */
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.notif-btn { position: relative; }
.notif-btn.has { color: var(--primary); }
.notif-btn .badge { position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
#notif-dd { min-width: 304px; max-width: 360px; max-height: 60vh; overflow: auto; }
.notif-head { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); }
.notif { padding: 10px; border-radius: 8px; }
.notif:hover { background: var(--surface-2); }
.notif .msg { font-size: 13px; line-height: 1.45; margin-bottom: 8px; }
.notif-actions { display: flex; gap: 8px; }
.notif-empty { padding: 18px; color: var(--text-muted); text-align: center; font-size: 13px; }

.sec-title.ws-head { display: flex; align-items: center; justify-content: space-between; padding-right: 8px; }
.ws-list { margin: 2px 0 8px; }
.nav-item.ws-item { gap: 8px; }
.nav-item.ws-item .wsic { display: flex; color: var(--text-muted); flex: none; }
.nav-item.ws-item .wsic svg { width: 17px; height: 17px; }
.nav-item.ws-item.active .wsic { color: var(--primary); }
.nav-item.ws-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.ws-item .count { font-size: 11px; color: var(--text-faint); background: var(--surface-2); border-radius: 9px; padding: 1px 7px; flex: none; }
.ws-empty { color: var(--text-faint); font-size: 12px; padding: 4px 12px; }

.member-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.member-row .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.member-row .ava { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.member-row .mw { min-width: 0; }
.member-row .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .em { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .ctrl { display: flex; align-items: center; gap: 6px; flex: none; }
.member-row.pending { opacity: .72; }
.role-tag { font-size: 12px; color: var(--text-muted); background: var(--surface-2); border-radius: 7px; padding: 3px 9px; }
.role-sel { padding: 5px 8px; font-size: 13px; width: auto; }
.invite-row { display: flex; gap: 8px; }
.invite-row input { flex: 1; }
.invite-row select { width: auto; }
@media (max-width: 520px) { .invite-row { flex-wrap: wrap; } }

/* ============================ Editor ============================ */
.editor { display: grid; grid-template-rows: var(--topbar-h) auto 1fr; height: 100vh; background: var(--canvas-bg); }
.ed-topbar { display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--surface);
  border-bottom: 1px solid var(--border); }
.ed-topbar .docname { font-weight: 600; border: 1px solid transparent; padding: 6px 8px; border-radius: 7px;
  max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.ed-topbar .docname:hover { border-color: var(--border); }
.save-status { color: var(--text-muted); font-size: 13px; display: flex; align-items: center; gap: 6px; min-width: 130px; }
.save-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.save-status.saving .dot { background: var(--warn); }
.save-status.error .dot { background: var(--danger); }

/* Live presence avatars */
.presence { display: flex; align-items: center; padding-right: 6px; transition: transform .2s; }
.presence.pulse { transform: scale(1.08); }
.presence .pav { width: 28px; height: 28px; border-radius: 50%; color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 12px; border: 2px solid var(--surface); margin-left: -8px; box-shadow: var(--shadow-sm); }
.presence .pav:first-child { margin-left: 0; }
.presence .pav.more { background: var(--text-faint); }

/* Read-only badge + viewer mode */
.ro-badge { font-size: 11px; font-weight: 700; color: var(--warn); background: rgba(217, 119, 6, .12);
  border: 1px solid rgba(217, 119, 6, .3); border-radius: 999px; padding: 2px 9px; margin-left: 8px; white-space: nowrap; }
body.read-only .toolbar .tool[data-tool],
body.read-only .toolbar #b-undo, body.read-only .toolbar #b-redo, body.read-only .toolbar #b-del,
body.read-only .toolbar .ctl, body.read-only .toolbar .divider { display: none; }
body.read-only .pg-ops, body.read-only #p-del { display: none; }

.toolbar { display: flex; align-items: center; gap: 4px; padding: 7px 12px; background: var(--toolbar-bg);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .tool { width: 38px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--toolbar-ink); }
.toolbar .tool:hover { background: var(--toolbar-hover); }
.toolbar .tool.active { background: var(--primary); color: #fff; }
.toolbar .tool:disabled { opacity: .4; cursor: not-allowed; }
.toolbar .tool:disabled:hover { background: transparent; }
.toolbar .tool svg { width: 19px; height: 19px; }
.toolbar .divider { width: 1px; height: 26px; background: var(--border); margin: 0 6px; }
.toolbar .ctl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.toolbar input[type=color] { width: 32px; height: 32px; padding: 2px; border-radius: 7px; border: 1px solid var(--border-strong); cursor: pointer; background: var(--input-bg); }
.toolbar select, .toolbar input[type=number] { padding: 6px 8px; }
.toolbar input[type=range] { width: 90px; }
.zoomlbl { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }

/* Right properties panel is hidden by default; the topbar toggle adds .props-shown. */
.ed-body { display: grid; grid-template-columns: 168px 1fr; min-height: 0; }
.ed-body > .props { display: none; }
.ed-body.props-shown { grid-template-columns: 168px 1fr 248px; }
.ed-body.props-shown > .props { display: block; }
.thumbs { background: var(--thumbs-bg); overflow-y: auto; padding: 12px 10px; }
.thumb-item { margin-bottom: 12px; cursor: pointer; border-radius: 6px; padding: 6px; border: 2px solid transparent; }
.thumb-item.active { border-color: var(--primary); background: rgba(255,255,255,.08); }
.thumb-item canvas { width: 100%; display: block; border-radius: 3px; box-shadow: 0 1px 4px rgba(0,0,0,.4); background: #fff; }
.thumb-item .lbl { color: #cbd5e1; font-size: 12px; text-align: center; margin-top: 5px; }

.canvas-scroll { overflow: auto; padding: 26px; }
.page-wrap { position: relative; margin: 0 auto 22px; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.4); }
.page-wrap canvas.pdf { display: block; }
.overlay-layer { position: absolute; inset: 0; }
.ann { position: absolute; box-sizing: border-box; }
.ann.selectable { cursor: move; }
.ann.selected { outline: 1.5px solid var(--primary); outline-offset: 1px; }
/* A box being drawn (e.g. a new text field) — visible while dragging. */
.ann.drawing { outline: 1.5px dashed var(--primary); outline-offset: 1px;
  background: rgba(127, 127, 127, .12); border-radius: 2px; }
/* Rubber-band rectangle for multi-selection (drag on empty canvas). */
.marquee { position: absolute; border: 1.5px dashed var(--primary); background: rgba(127, 127, 127, .12);
  border-radius: 2px; pointer-events: none; z-index: 4; }
/* Match pdf-lib's Helvetica so on-screen wrapping mirrors the flattened PDF.
   Fully neutralise the global input/textarea chrome (border, radius, background,
   and especially the :focus box-shadow ring) so the annotation field is invisible
   apart from its text — otherwise the focus ring drew a second, inner box. */
.ann textarea { width: 100%; height: 100%; border: none; background: transparent; resize: none;
  overflow: hidden; padding: 4px; line-height: 1.25; border-radius: 0; box-shadow: none;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
.ann textarea::placeholder { color: #94a3b8; opacity: .7; }
.ann textarea:focus { outline: none; background: transparent; box-shadow: none; border-color: transparent; }
.ann .handle { position: absolute; width: 11px; height: 11px; background: #fff; border: 1.5px solid var(--primary);
  border-radius: 2px; z-index: 5; }
.ann .handle.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.ann .handle.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.ann .handle.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.ann .handle.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.ann .endpt { position: absolute; width: 12px; height: 12px; background: #fff; border: 1.5px solid var(--primary);
  border-radius: 50%; transform: translate(-50%, -50%); z-index: 6; cursor: pointer; }
.ann img { width: 100%; height: 100%; display: block; pointer-events: none; }

/* AI field-detection markers: clickable overlays the model proposes. Live on a
   layer above the annotations; the layer itself lets clicks pass through, only the
   markers capture them. */
.ai-layer { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.ai-field { position: absolute; box-sizing: border-box; pointer-events: auto; cursor: pointer;
  border: 1.5px dashed var(--primary); border-radius: 3px;
  background: rgba(79, 70, 229, .12);
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  display: grid; place-items: center; animation: aiPop .18s ease-out; }
.ai-field.checkbox { border-style: solid; border-radius: 4px; }
.ai-field:hover { background: rgba(79, 70, 229, .28);
  background: color-mix(in srgb, var(--primary) 30%, transparent);
  box-shadow: 0 0 0 2px var(--primary); }
.ai-field::after { font-size: 11px; font-weight: 700; line-height: 1; color: var(--primary);
  opacity: 0; transition: opacity .12s; }
.ai-field.checkbox::after { content: '✓'; }
.ai-field.line::after { content: '✎'; }
.ai-field:hover::after { opacity: .9; }
@keyframes aiPop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.toolbar .tool.busy { opacity: .55; cursor: progress; }

.props { background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; padding: 16px; }
.props h4 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); }
.props .pg-ops { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.props .pg-ops .btn { justify-content: center; padding: 9px; font-size: 13px; }
.props .hint { color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.props .pinfo { background: var(--surface-2); border-radius: 9px; padding: 12px; margin-bottom: 16px; font-size: 13px; }
.props .pinfo .big { font-size: 17px; font-weight: 700; }

/* signature pad modal */
.sig-pad { border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2); width: 100%; height: 180px; touch-action: none; cursor: crosshair; }
.sig-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.type-sig { font-size: 38px; font-family: "Segoe Script", "Brush Script MT", cursive; height: 120px;
  display: grid; place-items: center; border: 1px dashed var(--border-strong); border-radius: 10px; }

.center-msg { color: #e2e8f0; text-align: center; padding-top: 80px; }
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ Rich-text ("Word") editor ============================ */
.texted { display: grid; grid-template-rows: var(--topbar-h) auto 1fr; height: 100vh; background: var(--bg); }
.rt-toolbar { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; padding: 7px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.rt-toolbar .tool { width: 34px; height: 32px; border-radius: 7px; border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--text-muted); font-size: 15px; }
.rt-toolbar .tool:hover { background: var(--hover); color: var(--text); }
.rt-toolbar .tool svg { width: 18px; height: 18px; }
.rt-toolbar .divider { width: 1px; height: 22px; background: var(--border); margin: 0 5px; }
.rt-block { padding: 6px 8px; font-size: 13px; width: auto; min-width: 130px; }
.rt-color { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--text-muted); font-weight: 700; font-size: 14px; padding: 0 4px; }
.rt-color input[type=color] { width: 26px; height: 26px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 6px; cursor: pointer; background: var(--input-bg); }
.rt-scroll { overflow: auto; padding: 28px 16px; }
/* The document itself is always a white page (like Word), independent of theme. */
.rt-page { max-width: 820px; min-height: 64vh; margin: 0 auto; background: #fff; color: #111827; border-radius: 4px;
  box-shadow: var(--shadow-md); padding: 56px 64px; outline: none; line-height: 1.55; font-size: 15px;
  font-family: Calibri, "Segoe UI", -apple-system, Roboto, Arial, sans-serif; }
.rt-page:focus { box-shadow: var(--shadow-lg); }
.rt-page img { max-width: 100%; height: auto; }
.rt-page h1 { font-size: 28px; margin: .5em 0 .3em; } .rt-page h2 { font-size: 22px; margin: .5em 0 .3em; } .rt-page h3 { font-size: 18px; margin: .5em 0 .3em; }
.rt-page blockquote { border-left: 3px solid #cbd5e1; margin: .4em 0; padding-left: 14px; color: #475569; }
.rt-page a { color: #2563eb; }
.rt-page ul, .rt-page ol { padding-left: 26px; }
@media (max-width: 700px) { .rt-page { padding: 28px 22px; } }

@media (max-width: 880px) {
  .body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .ed-body, .ed-body.props-shown { grid-template-columns: 1fr; }
  .thumbs, .props, .ed-body.props-shown > .props { display: none; }
}

/* ============================ Auth page extras ======================== */
.auth-foot { margin: 18px 0 0; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Dropdown menu icons (shared by dashboard + admin). */
.dropdown .item svg { width: 18px; height: 18px; flex: none; }

/* ============================ Admin panel ============================ */
.admin-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 999px;
}
.admin-main { overflow-y: auto; padding: 28px clamp(18px, 5vw, 56px) 64px; }

.admin-gate { display: grid; place-items: center; min-height: 60vh; color: var(--text-muted); }
.gate-card { text-align: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 38px 40px; max-width: 380px; }
.gate-card .gate-ic { display: inline-grid; place-items: center; width: 56px; height: 56px;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.gate-card .gate-ic svg { width: 30px; height: 30px; }
.gate-card h2 { margin: 0 0 6px; }
.gate-card p { margin: 0 0 18px; color: var(--text-muted); }

.admin-section { max-width: 1100px; margin: 0 auto 34px; }
.admin-h { font-size: 16px; font-weight: 700; margin: 0 0 14px; }
.admin-h .muted { color: var(--text-faint); font-weight: 500; }
.admin-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.admin-section-head .admin-h { margin: 0; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.stat-card { display: flex; align-items: center; gap: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-ic { display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none;
  border-radius: 11px; background: var(--primary-soft); color: var(--primary); }
.stat-ic svg { width: 22px; height: 22px; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.stat-sub { color: var(--text-faint); font-size: 11.5px; margin-top: 2px; }

/* User table */
.admin-table-wrap { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted);
  padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.admin-table th.num, .admin-table td.num { text-align: right; }
.admin-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--surface-2); }
.admin-table .muted { color: var(--text-muted); font-size: 13px; }

.user-cell { display: flex; align-items: center; gap: 11px; }
.mini-avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.user-name { font-weight: 600; }
.user-name .you { color: var(--text-faint); font-weight: 500; }
.user-email { color: var(--text-muted); font-size: 12.5px; }

.role-badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.role-badge.admin { background: var(--primary-soft); border-color: transparent; color: var(--primary); }

.actions-col { width: 1%; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; }
.row-actions .icon-btn svg { width: 17px; height: 17px; }
.row-actions .icon-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }

.check-row { display: flex; align-items: center; gap: 9px; margin: 4px 0 2px; cursor: pointer; font-size: 14px; }
.check-row input { width: auto; }

/* Folder colour picker (swatches) */
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatches .swatch { width: 32px; height: 32px; padding: 0; border: 2px solid transparent; border-radius: 8px;
  background: var(--surface-2); display: grid; place-items: center; cursor: pointer; transition: border-color .12s; }
.color-swatches .swatch:hover { border-color: var(--border-strong); }
.color-swatches .swatch.active { border-color: var(--primary); }
.color-swatches .swatch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.color-swatches .swatch-dot { width: 18px; height: 18px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.color-swatches.lg .swatch { width: 40px; height: 40px; }
.color-swatches.lg .swatch-dot { width: 24px; height: 24px; }

@media (max-width: 700px) {
  .admin-table th.num, .admin-table td.num { display: none; }
}

/* ============================ Workspace chat ========================== */
/* Unread badge on the toolbar "Chat" button */
#btn-chat { position: relative; }
#btn-chat.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chat-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  margin-left: 2px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }

/* Slide-in side drawer */
.chat-scrim { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(15, 23, 42, .18);
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 60; }
.chat-scrim.show { opacity: 1; pointer-events: auto; }

.chat-panel { position: fixed; top: var(--topbar-h); right: 0; width: 380px; max-width: 92vw;
  height: calc(100vh - var(--topbar-h)); background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; z-index: 61;
  transform: translateX(100%); transition: transform .2s ease; }
.chat-panel.open { transform: translateX(0); }

.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.chat-head .chat-ic { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 9px; background: var(--primary-soft); color: var(--primary); }
.chat-head .chat-ic svg { width: 18px; height: 18px; }
.chat-titles { flex: 1; min-width: 0; }
.chat-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12px; color: var(--text-muted); }
.chat-close svg { transform: rotate(0); }

.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { margin: auto; color: var(--text-faint); text-align: center; font-size: 13px; padding: 20px; }

.chat-msg { display: flex; gap: 9px; align-items: flex-end; max-width: 90%; }
.chat-msg.mine { flex-direction: row-reverse; align-self: flex-end; }
.chat-avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 11px; }
.chat-bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 7px 11px; min-width: 0; }
.chat-msg.mine .chat-bubble { background: var(--primary-soft); border-color: transparent; }
.chat-meta { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; }
.chat-name { font-size: 12px; font-weight: 700; color: var(--text); }
.chat-time { font-size: 10.5px; color: var(--text-faint); }
.chat-body { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

.chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-input textarea { flex: 1; resize: none; max-height: 140px; line-height: 1.4; padding: 9px 12px; }
.chat-input .icon-btn.primary { flex: none; width: 40px; height: 40px; background: var(--primary);
  border: 1px solid var(--primary); color: #fff; border-radius: var(--radius-sm); }
.chat-input .icon-btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.chat-input .icon-btn.primary svg { width: 18px; height: 18px; }

@media (max-width: 520px) { .chat-panel { width: 100vw; max-width: 100vw; } }
