/* ============================================
   OFFICEFORGED — Main Stylesheet (Full)
   ============================================ */

:root {
  --bg-dark: #1a1a2e;
  --bg-panel: #16213e;
  --bg-editor: #ffffff;
  --bg-card-panel: #f8f9fa;
  --sidebar-width: 72px;
  --sidebar-bg: #0f0f23;
  --sidebar-active: #e94560;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0b8;
  --text-dark: #2d2d2d;
  --border: #2a2a4a;
  --border-light: #e0e0e0;
  --card-bg: #ffffff;
  --card-hover: #f0f4ff;
  --tag-bg: #e8eaff;
  --tag-text: #4a4a8a;
  --toolbar-bg: #f5f5f7;
  --toolbar-border: #e0e0e0;
  --success: #2ecc71;
  --warning: #f39c12;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #f8f9fa;
  color: var(--text-primary);
}

/* ============================================
   HEADER & DOCK (ProfitForged style)
   ============================================ */

#header {
  width: 100%;
  height: 56px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: none;
  flex-shrink: 0;
  z-index: 10;
  /* Spacer below header — clears the dock coin overhang */
  margin-bottom: 30px;
}

#header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

#header-brand {
  font-size: 14px;
  font-weight: 800;
  color: #1e40af;
  background: rgba(30,64,175,0.1);
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

#header-brand-text {
  font-size: 11px;
  color: #6b7280;
  letter-spacing: 0.3px;
}

#header-brand-text strong { color: #1e40af; }

#header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dock-action {
  background: none;
  border: 1px solid #d1d5db;
  color: #6b7280;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.dock-action:hover { background: rgba(30,64,175,0.08); color: #1e40af; border-color: #93c5fd; }

/* Dock pill — white rounded capsule, centered */
#dock-pill {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding: 6px 16px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(229,231,235,0.5);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.dock-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #4b5563;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.dock-slot:hover { background: #f9fafb; }

.dock-slot-icon { font-size: 20px; line-height: 1; }
.dock-slot-label { font-size: 9px; font-weight: 500; color: #6b7280; margin-top: 2px; }

/* Center coin — navy blue with silver ring, drops below dock */
#dock-coin {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 4px;
  margin-bottom: -24px;
  transition: transform 0.2s ease;
  z-index: 11;
  flex-shrink: 0;
  padding: 0;
}

#dock-coin:hover {
  transform: scale(1.05);
}

#dock-coin-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #e8e8e8 0%, #c0c0c0 20%, #f5f5f5 40%, #b8b8b8 60%, #d8d8d8 80%, #e0e0e0 100%);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.9), inset 0 -2px 4px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.15);
}

#dock-coin-face {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1e40af, #1e3a8a);
  box-shadow: 0 4px 12px rgba(30,64,175,0.3), inset 0 1px 2px rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

#dock-coin-icon {
  font-size: 22px;
  color: white;
  line-height: 1;
}

#dock-coin-label {
  font-size: 8px;
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-top: 2px;
  text-transform: uppercase;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-editor);
  margin-top: 12px;
}

/* ============================================
   TOOLBAR — Top Row (title bar)
   ============================================ */

#toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  flex-shrink: 0;
}

#doc-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  outline: none;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  min-width: 200px;
}

#doc-title:focus { border-color: var(--accent); background: white; }

#toolbar-top-right { display: flex; gap: 6px; }

.toolbar-btn-sm {
  background: none;
  border: 1px solid var(--toolbar-border);
  color: var(--text-dark);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.15s ease;
}

.toolbar-btn-sm:hover { background: #e8e8ec; }

/* ============================================
   TOOLBAR — Formatting Row
   ============================================ */

#toolbar {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  flex-shrink: 0;
  flex-wrap: nowrap;
  gap: 1px;
  min-height: 36px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.toolbar-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dark);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 3px;
  font-size: 12px;
  transition: all 0.12s ease;
  white-space: nowrap;
  line-height: 1.2;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.toolbar-btn:hover { background: #e0e0e4; border-color: #d0d0d0; }
.toolbar-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: #d0d0d0;
  margin: 0 3px;
  flex-shrink: 0;
}

.toolbar-select {
  padding: 2px 4px;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  font-size: 11px;
  background: white;
  color: var(--text-dark);
  cursor: pointer;
  outline: none;
  height: 26px;
  flex-shrink: 0;
}

