:root {
  --brand: #132C52;
  --brand-dark: #0C1E3A;
  --brand-deep: #1A3A6B;
  --brand-light: #EEF3F9;
  --brand-soft: #DBEAFE;
  --brand-border: #93C5FD;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #CBD5E1;
  --border-soft: #E2E8F0;
  --text: #0F172A;
  --text-muted: #605E5C;
  --danger: #B91C1C;
  --danger-bg: #FEF2F2;
  --success: #15803D;
  --success-bg: #F0FDF4;
  --warn: #B45309;
  --warn-bg: #FFFBEB;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(12, 30, 58, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.muted-text {
  color: var(--text-muted);
  font-size: 12.5px;
}

.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* Đăng nhập */
.login-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(145deg, var(--brand-dark) 0%, var(--brand) 55%, var(--brand-deep) 100%);
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.login-brand h1 {
  font-size: 20px;
  color: var(--brand);
  line-height: 1.2;
}

.login-brand p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--brand);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-mark.small svg {
  width: 19px;
  height: 19px;
}

/* Layout chính */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 30, 58, 0.48);
  backdrop-filter: blur(2px);
  z-index: 790;
}

.sidebar-backdrop.open {
  display: block;
}

.mobile-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mobile-ws-sub {
  display: none;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 52vw;
}

.mobile-bottom-nav {
  display: none;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.quick-prompt-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}

.sidebar {
  width: 280px;
  background: var(--brand-dark);
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  color: #FFFFFF;
}

.brand-sub {
  font-size: 11.5px;
  color: #93C5FD;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.section-label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94A3B8;
  margin-bottom: 6px;
}

.workspace-picker {
  display: flex;
  gap: 6px;
}

.workspace-picker select {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.09);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  padding: 7px 10px;
}

.workspace-picker select option {
  color: var(--text);
  background: #FFFFFF;
}

.workspace-picker .icon-btn {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.path-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: #94A3B8;
  word-break: break-all;
}

.nav-list {
  padding: 10px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #CBD5E1;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item.active {
  background: var(--brand-deep);
  color: #FFFFFF;
}

.nav-badge {
  margin-left: auto;
  background: #2563EB;
  color: #FFFFFF;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #94A3B8;
  margin-bottom: 8px;
}

.btn-link {
  background: none;
  border: none;
  color: #93C5FD;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: #E2E8F0;
  cursor: pointer;
  font-size: 12.5px;
}

.conv-item.active {
  background: rgba(147, 197, 253, 0.18);
  color: #FFFFFF;
}

.conv-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.conv-act-btn,
.conv-del {
  background: none;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  padding: 4px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background 0.14s ease, color 0.14s ease;
}

.conv-act-btn svg,
.conv-del svg {
  width: 14px;
  height: 14px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.sidebar-footer .btn-ghost {
  color: #CBD5E1;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Main Area */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h2 {
  font-size: 16px;
  color: var(--brand);
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.ok {
  background: var(--success-bg);
  color: var(--success);
}

.status-badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-badge.err {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-badge.neutral {
  background: var(--brand-light);
  color: var(--brand);
}

.notice-banner {
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid #FDE68A;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* Nút & Form */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--brand);
  color: #FFFFFF;
}

.btn-outline {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #FECACA;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.field input, .field select, .field textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13px;
}

.alert-error {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}

/* Chat */
.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-field label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.inline-field select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 440px;
  padding: 24px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--brand);
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--text-muted);
  line-height: 1.5;
}

.msg-bubble {
  max-width: 85%;
  padding: 11px 15px;
  border-radius: 12px;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}

.msg-user-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bubble.user {
  align-self: flex-end;
  background: var(--brand);
  color: #FFFFFF;
  border-radius: 14px 14px 4px 14px;
}

.msg-bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-soft);
  max-width: 94%;
  white-space: normal;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

/* Định dạng Markdown đầy đủ giống Antigravity */
.md-body {
  font-size: 13.8px;
  line-height: 1.62;
  color: var(--text);
  word-break: break-word;
}

.md-p {
  margin: 0 0 10px;
}

.md-p:last-child {
  margin-bottom: 0;
}

.md-h {
  color: var(--brand);
  font-weight: 700;
  margin: 14px 0 8px;
  line-height: 1.35;
}

.md-h:first-child {
  margin-top: 2px;
}

.md-h1 { font-size: 18px; border-bottom: 1px solid var(--border-soft); padding-bottom: 5px; }
.md-h2 { font-size: 16px; border-bottom: 1px solid var(--border-soft); padding-bottom: 4px; }
.md-h3 { font-size: 14.5px; }
.md-h4 { font-size: 13.8px; }

.md-list {
  margin: 6px 0 10px 20px;
  padding: 0;
}

.md-list li {
  margin-bottom: 4px;
}

.md-task-item {
  list-style: none;
  margin-left: -18px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.md-hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 12px 0;
}

.md-inline-code {
  background: var(--brand-light);
  color: var(--brand-dark);
  border: 1px solid #DCE7F5;
  padding: 1px 6px;
  border-radius: 5px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
}

.md-link {
  color: #1D4ED8;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.md-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--brand-border);
  background: var(--brand-light);
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  vertical-align: middle;
  touch-action: manipulation;
}

.md-file-chip svg {
  width: 12.5px;
  height: 12.5px;
  flex-shrink: 0;
}

/* Bảng Markdown chuẩn Antigravity */
.md-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.md-table th {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 700;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.md-table td {
  padding: 7px 11px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.md-table tbody tr:last-child td {
  border-bottom: none;
}

.md-table tbody tr:nth-child(even) {
  background: #F8FAFC;
}

/* Khối Code có tiêu đề ngôn ngữ + tô màu + nút sao chép ghim cố định khi cuộn */
.md-code-block {
  margin: 10px 0 12px;
  border-radius: 9px;
  overflow: visible;
  border: 1px solid #1E293B;
  background: #0F172A;
}

.md-code-head {
  position: sticky;
  top: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #1E293B;
  border-bottom: 1px solid #334155;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.28);
}

.md-code-lang {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #93C5FD;
  letter-spacing: 0.4px;
}

.md-code-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.md-code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #475569;
  background: rgba(255, 255, 255, 0.06);
  color: #E2E8F0;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.md-code-copy.preview-btn {
  border-color: #3B82F6;
  background: rgba(59, 130, 246, 0.18);
  color: #BFDBFE;
}

/* Khung xem trước HTML/SVG trực tiếp trong Trình code & Hộp thoại Chat */
.code-viewport.split-mode {
  flex-direction: row;
}

.code-viewport.split-mode .cv-edit-wrap {
  flex: 1 1 50%;
  border-right: 1px solid var(--border);
}

.code-viewport.split-mode .cv-html-preview-pane {
  flex: 1 1 50%;
}

.cv-html-preview-pane {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #E2E8F0;
}

.cv-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 12px;
}

.cv-preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 0;
  background: #CBD5E1;
}

.cv-preview-stage.mobile-sim {
  padding: 12px;
}

.cv-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 360px;
  border: none;
  background: #FFFFFF;
}

.cv-preview-stage.mobile-sim .cv-preview-frame {
  width: 390px;
  max-width: 100%;
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.25);
  border: 1px solid var(--border);
}

.modal-html-preview-stage {
  height: 68vh;
  min-height: 380px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  background: #CBD5E1;
}

.modal-html-preview-stage.mobile-sim {
  padding: 10px;
}

.modal-html-preview-stage iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #FFFFFF;
}

.modal-html-preview-stage.mobile-sim iframe {
  width: 390px;
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
}

@media (max-width: 980px) {
  .code-viewport.split-mode {
    flex-direction: column;
  }
  .code-viewport.split-mode .cv-edit-wrap {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.md-code-copy svg {
  width: 13px;
  height: 13px;
}

.md-code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 0 0 8px 8px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: #E2E8F0;
}

/* Khung bao chat + Nút cuộn nhanh xuống cuối (To Bottom) */
.chat-stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.btn-scroll-bottom {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 25;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}

.btn-scroll-bottom svg {
  width: 17px;
  height: 17px;
  display: block;
}

/* Icon phiên đang trả lời trong danh sách Hội thoại gần đây */
.conv-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conv-running-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #60A5FA;
  flex-shrink: 0;
}

.conv-running-icon svg {
  width: 14px;
  height: 14px;
}

.conv-item.is-running {
  background: rgba(96, 165, 250, 0.14);
  border-left: 2px solid #60A5FA;
}

.conv-paused-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #FBBF24;
  flex-shrink: 0;
}

.conv-paused-icon svg {
  width: 14px;
  height: 14px;
}

.conv-item.is-paused {
  background: rgba(251, 191, 36, 0.12);
  border-left: 2px solid #FBBF24;
}

/* Khay hàng đợi tin nhắn chờ gửi tuần tự */
.chat-queue-tray {
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
}

.chat-queue-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.chat-queue-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.chat-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  font-size: 12.5px;
}

.chat-queue-item.is-editing {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 7px 8px;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(19, 44, 82, 0.1);
}

