/* ==================== ACE VM PRO DOCUMENT & IMAGE SUITE ==================== */
/* Matches ACE Dark Matte & Crisp Light (body.ace-flame-mode) with zero Grid overlap */

/* Bulletproof fix: Hide VM grid/list/dropzone whenever full-canvas studio is open */
#ace-pc-shell:has(#ace-pc-viewer.show.ace-doc-full) .ace-pc-grid-view,
#ace-pc-shell:has(#ace-pc-viewer.show.ace-doc-full) .ace-pc-list-view,
#ace-pc-shell:has(#ace-pc-viewer.show.ace-doc-full) #ace-pc-dropzone,
#ace-pc-shell:has(#ace-pc-viewer.show.ace-doc-full) .ace-pc-actionbar {
  display: none !important;
}

#ace-pc-viewer.show.ace-doc-full {
  position: fixed !important;
  top: 56px !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 4960 !important;
  display: flex !important;
  flex-direction: column !important;
  background: #121318 !important;
  color: #f4f4f6 !important;
  overflow: hidden !important;
}
body.ace-flame-mode #ace-pc-viewer.show.ace-doc-full {
  background: #f3f5f8 !important;
  color: #1a1c22 !important;
}
@media (max-width: 720px) {
  #ace-pc-viewer.show.ace-doc-full { top: 0 !important; height: 100dvh !important; }
}