.toolbar-select:focus { border-color: var(--accent); }
.toolbar-select-wide { min-width: 90px; }
.toolbar-select-narrow { width: 46px; }

/* Color picker button + strip */
.toolbar-color-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.toolbar-color-input {
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 28px;
  height: 8px;
  opacity: 0;
  cursor: pointer;
}

.toolbar-color-bar {
  width: 20px;
  height: 3px;
  border-radius: 1px;
  margin-top: -2px;
  pointer-events: none;
}

.toolbar-color-wrap .toolbar-btn {
  font-weight: 700;
}

.toolbar-color-wrap:hover .toolbar-color-input {
  opacity: 1;
  height: 20px;
  bottom: -12px;
  width: 32px;
}

/* ============================================
   WORKSPACE (Editor + Card Panel)
   ============================================ */

#workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

#editor-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  background: #e8e8ec;
  min-height: 0;
}

#editor {
  max-width: 800px;
  margin: 0 auto;
  min-height: 100%;
}

/* ============================================
   PROSEMIRROR CONTENT STYLES
   ============================================ */

.ProseMirror {
  outline: none;
  min-height: 500px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-dark);
}

.ProseMirror p { margin-bottom: 8px; }

.ProseMirror h1 {
  font-size: 28px; font-weight: 700;
  margin: 24px 0 16px; color: #1a1a1a;
}
.ProseMirror h2 {
  font-size: 22px; font-weight: 600;
  margin: 20px 0 12px; color: #2a2a2a;
}
.ProseMirror h3 {
  font-size: 18px; font-weight: 600;
  margin: 16px 0 8px; color: #3a3a3a;
}

.ProseMirror strong { font-weight: 700; }
.ProseMirror em { font-style: italic; }
.ProseMirror u { text-decoration: underline; }
.ProseMirror s { text-decoration: line-through; }
.ProseMirror sup { vertical-align: super; font-size: 0.75em; }
.ProseMirror sub { vertical-align: sub; font-size: 0.75em; }

.ProseMirror a {
  color: #1a73e8;
  text-decoration: underline;
  cursor: pointer;
}

.ProseMirror ul, .ProseMirror ol {
  padding-left: 28px;
  margin-bottom: 8px;
}

.ProseMirror ul { list-style-type: disc; }
.ProseMirror ol { list-style-type: decimal; }

.ProseMirror li {
  margin-bottom: 4px;
}

.ProseMirror li p {
  margin-bottom: 2px;
}

.ProseMirror blockquote {
  border-left: 4px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  background: #fdf2f4;
  color: #555;
  border-radius: 0 4px 4px 0;
}

.ProseMirror pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 16px;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  overflow-x: auto;
  margin: 12px 0;
  line-height: 1.5;
}

.ProseMirror hr {
  border: none;
  border-top: 2px solid var(--border-light);
  margin: 20px 0;
}

.ProseMirror img {
  max-width: 100%;
  border-radius: 4px;
  margin: 8px 0;
}

.ProseMirror .placeholder:first-child::before {
  content: "Start typing — every paragraph becomes a card...";
  color: #bbb;
  font-style: italic;
  pointer-events: none;
  position: absolute;
}

/* ============================================
   TABLE CARD
   ============================================ */

.table-card-wrapper {
  margin: 16px 0;
  border: 2px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.table-card-wrapper:hover { border-color: var(--accent); }
.table-card-wrapper.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-secondary);
}

.table-card-name {
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
}

.table-card-name:hover { background: rgba(233, 69, 96, 0.1); }

.table-card-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-card-grid th {
  background: #f0f2f5;
  padding: 6px 12px;
  text-align: center;
  font-weight: 600;
  color: #666;
  border: 1px solid #e0e0e0;
  font-size: 11px;
  min-width: 80px;
}

.table-card-grid td {
  padding: 4px 8px;
  border: 1px solid #e8e8e8;
  min-width: 80px;
  min-height: 28px;
  outline: none;
  transition: background 0.1s ease;
}

.table-card-grid td:focus {
  background: #f0f4ff;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.table-card-grid .row-header {
  background: #f0f2f5;
  text-align: center;
  font-weight: 600;
  color: #666;
  font-size: 11px;
  width: 36px;
  min-width: 36px;
}

/* ============================================
   CARD REFERENCE (inline)
   ============================================ */