.chat-queue-text {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.chat-queue-idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-queue-prompt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  cursor: pointer;
}

.chat-queue-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chat-queue-edit-input {
  width: 100%;
  min-height: 48px;
  max-height: 130px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
}

.chat-queue-edit-input:focus {
  border-color: var(--brand);
}

.chat-queue-edit-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-queue-edit-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-queue-edit-btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-queue-edit-btns .btn {
  padding: 4px 10px;
  font-size: 12px;
  height: 26px;
}

@media (hover: hover) and (pointer: fine) {
  .btn-scroll-bottom:hover { background: rgba(255, 255, 255, 0.92); border-color: rgba(19, 44, 82, 0.28); transform: translateX(-50%) translateY(-1px); }
  .chat-attach-btn:hover { background: var(--brand-light); border-color: var(--brand-border); color: var(--brand); }
}

/* Đính kèm ảnh / tệp trong khung chat (Ctrl+V, chọn tệp, kéo thả) */
.chat-composer.drag-over {
  border: 2px dashed var(--brand);
  background: var(--brand-light);
}

.chat-attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
}

.chat-attach-btn svg {
  width: 17px;
  height: 17px;
}

.chat-attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}

.chat-att-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 4px 5px;
  border-radius: 9px;
  border: 1px solid var(--brand-border);
  background: var(--brand-light);
  color: var(--brand);
  font-size: 12px;
  max-width: 230px;
}

.chat-att-thumb-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-att-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-att-chip.uploading {
  border-style: dashed;
  background: #F1F5F9;
}

.chat-att-chip.uploading .chat-att-thumb {
  opacity: 0.45;
  filter: blur(0.6px);
}

.chat-att-spin-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 30, 58, 0.34);
  color: #FFFFFF;
}

.chat-att-spin-overlay svg {
  width: 16px;
  height: 16px;
}

.chat-att-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  flex-shrink: 0;
}

.chat-att-icon svg {
  width: 16px;
  height: 16px;
}

.chat-att-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-att-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-att-size {
  font-size: 10.5px;
  color: var(--text-muted);
}

.chat-att-del {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: none;
  background: rgba(19, 44, 82, 0.12);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-att-del svg {
  width: 12px;
  height: 12px;
}

.msg-user-attachments {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 8px;
}

.msg-user-att-files {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.msg-user-att-imgs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
}

.msg-user-att-img {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #E2E8F0;
  text-decoration: none;
}

.msg-user-att-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.msg-user-att-img.loaded img {
  opacity: 1;
}

.msg-user-att-img.broken img {
  display: none;
}

.msg-user-att-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 30, 58, 0.32);
  color: #E2E8F0;
}

.msg-user-att-loader svg {
  width: 18px;
  height: 18px;
}

.msg-user-att-img.loaded .msg-user-att-loader,
.msg-user-att-img.broken .msg-user-att-loader {
  display: none;
}

.msg-user-att-fallback {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px;
  text-align: center;
  font-size: 10px;
  line-height: 1.25;
  color: #CBD5E1;
  width: 100%;
}

.msg-user-att-fallback svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

