/* ==================== MODALS, DIALOGS, BACKDROPS & POPOVERS ==================== */
/* ==================== UPWARD POPOVER MENUS ==================== */

.popover-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  background-color: var(--bg-popover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 320px;
  z-index: 1000;
  animation: popoverSlideUp 0.18s ease-out;
  overflow: hidden;
  pointer-events: auto;
}

.popover-menu.popover-tools { width: 340px; }
.popover-menu.popover-si { width: 440px; }
.popover-menu.popover-params { width: 350px; }

@keyframes popoverSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popover-body {
  padding: 10px 14px;
  max-height: 320px;
  overflow-y: auto;
}

.popover-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.popover-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.popover-item:hover {
  background-color: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
}

.popover-item.active {
  background-color: rgba(139, 92, 246, 0.2);
  border-color: var(--primary);
}

.model-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-item-name {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-item-desc {
  font-size: 10.5px;
  color: var(--text-dim);
}

.popover-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 6px;
}

.popover-input {
  flex: 1;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 11.5px;
  padding: 5px 8px;
  outline: none;
}

.btn-popover-sm {
  background-color: var(--primary);
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* TOOL SWITCH ROWS IN POPOVER & RUN SETTINGS */
.tool-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm, 6px);
  gap: 12px;
  box-sizing: border-box;
}

.tool-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tool-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 7px;
}

.tool-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* TOGGLE SWITCH */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .2s;
  border-radius: 18px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent-green);
}

input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

.url-inline-box {
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.url-inline-status {
  font-size: 11px;
  color: var(--accent-green);
  margin-top: 4px;
}

/* SI POPOVER STYLING */
.si-controls-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.popover-select {
  flex: 1;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: rgba(18, 24, 38, 0.95);
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%2394A3B8%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm, 6px);
  color: #F1F5F9;
  padding: 8px 30px 8px 12px;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.popover-select:hover {
  background-color: rgba(26, 34, 52, 0.98);
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: none;
}

.popover-select:focus {
  background-color: rgba(18, 24, 38, 0.98);
  border-color: var(--primary);
  box-shadow: none;
}

.popover-select option {
  background-color: #111522;
  color: #E2E8F0;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 500;
}

.si-actions-mini {
  display: flex;
  gap: 3px;
}

.icon-btn-sm {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
}

.icon-btn-sm:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.popover-textarea {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  padding: 8px;
  resize: vertical;
  outline: none;
}

.saved-badge-sm {
  font-size: 10px;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
}

/* PARAMS POPOVER STYLING */
.params-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.param-label {
  font-size: 11px;
  color: var(--text-muted);
}

.param-slider-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slider-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.slider-val-sm {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-cyan);
}

.form-range-sm {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 4px 0 2px;
}

.form-range-sm::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--primary, #6366F1);
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.6);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.form-range-sm::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--primary, #6366F1);
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.6);
  cursor: pointer;
}

.form-range-sm:hover::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.85);
}

.form-range-sm:hover::-moz-range-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.85);
}

.text-link-sm {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.text-link-sm:hover { text-decoration: underline; }

.text-link-danger {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s ease;
}

.text-link-danger:hover {
  opacity: 0.8;
  text-decoration: underline;
}




/* ==================== GLOBAL MODAL FORM INPUTS & BUTTONS ==================== */

.form-input {
  background: rgba(15, 23, 42, 0.75) !important;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12)) !important;
  color: var(--text-main, #f8fafc) !important;
  border-radius: var(--radius-sm, 8px) !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  font-family: inherit !important;
  outline: none !important;
  box-sizing: border-box !important;
  transition: all 0.2s ease !important;
}

.form-input.has-icon-left {
  padding-left: 36px !important;
}