.card-ref {
  display: inline;
  background: linear-gradient(135deg, #e8eaff, #f0e8ff);
  color: #4a3aaa;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #d0d0f0;
  cursor: default;
}

.card-ref.unresolved {
  background: #fff3f3;
  color: #cc3333;
  border-color: #ffcccc;
}

/* ============================================
   @ CARD MENTION DROPDOWN
   ============================================ */

#card-mention-dropdown .mention-item:hover,
#card-mention-dropdown .mention-item.active {
  background: #e8f0fe;
}
#card-mention-dropdown .mention-item:first-child {
  border-radius: 8px 8px 0 0;
}
#card-mention-dropdown .mention-item:last-child {
  border-radius: 0 0 8px 8px;
}

/* ============================================
   CARD LIBRARY PANEL
   ============================================ */

#card-panel {
  width: 280px;
  background: var(--bg-card-panel);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.2s ease;
}

#card-panel.collapsed { width: 0; border: none; overflow: hidden; }

#card-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

#card-panel-header h3 { font-size: 13px; font-weight: 600; color: var(--text-dark); }

#card-count {
  font-size: 11px;
  color: var(--text-secondary);
  background: #eee;
  padding: 2px 8px;
  border-radius: 10px;
}

#card-list { flex: 1; overflow-y: auto; padding: 8px; }

.card-item {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.card-item:hover { background: var(--card-hover); border-color: var(--accent); }
.card-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.15);
}

.card-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.card-item-name { font-size: 12px; font-weight: 600; color: var(--text-dark); }

.card-item-type {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-item-type.text { background: #e8f4fd; color: #2980b9; }
.card-item-type.table { background: #e8fde8; color: #27ae60; }
.card-item-type.image { background: #fde8f4; color: #8e44ad; }
.card-item-type.heading { background: #fdf3e8; color: #d35400; }

.card-item-preview {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.card-item-tags { display: flex; flex-wrap: wrap; gap: 3px; }

.card-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--tag-bg);
  color: var(--tag-text);
  cursor: pointer;
}

.card-tag:hover { background: #d0d4ff; }

.card-tag-add {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: none;
  border: 1px dashed #ccc;
  color: #aaa;
  cursor: pointer;
}

.card-tag-add:hover { border-color: var(--accent); color: var(--accent); }

/* ============================================
   DOCS — Page-style editor
   ============================================ */

#module-docs {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
}

#editor-page {
  background: white;
  max-width: 816px; /* 8.5" at 96dpi */
  min-height: 1056px; /* 11" at 96dpi */
  margin: 0 auto;
  padding: 72px 72px; /* 0.75" margins */
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  border-radius: 2px;
}

/* editor-container background set above in workspace section */

/* ============================================
   STATUS BAR (Docs)
   ============================================ */

#status-bar {
  display: flex;
  align-items: center;
  padding: 4px 16px;
  background: var(--toolbar-bg);
  border-top: 1px solid var(--toolbar-border);
  font-size: 11px;
  color: #888;
  gap: 16px;
  flex-shrink: 0;
}

.status-spacer { flex: 1; }

.status-zoom {
  font-size: 11px;
  color: #888;
}

.status-zoom select {
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 11px;
  background: white;
}

/* ============================================
   GRID MODULE — Spreadsheet
   ============================================ */

/* ============================================
   GRID MODULE — Excel/LibreOffice Style
   ============================================ */

#module-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
  background: white;
  font-family: Calibri, Arial, sans-serif;
}

/* Title Bar */
#grid-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: #1e40af;
  border-bottom: none;
}

#grid-title {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  outline: none;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
}

#grid-title:focus { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.15); color: #fff; }
#grid-title-right { display: flex; gap: 2px; align-items: center; }