.msg-user-att-fallback span {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-user-att-img.broken .msg-user-att-fallback {
  display: flex;
}

.msg-user-att-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 205px;
  max-width: 100%;
  padding: 6px 9px 6px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.att-ft-badge {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #FFFFFF;
}

.att-ft-badge svg {
  width: 15px;
  height: 15px;
  display: block;
}

.att-ft-badge.ft-sheet { background: #16A34A; }
.att-ft-badge.ft-pdf { background: #DC2626; }
.att-ft-badge.ft-doc { background: #2563EB; }
.att-ft-badge.ft-zip { background: #D97706; }
.att-ft-badge.ft-code { background: #4F46E5; }
.att-ft-badge.ft-other { background: #475569; }

.msg-user-att-finfo {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 1px;
}

.msg-user-att-fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: #F8FAFC;
}

.msg-user-att-fsize {
  font-size: 10.5px;
  line-height: 1.2;
  color: #CBD5E1;
  font-weight: 500;
}

@media (hover: hover) and (pointer: fine) {
  .msg-user-att-file:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.34);
  }
  .msg-user-att-img:hover {
    border-color: rgba(255, 255, 255, 0.55);
  }
}

.tok-comment { color: #94A3B8; font-style: italic; }
.tok-str { color: #86EFAC; }
.tok-kw { color: #93C5FD; font-weight: 600; }
.tok-num { color: #FDBA74; }
.tok-tag { color: #F9A8D4; }
.tok-var { color: #FDE047; }

/* Trích dẫn & Hộp cảnh báo GitHub Alerts */
.md-quote {
  margin: 8px 0 10px;
  padding: 8px 12px;
  border-left: 3.5px solid var(--brand);
  background: var(--brand-light);
  border-radius: 0 7px 7px 0;
  color: var(--text);
}

.md-alert {
  margin: 8px 0 10px;
  padding: 9px 12px;
  border-radius: 8px;
  border-left: 4px solid var(--brand);
  background: var(--brand-light);
}

.md-alert-title {
  font-weight: 700;
  font-size: 12.5px;
  margin-bottom: 3px;
  color: var(--brand);
}

.md-alert-tip { border-left-color: #15803D; background: #F0FDF4; }
.md-alert-tip .md-alert-title { color: #15803D; }
.md-alert-warning, .md-alert-caution { border-left-color: #B45309; background: #FFFBEB; }
.md-alert-warning .md-alert-title, .md-alert-caution .md-alert-title { color: #B45309; }

/* Hiển thị ảnh trực tiếp trong tin nhắn + Bấm mở link gốc */
.md-img-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.md-img-card {
  display: flex;
  flex-direction: column;
  max-width: 440px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #F8FAFC;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 4px 14px rgba(12, 30, 58, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.md-img-frame {
  background: #0F172A;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 360px;
  overflow: hidden;
}

.md-img-frame img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.md-img-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 11px;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
}

.md-img-name {
  font-weight: 600;
  color: var(--brand);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-img-open {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.md-img-open svg {
  width: 13px;
  height: 13px;
}

@media (hover: hover) and (pointer: fine) {
  .md-file-chip:hover { background: var(--brand-soft); }
  .md-code-copy:hover { background: rgba(255, 255, 255, 0.14); color: #FFFFFF; }
  .md-img-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(12, 30, 58, 0.16); border-color: var(--brand-border); }
  .md-img-card:hover .md-img-open { color: var(--brand); }
}

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.msg-bubble.user .msg-footer {
  border-top-color: rgba(255, 255, 255, 0.16);
}

.msg-meta {
  font-size: 11px;
  opacity: 0.78;
  margin-top: 0;
}

.msg-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.msg-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  border: 1px solid var(--border-soft);
  background: #F8FAFC;
  color: #475569;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.msg-act-btn svg {
  width: 12.5px;
  height: 12.5px;
  flex-shrink: 0;
}

.msg-act-btn.is-icon {
  width: 24px;
  padding: 0;
  justify-content: center;
}

.msg-act-btn.is-icon svg {
  width: 13px;
  height: 13px;
}

.msg-act-btn.copied {
  border-color: #86EFAC;
  background: #F0FDF4;
  color: #15803D;
}

.msg-bubble.user .msg-act-btn {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.22);
  color: #E2E8F0;
}

.msg-bubble.user .msg-act-btn.copied {
  background: rgba(34, 197, 94, 0.28);
  border-color: rgba(134, 239, 172, 0.55);
  color: #FFFFFF;
}

.msg-edit-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: min(520px, 76vw);
}

.msg-edit-input {
  width: 100%;
  min-height: 76px;
  max-height: 260px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid rgba(147, 197, 253, 0.65);
  background: #FFFFFF;
  color: #0F172A;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.msg-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.msg-edit-hint {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.85);
}

.msg-edit-btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.msg-edit-cancel,
.msg-edit-save {
  height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.msg-edit-cancel {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: #FFFFFF;
}

.msg-edit-save {
  background: #FFFFFF;
  border: 1px solid #FFFFFF;
  color: var(--brand-dark);
}

@media (hover: hover) and (pointer: fine) {
  .msg-act-btn:hover { background: var(--brand-light); border-color: var(--brand-border); color: var(--brand); }
  .msg-bubble.user .msg-act-btn:hover { background: rgba(255, 255, 255, 0.24); color: #FFFFFF; }
  .msg-edit-cancel:hover { background: rgba(255, 255, 255, 0.24); }
  .msg-edit-save:hover { background: #EFF6FF; }
}

.msg-log {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  background: #0F172A;
  color: #CBD5E1;
  font-family: Consolas, monospace;
  font-size: 12px;
  max-height: 160px;
  overflow-y: auto;
}

.chat-composer {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.chat-composer textarea {
  width: 100%;
  border: none;
  resize: vertical;
  min-height: 58px;
  max-height: 200px;
  outline: none;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

.composer-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Thanh thông số hạn mức & Token gọn ngay dưới khung nhập chat */
.chat-usage-strip {
  margin-top: 6px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  user-select: none;
}

.chat-usage-strip:hover {
  border-color: var(--border);
  background: #F8FAFC;
}

.chat-usage-strip.is-reloading {
  opacity: 0.62;
  cursor: progress;
}

.chat-usage-strip-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  min-width: 0;
  flex: 1;
}

.chat-usage-loading {
  font-size: 11.5px;
  color: var(--text-muted);
}

.cus-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cus-ring-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.cus-ring-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 1.5;
}

.cus-ring-pct {
  font-weight: 600;
  color: var(--text);
}

.cus-ring-item .usage-ring {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.cus-divider {
  display: none;
}

.cus-group-tokens {
  margin-left: auto;
  justify-content: flex-end;
}

.cus-group-sep {
  color: #94A3B8;
  font-weight: 600;
  padding: 0 2px;
  flex-shrink: 0;
  user-select: none;
}

.cus-stat-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.cus-stat-label {
  color: var(--text-muted);
}

.cus-stat-val {
  font-weight: 700;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
}

.cus-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.cus-refresh-btn:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.cus-refresh-btn svg {
  width: 13px;
  height: 13px;
}

.cus-refresh-btn.spinning svg {
  animation: agSpin 0.8s linear infinite;
}

.btn-pause-session {
  background: #FEF3C7;
  color: #B45309;
  border: 1px solid #FCD34D;
  font-weight: 600;
}

.btn-pause-session:hover:not(:disabled) {
  background: #FDE68A;
  border-color: #F59E0B;
  color: #92400E;
}

.btn-resume-session {
  background: #ECFDF5;
  color: #047857;
  border: 1px solid #6EE7B7;
  font-weight: 600;
}

.btn-resume-session:hover:not(:disabled) {
  background: #D1FAE5;
  border-color: #10B981;
  color: #065F46;
}

.btn-pause-session:disabled,
.btn-resume-session:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Cards, Tables, Files */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 12px;
  min-width: 0;
}

.card h3 {
  font-size: 15px;
  color: var(--brand);
  min-width: 0;
  flex: 1 1 auto;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
}

.crumb-btn {
  background: var(--brand-light);
  color: var(--brand);
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-label {
  cursor: pointer;
}

.files-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.file-list-card, .editor-card {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  overflow: hidden;
}

.file-list-card {
  padding: 0;
  overflow-y: auto;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.code-editor {
  flex: 1;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  background: #F8FAFC;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.data-table th {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #F8FAFC;
  position: sticky;
  top: 0;
}

.col-actions {
  width: 120px;
  text-align: right !important;
}

.file-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--brand);
  font-weight: 500;
}

.file-name-cell svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.two-col-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.list-card {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
  background: #F8FAFC;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.list-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 10px;
  min-width: 0;
}

.list-card-top > div {
  min-width: 0;
  max-width: 100%;
}

.list-card-top .status-badge {
  white-space: nowrap;
  flex-shrink: 0;
}

.list-card .toolbar-actions {
  flex-wrap: wrap;
  gap: 6px;
}

.code-box {
  background: #0F172A;
  color: #E2E8F0;
  border-radius: 8px;
  padding: 12px;
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

.cmd-inline {
  margin-top: 8px;
  padding: 8px;
  border-radius: 6px;
  background: #0F172A;
  color: #E2E8F0;
  font-family: Consolas, monospace;
  font-size: 11.5px;
  word-break: break-all;
}

/* Modal căn chính giữa */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 30, 58, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 900;
}

.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  font-size: 15.5px;
  color: var(--brand);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--brand-dark);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: 9px;
  box-shadow: var(--shadow);
  z-index: 1000;
  font-size: 13px;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Bộ chọn Model kiểu Antigravity 2.0 */
.model-picker-wrap {
  position: relative;
}

.model-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.model-trigger-name {
  color: var(--brand);
}

.model-trigger-level {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}

.chev-icon, .chev-right {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 370px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(12, 30, 58, 0.16);
  z-index: 600;
  padding: 8px;
}

.model-dropdown-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 10px 8px;
}

.model-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 410px;
  overflow-y: auto;
}

.model-row {
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.model-row.selected {
  background: var(--brand-light);
}

.model-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.model-row-main {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}

.model-row-name {
  font-weight: 600;
  color: var(--text);
  font-size: 13.5px;
}

.model-row-level {
  color: var(--text-muted);
  font-size: 12.5px;
}

.model-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.model-tag.new {
  background: var(--brand-light);
  color: var(--brand);
  border-color: var(--brand-border);
}

.model-tag.soon {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #FDE68A;
}

.model-check {
  width: 16px;
  height: 16px;
  color: var(--brand);
  flex-shrink: 0;
}

.model-levels {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.level-pill {
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.level-pill.active {
  background: var(--brand);
  color: #FFFFFF;
  border-color: var(--brand);
}

.model-dropdown-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 8px 4px;
}

.model-usage-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
}

.model-usage-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-usage-left svg {
  width: 16px;
  height: 16px;
}

.usage-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.usage-stat-box {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 12px;
  background: #F8FAFC;
}

.usage-stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
}

.usage-stat-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
  margin-top: 3px;
}

.usage-stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.usage-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 10px;
}

.usage-section-head h4 {
  font-size: 14px;
  color: var(--brand);
  font-weight: 700;
}

.usage-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.usage-filter-pill {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.usage-filter-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #FFFFFF;
}

.usage-custom-dates {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.usage-custom-dates input[type="date"] {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
}

.usage-sessions-wrap {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
}

.usage-sessions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.usage-sessions-table th, .usage-sessions-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}

.usage-sessions-table th {
  background: #F8FAFC;
  color: var(--text-muted);
  font-size: 11.5px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.usage-sessions-table tr:last-child td {
  border-bottom: none;
}

.conv-tok-pill {
  font-size: 10.5px;
  color: #CBD5E1;
  opacity: 0.85;
}

@media (hover: hover) and (pointer: fine) {
  .model-trigger:hover { background: var(--brand-light); border-color: var(--brand-border); }
  .model-row:hover { background: #F1F5F9; }
  .model-row.selected:hover { background: var(--brand-light); }
  .model-usage-btn:hover { background: var(--brand-light); }
  .level-pill:hover:not(.active) { border-color: var(--brand); color: var(--brand); }
}

.sidebar-new-wrap {
  padding: 12px 14px 4px;
}

.btn-new-conv {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  background: var(--brand-deep);
  color: #FFFFFF;
  font-weight: 600;
  cursor: pointer;
}

.btn-new-conv svg {
  width: 16px;
  height: 16px;
}

.google-auth-pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(147, 197, 253, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
}

.google-auth-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  text-align: left;
  flex: 1;
}

.google-auth-pill svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.google-auth-pill.connected {
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(21, 128, 61, 0.25);
}

.mt-8 { margin-top: 8px; }

.notice-banner.info {
  background: var(--brand-light);
  color: var(--brand);
  border-bottom-color: var(--brand-border);
}

.composer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.model-dropdown.drop-up {
  top: auto;
  bottom: calc(100% + 8px);
}

.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 10px;
}

.auth-tab-btn {
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}

.auth-tab-btn.active {
  background: var(--brand);
  color: #FFFFFF;
  border-color: var(--brand);
}

.step-box {
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 12px;
  background: #F8FAFC;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--brand);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  margin-right: 6px;
}

@media (max-width: 720px) {
  .hide-mobile { display: none; }
  .usage-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Hạn mức (Usage) giống Antigravity */
.usage-card {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 16px 18px;
  background: var(--surface);
  margin-bottom: 14px;
}

.usage-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.usage-group {
  padding: 10px 0;
  border-top: 1px solid var(--border-soft);
}

.usage-group:first-of-type {
  border-top: none;
  padding-top: 0;
}

.usage-group-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.usage-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.usage-limit-name {
  font-size: 13.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.usage-reset-text {
  font-size: 12.5px;
  color: #64748B;
}

.usage-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.usage-pct-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 72px;
  text-align: right;
}

.usage-ring {
  width: 22px;
  height: 22px;
  transform: rotate(-90deg);
}

.usage-ring-bg {
  fill: none;
  stroke: #E2E8F0;
  stroke-width: 2.6;
}

.usage-ring-fg {
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
}

/* Trình chọn thư mục con & huy hiệu khóa phạm vi dự án */
.folder-picker-box {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #F8FAFC;
  overflow: hidden;
}

.folder-picker-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}

.folder-picker-path {
  font-family: Consolas, monospace;
  color: var(--brand);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-picker-list {
  max-height: 210px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.folder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  background: transparent;
}

.folder-row.selected {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.folder-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.folder-row-left svg {
  width: 16px;
  height: 16px;
  color: var(--brand);
  flex-shrink: 0;
}

.folder-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lock-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}

.lock-pill svg {
  width: 13px;
  height: 13px;
}

.conv-text-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-ws-tag {
  font-size: 10.5px;
  color: #93C5FD;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .folder-row:hover { background: var(--brand-light); }
}

/* Thanh trạng thái Đang xử lý / Đã hoàn thành trên tin nhắn trợ lý */
.msg-status-bar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.msg-status-bar.running {
  background: var(--brand-soft);
  color: var(--brand);
}

.msg-status-bar.done {
  background: var(--success-bg);
  color: var(--success);
}

.msg-status-bar.failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.msg-status-bar.paused {
  background: #FEF3C7;
  color: #B45309;
}

.msg-act-btn.msg-act-resume {
  background: #ECFDF5;
  color: #047857;
  border-color: #6EE7B7;
  font-weight: 600;
}

@media (hover: hover) and (pointer: fine) {
  .msg-act-btn.msg-act-resume:hover {
    background: #D1FAE5;
    border-color: #10B981;
    color: #065F46;
  }
}

.msg-status-bar svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

@keyframes agSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin-svg {
  animation: agSpin 0.9s linear infinite;
}

.msg-steps-box {
  margin: 6px 0 8px;
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(19, 44, 82, 0.05);
  border: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.msg-steps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand);
}

.msg-steps-meta {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
}

.msg-steps-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 190px;
  overflow-y: auto;
}

.msg-step-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
  word-break: break-word;
}

.msg-step-line strong {
  color: var(--brand);
  flex-shrink: 0;
  font-size: 11.5px;
}

.msg-step-line.is-active {
  color: var(--text);
  font-weight: 500;
}

.msg-step-line.is-active strong {
  color: #2563EB;
}

.msg-step-line.is-done strong {
  color: #059669;
}

.msg-step-line.is-paused strong {
  color: #B45309;
}

.msg-step-output {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 4px;
}

.mobile-only {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) { background: var(--brand-deep); }
  .btn-outline:hover:not(:disabled) { background: var(--brand-light); border-color: var(--brand-border); }
  .btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
  .btn-danger:hover:not(:disabled) { background: #FEE2E2; }
  .nav-item:hover:not(.active) { background: rgba(255, 255, 255, 0.08); color: #FFFFFF; }
  .conv-item:hover { background: rgba(255, 255, 255, 0.1); }
  .conv-act-btn:hover { background: rgba(255, 255, 255, 0.14); color: #FFFFFF; }
  .conv-del:hover { background: rgba(239, 68, 68, 0.22); color: #FCA5A5; }
  .file-name-cell:hover { text-decoration: underline; }
  .fm-row-btn:hover { background: var(--brand-light); border-color: var(--brand-border); color: var(--brand); }
  .fm-row-btn.danger:hover { background: var(--danger-bg); border-color: #FCA5A5; color: var(--danger); }
  .fm-table tbody tr:hover { background: #F8FAFC; }
}

/* File Manager Pro (fmg.php style trong hệ màu DC Navy) */
.fm-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.fm-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 240px;
  max-width: 380px;
}

.fm-search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.fm-search-wrap input {
  width: 100%;
  padding: 7px 30px 7px 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.fm-search-clear {
  position: absolute;
  right: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 5px;
}

.fm-search-clear svg {
  width: 14px;
  height: 14px;
}

.fm-sort-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.fm-action-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.fm-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
}

.fm-icon-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.fm-pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}

.fm-pill-count.warn {
  background: var(--brand-soft);
  color: var(--brand);
}

.fm-batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  margin-bottom: 10px;
  border-radius: 9px;
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
}

.fm-batch-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fm-batch-text {
  font-weight: 600;
  color: var(--brand);
  font-size: 13px;
}

.fm-clip-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--brand);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 600;
}

.fm-upload-progress {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--brand-border);
}

.file-list-card {
  position: relative;
}

.file-list-card.drag-over {
  border: 2px dashed var(--brand);
  background: var(--brand-light);
}

.fm-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(19, 44, 82, 0.86);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  pointer-events: none;
}

.fm-drop-overlay svg {
  width: 34px;
  height: 34px;
}

.fm-search-notice {
  padding: 8px 12px;
  background: var(--brand-light);
  border-bottom: 1px solid var(--brand-border);
  font-size: 12.5px;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fm-table th, .fm-table td {
  padding: 8px 9px;
  font-size: 13px;
}

.col-check {
  width: 34px;
  text-align: center !important;
}

.col-size {
  width: 82px;
  white-space: nowrap;
}

.col-date {
  width: 116px;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}

.col-fm-actions {
  width: 158px;
  text-align: right !important;
  white-space: nowrap;
}

.fm-table tr.selected-row {
  background: var(--brand-light);
}

.fm-name-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fm-subpath {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fm-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.fm-row-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}

.fm-row-btn svg {
  width: 14px;
  height: 14px;
}

.fm-file-icon.dir { color: #1A3A6B; }
.fm-file-icon.code { color: #0369A1; }
.fm-file-icon.img { color: #0F766E; }
.fm-file-icon.zip { color: #B45309; }
.fm-file-icon.pdf { color: #B91C1C; }

.editor-title-wrap {
  min-width: 0;
  flex: 1;
}

.editor-title-wrap strong, .editor-title-wrap .muted-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-card.fullscreen {
  position: fixed;
  inset: 14px;
  z-index: 880;
  min-height: 0;
  height: calc(100vh - 28px);
  box-shadow: 0 24px 64px rgba(12, 30, 58, 0.36);
}

.fm-find-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 8px;
  background: #F8FAFC;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}

.fm-find-bar input {
  flex: 1 1 130px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
}

.fm-media-preview {
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 12px;
}

.fm-media-preview img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}

.fm-media-preview iframe {
  width: 100%;
  height: 100%;
  min-height: 460px;
  border: none;
  border-radius: 6px;
  background: #FFFFFF;
}

.fm-editor-status {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-box.modal-wide {
  max-width: 780px;
}

.fm-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.fm-badge-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand);
}

.fm-badge-tag.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

@media (max-width: 980px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 800;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .files-grid, .two-col-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .tab-panel {
    overflow-x: hidden;
    max-width: 100%;
    padding: 10px 10px 14px;
  }

  .tab-panel .card {
    padding: 12px;
  }

  .tab-panel .card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tab-panel .card-head .btn {
    align-self: flex-start;
    max-width: 100%;
  }

  .tab-panel .list-card {
    padding: 10px;
  }

  .tab-panel .list-card-top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tab-panel .list-card-top > .status-badge {
    align-self: flex-start;
  }

  .tab-panel .list-card .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tab-panel .list-card .muted-text {
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .topbar-right .status-badge {
    white-space: nowrap;
    font-size: 11px;
    padding: 4px 8px;
  }
  .msg-bubble {
    max-width: 95%;
  }
  .col-date {
    display: none;
  }
  .code-ide-shell {
    grid-template-columns: 1fr;
  }
  .code-tree-pane {
    max-height: 220px;
  }
}

/* Trình xem code (Code Viewer IDE) */
.code-ide-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.code-ide-shell.tree-collapsed {
  grid-template-columns: 1fr;
}

.code-ide-shell.tree-collapsed .code-tree-pane {
  display: none;
}

.code-ide-shell.fullscreen {
  position: fixed;
  inset: 12px;
  z-index: 890;
  height: calc(100vh - 24px);
  background: var(--bg);
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(12, 30, 58, 0.36);
}

.code-tree-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.code-tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: #F8FAFC;
}

.code-tree-head strong {
  font-size: 13px;
  color: var(--brand);
}

.code-tree-filter-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
}

.code-tree-filter-wrap input {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
  background: var(--surface);
}

.code-tree-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.ct-node {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-size: 12.8px;
  touch-action: manipulation;
}

.ct-node.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.ct-chev {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.14s ease;
}

.ct-chev.open {
  transform: rotate(90deg);
}

.ct-spacer {
  width: 13px;
  flex-shrink: 0;
}

.ct-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.ct-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ct-children {
  padding-left: 14px;
}

.code-main-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.code-tabs-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px 0;
  background: #EEF3F9;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  min-height: 38px;
}

.code-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

.code-tab.active {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--border);
  font-weight: 600;
}

.code-tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #D97706;
  flex-shrink: 0;
}

.code-tab-close {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.72;
}

.code-tab-close svg {
  width: 12px;
  height: 12px;
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.code-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 220px;
}

.cv-path-text {
  font-family: Consolas, monospace;
  font-size: 12.5px;
  color: var(--brand);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-mode-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.cv-mode-btn {
  padding: 4px 10px;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.cv-mode-btn.active {
  background: var(--brand);
  color: #FFFFFF;
}

.cv-find-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px 12px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-soft);
}

.cv-find-bar input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
}

.cv-find-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.code-viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0F172A;
  color: #E2E8F0;
}

.code-viewport.theme-light {
  background: #FFFFFF;
  color: #0F172A;
}

.cv-code-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: var(--cv-font-size, 13px);
  line-height: 1.58;
}

.cv-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.cv-table tr.cv-line-active {
  background: rgba(147, 197, 253, 0.16);
}

.code-viewport.theme-light .cv-table tr.cv-line-active {
  background: #DBEAFE;
}

.cv-table tr.cv-line-hit {
  background: rgba(250, 204, 21, 0.22);
}

.cv-ln {
  width: 52px;
  min-width: 52px;
  padding: 0 12px 0 10px;
  text-align: right;
  user-select: none;
  color: #64748B;
  border-right: 1px solid rgba(148, 163, 184, 0.22);
  vertical-align: top;
  cursor: pointer;
}

.cv-code {
  padding: 0 14px;
  white-space: pre;
  vertical-align: top;
}

.cv-code-scroll.wrap-on .cv-code {
  white-space: pre-wrap;
  word-break: break-word;
}

.code-viewport.theme-light .tok-comment { color: #64748B; }
.code-viewport.theme-light .tok-str { color: #15803D; }
.code-viewport.theme-light .tok-kw { color: #1D4ED8; }
.code-viewport.theme-light .tok-num { color: #C2410C; }
.code-viewport.theme-light .tok-tag { color: #BE185D; }
.code-viewport.theme-light .tok-var { color: #7E22CE; }

.cv-mark {
  background: #FACC15;
  color: #0F172A;
  border-radius: 2px;
  padding: 0 1px;
}

.cv-edit-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.cv-edit-gutter {
  width: 54px;
  min-width: 54px;
  padding: 12px 10px 12px 6px;
  text-align: right;
  font-family: Consolas, "Courier New", monospace;
  font-size: var(--cv-font-size, 13px);
  line-height: 1.58;
  color: #64748B;
  background: rgba(15, 23, 42, 0.35);
  border-right: 1px solid rgba(148, 163, 184, 0.22);
  overflow: hidden;
  user-select: none;
  white-space: pre;
}

.code-viewport.theme-light .cv-edit-gutter {
  background: #F8FAFC;
}

.cv-edit-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.cv-edit-highlight,
.cv-textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: none;
  padding: 12px 14px;
  box-sizing: border-box;
  font-family: Consolas, "Courier New", monospace;
  font-size: var(--cv-font-size, 13px);
  line-height: 1.58;
  letter-spacing: 0;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  -moz-tab-size: 2;
}

.cv-edit-highlight::-webkit-scrollbar,
.cv-textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.cv-edit-highlight::-webkit-scrollbar-thumb,
.cv-edit-highlight::-webkit-scrollbar-track,
.cv-edit-highlight::-webkit-scrollbar-corner {
  background: transparent;
}

.cv-edit-highlight {
  z-index: 1;
  pointer-events: none;
  user-select: none;
  background: transparent;
  color: inherit;
  scrollbar-color: transparent transparent;
}

.cv-edit-highlight code {
  display: block;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  tab-size: inherit;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0;
}

.cv-textarea {
  z-index: 2;
  outline: none;
  resize: none;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: #F8FAFC;
}

.code-viewport.theme-light .cv-textarea {
  caret-color: #0F172A;
}

.cv-textarea::selection {
  background: rgba(96, 165, 250, 0.36);
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.code-viewport.theme-light .cv-textarea::selection {
  background: rgba(37, 99, 235, 0.24);
}

.cv-textarea.plain-fallback {
  color: inherit;
  -webkit-text-fill-color: inherit;
}

.cv-edit-highlight.wrap-on,
.cv-textarea.wrap-on {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

.cv-empty {
  margin: auto;
  text-align: center;
  padding: 28px;
  max-width: 420px;
  color: #94A3B8;
}

.code-viewport.theme-light .cv-empty {
  color: var(--text-muted);
}

.cv-empty svg {
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
  color: #93C5FD;
}

.code-viewport.theme-light .cv-empty svg {
  color: var(--brand);
}

.cv-empty h4 {
  font-size: 15px;
  margin-bottom: 6px;
  color: #F8FAFC;
}

.code-viewport.theme-light .cv-empty h4 {
  color: var(--brand);
}

@media (hover: hover) and (pointer: fine) {
  .ct-node:hover:not(.active) { background: var(--brand-light); }
  .code-tab:hover:not(.active) { background: rgba(255, 255, 255, 0.65); color: var(--brand); }
  .code-tab-close:hover { background: rgba(19, 44, 82, 0.14); opacity: 1; }
  .cv-ln:hover { color: #93C5FD; }
  .quick-prompt-chip:hover { background: var(--brand-light); border-color: var(--brand-border); }
}

/* Tối ưu Mobile chuẩn App Chat AI (<= 980px & <= 640px) */
@media (max-width: 980px) {
  .mobile-only { display: inline-flex; }
  .hide-mobile { display: none !important; }
  .mobile-ws-sub { display: block; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 310px);
    z-index: 810;
    transform: translateX(-104%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 16px 0 42px rgba(12, 30, 58, 0.34);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .main-area {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    height: 100%;
  }

  .topbar {
    min-height: 54px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
    gap: 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
  }

  .topbar h2 {
    font-size: 15.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tab-panel {
    padding: 10px 10px 0;
    flex: 1;
    min-height: 0;
  }

  /* Tab Chat kiểu App Chat AI: tràn viền, khung nhập ghim đáy gọn đẹp */
  #tab-chat {
    padding: 0;
    background: var(--bg);
  }

  #tab-chat .chat-messages {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 12px 12px 16px;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
  }

  #tab-chat .msg-bubble.user {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 18px 18px 4px 18px;
    font-size: 14.5px;
    line-height: 1.48;
  }

  #tab-chat .msg-bubble.assistant {
    max-width: 100%;
    width: 100%;
    padding: 12px 13px;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
  }

  #tab-chat .chat-composer {
    margin: 0 8px 6px;
    padding: 6px 8px 7px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 -2px 14px rgba(12, 30, 58, 0.08);
  }

  #tab-chat .chat-composer textarea {
    min-height: 34px;
    max-height: 112px;
    resize: none;
    font-size: 16px;
    line-height: 1.35;
    padding: 2px 4px 0;
  }

  #tab-chat .composer-bar {
    margin-top: 5px;
    padding-top: 5px;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
  }

  #tab-chat .composer-left {
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
  }

  #tab-chat .chat-attach-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    line-height: 0;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #tab-chat .chat-attach-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
  }

  #tab-chat .model-picker-wrap {
    flex: 1;
    min-width: 0;
    max-width: 100%;
  }

  #tab-chat .model-trigger {
    height: 32px;
    padding: 0 8px;
    gap: 4px;
    max-width: 100%;
    min-width: 0;
    font-size: 12px;
    border-radius: 999px;
  }

  #tab-chat .model-trigger-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  #tab-chat .model-trigger-level {
    font-size: 11px;
    flex-shrink: 0;
  }

  #tab-chat .model-trigger .chev-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
  }

  #tab-chat .composer-actions {
    flex-shrink: 0;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
  }

  #tab-chat #btnPauseChat,
  #tab-chat #btnResumeChat {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    line-height: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  #tab-chat #btnPauseChat span,
  #tab-chat #btnResumeChat span {
    display: none;
  }

  #tab-chat #btnPauseChat svg,
  #tab-chat #btnResumeChat svg {
    width: 14px;
    height: 14px;
    display: block;
    flex-shrink: 0;
  }

  #tab-chat #btnSendChat {
    height: 32px;
    min-height: 32px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  #tab-chat #btnSendChat svg {
    width: 14px;
    height: 14px;
    display: block;
    flex-shrink: 0;
  }

  #tab-chat .chat-usage-strip {
    margin: 0 8px 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
  }

  #tab-chat .chat-usage-strip-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 4px;
    min-width: 0;
  }

  #tab-chat .cus-divider {
    display: none;
  }

  #tab-chat .cus-group {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 7px;
    min-width: 0;
  }

  #tab-chat .cus-group::-webkit-scrollbar {
    display: none;
  }

  #tab-chat .cus-group-tokens {
    margin-left: 0;
    justify-content: flex-start;
    padding-top: 4px;
    border-top: 1px solid var(--border-soft);
    gap: 9px;
    font-size: 10.5px;
  }

  /* Model picker chuyển thành Bottom Sheet trên mobile */
  .model-dropdown,
  .model-dropdown.drop-up {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    max-height: 70dvh;
    border-radius: 16px;
    box-shadow: 0 -10px 44px rgba(12, 30, 58, 0.3);
    z-index: 860;
    padding: 10px;
  }

  .model-dropdown-list {
    max-height: calc(70dvh - 96px);
  }

  .model-trigger {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    max-width: 56vw;
  }

  .model-trigger-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Thanh điều hướng nhanh phía dưới màn hình kiểu App Mobile */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--border-soft);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    z-index: 600;
  }

  body.kbd-open .mobile-bottom-nav {
    display: none;
  }

  .mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    touch-action: manipulation;
  }

  .mbn-item svg {
    width: 19px;
    height: 19px;
  }

  .mbn-item.active {
    color: var(--brand);
    background: var(--brand-light);
  }

  /* Tối ưu các tab khác trên mobile */
  .files-grid, .two-col-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .tab-panel {
    overflow-x: hidden;
    max-width: 100%;
    padding: 10px 10px 14px;
  }

  .tab-panel .card {
    padding: 12px;
  }

  .tab-panel .card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tab-panel .card-head .btn {
    align-self: flex-start;
    max-width: 100%;
  }

  .tab-panel .list-card {
    padding: 10px;
  }

  .tab-panel .list-card-top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tab-panel .list-card-top > .status-badge {
    align-self: flex-start;
  }

  .tab-panel .list-card .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tab-panel .list-card .muted-text {
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .topbar-right .status-badge {
    white-space: nowrap;
    font-size: 11px;
    padding: 4px 8px;
  }

  .fm-action-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .fm-action-toolbar .toolbar-actions {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .code-ide-shell {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .code-tree-pane {
    max-height: 36dvh;
  }

  .code-toolbar {
    padding: 6px 8px;
  }

  .code-toolbar .toolbar-actions {
    overflow-x: auto;
    flex-wrap: nowrap;
    max-width: 100%;
    padding-bottom: 2px;
  }

  .modal-overlay {
    padding: 12px;
  }

  .modal-box {
    max-height: 88dvh;
    border-radius: 14px;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    text-align: center;
  }
}

/* Chống tự động phóng to (auto-zoom) khi focus ô nhập liệu trên iOS (iPhone dọc/ngang, iPad, PWA) */
@media (max-width: 980px), (hover: none) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea,
  [contenteditable="true"] {
    font-size: 16px !important;
  }

  .cv-edit-gutter,
  .cv-edit-highlight,
  .cv-textarea {
    font-size: 16px !important;
    font-size: max(var(--cv-font-size, 13px), 16px) !important;
  }
}

@supports (-webkit-touch-callout: none) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea,
  [contenteditable="true"] {
    font-size: 16px !important;
  }

  .cv-edit-gutter,
  .cv-edit-highlight,
  .cv-textarea {
    font-size: 16px !important;
    font-size: max(var(--cv-font-size, 13px), 16px) !important;
  }
}