.form-input:focus {
  border-color: var(--primary, #6366f1) !important;
  background: rgba(15, 23, 42, 0.95) !important;
  box-shadow: none !important;
}

.form-input::placeholder {
  color: var(--text-dim, #64748b) !important;
}

.icon-btn.btn-close-modal,
.btn-close-modal:not(.btn-secondary):not(.btn-cancel):not(button:has(span)) {
  width: 30px !important;
  height: 30px !important;
  border-radius: 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: var(--text-dim, #94a3b8) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0 !important;
}

.icon-btn.btn-close-modal:hover,
.btn-close-modal:not(.btn-secondary):not(.btn-cancel):not(button:has(span)):hover {
  background: rgba(239, 68, 68, 0.18) !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
  color: #f87171 !important;
  transform: scale(1.05) !important;
}

/* ==================== UNIFIED MODAL FOOTER BUTTONS DESIGN SYSTEM ==================== */
.modal-footer {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
}

.modal-footer button:not(.btn-si-wrap-toggle),
.modal-footer .btn-secondary:not(.btn-si-wrap-toggle),
.modal-footer .btn-primary,
.modal-footer .btn-cancel,
.modal-footer .btn-danger,
.gdrive-footer-buttons button,
.gdrive-footer-buttons .btn-secondary,
.gdrive-footer-buttons .btn-primary,
.btn-secondary.btn-close-modal,
.btn-cancel.btn-close-modal {
  width: auto !important;
  min-width: 80px !important;
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 18px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  gap: 8px !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.modal-footer .btn-secondary,
.modal-footer .btn-cancel,
.gdrive-footer-buttons .btn-secondary,
.btn-secondary.btn-close-modal,
.btn-cancel.btn-close-modal {
  color: var(--text-main, #f8fafc) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.modal-footer .btn-secondary:hover,
.modal-footer .btn-cancel:hover,
.gdrive-footer-buttons .btn-secondary:hover,
.btn-secondary.btn-close-modal:hover,
.btn-cancel.btn-close-modal:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  color: #fff !important;
  transform: translateY(-0.5px) !important;
}

.modal-footer .btn-primary,
.gdrive-footer-buttons .btn-primary {
  background: var(--primary) !important;
  color: #fff !important;
  border: 1px solid var(--primary-hover) !important;
  box-shadow: none !important;
}

.modal-footer .btn-primary:hover,
.gdrive-footer-buttons .btn-primary:hover {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  box-shadow: none !important;
}

.modal-palette {
  max-width: 540px;
  background-color: var(--bg-modal);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

.palette-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.search-palette-icon {
  color: var(--text-muted);
  font-size: 14px;
}

.palette-header input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text-main);
  font-family: var(--font-sans);
}

.palette-body {
  padding: 12px 16px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.palette-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.palette-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.palette-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.session-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.session-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.session-list-item:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.25);
}

.session-list-item.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary);
}

.session-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.session-item-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item-meta {
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}

.session-item-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-session-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  opacity: 0.6;
}

.btn-session-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  opacity: 1;
}



/* ==================== MODAL STYLING ==================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(4, 6, 12, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease-out;
}

.modal-overlay.hidden { display: none; }

.modal-card {
  background-color: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-card.modal-lg { max-width: 760px; }

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-bright);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 7px 10px;
  font-size: 12.5px;
  outline: none;
  width: 100%;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: none;
}

.inline-input { display: flex; gap: 6px; }

.doc-reader-body {
  font-size: 14px;
  line-height: 1.75;
  white-space: normal;
  background: var(--bg-surface, #1e1e1e);
  color: var(--text-main, #d4d4d4);
  padding: 24px 28px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  max-height: 68vh;
  overflow-y: auto;
}

.doc-reader-body h1, .doc-reader-body h2, .doc-reader-body h3, .doc-reader-body h4 {
  color: var(--text-bright, #ffffff);
  margin-top: 20px;
  margin-bottom: 10px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.doc-reader-body h1 {
  font-size: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.doc-reader-body h2 {
  font-size: 17px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 6px;
}

.doc-reader-body h3 { font-size: 15px; }

.doc-reader-body p {
  margin: 0 0 14px 0;
}

.doc-reader-body blockquote {
  margin: 14px 0;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--primary, #0078D4);
  border-radius: 0 4px 4px 0;
  color: var(--text-secondary, #cccccc);
}

.doc-reader-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.doc-reader-body th, .doc-reader-body td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  font-size: 13px;
}

.doc-reader-body th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.doc-reader-body pre {
  background: #181818;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.doc-reader-body code:not(pre code) {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.citation-meta {
  font-size: 11.5px;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.citation-snippet {
  background: var(--bg-input);
  padding: 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 380px;
  overflow-y: auto;
}

/* UTILITY */
.hidden { display: none !important; }
.mobile-only { display: none; }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: -320px; transition: left 0.3s ease; }
  .sidebar.open { left: 0; }
  .mobile-only { display: flex; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* ATTACHMENT PREVIEW STRIP */
.attach-preview-strip {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
  flex-wrap: wrap;
}

.attach-preview-item {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 220px;
  transition: border-color 0.15s ease;
}

.attach-preview-item:hover {
  border-color: var(--primary);
}

.attach-preview-item .attach-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.attach-preview-item .attach-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--primary-rgb), 0.12);
  border-radius: 4px;
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}