/* ── Grid toolbar grouped dropdown menus ── */
.grid-menu { position: relative; }
.grid-menu-trigger {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.9);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.grid-menu-trigger:hover,
.grid-menu.open .grid-menu-trigger {
  background: rgba(255,255,255,0.18);
}
.grid-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 210px;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  z-index: 9000;
  padding: 4px 0;
  flex-direction: column;
}
.grid-menu.open .grid-menu-dropdown { display: flex; }
/* keep rightmost dropdowns from overflowing viewport */
.grid-menu[data-menu="tools"] .grid-menu-dropdown,
.grid-menu[data-menu="format"] .grid-menu-dropdown {
  right: 0; left: auto;
}
.grid-menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  font-size: 13px;
  color: #222;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.1s;
}
.grid-menu-item:hover { background: #e8f0fe; }
.grid-menu-sep { height: 1px; background: #e0e0e0; margin: 3px 8px; }

/* Spreadsheet Container — Univer fills this */
#grid-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: white;
  min-height: 0;
}

#grid-spreadsheet {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* Pivot Table Dialog */
#pivot-dialog {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pivot-dialog-inner {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  width: 380px;
  max-width: 95vw;
  padding: 0;
  overflow: hidden;
}
.pivot-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  font-weight: 600;
  font-size: 14px;
}
.pivot-dialog-header button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
}
.pivot-fields {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pivot-field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.pivot-field-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
}
.pivot-field-group select[multiple] {
  height: auto;
}
.pivot-actions {
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  text-align: right;
}
.pivot-actions button {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.pivot-actions button:hover {
  background: #1d4ed8;
}

/* SQL + AI + Search Dialogs (reuse pivot overlay pattern) */
#sql-dialog, #ai-dialog, #search-dialog {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   JS SCRIPTING CONSOLE
   ============================================ */
#script-console-dialog {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.script-console-inner {
  width: 850px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.script-console-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.script-console-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.script-console-toolbar select,
.script-console-toolbar input {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 12px;
}
.script-console-toolbar select { flex: 1; min-width: 120px; }
.script-console-toolbar input[type="text"] { width: 150px; }
#script-editor-mount {
  border: 1px solid #444;
  border-radius: 6px;
  overflow: hidden;
  min-height: 200px;
}
#script-editor-fallback {
  width: 100%;
  height: 300px;
  font-family: 'Fira Code','Source Code Pro',monospace;
  font-size: 13px;
  padding: 10px;
  border: none;
  resize: vertical;
  line-height: 1.5;
  tab-size: 2;
  background: #1e1e2e;
  color: #cdd6f4;
}
.script-console-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.script-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.script-btn-green { background: #059669; color: #fff; }
.script-btn-green:hover { background: #047857; }
.script-btn-blue { background: #2563eb; color: #fff; }
.script-btn-blue:hover { background: #1d4ed8; }
.script-btn-red { background: #dc2626; color: #fff; }
.script-btn-red:hover { background: #b91c1c; }
.script-btn-gray { background: #e5e7eb; color: #374151; }
.script-btn-gray:hover { background: #d1d5db; }
#script-status {
  font-size: 12px;
  color: #666;
  line-height: 32px;
  margin-left: auto;
}
.script-console-output-header {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  margin: 10px 0 4px;
}
#script-output {
  background: #1e1e2e;
  color: #a6e3a1;
  padding: 10px;
  border-radius: 6px;
  font-family: 'Fira Code',monospace;
  font-size: 12px;
  max-height: 200px;
  overflow: auto;
  min-height: 60px;
  white-space: pre-wrap;
  margin: 0;
}
.script-error { color: #f38ba8 !important; }
.script-warn { color: #f9e2af !important; }
.script-console-api-ref {
  margin-top: 8px;
  font-size: 10px;
  color: #999;
  border-top: 1px solid #eee;
  padding-top: 8px;
}
.script-console-api-ref code {
  background: #f0f0f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
}

/* ============================================
   ML PREDICTIONS DIALOG
   ============================================ */
#ml-predict-dialog {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   NETWORK GRAPH DIALOG
   ============================================ */
#network-graph-dialog {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   GEO MAP DIALOG
   ============================================ */
#geo-map-dialog {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* PivotTable.js overrides */
.pvtUi { font-size: 12px !important; }
.pvtAxisContainer li { font-size: 11px !important; padding: 3px 6px !important; }
.pvtTable td, .pvtTable th { font-size: 11px !important; padding: 3px 6px !important; }
.pvtRendererArea { overflow: auto; }

/* ============================================
   MODULE PLACEHOLDERS
   ============================================ */

.module-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-placeholder { text-align: center; color: var(--text-secondary); }
.placeholder-icon { font-size: 64px; display: block; margin-bottom: 16px; opacity: 0.5; }
.module-placeholder h2 { font-size: 24px; color: var(--text-dark); margin-bottom: 8px; }
.module-placeholder p { font-size: 14px; color: #999; }

/* ============================================
   TAG INPUT POPOVER
   ============================================ */

.tag-input-popover {
  position: absolute;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
}

.tag-input-popover input {
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
  width: 140px;
}

.tag-input-popover input:focus { border-color: var(--accent); }

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ============================================
   DONUT SELECTOR
   ============================================ */

@keyframes donutFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes donutScaleIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.donut-item:focus { outline: none; }

/* ============================================
   RESPONSIVE — Tablet landscape
   ============================================ */

@media (max-width: 1024px) {
  #editor-container { padding: 16px 12px; }
  #card-panel { display: none; }
  .toolbar-select-wide { min-width: 80px; }

  #editor-page {
    max-width: 100%;
    padding: 40px 32px;
    min-height: auto;
    box-shadow: none;
    border-radius: 0;
  }

  #doc-title { min-width: 140px; font-size: 14px; }
}

/* ============================================
   RESPONSIVE — iPad portrait / narrow tablet
   ============================================ */

@media (max-width: 860px) {
  /* Compact header */
  #header { padding: 0 8px; }
  #header-brand-text { display: none; }
  .dock-slot-label { display: none; }
  .dock-action { padding: 4px 8px; font-size: 10px; }
  #dock-pill { padding: 4px 10px; gap: 2px; }

  /* Hide card panel */
  #card-panel { display: none; }

  /* Toolbar compact */
  #toolbar { padding: 4px 6px; gap: 1px; }

  /* Title bar */
  #doc-title { min-width: 120px; font-size: 14px; }

  /* Editor page: full width */
  #editor-container { padding: 12px 8px; }
  #editor-page {
    max-width: 100%;
    padding: 24px 20px;
    min-height: auto;
    box-shadow: none;
    border-radius: 0;
  }

  #grid-title { font-size: 14px; }
  #status-bar { gap: 8px; padding: 4px 8px; }
}

/* ============================================
   RESPONSIVE — Small phone (unlikely but safe)
   ============================================ */

@media (max-width: 480px) {
  #header-brand { display: none; }
  .dock-action { display: none; }
  #dock-coin { width: 56px; height: 56px; }
  #dock-coin-icon { font-size: 18px; }
  #dock-coin-label { font-size: 7px; }

  #toolbar-top { padding: 4px 8px; }
  #doc-title { min-width: 80px; font-size: 13px; }
  .toolbar-btn-sm { padding: 3px 6px; font-size: 11px; }

  #editor-page { padding: 16px 12px; }
  .ProseMirror { font-size: 14px; }

  #status-bar span { font-size: 10px; }
}

/* ============================================
   PAGE BREAK
   ============================================ */

.page-break {
  page-break-after: always;
  border: none;
  text-align: center;
  color: #999;
  font-size: 11px;
  padding: 8px 0;
  margin: 20px 0;
  user-select: none;
  position: relative;
  cursor: default;
}
.page-break::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 2px dashed #ccc;
}
.page-break::after {
  content: 'Page Break';
  background: white;
  padding: 0 12px;
  position: relative;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #bbb;
}

/* ============================================
   SAVE INDICATOR
   ============================================ */

#save-indicator {
  color: #4ade80;
  font-size: 11px;
  font-weight: 600;
  transition: color 0.3s;
}

/* ============================================
   HEADER & FOOTER (in-page)
   ============================================ */

#page-header, #page-footer {
  padding: 8px 0;
  font-size: 11px;
  color: #888;
  min-height: 24px;
  outline: none;
  font-family: inherit;
}
#page-header {
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 16px;
}
#page-footer {
  border-top: 1px solid #e5e7eb;
  margin-top: 16px;
}
#page-header:empty::before {
  content: attr(data-placeholder);
  color: #ccc;
  font-style: italic;
}
#page-footer:empty::before {
  content: attr(data-placeholder);
  color: #ccc;
  font-style: italic;
}