@media (max-width: 640px) {
  .hide-xs { display: none !important; }
  .top-usage-btn { padding: 6px 8px; }
  .col-size, .col-date { display: none; }
  .col-fm-actions { width: 112px; }
  .md-img-card { max-width: 100%; width: 100%; }
  .md-img-frame img { max-height: 280px; }
  .usage-stats-grid { grid-template-columns: 1fr; }
}

/* Bố cục Quản lý tệp đa năng + Trình code tích hợp (kiểu fmg.php) */
.fm-pro-panel {
  gap: 8px;
}

.fm-address-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.fm-nav-btns {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.fm-crumb-box {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 3px 8px;
  background: #F8FAFC;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  min-height: 32px;
}

.fm-command-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.fm-cmd-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fm-cmd-sep {
  width: 1px;
  height: 20px;
  background: var(--border-soft);
  margin: 0 2px;
}

.fm-cmd-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}

.fm-cmd-btn svg {
  width: 15px;
  height: 15px;
}

.fm-cmd-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.fm-cmd-btn.highlight {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand-border);
  font-weight: 600;
}

.fm-cmd-btn.danger:not(:disabled) {
  color: var(--danger);
}

/* Khung 3 cột linh hoạt: Cây thư mục | Bảng/Lưới tệp | Trình Code đa tab */
.fm-workspace-shell {
  display: grid;
  grid-template-columns: 230px minmax(340px, 1fr) minmax(420px, 1.15fr);
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.fm-workspace-shell.tree-collapsed {
  grid-template-columns: minmax(340px, 1fr) minmax(420px, 1.15fr);
}

.fm-workspace-shell.tree-collapsed .fm-tree-pane {
  display: none;
}

.fm-workspace-shell.code-closed {
  grid-template-columns: 240px 1fr;
}

.fm-workspace-shell.code-closed .fm-code-dock {
  display: none;
}

.fm-workspace-shell.tree-collapsed.code-closed {
  grid-template-columns: 1fr;
}

.fm-tree-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.fm-explorer-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
}