.attach-preview-item .attach-info {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.attach-preview-item .attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
  font-weight: 500;
  color: var(--text-main);
  font-size: 11px;
}

.attach-preview-item .attach-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.attach-preview-item .attach-size {
  font-size: 10px;
  color: var(--text-dim);
}

.attach-preview-item .attach-tokens-badge {
  font-size: 9.5px;
  font-family: var(--font-mono, monospace);
  color: var(--accent-cyan, #38bdf8);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 0px 4px;
  border-radius: 4px;
  white-space: nowrap;
}

.attach-preview-item .btn-remove-attach {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent-red, #ef4444);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.attach-preview-item:hover .btn-remove-attach {
  opacity: 1;
}

#btnAttachFile:hover {
  color: var(--primary);
}

/* Attachment images in chat messages */
.msg-attachment-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.msg-attachment-strip img {
  max-width: 260px;
  max-height: 180px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: all 0.2s ease;
  background: #181818;
  display: block;
}

.msg-attachment-strip img:hover {
  transform: scale(1.02);
  border-color: var(--accent-blue, #0078d4);
  box-shadow: 0 4px 14px rgba(0, 120, 212, 0.25);
}

.msg-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(var(--primary-rgb), 0.08);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-dim);
}

/* ==================== IMAGE LIGHTBOX MODAL ==================== */
.modal-lightbox-card {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  background: #121212;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(30, 30, 30, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
}