/* ============================================
   DRAG & DROP OVERLAY
   ============================================ */

#editor.drag-over {
  outline: 2px dashed #3b82f6;
  outline-offset: -4px;
  background: rgba(59, 130, 246, 0.04);
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  #header, #toolbar, #toolbar-top, #status-bar, #card-panel,
  .dock-action, #dock-pill, #donut-overlay,
  #grammar-panel, #template-panel, #wordcount-panel, #page-setup-panel {
    display: none !important;
  }
  body { background: white; }
  #main-content { padding: 0; }
  #editor-container { box-shadow: none; border: none; background: white; padding: 0; }
  #editor-page {
    max-width: none;
    box-shadow: none;
    margin: 0;
    padding: 0;
    border: none;
  }
  #page-header, #page-footer {
    display: block !important;
    color: #333;
  }
  .page-break {
    visibility: hidden;
    page-break-after: always;
    height: 0;
    margin: 0;
    padding: 0;
  }
  .page-break::before, .page-break::after { display: none; }
  @page { margin: 0.75in; }
}

/* ============================================
   PDF MODULE
   ============================================ */

#module-pdf {
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  min-height: 0;
}

/* PDF toolbar — two-row layout */
#pdf-toolbar-wrap {
  flex-shrink: 0;
  background: #f8f9fa;
}
.pdf-toolbar-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
}
#pdf-toolbar {
  padding-top: 6px;
}
.pdf-toolbar-secondary {
  padding-bottom: 6px;
  border-top: 1px solid #eee;
}
.pdf-toolbar-secondary .toolbar-btn {
  font-size: 11px;
  padding: 3px 7px;
}
/* Primary tool button — stands out */
.pdf-tool-primary {
  background: #eef2ff !important;
  border-color: #818cf8 !important;
  font-weight: 600;
}
.pdf-tool-primary.active {
  background: #4f46e5 !important;
  color: white !important;
  border-color: #4f46e5 !important;
}