.fm-explorer-pane.drag-over {
  border: 2px dashed var(--brand);
  background: var(--brand-light);
}

.fm-explorer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.fm-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: #F8FAFC;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.fm-status-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fm-status-sel {
  color: var(--brand);
  font-weight: 600;
}

.fm-link-btn {
  border: none;
  background: transparent;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0 2px;
}

/* Chế độ Lưới biểu tượng (Grid View kiểu Win11 fmg.php) */
.fm-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
  padding: 12px;
}

.fm-grid-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 12px 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
}

.fm-grid-card.selected-row {
  background: var(--brand-light);
  border-color: var(--brand-border);
}

.fm-grid-check {
  position: absolute;
  top: 7px;
  left: 7px;
}

.fm-grid-icon svg {
  width: 34px;
  height: 34px;
}

.fm-grid-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.fm-grid-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.fm-code-tabs-row {
  display: flex;
  align-items: center;
  background: #EEF3F9;
  border-bottom: 1px solid var(--border);
  gap: 4px;
}

.fm-code-tabs-row .code-tabs-bar {
  flex: 1;
  border-bottom: none;
}

.fm-code-dock.fullscreen {
  position: fixed;
  inset: 12px;
  z-index: 890;
  display: flex !important;
  height: calc(100vh - 24px);
  height: calc(100dvh - 24px);
  box-shadow: 0 24px 64px rgba(12, 30, 58, 0.4);
}

