/* Chip file + trình xem file (web/file_pages.py, docs/dev-notes/file-open.md). Tách khỏi app.css để thay đổi khu trú. */
.fchip { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; flex: none; }
.fchip-view, .fchip-act { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 11.5px; font-weight: 550; line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap; }
.fchip-view:hover, .fchip-act:hover { background: var(--surface-2); color: var(--text); text-decoration: none; border-color: var(--accent); }
.fchip-view .ic, .fchip-act .ic { width: 12px; height: 12px; color: var(--muted); }
.fchip-act[disabled] { opacity: .55; cursor: progress; }
/* "Mở"/"Thư mục" chỉ hiện khi dùng web trên chính máy chạy hub (files.js gắn class; server vẫn tự kiểm) */
.fchip-act { display: none; }
html.file-local .fchip-act, .fchip-act.show { display: inline-flex; }
.dfile summary .fchip { margin-left: 4px; }

.fview-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.fview-head h1 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.fview-path { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.fview-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.fview-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.fview-code { margin: 0; overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55; tab-size: 4; counter-reset: ln; }
.fview-code .ln { display: block; padding: 0 12px 0 0; white-space: pre; min-height: 1.55em; }
.fview-code .ln::before { counter-increment: ln; content: counter(ln); display: inline-block; width: 4.5em; padding-right: 12px; margin-right: 12px; text-align: right;
  color: var(--faint); border-right: 1px solid var(--line); user-select: none; position: sticky; left: 0; background: var(--surface-2); }
.fview-code.wrap .ln { white-space: pre-wrap; overflow-wrap: anywhere; padding-left: 5.9em; text-indent: -5.9em; }
.fview-img { display: block; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px; }
@media (max-width: 760px) { .fview-code { font-size: 12px; } .fview-code .ln::before { width: 3.2em; } }
.fview-open { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* Markdown: "Xem đẹp" (mặc định) ↔ "Mã nguồn" — data-mode do static/files.js đổi, nhớ theo người xem */
.fview-modes { margin: 0 0 12px; }
.fview-modes .seg-b { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border: 0; border-radius: 999px; background: none;
  color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: 560; cursor: pointer; }
.fview-modes .seg-b .ic { width: 13px; height: 13px; }
.fview-modes .seg-b[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.fview-body[data-mode="md"] .fview-code, .fview-body[data-mode="src"] .fview-md { display: none; }
.fview-md { max-width: 78ch; margin: 0 auto; padding: 4px 4px 12px; font-family: var(--serif); font-size: 16px; line-height: 1.7; color: var(--text);
  overflow-wrap: anywhere; }
.fview-md h1, .fview-md h2, .fview-md h3, .fview-md h4 { font-family: var(--sans, inherit); line-height: 1.3; margin: 1.4em 0 .5em; }
.fview-md h1 { font-size: 1.6em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.fview-md h2 { font-size: 1.3em; padding-bottom: .25em; border-bottom: 1px solid var(--line); }
.fview-md h3 { font-size: 1.12em; } .fview-md h4 { font-size: 1em; }
.fview-md p { margin: .7em 0; } .fview-md ul, .fview-md ol { margin: .6em 0; padding-left: 1.6em; } .fview-md li { margin: .25em 0; }
.fview-md blockquote { margin: .8em 0; padding: .2em 1em; border-left: 3px solid var(--accent); color: var(--text-2); background: var(--surface-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.fview-md code { font-family: var(--mono); font-size: .86em; padding: .1em .35em; border-radius: 4px; background: var(--surface-3); }
.fview-md pre { font-size: 13px; line-height: 1.5; overflow: auto; } .fview-md pre code { padding: 0; background: none; font-size: inherit; }
.fview-md hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.fview-md table { border-collapse: collapse; margin: .8em 0; font-size: .92em; } .fview-md th { background: var(--surface-2); font-weight: 600; }
.fview-md td, .fview-md th { border: 1px solid var(--line); padding: .35em .65em; vertical-align: top; }
.fview-md .tx-table { overflow-x: auto; }
.fview-md .al-center { text-align: center; } .fview-md .al-right { text-align: right; }
.fview-md input[type="checkbox"] { margin-right: .4em; }

/* Panel xem file trượt từ phải (kiểu claude.ai) — base.html #fpanel, static/files.js */
.fpanel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; width: min(760px, 52vw); min-width: 380px; display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line-2); box-shadow: var(--shadow-lg); transform: translateX(100%);
  transition: transform .22s cubic-bezier(.2, .7, .2, 1); outline: none; }
.fpanel[hidden] { display: none; }
html.fpanel-open .fpanel { transform: none; }
.fpanel-bar { display: flex; align-items: center; gap: 4px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.fpanel-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fpanel-body { flex: 1; overflow: auto; padding: 12px; overscroll-behavior: contain; }
.fpanel-body .card { margin: 0 0 12px; }
.fpanel-body .fview-head h1 { font-size: 17px; }
.fpanel-body .fview-code { max-height: none; }
.fpanel-body .fview-img { width: auto; max-height: 70vh; }
.fpanel-body .fview-md { font-size: 15px; }
.fpanel-body.loading { opacity: .55; }
.fpanel-msg { padding: 24px 8px; color: var(--muted); text-align: center; }
.fchip-view.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
/* màn rộng: đẩy nội dung chính sang trái thay vì che — chat vẫn đọc được cạnh file */
@media (min-width: 1200px) { html.fpanel-open #main { width: auto; margin-right: min(760px, 52vw); min-width: 0; transition: margin-right .22s; } }
@media (max-width: 760px) { .fpanel { width: 100vw; min-width: 0; border-left: 0; } }
@media (prefers-reduced-motion: reduce) { .fpanel { transition: none; } }
/* toast (kết quả "Mở bằng ứng dụng"/"Mở thư mục" trong panel) luôn nổi trên panel */
html.fpanel-open .toasts { z-index: 70; }
/* chat điều phối: panel mở thì gập cột thông tin bên phải để khung chat không bị ép */
html.fpanel-open .mgr-grid { grid-template-columns: minmax(0, 1fr) 0; }
html.fpanel-open .mgr-side { display: none; }