#pdf-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: #525659;
  min-height: 0;
}

/* Thumbnails sidebar */
#pdf-thumbnails {
  width: 160px;
  min-width: 160px;
  background: #3c3f41;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pdf-thumbnail {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 2px;
  transition: all 0.15s;
  position: relative;
  background: white;
}
.pdf-thumbnail:hover { border-color: rgba(255,255,255,0.5); }
.pdf-thumbnail.active { border-color: #3b82f6; box-shadow: 0 0 8px rgba(59,130,246,0.4); }
.pdf-thumbnail canvas { display: block; border-radius: 2px; }
.pdf-thumb-label {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}

/* Main viewer */
#pdf-viewer-container {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  position: relative;
  min-height: 0;
}
#pdf-viewer-container.pdf-drag-over {
  outline: 3px dashed #3b82f6;
  outline-offset: -8px;
  background: rgba(59,130,246,0.08);
}

#pdf-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Individual PDF page */
.pdf-page {
  position: relative;
  background: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  border-radius: 2px;
}
.pdf-page canvas { display: block; }
.pdf-page-label {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  font-weight: 500;
}

/* Text layer — editable text over canvas */
.pdf-text-layer {
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  line-height: 1;
  pointer-events: auto;
  z-index: 1;
}
.pdf-text-layer span {
  position: absolute;
  white-space: pre;
  pointer-events: auto;
  color: transparent;
  cursor: default;
  transition: background 0.15s;
  border-radius: 2px;
  padding: 0;
  margin: 0;
}
.pdf-text-layer span::selection {
  background: rgba(59, 130, 246, 0.3);
}
/* Hide PDF.js endOfContent marker */
.pdf-text-layer .endOfContent {
  display: none;
}
/* ===== ACTIVE EDITING — white mask covers canvas text beneath ===== */
.pdf-text-layer span.pdf-text-editing {
  color: #000;
  background: #fff;
  /* Horizontal bleed only — don't cover line above/below */
  box-shadow: -2px 0 0 0 #fff, 2px 0 0 0 #fff;
  outline: 2px solid #1e40af;
  outline-offset: 1px;
  z-index: 10;
  cursor: text;
  min-width: 4px;
  border-radius: 2px;
}
/* Edited (committed) text — stays visible with white mask */
.pdf-text-layer span.pdf-text-edited {
  color: #000;
  background: #fff;
  box-shadow: -1px 0 0 0 #fff, 1px 0 0 0 #fff;
  border-radius: 2px;
}
/* Long-press visual hint */
.pdf-text-layer span.pdf-text-pressing {
  background: rgba(30, 64, 175, 0.1);
}

/* ===== EDIT MODE — dashed borders show tap targets, text stays invisible ===== */
/* Text remains transparent so there's no doubling with canvas text */
.pdf-text-layer.pdf-edit-mode span {
  color: transparent;
  border-bottom: 1.5px dashed rgba(59, 130, 246, 0.5);
  cursor: text;
}
.pdf-text-layer.pdf-edit-mode span:hover,
.pdf-text-layer.pdf-edit-mode span:active {
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.15);
}
/* Edited spans in edit mode — already have white mask */
.pdf-text-layer.pdf-edit-mode span.pdf-text-edited {
  color: #000;
  background: #fff;
  box-shadow: -1px 0 0 0 #fff, 1px 0 0 0 #fff;
  border-bottom: 1.5px solid rgba(74, 222, 128, 0.5);
}
/* Active editing span in edit mode */
.pdf-text-layer.pdf-edit-mode span.pdf-text-editing {
  color: #000;
  background: #fff;
  box-shadow: -2px 0 0 0 #fff, 2px 0 0 0 #fff;
  border-bottom: none;
  outline: 2px solid #1e40af;
}