.lightbox-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lightbox-icon {
  color: var(--accent-cyan, #38bdf8);
  font-size: 15px;
}

.lightbox-img-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.lightbox-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-lightbox-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-lightbox-action:hover {
  background: var(--accent-blue, #0078d4);
  border-color: var(--accent-blue, #0078d4);
  color: #ffffff;
}

.btn-lightbox-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-lightbox-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.lightbox-body {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d0d;
  overflow: auto;
  max-height: calc(90vh - 65px);
}

.lightbox-img {
  max-width: 100%;
  max-height: calc(85vh - 75px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}



/* ==================== AUTH & ACCESS KEY FULLSCREEN LANDING SCREEN (PS5 MICRO-PATTERN) ==================== */

#modalAuth.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  background: #08090f !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  opacity: 1;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s ease;
}

#modalAuth.modal-overlay.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* SONY PS5-STYLE 45-DEGREE ROTATED MICRO-PATTERN WALLPAPER (DIAMOND TEXTURE) */
.auth-ps5-grid-bg {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  z-index: 1;
  transform: rotate(45deg);
  transform-origin: center center;
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
                    url("data:image/svg+xml,%3Csvg width='140' height='140' viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%236366f1' fill-opacity='0.045'%3E%3C!-- Brain --%3E%3Cpath d='M25 15c-3 0-5 2-5 5 0 1 .3 2 .8 3-2.3 1-3.8 3.3-3.8 6 0 2.2 1.1 4.1 2.8 5.2-.5 1-.8 2.2-.8 3.5 0 4.4 3.6 8 8 8 1 0 1.9-.2 2.8-.5.8 2.6 3.2 4.5 6.2 4.5V15h-11z'/%3E%3C!-- Sparkles --%3E%3Cpath d='M95 20l2 5 5 2-5 2-2 5-2-5-5-2 5-2z'/%3E%3C!-- Database --%3E%3Cpath d='M20 85c0-3 6-5 14-5s14 2 14 5v4c0 3-6 5-14 5s-14-2-14-5zm0 8c0 3 6 5 14 5s14-2 14-5v4c0 3-6 5-14 5s-14-2-14-5z'/%3E%3C!-- Terminal / Code --%3E%3Cpath d='M90 85l-4-4 1.4-1.4L91.2 83l3.8-3.8 1.4 1.4-5 5zm10 0v-2h8v2h-8z'/%3E%3C!-- Bolt --%3E%3Cpath d='M60 45l-6 10h5l-2 9 8-11h-5l4-8z'/%3E%3C!-- Notes --%3E%3Cpath d='M120 45h-12c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V47c0-1.1-.9-2-2-2zm-2 14h-8v-2h8v2zm0-4h-8v-2h8v2z'/%3E%3C!-- Network --%3E%3Ccircle cx='60' cy='115' r='3'/%3E%3Ccircle cx='45' cy='125' r='2'/%3E%3Ccircle cx='75' cy='125' r='2'/%3E%3Cpath d='M60 115l-15 10m15-10l15 10' stroke='%236366f1' stroke-opacity='0.045' stroke-width='1'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 24px 24px, 140px 140px;
  background-position: 0 0, 0 0;
  opacity: 0.9;
}

.modal-auth-card {
  position: relative;
  z-index: 10;
  max-width: 460px;
  width: 92%;
  padding: 36px 32px;
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: authCardFloatIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardFloatIn {
  from { opacity: 0; transform: scale(0.95) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-header {
  margin-bottom: 24px;
}

.auth-icon-circle {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  background: var(--primary-subtle);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--primary);
}

.auth-header h3 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
  letter-spacing: -0.4px;
}

.auth-header p {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
}


/* GOOGLE GIS AUTH BUTTON WRAPPER */
.google-auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0 16px;
  width: 100%;
}

.google-signin-btn-box {
  min-height: 44px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.btn-google-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 18px;
  background: #ffffff;
  color: #1f1f1f;
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font-sans);
  border: 1px solid #dadce0;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.btn-google-custom:hover {
  background: #f8f9fa;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.google-icon-svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* AUTH DIVIDER */
.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-divider span {
  padding: 0 12px;
}

/* DEV MOCK FAST LOGIN BOX */
.dev-auth-box {
  background: rgba(15, 17, 26, 0.7);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.dev-auth-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.dev-auth-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.select-dev-email {
  flex: 1;
  background: #0b0d14;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12.5px;
  font-family: var(--font-sans);
  padding: 9px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
  min-width: 0;
}

.select-dev-email:focus {
  border-color: var(--primary);
}

.btn-dev-fast-login {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.btn-dev-fast-login:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.auth-error-msg {
  font-size: 12.5px;
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  text-align: left;
  line-height: 1.4;
  margin-top: 10px;
}

.auth-footer-note {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ==================== SIDEBAR USER PROFILE WIDGET ==================== */
.sidebar-user-section {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(12, 14, 22, 0.4);
}

.sidebar-user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.sidebar-user-profile:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.25);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--primary);
  flex-shrink: 0;
  background: #141724;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  text-align: left;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}




/* ==================== DOCUMENT PREVIEW READER ==================== */

.doc-reader-body {
  padding: 20px 24px;
  max-height: 75vh;
  overflow-y: auto;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.8;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(11, 13, 20, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: 16px 20px 20px;
}

/* CITATION FOCUS HIGHLIGHT IN FULL DOC (ANTIGRAVITY BLUE GLOW) */
.citation-in-doc-highlight {
  background: rgba(0, 120, 212, 0.22) !important;
  color: #FFFFFF !important;
  border: 1px solid rgba(0, 120, 212, 0.6) !important;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  display: inline;
  box-shadow: 0 0 10px rgba(0, 120, 212, 0.25);
  animation: citationTargetPulse 2.5s infinite ease-in-out;
}

/* PREVIEW FIND IN-DOC MATCHES (ANTIGRAVITY FIND MATCH) */
.preview-find-match {
  background: rgba(187, 128, 9, 0.35) !important;
  color: #CCCCCC !important;
  padding: 1px 4px;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.preview-find-match.active-match {
  background: #9E6A03 !important;
  color: #FFFFFF !important;
  font-weight: 600;
  outline: 1px solid #BB8009;
  border-radius: 2px;
}

@keyframes citationTargetPulse {
  0%, 100% {
    box-shadow: 0 0 6px rgba(0, 120, 212, 0.2);
    border-color: rgba(0, 120, 212, 0.4);
  }
  50% {
    box-shadow: 0 0 14px rgba(0, 120, 212, 0.45);
    border-color: #0078D4;
  }
}



/* ==================== DOCUMENT STUDIO EDITOR & AI REWRITER ==================== */

.modal-doc-editor {
  width: 840px;
  max-width: 96vw;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.doc-editor-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  min-height: 0;
  gap: 10px;
}

.editor-ai-toolbar {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-toolbar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-copilot-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.ai-preset-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.ai-preset-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.ai-preset-chip:hover {
  background: rgba(139, 92, 246, 0.2);
  color: #fff;
  border-color: var(--primary);
}

/* IN-EDITOR FIND BAR */
.editor-find-bar {
  background: rgba(18, 20, 32, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slashFadeIn 0.2s ease;
}

.editor-find-bar .find-icon {
  font-size: 12px;
  color: var(--text-dim);
}

.editor-find-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 12.5px;
  font-family: var(--font-main);
  outline: none;
}

.find-counter-badge {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.btn-find-nav {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-find-nav:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.ai-instruction-input-row {
  display: flex;
  gap: 8px;
}

.ai-instruction-input-row input {
  flex: 1;
  background: rgba(11, 13, 20, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.ai-instruction-input-row input:focus {
  border-color: var(--primary);
  box-shadow: none;
}

.btn-run-rewrite {
  padding: 0 16px;
  white-space: nowrap;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* EDITOR TEXTAREA & SYNCHRONIZED BACKDROP */
.editor-textarea-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 260px;
  display: flex;
  background: rgba(11, 13, 20, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.editor-textarea-wrapper:focus-within {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

.editor-highlight-backdrop {
  position: absolute;
  inset: 0;
  padding: 16px 18px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: transparent;
  background: transparent;
  overflow-y: auto;
  pointer-events: none;
  user-select: none;
  border: 1px solid transparent;
  z-index: 1;
}

.doc-editor-textarea {
  position: relative;
  flex: 1;
  width: 100%;
  background: transparent !important;
  border: none;
  padding: 16px 18px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.75;
  resize: none;
  outline: none;
  min-height: 260px;
  z-index: 2;
  caret-color: #fde68a;
}

/* IN-EDITOR FIND MATCHES (ANTIGRAVITY THEME) */
.editor-find-match {
  background: rgba(187, 128, 9, 0.35) !important;
  color: transparent !important;
  border-radius: 2px;
}

.editor-find-match.active-match {
  background: #9E6A03 !important;
  outline: 1px solid #BB8009;
  border-radius: 2px;
}

.doc-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.doc-editor-footer-left, .doc-editor-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-gdrive-sync {
  background: rgba(66, 133, 244, 0.15);
  border: 1px solid rgba(66, 133, 244, 0.4);
  color: #93c5fd;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-gdrive-sync:hover {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.4);
}

.btn-gdrive-sync.synced {
  background: rgba(34, 197, 94, 0.2) !important;
  border-color: #22c55e !important;
  color: #86efac !important;
}

/* TUNING MODAL CONTAINER */


/* ==================== GLOBAL APP DIALOG MODAL (CONFIRM & PROMPT) ==================== */
.modal-dialog-card {
  max-width: 440px;
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.dialog-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.dialog-icon-circle.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.2);
}

.dialog-icon-circle.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
}

.dialog-icon-circle.success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.35);
}

.dialog-header-texts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.dialog-header-texts h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
  line-height: 1.3;
}

.dialog-header-texts p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  word-break: break-word;
}

.dialog-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dialog-input {
  background: rgba(15, 17, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dialog-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.dialog-input-error {
  font-size: 11.5px;
  color: #ef4444;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.dialog-actions button {
  min-width: 90px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.dialog-actions .btn-danger-confirm {
  background: #dc2626 !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

.dialog-actions .btn-danger-confirm:hover {
  background: #b91c1c !important;
  border-color: #f87171 !important;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
}

.toast-item {
  pointer-events: auto;
  background: var(--bg-popover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text-main);
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.25s ease;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.toast-item.toast-hiding {
  opacity: 0;
  transform: translateX(40px) scale(0.9);
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-item.toast-success {
  border-left: 3px solid #10b981;
}
.toast-item.toast-success .toast-icon { color: #10b981; }

.toast-item.toast-error {
  border-left: 3px solid #ef4444;
}
.toast-item.toast-error .toast-icon { color: #ef4444; }

.toast-item.toast-warning {
  border-left: 3px solid #f59e0b;
}
.toast-item.toast-warning .toast-icon { color: #f59e0b; }

.toast-item.toast-info {
  border-left: 3px solid var(--primary);
}
.toast-item.toast-info .toast-icon { color: var(--primary); }

.toast-message {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.toast-close:hover {
  color: var(--text-main);
}

/* ==================== ALL WORKSPACES MODAL STYLING ==================== */
.all-workspaces-scroll-list {
  padding: 4px 4px 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ws-modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 8px);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  box-sizing: border-box;
}

.ws-modal-item:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.ws-modal-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.ws-modal-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14.5px;
  flex-shrink: 0;
}

.ws-modal-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.ws-modal-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-modal-item-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ws-modal-item-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ws-modal-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  flex-shrink: 0;
}

.ws-modal-action-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ws-modal-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.ws-modal-action-btn.btn-delete-ws:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

@media (max-width: 640px) {
  .modal-workspaces-manager {
    width: 94vw !important;
    max-width: 94vw !important;
    margin: 0 auto !important;
  }
  .ws-modal-item {
    padding: 8px 10px !important;
    gap: 8px !important;
    border-radius: 8px !important;
  }
  .ws-modal-item-left {
    gap: 9px !important;
  }
  .ws-modal-item-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
  }
  .ws-modal-item-name {
    font-size: 12.5px !important;
    max-width: 140px !important;
  }
  .ws-modal-item-meta {
    font-size: 10px !important;
    gap: 4px !important;
  }
  .ws-modal-item-actions {
    gap: 4px !important;
    margin-left: 4px !important;
  }
  .ws-modal-action-btn {
    width: 26px !important;
    height: 26px !important;
    font-size: 10.5px !important;
    border-radius: 5px !important;
  }
  .ws-modal-action-btn.btn-open-ws {
    display: none !important; /* redundant on mobile since whole card opens workspace */
  }
}

/* ==================== DISKUSI 06: SYSTEM DIALOG Z-INDEX & MODAL POLISH ==================== */

/* Top-level Alert & Confirm Dialogs: Always on top of all modals */
#modalAppDialog {
  z-index: 100000 !important;
}

/* Create / Edit Project Modal: Obsidian Pro proportions */
#modalProjectEditor .modal-card,
.modal-project-editor {
  width: 450px !important;
  max-width: calc(100vw - 28px) !important;
  border-radius: 14px !important;
  border: 1px solid rgba(99, 102, 241, 0.3) !important;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7), 0 0 24px rgba(99, 102, 241, 0.18) !important;
}

#modalProjectEditor .modal-header {
  padding: 16px 20px 14px !important;
}

#modalProjectEditor .modal-body {
  padding: 16px 20px 18px !important;
  gap: 16px !important;
}

#modalProjectEditor textarea#inputProjectDesc {
  min-height: 68px !important;
  resize: vertical !important;
}

#modalProjectEditor .modal-footer {
  padding: 14px 20px !important;
}

/* GDrive Picker Footer Button Vertical Centering & Mobile Actions */
.gdrive-modal-footer {
  padding: 12px 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  background: var(--bg-card) !important;
  box-sizing: border-box !important;
}

.gdrive-footer-buttons {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.gdrive-footer-buttons {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.gdrive-footer-buttons button,
.gdrive-footer-buttons .btn-secondary,
.gdrive-footer-buttons #btnSubmitGDrivePicker,
#btnSubmitGDrivePicker {
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 16px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  border-radius: var(--radius-sm, 6px) !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  gap: 6px !important;
  margin: 0 !important;
}

#btnSubmitGDrivePicker i {
  font-size: 13px !important;
  display: inline-block !important;
  line-height: 1 !important;
}

#btnSubmitGDrivePicker span {
  display: inline-block !important;
  line-height: 1 !important;
}

/* ==================== CUSTOM DARK PROJECT COLOR SWATCHES ==================== */
.project-color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 28px);
  gap: 8px;
  padding: 4px 0;
  justify-content: flex-start;
}

@media (max-width: 768px) {
  .project-color-swatches {
    grid-template-columns: repeat(4, 28px);
    gap: 10px;
  }
}

.swatch-color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.swatch-color-btn:hover {
  transform: scale(1.15);
  border-color: rgba(255, 255, 255, 0.7);
}

.swatch-color-btn i {
  font-size: 11px;
  color: #ffffff;
  display: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

.swatch-color-btn.active {
  border-color: #ffffff !important;
  transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.6), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.swatch-color-btn.active i {
  display: block;
}

/* ==================== BULLETPROOF MOBILE MODAL FOOTER (< 768px) ==================== */
@media (max-width: 768px) {
  /* 1. HIDE ALL CANCEL / CLOSE / SECONDARY FOOTER BUTTONS WITH ULTRA-HIGH SPECIFICITY */
  .modal-footer button.btn-secondary,
  .modal-footer button.btn-cancel,
  .modal-footer button.btn-close-modal,
  .modal-footer button.btn-si-cancel,
  .modal-footer .btn-secondary,
  .modal-footer .btn-cancel,
  .modal-footer .btn-close-modal,
  .modal-footer .btn-si-cancel,
  .btn-secondary.btn-close-modal,
  .btn-cancel.btn-close-modal,
  .gdrive-footer-buttons button.btn-secondary,
  .gdrive-footer-buttons button.btn-cancel,
  .gdrive-footer-buttons .btn-secondary,
  .gdrive-footer-buttons .btn-cancel,
  #modalProjectEditor .modal-footer button:not(.btn-primary),
  #modalProjectEditor .modal-footer .btn-secondary,
  #modalProjectEditor .modal-footer .btn-close-modal,
  #modalDocEditor .modal-footer button.btn-secondary,
  #modalDocEditor .modal-footer .btn-secondary,
  #modalNoteEditor .modal-footer button.btn-secondary,
  #modalNoteEditor .modal-footer .btn-secondary,
  #modalQuickScratchpad .modal-footer button.btn-secondary,
  #modalQuickScratchpad .modal-footer .btn-secondary,
  #modalVoiceDictation .modal-footer button.btn-secondary,
  #modalVoiceDictation .modal-footer .btn-secondary,
  #modalWebClipper .modal-footer button.btn-secondary,
  #modalWebClipper .modal-footer .btn-secondary,
  #modalPromoteSession .modal-footer button.btn-secondary,
  #modalPromoteSession .modal-footer .btn-secondary,
  #modalSIStudio .modal-footer button.btn-si-cancel,
  #modalSIStudio .modal-footer button.btn-secondary,
  #modalSIStudio .si-studio-footer .btn-si-cancel,
  #modalSIStudio .si-studio-footer .btn-secondary,
  #modalAllWorkspaces .modal-footer button.btn-secondary,
  #modalAllWorkspaces .modal-footer .btn-secondary,
  #modalExportChat .modal-footer button.btn-secondary,
  #modalExportChat .modal-footer .btn-secondary,
  #modalTodoDashboard .modal-footer button.btn-secondary,
  #modalTodoDashboard .modal-footer .btn-secondary,
  #modalNotesRollup .modal-footer button.btn-secondary,
  #modalNotesRollup .modal-footer .btn-secondary {
    display: none !important;
  }

  /* 2. MAKE ALL PRIMARY ACTION BUTTONS 100% FULL-WIDTH & 42PX MIN-HEIGHT */
  .modal-footer {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom)) !important;
  }

  .modal-footer-actions {
    width: 100% !important;
    display: flex !important;
  }

  .modal-footer .btn-primary,
  .modal-footer button.btn-primary,
  .modal-footer-actions .btn-primary,
  .modal-footer .btn-si-save,
  .gdrive-footer-buttons .btn-primary,
  .gdrive-footer-buttons #btnSubmitGDrivePicker,
  #modalProjectEditor .modal-footer .btn-primary,
  #modalProjectEditor #btnSaveProject,
  #btnSaveProject {
    width: 100% !important;
    max-width: 100% !important;
    justify-content: center !important;
    height: 42px !important;
    min-height: 42px !important;
    font-size: 13.5px !important;
    box-sizing: border-box !important;
  }

  .gdrive-modal-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom)) !important;
  }

  .gdrive-selection-info {
    text-align: center !important;
  }

  .gdrive-footer-buttons {
    width: 100% !important;
  }
}