@media (hover: hover) and (pointer: fine) {
  .fm-cmd-btn:hover:not(:disabled) { background: var(--brand-light); border-color: var(--brand-border); color: var(--brand); }
  .fm-cmd-btn.danger:hover:not(:disabled) { background: var(--danger-bg); border-color: #FCA5A5; color: var(--danger); }
  .fm-grid-card:hover { border-color: var(--brand-border); background: #F8FAFC; }
}

@media (max-width: 1180px) {
  .fm-workspace-shell {
    grid-template-columns: 1fr 1.1fr;
  }
  .fm-workspace-shell .fm-tree-pane {
    display: none;
  }
  .fm-workspace-shell.tree-mobile-open .fm-tree-pane {
    display: flex;
    position: fixed;
    left: 10px;
    top: 64px;
    bottom: 68px;
    width: min(82vw, 290px);
    z-index: 820;
    box-shadow: 0 20px 50px rgba(12, 30, 58, 0.34);
  }
  .fm-workspace-shell.code-closed {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .fm-command-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .fm-cmd-group {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
  .fm-workspace-shell {
    grid-template-columns: 1fr;
  }
  /* Trên mobile, khi mở Trình code thì phủ gọn toàn màn hình với nút quay lại Tệp tin */
  .fm-workspace-shell:not(.code-closed) .fm-code-dock {
    position: fixed;
    inset: 0;
    z-index: 840;
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .fm-status-right {
    display: none;
  }
  .fm-grid-view {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
    padding: 8px;
  }
}

/* ===== MENU THEO DÕI CẤU HÌNH VPS ===== */
.vps-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.vps-toolbar-left h3 {
  font-size: 16px;
  color: var(--brand);
  margin-bottom: 2px;
}

.vps-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.vps-auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.vps-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.vps-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vps-kpi-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.vps-kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.vps-kpi-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand);
}

.vps-kpi-sub {
  font-size: 12px;
  line-height: 1.4;
}

.vps-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}

.vps-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.3s ease, background-color 0.25s ease;
}

.vps-bar-fill.ok { background: var(--success); }
.vps-bar-fill.warn { background: var(--warn); }
.vps-bar-fill.danger { background: var(--danger); }

.vps-kv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.vps-kv-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 13px;
}

.vps-kv-row:last-child {
  border-bottom: none;
}

.vps-kv-key {
  color: var(--text-muted);
  flex-shrink: 0;
}

.vps-kv-val {
  color: var(--text);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

.vps-svc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg);
}

.vps-svc-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.vps-svc-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.vps-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.vps-badge.active {
  background: var(--success-bg);
  color: var(--success);
}

.vps-badge.inactive {
  background: var(--border-soft);
  color: var(--text-muted);
}

.vps-badge.failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.vps-disk-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.vps-disk-bar-wrap .vps-bar {
  flex: 1;
}

@media (max-width: 1080px) {
  .vps-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .vps-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== IMAGE LIGHTBOX POPUP ===== */
.msg-user-att-img,
.md-img-card,
.cv-media-img-link,
.chat-att-chip .chat-att-thumb {
  cursor: zoom-in;
}

.img-lb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(8, 15, 28, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  animation: imgLbFadeIn 0.16s ease-out;
}

.img-lb-overlay.hidden {
  display: none;
}

@keyframes imgLbFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.img-lb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(8, 15, 28, 0.85) 0%, rgba(8, 15, 28, 0) 100%);
  color: #f8fafc;
  flex-shrink: 0;
  z-index: 2;
}

.img-lb-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.img-lb-count {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  flex-shrink: 0;
}

.img-lb-count.hidden {
  display: none;
}

.img-lb-title {
  font-size: 14px;
  font-weight: 500;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.img-lb-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.img-lb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  min-width: 34px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.img-lb-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.34);
}