/* ===== SEARCH HIGHLIGHTS ===== */
.pdf-text-layer span.pdf-search-match {
  color: #000 !important;
  background: rgba(255, 235, 59, 0.45) !important;
  border-radius: 2px;
}
.pdf-text-layer span.pdf-search-current {
  color: #000 !important;
  background: rgba(255, 152, 0, 0.55) !important;
  outline: 2px solid #f57c00;
  outline-offset: 1px;
  border-radius: 2px;
}

/* ===== LONG-PRESS CONTEXT MENU ===== */
.pdf-context-menu {
  position: absolute;
  z-index: 100;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
  padding: 4px 0;
  min-width: 120px;
  font-size: 13px;
}
.pdf-context-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  color: #1a1a1a;
}
.pdf-context-menu button:hover,
.pdf-context-menu button:active {
  background: #f0f4ff;
}
.pdf-context-menu button.destructive {
  color: #dc2626;
}

/* Annotation overlay */
.pdf-annotation-layer {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  z-index: 2;
}

/* Notes layer */
.pdf-notes-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}
.pdf-sticky-note {
  position: absolute;
  pointer-events: auto;
  cursor: default;
}
.pdf-note-icon {
  font-size: 24px;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}
.pdf-note-body {
  display: none;
  position: absolute;
  top: 28px;
  left: 0;
  background: #fff9c4;
  border: 1px solid #f0e68c;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: #333;
  min-width: 140px;
  max-width: 220px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  white-space: pre-wrap;
  z-index: 10;
}
.pdf-sticky-note.expanded .pdf-note-body { display: block; }
.pdf-note-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: #e94560;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.pdf-sticky-note:hover .pdf-note-delete { display: flex; }

/* Empty state */
#pdf-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: rgba(255,255,255,0.8);
  text-align: center;
}
.pdf-empty-icon {
  font-size: 72px;
  margin-bottom: 16px;
  opacity: 0.5;
}
#pdf-empty-state h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  color: white;
}
#pdf-empty-state p {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  margin: 0 0 24px;
}
.pdf-open-btn {
  padding: 12px 32px;
  background: linear-gradient(145deg, #1e40af, #1e3a8a);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(30,64,175,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  margin-bottom: 32px;
}
.pdf-open-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 20px rgba(30,64,175,0.4);
}
.pdf-features-grid {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 12px 24px;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

/* PDF Status bar */
#pdf-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 16px;
  background: #f8f9fa;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
}

/* Empty state centering */
#pdf-viewer-container:has(#pdf-empty-state:not([style*="display: none"])) {
  align-items: center;
  justify-content: center;
}

/* ============================================
   PDF TEXT ANNOTATIONS
   ============================================ */

.pdf-text-annotation {
  position: absolute;
  z-index: 5;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #3b82f6;
  border-radius: 4px;
  min-height: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: border-color 0.15s, background 0.15s;
}
.pdf-text-annotation.committed {
  background: transparent;
  border: 1px dashed rgba(59, 130, 246, 0.3);
  box-shadow: none;
}
.pdf-text-annotation.committed:hover {
  border: 2px solid #3b82f6;
  background: rgba(255, 255, 255, 0.6);
}
.pdf-text-annotation.committed .pdf-text-delete,
.pdf-text-annotation.committed .pdf-text-drag-handle {
  display: none;
}
.pdf-text-annotation.committed:hover .pdf-text-delete,
.pdf-text-annotation.committed:hover .pdf-text-drag-handle {
  display: flex;
}

.pdf-text-input {
  display: block;
  width: 100%;
  min-height: 24px;
  border: none;
  background: transparent;
  outline: none;
  resize: horizontal;
  font-family: sans-serif;
  line-height: 1.4;
  padding: 4px 6px;
  overflow: hidden;
}

.pdf-text-drag-handle {
  position: absolute;
  top: -14px;
  left: 4px;
  background: #3b82f6;
  color: white;
  width: 20px;
  height: 14px;
  border-radius: 3px 3px 0 0;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.pdf-text-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  background: #e94560;
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 6;
}

/* ============================================
   PDF MODAL OVERLAY (shared)
   ============================================ */