/* ==================== SYSTEM INSTRUCTIONS (SI) PREVIEW CARD & STUDIO ==================== */
.si-preview-card {
  margin-top: 6px;
  background: rgba(16, 20, 33, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.si-preview-card:hover {
  background: rgba(22, 28, 48, 0.95);
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 0 10px rgba(99, 102, 241, 0.15);
  transform: translateY(-1px);
}

.si-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.si-card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #818cf8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.si-card-snippet {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 8px;
  border-radius: 4px;
}

.modal-si-studio-card {
  width: 780px !important;
  max-width: 95vw !important;
  height: 680px !important;
  max-height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  padding: 0 !important;
  transition: width 0.2s ease, height 0.2s ease;
}

.modal-si-studio-card.fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
  margin: 0 !important;
  border: none !important;
}

.si-studio-footer {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  background: #090B14 !important;
  border-top: 1px solid var(--border-color) !important;
  padding: 8px 16px !important;
  flex-shrink: 0 !important;
}

@media (max-width: 768px) {
  .modal-si-studio-card {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    border: none !important;
  }
  .si-studio-footer .btn-si-cancel,
  .modal-footer .btn-si-cancel,
  #modalSIStudio .btn-si-cancel,
  #modalSIStudio .modal-footer .btn-secondary {
    display: none !important;
  }
}

