/* Trợ lý Học thuật – glassmorphism, tối giản, chữ lớn */
:root {
  --fs: 20px;
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;

  --bg: #eef4f6;
  --bg-grad: linear-gradient(135deg, #e6f0f9 0%, #eef7f6 50%, #f2f8e8 100%);
  --blob1: #8fc0e8;
  --blob2: #9fdad8;
  --blob3: #cbe5a0;

  --glass: rgba(255, 255, 255, 0.60);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-soft: rgba(255, 255, 255, 0.42);
  --edge: rgba(255, 255, 255, 0.85);
  --line: rgba(28, 36, 56, 0.10);
  --shadow: 0 10px 40px rgba(40, 50, 90, 0.10), 0 2px 8px rgba(40, 50, 90, 0.05);

  --text: #1a2132;
  --muted: #566077;
  --accent: #1b6fae;
  --accent-2: #2f9ea3;
  --accent-soft: rgba(34, 128, 193, 0.11);
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --ok: #0f7a4f;
  --warn-soft: rgba(217, 119, 6, 0.12);

  --c-auto: #1b6fae;
  --c-luan-an: #1f5d99;
  --c-nghien-cuu: #15817f;
  --c-giao-trinh: #5a8a1c;
  --brand-grad: linear-gradient(90deg, #2280c1 0%, #58bbbc 52%, #9ec95c 100%);
  --btn-grad: linear-gradient(135deg, #1b6fae 0%, #2a92ad 100%);

  --r-lg: 28px;
  --r-md: 18px;
  --r-sm: 12px;
  --focus: 0 0 0 4px rgba(34, 128, 193, 0.35);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1519;
    --bg-grad: linear-gradient(135deg, #0d1826 0%, #0e1d1f 50%, #141c10 100%);
    --blob1: #1d4f7a; --blob2: #17605f; --blob3: #43602a;
    --glass: rgba(28, 34, 54, 0.58);
    --glass-strong: rgba(34, 41, 64, 0.86);
    --glass-soft: rgba(40, 48, 74, 0.45);
    --edge: rgba(255, 255, 255, 0.10);
    --line: rgba(255, 255, 255, 0.10);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    --text: #eef1f8; --muted: #aab3c7;
    --accent: #6cb6ea; --accent-2: #6fd0cc; --accent-soft: rgba(88, 187, 188, 0.16);
    --on-accent: #10132a;
    --danger: #ff8a80; --danger-soft: rgba(255, 99, 99, 0.14); --ok: #5fd3a0;
    --c-auto: #6cb6ea; --c-luan-an: #8fb8f0; --c-nghien-cuu: #6fd0cc; --c-giao-trinh: #b5d97a;
    --btn-grad: linear-gradient(135deg, #5fb0e6 0%, #58bbbc 100%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: var(--fs); }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); color: var(--text);
  background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed;
  line-height: 1.6; -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* nền mờ */
.backdrop {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38vw 38vw at 4% 2%, color-mix(in srgb, var(--blob1) 70%, transparent), transparent 70%),
    radial-gradient(34vw 34vw at 98% 38%, color-mix(in srgb, var(--blob2) 60%, transparent), transparent 70%),
    radial-gradient(36vw 36vw at 48% 108%, color-mix(in srgb, var(--blob3) 60%, transparent), transparent 70%);
}
.blob { display: none; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow);
  border-radius: var(--r-lg);
}

/* bố cục */
.app {
  display: grid; grid-template-columns: 15.5rem minmax(0, 1fr) 19rem;
  gap: 18px; height: 100vh; padding: 18px;
}
.app.files-closed { grid-template-columns: 15.5rem minmax(0, 1fr); }
.app.files-closed .files { display: none; }

/* nút */
.ico { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
.ico svg { width: 100%; height: 100%; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 2.6rem; padding: 0.45rem 1.05rem; border-radius: var(--r-md);
  border: 1px solid transparent; font-weight: 600; font-size: 0.95rem;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary { background: var(--btn-grad); color: var(--on-accent); box-shadow: 0 6px 18px rgba(34,128,193,.28); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: var(--glass-soft); border-color: var(--edge); color: var(--text); }
.btn-ghost:hover { background: var(--glass-strong); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { filter: brightness(0.97); }
.btn-stop { background: var(--danger-soft); color: var(--danger); border-color: rgba(220,38,38,.25); }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.6rem; height: 2.6rem; flex: none;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--glass-soft); color: var(--text); }
.icon-btn .ico { width: 1.25em; height: 1.25em; }

/* thanh bên */
.sidebar { display: flex; flex-direction: column; gap: 1.1rem; padding: 1.2rem; min-height: 0; }
.brand { display: flex; align-items: center; gap: .7rem; padding: .2rem .2rem .3rem; }
.brand-mark { width: 2.6rem; height: 2.6rem; flex: none; background: url("imind-mark.png") center / contain no-repeat; }
.brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.brand-sub { color: var(--muted); font-size: .8rem; }
.side-section { display: flex; flex-direction: column; gap: .5rem; min-height: 0; }
.side-section.grow { flex: 1; }
.side-label { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 .3rem; }

.agent-list { display: flex; flex-direction: column; gap: .35rem; }
.agent {
  display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left;
  padding: .55rem .7rem; border-radius: var(--r-md); border: 1px solid transparent; background: transparent;
  font-size: .92rem; font-weight: 500; line-height: 1.3;
}
.agent:hover { background: var(--glass-soft); }
.agent[aria-checked="true"] { background: var(--glass-strong); border-color: var(--edge); box-shadow: 0 2px 10px rgba(40,50,90,.06); font-weight: 600; }
.agent .dot { width: .75rem; height: .75rem; border-radius: 50%; flex: none; background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); }

.conv-list { display: flex; flex-direction: column; gap: .2rem; overflow-y: auto; overflow-x: hidden; min-height: 0; margin: 0 -.3rem; padding: 0 .3rem; }
.conv {
  display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
  padding: .5rem .65rem; border-radius: var(--r-sm); border: 0; background: transparent;
  font-size: .88rem; color: var(--text);
}
.conv:hover { background: var(--glass-soft); }
.conv.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.conv .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--c); flex: none; }
.conv .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .spin { width: .9em; height: .9em; }
.conv-row { display: flex; align-items: center; border-radius: var(--r-sm); min-width: 0; }
.conv-row .conv { min-width: 0; flex: 1; }
.conv-row:hover { background: var(--glass-soft); }
.conv-row:has(.conv.active) { background: var(--accent-soft); }
.conv-row .conv.active { background: transparent; }
.conv-row .conv:hover { background: transparent; }
.conv-del { width: 2.1rem; height: 2.1rem; opacity: 0; }
.conv-row:hover .conv-del, .conv-del:focus-visible { opacity: 1; }
.conv-del:hover { color: var(--danger); background: var(--danger-soft); }
.conv-empty { color: var(--muted); font-size: .85rem; padding: .3rem; }

.font-ctrl { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.seg { display: inline-flex; align-items: center; background: var(--glass-soft); border: 1px solid var(--edge); border-radius: var(--r-md); padding: 3px; }
.seg-btn { border: 0; background: transparent; min-width: 2.4rem; height: 2.2rem; border-radius: 12px; font-weight: 700; }
.seg-btn:hover { background: var(--glass-strong); }
.seg-val { min-width: 3.2rem; text-align: center; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* khu trò chuyện */
.chat { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: .8rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: .7rem; }
.chat-title h1 { margin: 0; font-size: 1.1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  display: inline-flex; align-items: center; gap: .4em; flex: none;
  font-size: .78rem; font-weight: 600; padding: .2rem .7rem; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
}
.chip:empty { display: none; }
.only-narrow { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 1.6rem clamp(1rem, 4vw, 3.2rem) 1rem; scroll-behavior: smooth; }
.messages > * { max-width: 46rem; margin-left: auto; margin-right: auto; }

/* màn hình chào */
.welcome { text-align: center; padding: 2vh 0 1rem; }
.welcome h2 { font-size: 2rem; font-weight: 700; margin: .4rem 0 .2rem; letter-spacing: -.01em; }
.welcome p { color: var(--muted); margin: 0 0 1.8rem; font-size: 1.05rem; }
.welcome-agent { display: inline-flex; margin-bottom: .6rem; }
.suggest-grid { display: grid; gap: .8rem; text-align: left; }
.suggest {
  display: flex; gap: .8rem; align-items: flex-start; width: 100%; text-align: left;
  padding: .9rem 1.1rem; border-radius: var(--r-md);
  background: var(--glass-soft); border: 1px solid var(--edge);
  font-size: .95rem; line-height: 1.45; transition: background .15s, transform .12s;
}
.suggest:hover { background: var(--glass-strong); transform: translateY(-1px); }
.suggest .ico { color: var(--c); margin-top: .15em; }
.suggest small { display: block; color: var(--muted); font-size: .78rem; font-weight: 600; margin-bottom: .1rem; }

/* tin nhắn */
.msg { margin-bottom: 1.4rem; }
.msg.user { display: flex; justify-content: flex-end; }
.bubble-user {
  max-width: 85%; padding: .8rem 1.15rem; border-radius: 22px 22px 6px 22px;
  background: var(--btn-grad); color: var(--on-accent);
  white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 6px 18px rgba(34,128,193,.22);
}
.msg.assistant { display: flex; gap: .8rem; align-items: flex-start; }
.avatar {
  width: 2.2rem; height: 2.2rem; border-radius: 12px; flex: none; margin-top: .2rem;
  background: var(--btn-grad); position: relative;
}
.avatar::after {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M7 13l9-4.5 9 4.5-9 4.5z M11 15.5v4.5c0 1.6 2.4 3 5 3s5-1.4 5-3v-4.5' fill='none' stroke='white' stroke-width='2.2' stroke-linejoin='round' stroke-linecap='round'/%3E%3C/svg%3E") center / 72% no-repeat;
}
.bubble-bot {
  flex: 1; min-width: 0; padding: .9rem 1.25rem; border-radius: 6px 22px 22px 22px;
  background: var(--glass-strong); border: 1px solid var(--edge);
}
.bubble-bot > :first-child { margin-top: 0; }
.bubble-bot > :last-child { margin-bottom: 0; }

/* nội dung markdown */
.md p { margin: .55rem 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 1.1rem 0 .4rem; }
.md h1 { font-size: 1.3rem; } .md h2 { font-size: 1.18rem; } .md h3 { font-size: 1.06rem; } .md h4 { font-size: 1rem; }
.md ul, .md ol { margin: .45rem 0; padding-left: 1.4rem; }
.md li { margin: .22rem 0; }
.md li::marker { color: var(--muted); }
.md strong { font-weight: 700; }
.md a { color: var(--accent); text-underline-offset: 3px; }
.md code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86em; background: var(--accent-soft); padding: .08em .38em; border-radius: 6px; }
.md pre { background: rgba(20, 24, 40, .06); border: 1px solid var(--line); padding: .8rem 1rem; border-radius: var(--r-sm); overflow-x: auto; font-size: .82rem; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: .6rem 0; padding: .3rem 1rem; border-left: 4px solid var(--accent-soft); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.md .table-wrap { overflow-x: auto; margin: .7rem 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
.md table { border-collapse: collapse; width: 100%; font-size: .88rem; }
.md th, .md td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.md th { background: var(--accent-soft); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }
.file-link {
  display: inline-flex; align-items: center; gap: .35em; border: 1px solid var(--edge);
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .88em;
  padding: .1em .6em; border-radius: 8px; word-break: break-all; text-align: left;
}
.file-link:hover { background: var(--glass-strong); }
.caret { display: inline-block; width: .5em; height: 1.1em; vertical-align: text-bottom; background: var(--accent); border-radius: 2px; animation: blink 1s steps(2) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* các bước làm việc */
.steps { margin: .6rem 0; }
.steps-live {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .9rem; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent); font-size: .92rem; font-weight: 500;
}
.steps-live .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps-live .time { font-variant-numeric: tabular-nums; font-size: .82rem; opacity: .85; }
details.steps-log { margin: .5rem 0; }
details.steps-log summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .45rem;
  font-size: .85rem; color: var(--muted); padding: .25rem .6rem; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--edge);
}
details.steps-log summary::-webkit-details-marker { display: none; }
details.steps-log summary .ico { width: 1em; height: 1em; transition: transform .15s; }
details.steps-log[open] summary .ico { transform: rotate(90deg); }
.step-items { list-style: none; margin: .5rem 0 0; padding: 0 0 0 .4rem; font-size: .85rem; }
.step-items li { display: flex; gap: .5rem; align-items: baseline; padding: .12rem 0; color: var(--muted); }
.step-items li.sub { padding-left: 1.3rem; font-size: .8rem; }
.step-items .st { width: 1rem; flex: none; text-align: center; }
.step-items .ok { color: var(--ok); } .step-items .err { color: var(--danger); }
.step-items b { font-weight: 600; color: var(--text); }
.spin { width: 1.1em; height: 1.1em; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-files { display: flex; flex-direction: column; gap: .5rem; margin-top: .9rem; }
.result-files .label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.file-card {
  display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; border-radius: var(--r-md);
  background: var(--glass-soft); border: 1px solid var(--edge);
}
.file-card .name { flex: 1; min-width: 0; font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .where { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.ftype { width: 2.3rem; height: 2.3rem; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: .62rem; font-weight: 700; color: #fff; letter-spacing: .02em; }
.ftype.docx { background: #2b579a; } .ftype.xlsx { background: #217346; } .ftype.pdf { background: #c7362c; }
.ftype.pptx { background: #c4502b; } .ftype.md { background: #5b6478; } .ftype.other { background: #8a93a8; }
.ftype.dir { background: color-mix(in srgb, var(--accent) 80%, #fff); }

.notice { margin-top: .8rem; padding: .7rem 1rem; border-radius: var(--r-sm); font-size: .9rem; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.warn { background: var(--warn-soft); }

/* ô nhập */
.composer { padding: .6rem clamp(1rem, 4vw, 3.2rem) 1rem; }
.composer-box {
  max-width: 46rem; margin: 0 auto; display: flex; align-items: flex-end; gap: .5rem;
  padding: .5rem .5rem .5rem .6rem; border-radius: 24px;
  background: var(--glass-strong); border: 1px solid var(--edge); box-shadow: 0 8px 30px rgba(40,50,90,.10);
}
.composer-box:focus-within { box-shadow: var(--focus), 0 8px 30px rgba(40,50,90,.10); }
.composer textarea {
  flex: 1; border: 0; background: transparent; resize: none; outline: none;
  padding: .45rem .3rem; min-height: 2.6rem; max-height: 40vh; line-height: 1.5; font-size: 1rem;
}
.composer textarea::placeholder { color: var(--muted); opacity: .85; }
.composer .send { min-width: 6.2rem; border-radius: 18px; }
.composer-hint { max-width: 46rem; margin: .45rem auto 0; text-align: center; color: var(--muted); font-size: .75rem; }
kbd { font-family: inherit; font-size: .9em; padding: .05em .4em; border-radius: 6px; border: 1px solid var(--line); background: var(--glass-soft); }

/* bảng tài liệu */
.files { display: flex; flex-direction: column; min-height: 0; padding: 1rem; gap: .7rem; }
.files-head { display: flex; align-items: center; gap: .4rem; }
.tabs { flex: 1; display: flex; gap: 3px; background: var(--glass-soft); border: 1px solid var(--edge); padding: 3px; border-radius: var(--r-md); }
.tab { flex: 1; border: 0; background: transparent; padding: .45rem .5rem; border-radius: 13px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--glass-strong); color: var(--text); box-shadow: 0 2px 8px rgba(40,50,90,.08); }
.tab-panel { display: flex; flex-direction: column; gap: .7rem; min-height: 0; flex: 1; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; font-size: .85rem; }
.crumbs button { border: 0; background: transparent; padding: .2rem .45rem; border-radius: 8px; color: var(--accent); font-weight: 600; }
.crumbs button:hover { background: var(--accent-soft); }
.crumbs button[aria-current] { color: var(--text); }
.crumbs .sep { color: var(--muted); }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center;
  padding: .9rem; border-radius: var(--r-md); border: 2px dashed color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: .88rem; transition: background .15s, border-color .15s;
}
.drop > .ico { width: 1.6rem; height: 1.6rem; color: var(--accent); }
.drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.drop-actions .btn { min-height: 2.2rem; padding: .3rem .8rem; font-size: .85rem; }
.entry-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; flex: 1; margin: 0 -.3rem; padding: 0 .3rem; }
.entry {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem; border-radius: var(--r-sm);
  font-size: .88rem;
}
.entry:hover { background: var(--glass-soft); }
.entry .main { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; border: 0; background: transparent; text-align: left; padding: 0; }
.entry .ftype { width: 2rem; height: 2rem; font-size: .56rem; border-radius: 9px; }
.entry .nm { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.entry .meta { display: block; font-size: .72rem; color: var(--muted); }
.entry.tech { opacity: .6; }
.entry .acts { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.entry:hover .acts, .entry:focus-within .acts { opacity: 1; }
.entry .icon-btn { width: 2.1rem; height: 2.1rem; }
.entries-empty { color: var(--muted); font-size: .85rem; text-align: center; padding: 1rem .5rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

/* thông báo & hộp thoại */
.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%); z-index: 50;
  padding: .7rem 1.3rem; border-radius: 999px; font-size: .92rem; font-weight: 500;
  background: var(--glass-strong); border: 1px solid var(--edge); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.toast.error { color: var(--danger); }
.dialog { padding: 1.5rem; width: min(28rem, 92vw); color: var(--text); background: var(--glass-strong); }
.dialog::backdrop { background: rgba(20, 24, 40, .25); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog h2 { margin: 0 0 .4rem; font-size: 1.15rem; }
.dialog input { width: 100%; margin: .4rem 0 1rem; padding: .6rem .8rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--glass); }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* màn hình hẹp */
@media (max-width: 1600px) {
  .app { grid-template-columns: 15.5rem minmax(0, 1fr); }
  .files { position: fixed; right: 18px; top: 18px; bottom: 18px; width: min(22rem, 90vw); z-index: 20; background: var(--glass-strong); }
  .app.files-closed .files { display: none; }
}
@media (max-width: 900px) {
  :root { --fs: 18px; }
  .app { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .app.files-closed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 10px; top: 10px; bottom: 10px; width: min(18rem, 86vw); z-index: 30; background: var(--glass-strong); transform: translateX(-110%); transition: transform .2s ease; }
  .sidebar.open { transform: none; }
  .only-narrow { display: inline-grid; }
  #filesToggle span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* iMind – chữ ký thương hiệu & giới thiệu */
.brand-line { height: 3px; border-radius: 3px; background: var(--brand-grad); opacity: .85; margin: -.3rem .2rem 0; }
.made-by {
  display: flex; align-items: center; justify-content: center; gap: .55rem; width: 100%;
  border: 0; background: transparent; padding: .35rem .4rem; border-radius: var(--r-sm);
  color: var(--muted); font-size: .72rem; letter-spacing: .02em;
}
.made-by img { height: 1.05rem; width: auto; opacity: .85; transition: opacity .15s; }
.made-by:hover { background: var(--glass-soft); color: var(--text); }
.made-by:hover img { opacity: 1; }
.about { width: min(34rem, 94vw); padding: 0; overflow: hidden; }
.about-top { position: relative; padding: 2rem 2rem 1.4rem; text-align: center; }
.about-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--brand-grad); }
.about-top img { width: min(15rem, 70%); height: auto; }
.about-top .icon-btn { position: absolute; top: .8rem; right: .8rem; }
.about-body { padding: 1.4rem 2rem 1.8rem; }
.about-body h2 { margin: 0 0 .3rem; font-size: 1.25rem; }
.about-body > p { margin: 0 0 1rem; color: var(--muted); font-size: .95rem; }
.about-feats { list-style: none; padding: 0; margin: 0 0 1.3rem; display: grid; gap: .5rem; }
.about-feats li { display: flex; gap: .7rem; align-items: baseline; font-size: .92rem; }
.about-feats .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--c); flex: none; transform: translateY(-.1em); }
.contact {
  display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; border-radius: var(--r-md);
  background: var(--accent-soft); border: 1px solid var(--edge);
}
.contact .ic { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--btn-grad); color: #fff; flex: none; }
.contact .ic svg { width: 1.2rem; height: 1.2rem; }
.contact .who { flex: 1; min-width: 0; line-height: 1.35; }
.contact .who small { display: block; color: var(--muted); font-size: .78rem; }
.contact .who a { font-size: 1.2rem; font-weight: 700; color: var(--accent); text-decoration: none; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.about-foot { margin-top: 1rem; text-align: center; font-size: .75rem; color: var(--muted); }

.agent[data-agent="auto"] .dot { background: var(--brand-grad); box-shadow: 0 0 0 4px rgba(88,187,188,.18); }

/* xem trước tệp */
.viewer { width: min(72rem, 94vw); height: 90vh; max-height: 90vh; padding: 0; flex-direction: column; overflow: hidden; }
.viewer[open] { display: flex; }
.vw-head { display: flex; align-items: center; gap: .8rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); position: relative; }
.vw-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--brand-grad); opacity: .8; }
.vw-title { flex: 1; min-width: 0; }
.vw-name { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-path { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-tabs { display: flex; gap: 4px; padding: .6rem 1.2rem 0; flex-wrap: wrap; }
.vw-tabs button { border: 1px solid var(--edge); background: var(--glass-soft); border-radius: 12px 12px 0 0; padding: .4rem 1rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
.vw-tabs button.active { background: var(--glass-strong); color: var(--accent); }
.vw-body { flex: 1; overflow: auto; padding: 1.4rem 2rem 2rem; background: var(--glass-strong); }
.vw-body.pdf { padding: 0; }
.vw-body iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.vw-doc { max-width: 52rem; margin: 0 auto; }
.vw-sheet { border-collapse: collapse; font-size: .8rem; min-width: 100%; }
.vw-sheet td { border: 1px solid var(--line); padding: .35rem .6rem; vertical-align: top; max-width: 28rem; white-space: pre-wrap; }
.vw-sheet tr:first-child td { font-weight: 700; font-size: .9rem; }
.vw-slides { display: grid; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); gap: 1rem; }
.vw-slide { aspect-ratio: 16 / 9; border-radius: var(--r-md); background: var(--glass); border: 1px solid var(--edge); box-shadow: var(--shadow); padding: 1rem 1.2rem 1rem 1.5rem; overflow: hidden; position: relative; font-size: .8rem; }
.vw-slide::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--brand-grad); }
.vw-slide .n { position: absolute; right: .8rem; bottom: .5rem; font-size: .7rem; color: var(--muted); }
.vw-slide h4 { margin: 0 0 .5rem; font-size: .98rem; color: var(--accent); }
.vw-slide p { margin: .25rem 0; line-height: 1.45; }
.vw-sheet td.ttl { font-size: 1.05rem; font-weight: 700; color: var(--accent); border: 0; padding: .2rem 0 .6rem; }

/* cài đặt AI */
.ai-btn { display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left; padding: .55rem .7rem; border-radius: var(--r-md); border: 1px solid var(--edge); background: var(--glass-soft); }
.ai-btn:hover { background: var(--glass-strong); }
.ai-btn > .ico { color: var(--accent); width: 1.3em; height: 1.3em; }
.ai-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ai-lbl { font-weight: 600; font-size: .88rem; }
.ai-cur { font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-dlg { width: min(60rem, 95vw); max-height: 92vh; padding: 0; overflow: hidden; }
.ai-dlg[open] { display: flex; flex-direction: column; }
.ai-head-ico { width: 2.3rem; height: 2.3rem; border-radius: 10px; display: grid; place-items: center; background: var(--btn-grad); color: #fff; }
.ai-body { display: grid; grid-template-columns: 17rem 1fr; min-height: 0; overflow: auto; }
.ai-list { display: flex; flex-direction: column; gap: .3rem; padding: 1rem; border-right: 1px solid var(--line); overflow-y: auto; }
.ai-item { display: flex; gap: .6rem; align-items: flex-start; width: 100%; text-align: left; padding: .6rem .7rem; border-radius: var(--r-md); border: 1px solid transparent; background: transparent; font-size: .88rem; line-height: 1.3; }
.ai-item:hover { background: var(--glass-soft); }
.ai-item[aria-checked="true"] { background: var(--glass-strong); border-color: var(--edge); box-shadow: 0 2px 10px rgba(40,50,90,.06); }
.ai-item .radio { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--muted); flex: none; margin-top: .1rem; }
.ai-item.active .radio { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }
.ai-item small { display: block; font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.ai-item .tag { display: inline-block; font-size: .66rem; font-weight: 700; color: var(--ok); margin-left: .3rem; }
.ai-form { padding: 1.2rem 1.6rem 1.4rem; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.ai-form h3 { margin: 0; font-size: 1.12rem; }
.fld { display: flex; flex-direction: column; gap: .3rem; margin: .5rem 0; font-size: .9rem; font-weight: 600; }
.fld > span { display: flex; justify-content: space-between; gap: 1rem; }
.fld a { font-weight: 500; font-size: .8rem; color: var(--accent); }
.fld small { font-weight: 400; font-size: .75rem; }
.fld input { width: 100%; padding: .6rem .8rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--glass-strong); font-weight: 400; font-size: .95rem; }
.fld input:focus { outline: none; box-shadow: var(--focus); }
.key-row { display: flex; gap: .4rem; }
.key-row .btn { min-height: 0; }
.ai-status { padding: .6rem .9rem; border-radius: var(--r-sm); font-size: .88rem; }
.ai-status.ok { background: rgba(15,122,79,.12); color: var(--ok); }
.ai-status.err { background: var(--danger-soft); color: var(--danger); }
.ai-status.info { background: var(--accent-soft); color: var(--accent); }
.ai-privacy { margin-top: .8rem; }
@media (max-width: 760px) { .ai-body { grid-template-columns: 1fr; } .ai-list { border-right: 0; border-bottom: 1px solid var(--line); } }

/* thanh bên: không co các khối, chỉ danh sách trò chuyện co giãn; màn thấp thì cuộn */
.sidebar { overflow-y: auto; overflow-x: hidden; }
.sidebar > * { flex-shrink: 0; }
.sidebar > .side-section.grow { flex: 1 1 auto; min-height: 6rem; }
.brand-name { font-size: 1.05rem; white-space: nowrap; }

/* đăng nhập (chế độ máy chủ) */
.login { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.login-card { width: min(27rem, 100%); padding: 2rem 2rem 1.6rem; display: flex; flex-direction: column; gap: .3rem; background: var(--glass-strong); }
.login-logo { width: 9rem; height: auto; align-self: center; margin-bottom: .4rem; }
.login-card h1 { text-align: center; font-size: 1.35rem; margin: 0 0 .8rem; }
.login-tabs { margin-bottom: .4rem; }
.login-card .btn-block { margin-top: .6rem; min-height: 3rem; font-size: 1rem; }
.login-help { text-align: center; margin-top: .8rem; }
.login-help a { color: var(--accent); font-weight: 600; text-decoration: none; }
body.need-login .app { filter: blur(6px); pointer-events: none; }
/* hộp người dùng */
.user-box { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: var(--r-md); background: var(--glass-soft); border: 1px solid var(--edge); }
.user-ava { width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--btn-grad); color: #fff; font-weight: 700; font-size: .9rem; }
.user-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-weight: 600; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-mail { font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* máy chủ: không có "mở bằng ứng dụng / mở thư mục" trên máy người dùng */
body.mode-server [data-reveal], body.mode-server #vwOpen { display: none !important; }
.font-ctrl .side-label { white-space: nowrap; }

/* kho lưu trữ (chế độ máy chủ) */
.only-server { display: none; }
body.mode-server .only-server { display: flex; }
.fld-row { display: grid; grid-template-columns: 1fr 10rem; gap: .8rem; }
details.adv { margin: .3rem 0; font-size: .85rem; }
details.adv summary { cursor: pointer; color: var(--muted); }
#stHelp { color: var(--accent); font-weight: 600; margin-bottom: .2rem; }
@media (max-width: 760px) { .fld-row { grid-template-columns: 1fr; } }