.pdf-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.pdf-modal-panel {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
}
.pdf-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 16px;
}
.pdf-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #999;
  padding: 0;
  line-height: 1;
}
.pdf-modal-close:hover { color: #333; }

/* ============================================
   STAMPS
   ============================================ */

.pdf-stamp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.pdf-stamp-option {
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s, box-shadow 0.1s;
}
.pdf-stamp-option:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ============================================
   FORM FIELDS
   ============================================ */

.pdf-form-field {
  position: absolute;
  z-index: 5;
  box-sizing: border-box;
}
.pdf-form-text {
  background: rgba(200, 220, 255, 0.3);
  border: 1.5px solid #3b82f6;
  border-radius: 2px;
  padding: 2px 4px;
  font-size: 12px;
  font-family: sans-serif;
  color: #1e3a5f;
  outline: none;
}
.pdf-form-text:focus {
  background: rgba(200, 220, 255, 0.6);
  border-color: #1e40af;
  box-shadow: 0 0 0 2px rgba(30,64,175,0.2);
}
.pdf-form-checkbox,
.pdf-form-radio {
  width: 16px !important;
  height: 16px !important;
  cursor: pointer;
  accent-color: #1e40af;
}
.pdf-form-select {
  background: rgba(200, 220, 255, 0.3);
  border: 1.5px solid #3b82f6;
  border-radius: 2px;
  padding: 1px 2px;
  font-size: 11px;
  color: #1e3a5f;
  cursor: pointer;
}

/* ============================================
   BOOKMARKS PANEL
   ============================================ */

#pdf-bookmarks-panel {
  display: none;
  flex-direction: column;
  width: 220px;
  min-width: 220px;
  background: #f8f9fa;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
}
.pdf-bookmarks-header {
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  background: white;
  position: sticky;
  top: 0;
  z-index: 1;
}
.pdf-bookmark-item {
  padding: 8px 12px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.1s;
  word-break: break-word;
}
.pdf-bookmark-item:hover {
  background: #e5e7eb;
  color: #1e40af;
}

/* ============================================
   DOCUMENT PROPERTIES TABLE
   ============================================ */

.pdf-props-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.pdf-props-table tr { border-bottom: 1px solid #f0f0f0; }
.pdf-prop-key {
  padding: 8px 8px 8px 0;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
  vertical-align: top;
  width: 100px;
}
.pdf-prop-val {
  padding: 8px 0;
  font-size: 12px;
  color: #1f2937;
  word-break: break-all;
}

/* ============================================
   PAGE REORDER
   ============================================ */

#pdf-thumbnails.reorder-mode .pdf-thumbnail {
  cursor: grab;
  border: 2px dashed transparent;
  transition: border-color 0.15s;
}
#pdf-thumbnails.reorder-mode .pdf-thumbnail:hover {
  border-color: #3b82f6;
}
#pdf-thumbnails.reorder-mode .pdf-thumbnail.dragging {
  opacity: 0.4;
}
#pdf-thumbnails.reorder-mode .pdf-thumbnail.drag-over {
  border-color: #1e40af;
  background: rgba(30, 64, 175, 0.1);
}

/* ============================================
   DARK MODE
   ============================================ */

.pdf-dark-mode {
  background: #1a1a2e !important;
}
.pdf-dark-mode .pdf-page canvas {
  filter: invert(0.88) hue-rotate(180deg);
}
.pdf-dark-mode .pdf-text-layer span {
  filter: invert(0.88) hue-rotate(180deg);
}
.pdf-dark-mode .pdf-page-label {
  color: rgba(255,255,255,0.5);
}

/* ============================================
   PRESENTATION MODE
   ============================================ */

.pdf-presentation {
  background: #000 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pdf-presentation #pdf-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.pdf-presentation .pdf-page {
  margin: 0 !important;
  box-shadow: none !important;
}
.pdf-presentation .pdf-page-label {
  display: none;
}

/* Active toolbar button state */
#pdf-toolbar .toolbar-btn.active,
#pdf-toolbar .toolbar-btn-sm.active,
#pdf-toolbar-row2 .toolbar-btn.active {
  background: #1e40af;
  color: white;
  border-color: #1e40af;
}

/* ── Export Menu ── */
.export-menu-dropdown div:first-child {
  border-radius: 8px 8px 0 0;
}
.export-menu-dropdown div:last-child {
  border-radius: 0 0 8px 8px;
}