.si-editor-workspace {
  flex: 1 1 auto;
  display: flex;
  position: relative;
  overflow: hidden;
  background: #080a11;
  min-height: 380px;
  height: 100%;
  align-items: stretch;
}

.si-editor-workspace .CodeMirror {
  width: 100% !important;
  height: 100% !important;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace !important;
  font-size: 13px !important;
  line-height: 1.65 !important;
  background: #080a11 !important;
}

.si-gutter {
  display: none !important;
}

.si-code-container {
  flex: 1 1 0;
  position: relative;
  height: 100%;
  min-height: 100%;
  align-self: stretch;
  overflow: hidden;
  background: #080a11;
  box-sizing: border-box;
}

.si-syntax-highlight {
  display: none !important;
}

/* SI Word Wrap Toggle Button in Footer */
.btn-si-wrap-toggle {
  height: 26px !important;
  padding: 0 10px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  border-radius: 6px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: rgba(255, 255, 255, 0.04) !important;
  color: var(--text-dim, #94a3b8) !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  transition: all 0.2s ease !important;
  user-select: none !important;
}

.btn-si-wrap-toggle:hover {
  border-color: rgba(255, 255, 255, 0.25) !important;
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.btn-si-wrap-toggle.active {
  background: rgba(99, 102, 241, 0.18) !important;
  border-color: rgba(99, 102, 241, 0.4) !important;
  color: #818cf8 !important;
}

@media (max-width: 860px) {
  .btn-si-wrap-toggle,
  #btnSIToggleWrap {
    display: none !important;
  }
}

.si-code-textarea {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  color: transparent !important;
  caret-color: #38bdf8;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace !important;
  font-size: 13px !important;
  line-height: 1.65 !important;
  padding: 14px 16px;
  box-sizing: border-box;
  outline: none;
  resize: none;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 2;
}

.si-code-textarea::selection {
  background: rgba(99, 102, 241, 0.45) !important;
  color: transparent !important;
}

/* SI STUDIO VS CODE DARK MODERN SYNTAX HIGHLIGHTING (1:1) */
.si-syntax-highlight .token-tag {
  color: #569CD6 !important; /* Tag Studio Blue */
  font-weight: 600;
}

.si-syntax-highlight .token-tag-bracket {
  color: #808080 !important; /* Angle Brackets */
}

.si-syntax-highlight .token-attr {
  color: #9CDCFE !important; /* Attribute Names Sky Blue */
}

.si-syntax-highlight .token-string {
  color: #CE9178 !important; /* Attribute Values / Strings Terra Cotta */
}

.si-syntax-highlight .token-comment {
  color: #6A9955 !important; /* Comments Olive Green */
  font-style: italic !important;
}

.si-syntax-highlight .token-keyword {
  color: #C586C0 !important; /* Keywords Magenta */
}

.si-syntax-highlight .token-constant {
  color: #4FC1FF !important; /* Constants Electric Blue */
}

.si-syntax-highlight .token-punctuation {
  color: #D4D4D4 !important; /* Punctuation Light */
}