.img-lb-btn svg {
  width: 16px;
  height: 16px;
}

.img-lb-zoom-val {
  min-width: 50px;
  font-variant-numeric: tabular-nums;
}

.img-lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 12px 56px 24px;
}

.img-lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
  transition: transform 0.14s ease-out;
  transform-origin: center center;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

.img-lb-img.zoomed {
  cursor: zoom-out;
}

.img-lb-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.72);
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.img-lb-nav:hover {
  background: rgba(30, 41, 59, 0.94);
  transform: translateY(-50%) scale(1.06);
}

.img-lb-nav.hidden {
  display: none;
}

.img-lb-prev { left: 16px; }
.img-lb-next { right: 16px; }

.img-lb-nav svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 640px) {
  .img-lb-topbar {
    padding: 10px 12px;
  }
  .img-lb-stage {
    padding: 8px 12px 20px;
  }
  .img-lb-nav {
    width: 36px;
    height: 36px;
  }
  .img-lb-prev { left: 8px; }
  .img-lb-next { right: 8px; }
  .img-lb-zoom-val {
    display: none;
  }
}

/* === CHAT RIGHT-SIDE MEDIA & CODE MULTI-TAB PANEL === */
.chat-workspace-split {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  gap: 0;
  position: relative;
}

.chat-primary-col {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-media-resizer {
  flex: 0 0 10px;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
}

.chat-media-resizer::after {
  content: "";
  width: 3px;
  height: 44px;
  border-radius: 99px;
  background: var(--border, #CBD5E1);
  transition: background 0.15s ease, height 0.15s ease;
}

.chat-media-resizer.dragging::after {
  background: var(--brand, #132C52);
  height: 68px;
}

.chat-media-pane {
  flex: 0 0 var(--cmp-width, 520px);
  width: var(--cmp-width, 520px);
  max-width: 72%;
  min-width: 340px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  border: 1px solid var(--border-soft, #CBD5E1);
  border-radius: var(--radius, 12px);
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

.chat-media-pane.is-expanded {
  flex: 0 0 70% !important;
  width: 70% !important;
  max-width: 80% !important;
}

/* Row 1: IDE Tab Bar (matches reference screenshot) */
.cmp-tabbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
  min-height: 42px;
}

.cmp-tabs-list {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.cmp-tabs-list::-webkit-scrollbar {
  display: none;
}

.cmp-tab {
  height: 30px;
  max-width: 215px;
  padding: 0 6px 0 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  touch-action: manipulation;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.cmp-tab.active {
  background: #FFFFFF;
  border-color: #CBD5E1;
  color: #0F172A;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.cmp-tab-ico {
  width: 14px;
  height: 14px;
  color: var(--brand, #132C52);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

.cmp-tab-ico svg {
  width: 14px;
  height: 14px;
  display: block;
}

.cmp-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cmp-tab-dirty {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand, #132C52);
  flex-shrink: 0;
}

.cmp-tab-close {
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 0;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: #64748B;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background 0.12s ease, color 0.12s ease;
}

.cmp-tab-close svg {
  width: 12px;
  height: 12px;
  display: block;
}

.cmp-tabbar-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

/* Row 2: Breadcrumb & Action Subbar */
.cmp-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  background: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
  min-height: 36px;
}

.cmp-breadcrumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  font-size: 12px;
  color: #64748B;
}

.cmp-breadcrumbs::-webkit-scrollbar {
  display: none;
}

.cmp-crumb-btn {
  border: none;
  background: transparent;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 12px;
  color: #64748B;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  touch-action: manipulation;
}

.cmp-crumb-sep {
  width: 12px;
  height: 12px;
  color: #94A3B8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cmp-crumb-sep svg {
  width: 12px;
  height: 12px;
  display: block;
}

.cmp-crumb-file {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: #0F172A;
  white-space: nowrap;
  flex-shrink: 0;
}

.cmp-crumb-file svg {
  width: 14px;
  height: 14px;
  color: var(--brand, #132C52);
  display: block;
}

.cmp-subbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cmp-folder-pill,
.cmp-save-pill {
  height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid #CBD5E1;
  background: #EEF3F9;
  color: var(--brand, #132C52);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.cmp-save-pill {
  background: var(--brand, #132C52);
  border-color: var(--brand, #132C52);
  color: #FFFFFF;
}

.cmp-folder-pill svg,
.cmp-save-pill svg {
  width: 14px;
  height: 14px;
  display: block;
  flex-shrink: 0;
}

.cmp-icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 0;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--brand, #132C52);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cmp-icon-btn.active {
  background: var(--brand-soft, #DBEAFE);
  border-color: var(--brand-border, #93C5FD);
  color: var(--brand-dark, #0C1E3A);
}

.cmp-icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

/* Row 3: Unified Stage */
.cmp-stage {
  flex: 1 1 auto;
  min-height: 200px;
  background: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.cmp-stage.is-media-dark {
  background: #0F172A;
}

.cmp-stage.is-audio-mode {
  background: linear-gradient(155deg, #0C1E3A 0%, #132C52 55%, #1A3A6B 100%);
  padding: 20px;
}

.cmp-stage.is-code-mode,
.cmp-stage.is-pdf-mode {
  background: #FFFFFF;
  align-items: stretch;
  justify-content: stretch;
}

.cmp-video-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.cmp-video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  background: #000000;
  outline: none;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
}

.cmp-audio-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.cmp-audio-visual {
  width: 100%;
  padding: 24px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(147, 197, 253, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.cmp-audio-disc {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(219, 234, 254, 0.14);
  border: 1px solid rgba(147, 197, 253, 0.35);
  color: #DBEAFE;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
}

.cmp-audio-disc svg {
  width: 28px;
  height: 28px;
  display: block;
}

.cmp-audio-eq {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 24px;
}

.cmp-audio-eq span {
  width: 4px;
  height: 6px;
  border-radius: 99px;
  background: #93C5FD;
  transition: height 0.2s ease;
}

.cmp-audio-visual.is-playing .cmp-audio-eq span {
  animation: cmpEqBounce 0.9s ease-in-out infinite;
}

.cmp-audio-visual.is-playing .cmp-audio-eq span:nth-child(2) { animation-delay: 0.15s; }
.cmp-audio-visual.is-playing .cmp-audio-eq span:nth-child(3) { animation-delay: 0.3s; }
.cmp-audio-visual.is-playing .cmp-audio-eq span:nth-child(4) { animation-delay: 0.45s; }
.cmp-audio-visual.is-playing .cmp-audio-eq span:nth-child(5) { animation-delay: 0.6s; }

@keyframes cmpEqBounce {
  0%, 100% { height: 6px; opacity: 0.6; }
  50% { height: 22px; opacity: 1; }
}

.cmp-audio-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #F8FAFC;
  word-break: break-word;
  max-width: 100%;
}

.cmp-audio {
  width: 100%;
  border-radius: 99px;
  outline: none;
}

.cmp-image-wrap {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.cmp-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  cursor: zoom-in;
  transition: transform 0.18s ease;
  transform-origin: center center;
}

.cmp-image.is-zoomed {
  cursor: zoom-out;
}

/* Code / Text Viewer inside Right Panel */
.cmp-code-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #FFFFFF;
}

.cmp-code-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 10px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: #0F172A;
  background: #FFFFFF;
}

.cmp-code-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.cmp-code-row.is-target-line {
  background: #FEF9C3;
}

.cmp-code-ln {
  width: 1%;
  min-width: 44px;
  padding: 0 12px 0 10px;
  text-align: right;
  color: #94A3B8;
  user-select: none;
  vertical-align: top;
  border-right: 1px solid #F1F5F9;
  font-size: 11.5px;
}

.cmp-code-cell {
  padding: 0 14px;
  white-space: pre;
  tab-size: 2;
  vertical-align: top;
}

.cmp-code-editor {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: #0F172A;
  background: #FFFFFF;
  tab-size: 2;
}

.cmp-html-frame,
.cmp-pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #FFFFFF;
}

.cmp-pdf-wrap {
  width: 100%;
  height: 100%;
  display: flex;
}

.cmp-binary-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.cmp-binary-card {
  max-width: 340px;
  width: 100%;
  padding: 24px 20px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.cmp-binary-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #EEF3F9;
  color: var(--brand, #132C52);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cmp-binary-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.cmp-binary-name {
  font-size: 14px;
  font-weight: 700;
  color: #0F172A;
  word-break: break-word;
}

.cmp-binary-desc {
  font-size: 12.5px;
  color: #605E5C;
  line-height: 1.45;
}

.cmp-binary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.cmp-status-msg {
  position: absolute;
  inset: auto 16px 16px 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(12, 30, 58, 0.92);
  color: #F8FAFC;
  font-size: 12.5px;
  text-align: center;
  border: 1px solid rgba(147, 197, 253, 0.35);
}

/* Row 4: Contextual Bottom Toolbar */
.cmp-toolbar {
  padding: 7px 12px;
  border-top: 1px solid #E2E8F0;
  background: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.cmp-tool-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

#cmpImageTools.cmp-tool-group {
  justify-content: center;
}

.cmp-code-meta {
  font-size: 11.5px;
  color: #605E5C;
  justify-content: space-between;
}

.cmp-speed-group,
.cmp-tool-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cmp-pill-btn {
  height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #0F172A;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.cmp-pill-btn.active {
  background: var(--brand, #132C52);
  border-color: var(--brand, #132C52);
  color: #FFFFFF;
}

.md-file-chip.is-media,
.md-file-chip.is-side-openable {
  border-color: var(--brand-border, #93C5FD);
  background: var(--brand-light, #EEF3F9);
  color: var(--brand, #132C52);
}

.md-file-chip.media-active {
  background: var(--brand, #132C52) !important;
  border-color: var(--brand, #132C52) !important;
  color: #FFFFFF !important;
}

.att-ft-badge.ft-video,
.att-ft-badge.ft-audio {
  background: var(--brand-light, #EEF3F9);
  color: var(--brand, #132C52);
}

/* Highlight revealed file row in File Manager */
.fm-reveal-highlight {
  animation: fmRevealPulse 2.4s ease;
}

@keyframes fmRevealPulse {
  0% { background: #DBEAFE; }
  30% { background: #BFDBFE; }
  100% { background: transparent; }
}

@media (hover: hover) and (pointer: fine) {
  .chat-media-resizer:hover::after {
    background: var(--brand, #132C52);
    height: 60px;
  }
  .cmp-tab:not(.active):hover {
    background: #EEF3F9;
    color: #0F172A;
  }
  .cmp-tab-close:hover {
    background: #E2E8F0;
    color: #0F172A;
  }
  .cmp-crumb-btn:hover {
    background: #EEF3F9;
    color: var(--brand, #132C52);
  }
  .cmp-folder-pill:hover {
    background: #DBEAFE;
    border-color: #93C5FD;
  }
  .cmp-save-pill:hover {
    background: var(--brand-dark, #0C1E3A);
  }
  .cmp-icon-btn:hover {
    background: #EEF3F9;
    color: var(--brand-dark, #0C1E3A);
  }
  .cmp-close-btn:hover {
    background: #FEE2E2;
    color: #B91C1C;
  }
  .cmp-pill-btn:not(.active):hover {
    background: #EEF3F9;
    border-color: #93C5FD;
  }
  .usage-bar-col:hover .usage-bar-fill {
    background: var(--brand-deep, #1A3A6B);
  }
}

/* Trang menu Thống kê sử dụng */
.usage-pace-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.usage-pace-item {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  background: #F8FAFC;
}

.usage-pace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.usage-pace-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand, #132C52);
}

.usage-pace-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}

.usage-pace-badge.ok {
  background: #DCFCE7;
  color: #166534;
}

.usage-pace-badge.warn {
  background: #FEF3C7;
  color: #92400E;
}

.usage-pace-badge.danger {
  background: #FEE2E2;
  color: #991B1B;
}

.usage-pace-bar {
  height: 7px;
  border-radius: 999px;
  background: #E2E8F0;
  overflow: hidden;
  margin-bottom: 10px;
}

.usage-pace-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand, #132C52);
  transition: width 0.25s ease;
}

.usage-pace-bar-fill.warn {
  background: #D97706;
}

.usage-pace-bar-fill.danger {
  background: #DC2626;
}

.usage-pace-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.usage-pace-metric {
  background: #FFFFFF;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 7px 9px;
}

.usage-pace-metric-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.usage-pace-metric-val {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.usage-pace-foot {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.usage-chart-box {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #F8FAFC;
}

.usage-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.usage-chart-head h4 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand, #132C52);
  margin: 0;
}

.usage-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 168px;
  padding: 18px 4px 4px;
  overflow-x: auto;
}

.usage-bar-col {
  flex: 1 1 32px;
  min-width: 34px;
  max-width: 68px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.usage-bar-val {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brand, #132C52);
  white-space: nowrap;
}

.usage-bar-track {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.usage-bar-fill {
  width: 72%;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: var(--brand, #132C52);
  transition: height 0.25s ease, background 0.18s ease;
}

.usage-bar-fill.is-zero {
  background: #CBD5E1;
  min-height: 3px;
}

.usage-bar-fill.is-peak {
  background: #1A3A6B;
  box-shadow: 0 2px 8px rgba(19, 44, 82, 0.24);
}

.usage-bar-lbl {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.usage-tab-sessions-wrap {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
}

.usage-tab-search {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
  min-width: 200px;
  background: var(--surface);
  color: var(--text);
}

@media (max-width: 900px) {
  .chat-media-resizer {
    display: none !important;
  }
  .chat-media-pane {
    position: fixed;
    inset: 0;
    z-index: 1200;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    border-radius: 0;
    border: none;
  }
  .cmp-folder-pill span {
    display: none;
  }
  .usage-pace-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .usage-tab-search {
    min-width: 0;
    width: 100%;
  }
}

/* ============================================================================
   LIVE BROWSER PANE (TRINH DUYET TRUC TIEP BEN PHAI KHUNG CHAT)
   ============================================================================ */
.top-browser-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.top-browser-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

.top-browser-btn.is-active {
  background: #EEF3F9;
  border-color: #93C5FD;
  color: #132C52;
}

.top-browser-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #16A34A;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.22);
  flex-shrink: 0;
}

.cmp-stage.is-browser-mode {
  background: #0F172A;
  padding: 0;
  overflow: hidden;
}

.cmp-browser-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #F8FAFC;
}

.cmp-browser-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: #FFFFFF;
  border-bottom: 1px solid #CBD5E1;
  flex-shrink: 0;
}

.cmp-browser-nav-btns {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.cmp-browser-icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}

.cmp-browser-icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

.cmp-browser-url-form {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmp-browser-url-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #CBD5E1;
  border-radius: 7px;
  background: #F8FAFC;
  color: #0F172A;
  font-size: 12.5px;
  outline: none;
}

.cmp-browser-url-input:focus {
  border-color: #132C52;
  background: #FFFFFF;
  box-shadow: 0 0 0 2px rgba(19, 44, 82, 0.12);
}

.cmp-browser-live-btn {
  height: 28px;
  padding: 0 9px;
  border: 1px solid #CBD5E1;
  border-radius: 999px;
  background: #FFFFFF;
  color: #475569;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}

.cmp-browser-live-btn.is-live {
  background: #EEF3F9;
  border-color: #93C5FD;
  color: #132C52;
}

.cmp-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #94A3B8;
  flex-shrink: 0;
}

.cmp-browser-live-btn.is-live .cmp-live-dot {
  background: #16A34A;
  animation: cmpLivePulse 1.6s ease-in-out infinite;
}

@keyframes cmpLivePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45); }
  50% { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0); }
}

.cmp-browser-power-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #132C52;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}

.cmp-browser-power-btn.is-stop {
  border-color: #FCA5A5;
  background: #FEF2F2;
  color: #B91C1C;
}

.cmp-browser-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #0F172A;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  outline: none;
}

.cmp-browser-canvas-box {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cmp-browser-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: crosshair;
  user-select: none;
  -webkit-user-drag: none;
  background: #FFFFFF;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.cmp-browser-click-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border-radius: 999px;
  border: 2px solid #2563EB;
  background: rgba(37, 99, 235, 0.25);
  pointer-events: none;
  animation: cmpClickRipple 0.45s ease-out forwards;
}

@keyframes cmpClickRipple {
  0% { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(1.7); opacity: 0; }
}

.cmp-browser-empty {
  max-width: 340px;
  padding: 24px 20px;
  border-radius: 12px;
  background: #1E293B;
  border: 1px solid #334155;
  color: #E2E8F0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.cmp-browser-empty-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(147, 197, 253, 0.14);
  color: #93C5FD;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cmp-browser-empty-ico svg {
  width: 24px;
  height: 24px;
  display: block;
}

.cmp-browser-empty h4 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: #FFFFFF;
}

.cmp-browser-empty p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #CBD5E1;
}

.cmp-browser-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px 10px;
  background: #FFFFFF;
  border-top: 1px solid #CBD5E1;
  flex-shrink: 0;
}

.cmp-browser-type-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmp-browser-type-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 9px;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  background: #F8FAFC;
  color: #0F172A;
  font-size: 12px;
  outline: none;
}

.cmp-browser-type-input:focus {
  border-color: #132C52;
  background: #FFFFFF;
}

.cmp-browser-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: #605E5C;
}

.cmp-browser-status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .cmp-browser-icon-btn:hover {
    background: #EEF3F9;
    color: #132C52;
  }
  .cmp-browser-live-btn:hover {
    border-color: #93C5FD;
    color: #132C52;
  }
  .cmp-browser-power-btn:not(.is-stop):hover {
    background: #EEF3F9;
    border-color: #93C5FD;
  }
  .cmp-browser-power-btn.is-stop:hover {
    background: #FEE2E2;
  }
}