.ace-suite-root {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Shared Ribbon Chrome */
.ace-ribbon-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 0;
  background: #17181f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  overflow-x: auto;
}
body.ace-flame-mode .ace-ribbon-tabs {
  background: #e9eef6;
  border-bottom-color: rgba(17, 17, 20, 0.1);
}
.ace-rtab {
  padding: 6px 13px;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: #a1a1b0;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ace-rtab:hover { color: #f4f4f6; background: rgba(255, 255, 255, 0.04); }
.ace-rtab.active {
  background: #1e2029;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.1);
}
body.ace-flame-mode .ace-rtab { color: #4b5563; }
body.ace-flame-mode .ace-rtab:hover { color: #111827; background: rgba(0, 0, 0, 0.04); }
body.ace-flame-mode .ace-rtab.active {
  background: #ffffff;
  color: #111827;
  border-color: rgba(17, 17, 20, 0.12);
}

.ace-ribbon-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: #1e2029;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  flex-shrink: 0;
}
body.ace-flame-mode .ace-ribbon-bar {
  background: #ffffff;
  border-bottom-color: rgba(17, 17, 20, 0.1);
}
.ace-rbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #272936;
  color: #f4f4f6;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.ace-rbtn:hover { background: #323545; border-color: rgba(255, 255, 255, 0.22); }
.ace-rbtn.active { background: #2563eb; border-color: #3b82f6; color: #ffffff; }
.ace-rbtn.primary { background: #2563eb; border-color: #3b82f6; color: #ffffff; font-weight: 600; }
.ace-rbtn.primary:hover { background: #1d4ed8; }
.ace-rbtn.success { background: #107c41; border-color: #16a34a; color: #ffffff; font-weight: 600; }
.ace-rbtn.danger { background: rgba(220, 38, 38, 0.16); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.ace-rbtn:disabled { opacity: 0.45; cursor: not-allowed; }
body.ace-flame-mode .ace-rbtn {
  background: #f3f4f6;
  color: #1f2937;
  border-color: rgba(17, 17, 20, 0.14);
}
body.ace-flame-mode .ace-rbtn:hover { background: #e5e7eb; }
body.ace-flame-mode .ace-rbtn.active,
body.ace-flame-mode .ace-rbtn.primary { background: #2563eb; color: #ffffff; border-color: #2563eb; }
body.ace-flame-mode .ace-rbtn.success { background: #107c41; color: #ffffff; border-color: #107c41; }
body.ace-flame-mode .ace-rbtn.danger { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

.ace-rsel, .ace-rin {
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #14151c;
  color: #f4f4f6;
  font-size: 12px;
  padding: 0 7px;
}
body.ace-flame-mode .ace-rsel,
body.ace-flame-mode .ace-rin {
  background: #ffffff;
  color: #111827;
  border-color: rgba(17, 17, 20, 0.18);
}
.ace-rcol {
  width: 30px;
  min-width: 30px;
  height: 28px;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  cursor: pointer;
}
body.ace-flame-mode .ace-rcol { border-color: rgba(17, 17, 20, 0.2); }
.ace-rsep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.14);
  margin: 0 2px;
  flex-shrink: 0;
}
body.ace-flame-mode .ace-rsep { background: rgba(17, 17, 20, 0.14); }

.ace-suite-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 14px;
  font-size: 11.5px;
  color: #9ca3af;
  background: #17181f;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  flex-wrap: wrap;
}
body.ace-flame-mode .ace-suite-status {
  background: #edf2fa;
  color: #4b5563;
  border-top-color: rgba(17, 17, 20, 0.1);
}

/* ==================== 1. PDF ==================== */
.ace-pdfst-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
.ace-pdfst-sidebar {
  width: 182px;
  min-width: 150px;
  max-width: 210px;
  background: #16171e;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
body.ace-flame-mode .ace-pdfst-sidebar {
  background: #e9eef6;
  border-right-color: rgba(17, 17, 20, 0.1);
}
@media (max-width: 720px) { .ace-pdfst-sidebar { width: 110px; min-width: 96px; } }
.ace-pdfst-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 7px;
  border-radius: 9px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  user-select: none;
}
.ace-pdfst-thumb.active { border-color: #3b82f6; background: rgba(59, 130, 246, 0.12); }
.ace-pdfst-thumb.drag-over { border-color: #22c55e; }
body.ace-flame-mode .ace-pdfst-thumb { background: #ffffff; }
.ace-pdfst-thumb-frame {
  width: 120px;
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0d0e12;
  border-radius: 4px;
}
body.ace-flame-mode .ace-pdfst-thumb-frame { background: #dde3ec; }
.ace-pdfst-thumb canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.ace-pdfst-stage {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  background: #0f1015;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px;
  position: relative;
}
body.ace-flame-mode .ace-pdfst-stage { background: #dce2ec; }
.ace-pdfst-canvas-wrap {
  position: relative;
  display: inline-block;
  background: #ffffff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.42);
  border-radius: 3px;
  touch-action: none;
}
.ace-pdfst-canvas-wrap canvas { display: block; }
.ace-pdfst-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.ace-pdfst-subpanel {
  width: 100%;
  max-width: 680px;
  background: #1b1c24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
body.ace-flame-mode .ace-pdfst-subpanel { background: #ffffff; border-color: rgba(17, 17, 20, 0.12); }

/* ==================== 2. DOCX EDITOR PRO EDITOR ==================== */
.ace-word-stage {
  flex: 1 1 auto;
  overflow: auto;
  background: #13141a;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
body.ace-flame-mode .ace-word-stage { background: #e2e8f0; }
.ace-word-sheet {
  width: 794px;
  max-width: 100%;
  min-height: 1123px;
  background: #ffffff;
  color: #111827;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  padding: 0;
  box-sizing: border-box;
}
.ace-word-sheet.letter { width: 816px; min-height: 1056px; }
.ace-word-hf {
  padding: 16px 64px 8px;
  font-size: 11px;
  color: #6b7280;
  border-bottom: 1px dashed #e5e7eb;
  outline: none;
  min-height: 32px;
}
.ace-word-hf.footer {
  border-bottom: none;
  border-top: 1px dashed #e5e7eb;
  padding: 8px 64px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ace-word-body {
  flex: 1 1 auto;
  padding: 36px 64px;
  outline: none;
  font-family: Calibri, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #111827;
}
@media (max-width: 720px) {
  .ace-word-body { padding: 20px 18px; }
  .ace-word-hf { padding: 10px 18px; }
}
.ace-word-body table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.ace-word-body table.no-borders td, .ace-word-body table.no-borders th { border: 1px dashed #e5e7eb; }
.ace-word-body th, .ace-word-body td { border: 1px solid #94a3b8; padding: 6px 9px; min-width: 54px; vertical-align: top; }
.ace-word-body th { background: #f1f5f9; font-weight: 600; }
.ace-word-body .ace-page-break {
  border: none;
  border-top: 2px dashed #94a3b8;
  margin: 26px -64px;
  position: relative;
  height: 18px;
  background: #e2e8f0;
  text-align: center;
  font-size: 10px;
  color: #64748b;
  line-height: 18px;
  user-select: none;
}
.ace-word-img-wrap {
  display: inline-block;
  position: relative;
  max-width: 100%;
  margin: 6px 0;
  resize: horizontal;
  overflow: hidden;
  border: 1px solid transparent;
}
.ace-word-img-wrap:hover { border-color: #3b82f6; }
.ace-word-img-wrap img { display: block; width: 100%; height: auto; }

/* ==================== 3. SPREADSHEET PRO EDITOR ==================== */
.ace-xl-fxbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #17181f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
body.ace-flame-mode .ace-xl-fxbar { background: #f8fafc; border-bottom-color: rgba(17, 17, 20, 0.1); }
.ace-xl-addr {
  min-width: 68px;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #252734;
  color: #f4f4f6;
}
body.ace-flame-mode .ace-xl-addr { background: #e2e8f0; color: #111827; }
.ace-xl-fx-in {
  flex: 1 1 auto;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #111218;
  color: #f4f4f6;
  padding: 0 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}
body.ace-flame-mode .ace-xl-fx-in { background: #ffffff; color: #111827; border-color: rgba(17, 17, 20, 0.18); }
.ace-xl-grid-wrap {
  flex: 1 1 auto;
  overflow: auto;
  background: #101116;
  position: relative;
}
body.ace-flame-mode .ace-xl-grid-wrap { background: #ffffff; }
.ace-xl-tbl {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12.5px;
  color: #f4f4f6;
}
body.ace-flame-mode .ace-xl-tbl { color: #111827; }
.ace-xl-tbl th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #1c1e27;
  color: #a1a1b0;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  font-weight: 600;
  font-size: 11.5px;
  height: 26px;
  padding: 0 6px;
  user-select: none;
}
body.ace-flame-mode .ace-xl-tbl th {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}
.ace-xl-tbl th.row-hdr {
  position: sticky;
  left: 0;
  z-index: 6;
  width: 44px;
  text-align: center;
}
.ace-xl-tbl th.corner-hdr { position: sticky; top: 0; left: 0; z-index: 9; width: 44px; }
.ace-xl-tbl td {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 7px;
  height: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: cell;
  background: #14151c;
}
body.ace-flame-mode .ace-xl-tbl td { background: #ffffff; border-color: #e2e8f0; }
.ace-xl-tbl td.sel { outline: 2px solid #107c41; outline-offset: -2px; z-index: 2; position: relative; }
.ace-xl-tbl td.in-range { background: rgba(16, 124, 65, 0.22) !important; }
.ace-xl-tbl td.wrap-txt { white-space: pre-wrap; word-break: break-word; }
.ace-xl-tbl.freeze-row tr:nth-child(2) td { position: sticky; top: 26px; z-index: 4; box-shadow: 0 2px 0 #107c41; }
.ace-xl-tbl.freeze-col td:nth-child(2) { position: sticky; left: 44px; z-index: 4; box-shadow: 2px 0 0 #107c41; }
.ace-xl-col-resizer {
  position: absolute;
  top: 0; right: 0; width: 5px; height: 100%;
  cursor: col-resize;
}
.ace-xl-tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: #17181f;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  overflow-x: auto;
}
body.ace-flame-mode .ace-xl-tabs { background: #e9eef6; border-top-color: rgba(17, 17, 20, 0.1); }
.ace-xl-tab {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #232530;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ace-xl-tab.active { background: #107c41; color: #ffffff; border-color: #107c41; }
body.ace-flame-mode .ace-xl-tab { background: #ffffff; color: #334155; border-color: #cbd5e1; }
body.ace-flame-mode .ace-xl-tab.active { background: #107c41; color: #ffffff; border-color: #107c41; }

/* ==================== 4. IMAGE SIZE & OPTIMIZER STUDIO ==================== */
.ace-img-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
@media (max-width: 820px) { .ace-img-layout { flex-direction: column; overflow-y: auto; } }
.ace-img-controls {
  width: 340px;
  min-width: 300px;
  background: #171820;
  border-right: 1px solid rgba(255, 255, 255, 0.09);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
body.ace-flame-mode .ace-img-controls { background: #ffffff; border-right-color: rgba(17, 17, 20, 0.1); }
@media (max-width: 820px) { .ace-img-controls { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.09); } }
.ace-img-card {
  padding: 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.ace-flame-mode .ace-img-card { background: #f8fafc; border-color: #e2e8f0; }
.ace-img-preview-stage {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  background: #0d0e13;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
body.ace-flame-mode .ace-img-preview-stage { background: #e2e8f0; }
.ace-img-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 980px;
}
.ace-img-pane {
  background: #171820;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
body.ace-flame-mode .ace-img-pane { background: #ffffff; border-color: #cbd5e1; }
.ace-img-pane img, .ace-img-pane canvas {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 6px;
  background: repeating-conic-gradient(#2a2d3a 0% 25%, #1e202b 0% 50%) 50% / 16px 16px;
}
.ace-img-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ace-img-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
}
body.ace-flame-mode .ace-img-badge { background: #dcfce7; color: #15803d; }

/* Signature Modal */
.ace-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 5600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ace-modal-box {
  width: 100%;
  max-width: 480px;
  background: #181922;
  color: #f4f4f6;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body.ace-flame-mode .ace-modal-box { background: #ffffff; color: #111827; border-color: #cbd5e1; }

#ace-pc-viewer.ace-doc-full .ace-pc-viewer-head { display:flex!important;align-items:center!important;justify-content:space-between!important;gap:10px!important;flex-wrap:wrap!important; }
#ace-pc-viewer.ace-doc-full .ace-pc-viewer-head .ace-pc-node-actions { display:flex!important;align-items:center!important;gap:6px!important;flex-wrap:nowrap!important;flex-shrink:0!important; }

/* ==================== STEP 2: HOME TREE, POPOVERS, SPLIT-SCREEN, MEDIA LAB PiP, ACCENT ==================== */
:root { --ace-accent: #2563eb; }
.ace-rbtn.primary, .ace-rbtn.active, .ace-xl-tab.active { background: var(--ace-accent, #2563eb) !important; border-color: var(--ace-accent, #2563eb) !important; }

/* Fix truncated Chat persona pill (Friendly (Human)) */
#persona-selector, .persona-pill, #ace-persona-pill, .ace-persona-trigger {
  max-width: none !important;
  width: auto !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

/* Full untruncated List View filenames */
.ace-pc-list-view { overflow-x: auto !important; }
.ace-pc-list-view .ace-pc-node-row { min-width: 540px; }
.ace-pc-list-view .ace-pc-node-name {
  white-space: normal !important;
  word-break: break-word !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

/* Desktop-style Expandable Folder Tree */
.ace-win-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 6px;
}
.ace-win-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text, #f4f4f6);
  user-select: none;
}
.ace-win-tree-row:hover { background: rgba(255, 255, 255, 0.06); }
.ace-win-tree-row.active { background: rgba(37, 99, 235, 0.22); font-weight: 600; }
body.ace-flame-mode .ace-win-tree-row { color: #1f2937; }
body.ace-flame-mode .ace-win-tree-row:hover { background: rgba(0, 0, 0, 0.05); }
body.ace-flame-mode .ace-win-tree-row.active { background: #dbeafe; color: #1d4ed8; }
.ace-win-chev {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  flex-shrink: 0;
}
.ace-win-lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ace-win-cnt { font-size: 11px; opacity: 0.65; }

/* Home Settings & Folder Actions Popover */
.ace-home-popover {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  padding: 10px;
  border-radius: 12px;
  background: #1b1c24;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 5300;
  flex-direction: column;
  gap: 6px;
}
.ace-home-popover.show { display: flex; }
body.ace-flame-mode .ace-home-popover { background: #ffffff; border-color: #cbd5e1; color: #111827; }

/* Chips */
.ace-chip-wrap { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.ace-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.09);
  color: #e5e7eb;
  border: none;
}
.ace-chip.ok { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.ace-chip.warn { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
body.ace-flame-mode .ace-chip { background: #e2e8f0; color: #334155; }
body.ace-flame-mode .ace-chip.ok { background: #dcfce7; color: #15803d; }
body.ace-flame-mode .ace-chip.warn { background: #fef3c7; color: #b45309; }

/* Chat + Home Split-Screen Dock */
.ace-split-dock {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  z-index: 4700;
  display: none;
  background: #14151c;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}
.ace-split-dock.show { display: flex; }
body.ace-flame-mode .ace-split-dock { background: #ffffff; border-left-color: #cbd5e1; }
.ace-split-resizer {
  width: 6px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
}
.ace-split-resizer:hover { background: var(--ace-accent, #2563eb); }
.ace-split-inner { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.ace-split-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #1b1c24;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  flex-shrink: 0;
}
body.ace-flame-mode .ace-split-head { background: #f1f5f9; border-bottom-color: #cbd5e1; }
.ace-split-body { flex: 1; min-height: 0; overflow: auto; }

/* Root-Mounted Media Lab & Draggable Floating Mini-Player (PiP) */
.ace-media-lab-root {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1040px, 95vw);
  height: min(640px, 84vh);
  z-index: 5500;
  background: #14151c;
  color: #f4f4f6;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.ace-flame-mode .ace-media-lab-root { background: #ffffff; color: #111827; border-color: #cbd5e1; }
.ace-media-lab-root.is-pip {
  top: auto;
  left: auto;
  right: 18px;
  bottom: 18px;
  transform: none;
  width: 340px;
  height: 235px;
  z-index: 5700;
}
.ace-media-lab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: #1b1c24;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  cursor: move;
  flex-shrink: 0;
}
body.ace-flame-mode .ace-media-lab-head { background: #f1f5f9; border-bottom-color: #cbd5e1; }
.ace-media-lab-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.ace-media-lab-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.ace-media-stage { flex: 1; min-width: 0; background: #090a0d; display: flex; align-items: center; justify-content: center; }
.ace-media-notes {
  width: 290px;
  padding: 10px;
  background: #181922;
  border-left: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
}
body.ace-flame-mode .ace-media-notes { background: #f8fafc; border-left-color: #cbd5e1; }

body.ace-gamer-mode .ace-rbtn { background: #1e2029 !important; color: #f4f4f6 !important; border-color: rgba(255,255,255,0.16) !important; }

/* ==================== USER VISUAL POLISH PASS ==================== */
/* 1. Split View button ONLY in Home mode */
.ace-home-only-split { display: none !important; }
body[data-ace-mode="pc"] .ace-home-only-split { display: inline-flex !important; }

/* 2. Remove standalone Media Player & 9-dot launcher (moved inside Home root!) */
#ace-vm-yt-quick,
#ace-vm-launcher-wrap {
  display: none !important;
}

/* 3. Remove duplicate old PLACES flat list in sidebar (keep ONLY expandable Desktop-style folder tree) */
.ace-pc-sidebar .ace-pc-side-label,
.ace-pc-sidebar .ace-pc-side-item:not(#ace-drive-root-btn) {
  display: none !important;
}

/* 4. Collapsible Sidebar via ☰ button */
.ace-pc-window.ace-side-collapsed .ace-pc-sidebar {
  display: none !important;
}
#ace-home-side-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  flex-shrink: 0;
}

/* 5. Crisp Grid / List View Toggle Buttons (fix tiny SVG icons) */
.ace-pc-nav-btns .ace-pc-icon-btn,
#ace-pc-view-grid,
#ace-pc-view-list {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  padding: 0 !important;
  border-radius: 9px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
#ace-pc-view-grid svg,
#ace-pc-view-list svg {
  width: 18px !important;
  height: 18px !important;
}

/* 6. Word Exact View clean non-overflowing container */
.ace-docx-preview-wrap {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  align-items: center !important;
}
.ace-docx-preview-wrap .docx-wrapper {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

/* 7. Built-in Apps cards inside Default Home Root (Notepad, Calculator, Media Lab) */
.ace-home-utils-sec {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
body.ace-flame-mode .ace-home-utils-sec { border-top-color: rgba(17, 17, 20, 0.1); }
.ace-home-utils-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.65;
  margin-bottom: 10px;
}
.ace-home-utils-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.ace-home-util-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text, #f4f4f6);
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease;
}
.ace-home-util-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--ace-accent, #2563eb);
}
.ace-home-util-card strong { font-size: 13.5px; }
.ace-home-util-card span { font-size: 11.5px; opacity: 0.68; }
body.ace-flame-mode .ace-home-util-card {
  background: #ffffff;
  color: #1f2937;
  border-color: rgba(17, 17, 20, 0.12);
}
body.ace-flame-mode .ace-home-util-card:hover { background: #f1f5f9; }

/* Final micro-polish: eliminate duplicate sidebar places, crisp 18px ☰ icon, zero Split View ribbon scrollbar */
.ace-pc-sidebar #ace-pc-places,
.ace-pc-sidebar .ace-pc-place,
.ace-pc-sidebar .ace-pc-places-list,
.ace-pc-sidebar [data-place] {
  display: none !important;
}
#ace-home-side-toggle svg {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  display: block !important;
}
.ace-split-body .ace-ribbon-tabs {
  flex-wrap: wrap !important;
  overflow-x: hidden !important;
  padding-bottom: 6px !important;
  gap: 4px !important;
}

#ace-pc-folder-tree { display: none !important; }

/* ==================== LAUNCH POLISH: LOGOS, MULTI-SELECT, BULK BAR, MOBILE 390px ==================== */
/* 1. Hide top-left Chat "=" button while in Home mode so it never stacks above Home ☰ */
body[data-ace-mode="pc"] #topbar button[onclick="toggleSidebar()"] {
  visibility: hidden !important;
  pointer-events: none !important;
}

/* 2. Hide dangerous red Delete Folder button from main toolbar (moved into Folder Actions ▾) */
#ace-pc-del-folder-btn { display: none !important; }

/* 3. 2-Line Filename Wrapping on Grid Cards */
.ace-pc-grid-view .ace-pc-tile-name {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  white-space: normal !important;
  word-break: break-word !important;
  overflow: hidden !important;
  line-height: 1.32 !important;
  max-height: 2.68em !important;
}

/* 4. Built-in Apps Cards with Crisp Logos (MyNotes, Calculator, Media Lab) */
.ace-home-utils-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
}
.ace-home-util-card {
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px 14px !important;
}
.ace-util-ico {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ace-util-ico.ico-notes { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.ace-util-ico.ico-calc  { background: rgba(16, 185, 129, 0.16); color: #34d399; }
.ace-util-ico.ico-media { background: rgba(239, 68, 68, 0.16); color: #f87171; }
body.ace-flame-mode .ace-util-ico.ico-notes { background: #fef3c7; color: #b45309; }
body.ace-flame-mode .ace-util-ico.ico-calc  { background: #dcfce7; color: #047857; }
body.ace-flame-mode .ace-util-ico.ico-media { background: #fee2e2; color: #dc2626; }
.ace-util-txt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ace-util-txt span {
  white-space: normal !important;
  line-height: 1.3;
}

/* 5. Multi-Select Checkboxes & Floating Bulk Action Bar */
.ace-pc-tile { position: relative !important; }
.ace-multi-cb {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 17px;
  height: 17px;
  z-index: 4;
  opacity: 0.72;
  cursor: pointer;
  accent-color: var(--ace-accent, #2563eb);
  transition: opacity 120ms ease;
}
.ace-pc-node-row .ace-multi-cb {
  position: static;
  opacity: 0.7;
  margin-right: 6px;
}
.ace-pc-tile:hover .ace-multi-cb,
.ace-pc-tile.ace-multi-sel .ace-multi-cb,
.ace-multi-cb:checked {
  opacity: 1 !important;
}
.ace-pc-tile.ace-multi-sel,
.ace-pc-node-row.ace-multi-sel {
  border-color: var(--ace-accent, #2563eb) !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28) !important;
}
.ace-bulk-bar {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5400;
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-radius: 14px;
  background: #181a23;
  color: #f4f4f6;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.52);
  max-width: 94vw;
}
.ace-bulk-bar.show { display: flex; }
body.ace-flame-mode .ace-bulk-bar { background: #ffffff; color: #111827; border-color: #cbd5e1; }

/* 6. Mobile (<768px) Responsive Polish: Slide-Over Sidebar Drawer & Zero Horizontal Overflow */
@media (max-width: 768px) {
  body[data-ace-mode="pc"] { overflow-x: hidden !important; }
  .ace-pc-window { position: relative !important; overflow-x: hidden !important; }
  .ace-pc-body { position: relative !important; }
  .ace-pc-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 260px !important;
    max-width: 82vw !important;
    z-index: 5250 !important;
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.55) !important;
  }
  .ace-pc-actionbar {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 8px 10px !important;
  }
  .ace-pc-actionbar .ace-pc-toolbar {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .ace-pc-winbar {
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 8px 10px !important;
  }
  .ace-pc-grid-view {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)) !important;
    gap: 10px !important;
  }
  .ace-pc-btn, .ace-rbtn { min-height: 34px !important; }
}

/* Split View slim single-row header & zero horizontal scrollbar + Media Lab Fullscreen */
.ace-split-head { flex-wrap: nowrap !important; overflow: hidden !important; }
.ace-split-body { overflow-x: hidden !important; overflow-y: auto !important; width: 100% !important; box-sizing: border-box !important; }
.ace-split-body iframe { width: 100% !important; max-width: 100% !important; display: block !important; border: none !important; }
.ace-media-lab-root.is-max {
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  transform: none !important;
  border-radius: 0 !important;
  z-index: 6000 !important;
}

.ace-util-ico.ico-writer { background: rgba(59, 130, 246, 0.16); color: #60a5fa; }
.ace-util-ico.ico-sheets { background: rgba(34, 197, 94, 0.16);  color: #4ade80; }
.ace-util-ico.ico-slides { background: rgba(249, 115, 22, 0.16); color: #fb923c; }
.ace-util-ico.ico-pdf    { background: rgba(239, 68, 68, 0.16);  color: #f87171; }
.ace-util-ico.ico-pix    { background: rgba(168, 85, 247, 0.16); color: #c084fc; }
body.ace-flame-mode .ace-util-ico.ico-writer { background: #dbeafe; color: #1d4ed8; }
body.ace-flame-mode .ace-util-ico.ico-sheets { background: #dcfce7; color: #15803d; }
body.ace-flame-mode .ace-util-ico.ico-slides { background: #ffedd5; color: #c2410c; }
body.ace-flame-mode .ace-util-ico.ico-pdf    { background: #fee2e2; color: #b91c1c; }
body.ace-flame-mode .ace-util-ico.ico-pix    { background: #f3e8ff; color: #7e22ce; }

/* ==================== LIVE CHROMIUM QA FIXES v2.7 ==================== */
/* 1. User Guide modal: keep inline strong/b inline and hide stale duplicate #ace-vm-guide-step */
#guide-modal .guide-card p strong,
#guide-modal .guide-card p b,
#guide-modal .guide-step p strong,
#guide-modal .guide-step p b {
  display: inline !important;
  font-weight: 700 !important;
  color: #f8fafc !important;
}
#guide-modal #ace-vm-guide-step { display: none !important; }
body.ace-flame-mode #guide-modal .guide-card p strong,
body.ace-flame-mode #guide-modal .guide-card p b { color: #0f172a !important; }

/* 2. Ask Dot Send button high-contrast visibility */
#ace-side-send {
  background: #3b82f6 !important;
  color: #ffffff !important;
  border: 1px solid #2563eb !important;
  font-weight: 600 !important;
  opacity: 1 !important;
}
#ace-side-send:hover { background: #2563eb !important; }

/* 3. Arcade HUD: prevent NEON MAZE / Lv / Score overlap with game tab bar */
#runner-panel #hud,
#arcade-panel #hud,
.runner-body #hud,
#arcade-stage #hud {
  position: relative !important;
  top: auto !important;
  margin: 12px auto 8px !important;
  padding: 4px 10px !important;
  clear: both !important;
}

/* 4. Split View footer clean wrapping + hide Split View button below 900px */
.disclaimer-bar { flex-wrap: wrap !important; justify-content: center !important; gap: 6px 10px !important; padding: 6px 12px !important; }
@media (max-width: 900px) {
  #ace-split-trigger { display: none !important; }
}

/* 5. Mobile (<768px) Home Drawer: solid slide-over hidden by default, zero overlap with toolbar/files */
@media (max-width: 768px) {
  body[data-ace-mode="pc"] #model-selector,
  body[data-ace-mode="pc"] .ace-custom-model-wrap,
  body[data-ace-mode="pc"] .model-wrap { display: none !important; }

  .ace-pc-sidebar,
  .ace-pc-left {
    position: fixed !important;
    top: 102px !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 255px !important;
    max-width: 80vw !important;
    background: #11131a !important;
    border-right: 1px solid rgba(255,255,255,0.12) !important;
    z-index: 90 !important;
    transform: translateX(-110%) !important;
    transition: transform 0.2s ease !important;
    box-shadow: 10px 0 32px rgba(0,0,0,0.7) !important;
  }
  body.ace-flame-mode .ace-pc-sidebar,
  body.ace-flame-mode .ace-pc-left { background: #f8fafc !important; }
  .ace-pc-window.ace-mobile-side-open .ace-pc-sidebar,
  .ace-pc-window.ace-mobile-side-open .ace-pc-left {
    transform: translateX(0) !important;
  }
  .ace-pc-empty {
    flex-direction: column !important;
    gap: 12px !important;
    text-align: center !important;
    padding: 28px 16px !important;
  }
  .ace-pc-statusbar {
    flex-wrap: wrap !important;
    gap: 4px 10px !important;
    font-size: 11px !important;
  }
}

/* 6. Keep toast above Home status bar */
body[data-ace-mode="pc"] #toast { bottom: 48px !important; }

/* v2.8 Final Polish: exact Split View mobile hide + Arcade HUD clearance */
@media (max-width: 900px) {
  #ace-split-btn, .ace-home-only-split { display: none !important; }
}
#native-arcade-stage { padding-top: 24px !important; box-sizing: border-box !important; }
#native-arcade-hud { margin-top: 6px !important; margin-bottom: 8px !important; }

/* v2.9 E2E QA Fixes */
#ace-media-lab-root { z-index: 9800 !important; }
#native-arcade-stage { padding-top: 40px !important; }
#native-arcade-hud { margin-top: 8px !important; margin-bottom: 10px !important; }
@media (max-width: 768px) {
  #ace-pc-dropzone .ace-pc-empty,
  #ace-pc-dropzone [class*="empty"],
  #ace-pc-list > div:only-child {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    text-align: center !important;
  }
}
