/* ════════════════════════════════════════════════════════════════
   DocuSense — Design System & Full Layout
   https://postlister.com/docusense/
   ════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&family=Instrument+Sans:wght@400;500;600&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────────── */
:root {
  /* Brand Colors */
  --c-primary:       #1B3E7A;
  --c-primary-mid:   #2556A8;
  --c-primary-light: #3B72D4;
  --c-primary-pale:  #EEF3FB;
  --c-accent:        #F5A623;
  --c-accent-dark:   #D4861A;

  /* Status Colors */
  --c-critical:      #C0392B;
  --c-critical-bg:   #FDECEA;
  --c-high:          #E74C3C;
  --c-high-bg:       #FEEFEE;
  --c-medium:        #E67E22;
  --c-medium-bg:     #FEF5EB;
  --c-low:           #27AE60;
  --c-low-bg:        #EBF8F1;
  --c-info:          #2980B9;
  --c-info-bg:       #EBF5FB;

  /* Neutrals */
  --c-bg:            #F0F4F8;
  --c-surface:       #FFFFFF;
  --c-surface-2:     #F7F9FC;
  --c-border:        #DDE3EC;
  --c-border-light:  #EEF2F7;
  --c-text:          #1A2332;
  --c-text-mid:      #4A5568;
  --c-text-muted:    #8896A8;
  --c-text-placeholder: #B0BCCC;

  /* AI Mode Colors */
  --c-ai-script:     #6B46C1;
  --c-ai-browser:    #0891B2;
  --c-ai-ollama:     #059669;
  --c-ai-openai:     #1A7F64;
  --c-ai-gemini:     #4285F4;
  --c-ai-claude:     #D97706;
  --c-ai-combined:   #7C3AED;

  /* Typography */
  --font-ui:         'Sora', sans-serif;
  --font-body:       'Instrument Sans', sans-serif;
  --font-mono:       'DM Mono', monospace;

  /* Sizing */
  --sidebar-w:       280px;
  --comment-w:       340px;
  --header-h:        54px;
  --tab-h:           42px;
  --border-r:        8px;
  --border-r-sm:     5px;
  --border-r-lg:     12px;

  /* Shadows */
  --shadow-sm:       0 1px 3px rgba(27,62,122,0.08);
  --shadow-md:       0 4px 12px rgba(27,62,122,0.10);
  --shadow-lg:       0 8px 24px rgba(27,62,122,0.12);
  --shadow-pop:      0 16px 40px rgba(27,62,122,0.16);

  /* Transitions */
  --t-fast:          0.12s ease;
  --t-mid:           0.22s ease;
  --t-slow:          0.36s ease;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
a { color: var(--c-primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }

/* ── Scrollbars ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-muted); }

/* ═══════════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════════ */
#ds-header {
  height: var(--header-h);
  background: var(--c-primary);
  display: flex;
  align-items: center;
  padding: 0 16px 0 14px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.ds-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}
.ds-logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #3B72D4 0%, var(--c-accent) 100%);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  font-family: var(--font-ui);
  letter-spacing: -0.5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.ds-logo-name {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}
.ds-logo-name span { color: var(--c-accent); }
.ds-logo-tag {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  margin-top: 1px;
  display: none;
}

.ds-header-sep {
  width: 1px; height: 22px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

/* AI Mode Badge in Header */
.ds-ai-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.ds-ai-badge:hover { background: rgba(255,255,255,0.18); }
.ds-ai-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.ds-ai-badge .label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  font-family: var(--font-ui);
  letter-spacing: 0.2px;
}

.ds-header-spacer { flex: 1; }

/* Header Action Buttons */
.ds-header-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--border-r-sm);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.75);
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.ds-header-btn:hover {
  background: rgba(255,255,255,0.16);
  color: #fff;
}
.ds-header-btn svg { width: 15px; height: 15px; }

.btn-run-check {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 16px;
  background: var(--c-accent);
  color: #fff;
  border-radius: var(--border-r-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: all var(--t-fast);
  box-shadow: 0 2px 8px rgba(245,166,35,0.35);
  flex-shrink: 0;
}
.btn-run-check:hover {
  background: var(--c-accent-dark);
  box-shadow: 0 3px 10px rgba(245,166,35,0.45);
  transform: translateY(-1px);
}
.btn-run-check svg { width: 13px; height: 13px; }

/* ═══════════════════════════════════════════════════════════════
   APP BODY — 3-PANEL LAYOUT
═══════════════════════════════════════════════════════════════ */
#ds-app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   LEFT PANEL — Guidelines & Rules
═══════════════════════════════════════════════════════════════ */
#ds-left {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--t-mid), min-width var(--t-mid);
}
#ds-left.collapsed {
  width: 44px;
  min-width: 44px;
}

.ds-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 40px;
  border-bottom: 1px solid var(--c-border-light);
  flex-shrink: 0;
  background: var(--c-surface-2);
}
.ds-panel-header h3 {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--c-text-mid);
}
.ds-panel-toggle {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-muted);
  background: transparent;
  transition: all var(--t-fast);
}
.ds-panel-toggle:hover { background: var(--c-border-light); color: var(--c-text); }
.ds-panel-toggle svg { width: 13px; height: 13px; }

.ds-left-inner {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
}

/* Accordion Sections */
.ds-section {
  border-bottom: 1px solid var(--c-border-light);
  margin-bottom: 0;
}
.ds-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast);
}
.ds-section-head:hover { background: var(--c-primary-pale); }
.ds-section-head svg {
  width: 14px; height: 14px;
  color: var(--c-primary-light);
  flex-shrink: 0;
}
.ds-section-head span {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text);
  flex: 1;
}
.ds-section-head .ds-chevron {
  color: var(--c-text-muted);
  transition: transform var(--t-fast);
}
.ds-section.open .ds-chevron { transform: rotate(180deg); }
.ds-section-body { display: none; padding: 6px 12px 10px; }
.ds-section.open .ds-section-body { display: block; }

/* Upload Zone (small) */
.ds-upload-zone-sm {
  border: 1.5px dashed var(--c-border);
  border-radius: var(--border-r-sm);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--c-surface-2);
  margin-bottom: 6px;
}
.ds-upload-zone-sm:hover, .ds-upload-zone-sm.drag-over {
  border-color: var(--c-primary-light);
  background: var(--c-primary-pale);
}
.ds-upload-zone-sm svg {
  width: 18px; height: 18px;
  color: var(--c-text-muted);
  margin-bottom: 3px;
}
.ds-upload-zone-sm p {
  font-size: 10.5px;
  color: var(--c-text-muted);
  line-height: 1.4;
}
.ds-upload-zone-sm p strong { color: var(--c-primary-light); }

/* Uploaded File Tags */
.ds-file-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--c-primary-pale);
  border-radius: var(--border-r-sm);
  margin-bottom: 4px;
  border: 1px solid rgba(59,114,212,0.12);
}
.ds-file-tag svg { width: 12px; height: 12px; color: var(--c-primary-light); flex-shrink: 0; }
.ds-file-tag span {
  font-size: 11px;
  color: var(--c-text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-file-tag .rm {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 3px;
  color: var(--c-text-muted);
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.ds-file-tag .rm:hover { background: var(--c-high-bg); color: var(--c-high); }

/* Rules Checklist */
.ds-rule-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 5px 0;
  border-bottom: 1px solid var(--c-border-light);
  cursor: pointer;
}
.ds-rule-item:last-child { border-bottom: none; }
.ds-rule-item input[type="checkbox"] {
  width: 13px; height: 13px;
  accent-color: var(--c-primary-light);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}
.ds-rule-item-text {
  flex: 1;
  font-size: 11.5px;
  color: var(--c-text);
  line-height: 1.4;
}
.ds-rule-item-cat {
  font-size: 9.5px;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--c-border-light);
  color: var(--c-text-muted);
  flex-shrink: 0;
}

/* ── Check Options panel ──────────────────────────────────────── */
.ds-opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
.ds-opt-label {
  font-size: 10.5px;
  color: var(--c-text-mid);
  flex-shrink: 0;
  min-width: 90px;
}
.ds-opt-select {
  flex: 1;
  font-size: 10.5px;
  font-family: var(--font-ui);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 3px 5px;
  min-width: 0;
}
.ds-opt-toggles {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--c-border-light);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ds-opt-toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--c-text-mid);
  cursor: pointer;
}
.ds-opt-toggle-row input[type="checkbox"] {
  width: 12px; height: 12px;
  flex-shrink: 0;
  cursor: pointer;
}
.ds-opt-toggle-row:hover { color: var(--c-text); }

/* Small Buttons */
.ds-btn-xs {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
  transition: all var(--t-fast);
  letter-spacing: 0.2px;
}
.ds-btn-xs.primary {
  background: var(--c-primary-light);
  color: #fff;
}
.ds-btn-xs.primary:hover { background: var(--c-primary-mid); }
.ds-btn-xs.ghost {
  background: transparent;
  color: var(--c-text-mid);
  border: 1px solid var(--c-border);
}
.ds-btn-xs.ghost:hover { background: var(--c-border-light); }
.ds-btn-xs svg { width: 10px; height: 10px; }

/* ═══════════════════════════════════════════════════════════════
   CENTER PANEL — Document Viewer
═══════════════════════════════════════════════════════════════ */
#ds-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
  min-width: 0;
}

/* Tab Bar */
#ds-tab-bar {
  display: flex;
  align-items: center;
  height: var(--tab-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 0 12px;
  gap: 2px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#ds-tab-bar::-webkit-scrollbar { display: none; }

.ds-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 13px;
  border-radius: var(--border-r-sm) var(--border-r-sm) 0 0;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text-muted);
  cursor: pointer;
  position: relative;
  transition: all var(--t-fast);
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.ds-tab:hover { color: var(--c-text); background: var(--c-surface-2); }
.ds-tab.active {
  color: var(--c-primary-light);
  background: var(--c-surface);
  border-color: var(--c-border) var(--c-border) var(--c-surface);
  border-bottom-color: var(--c-primary-light);
  font-weight: 600;
}
.ds-tab svg { width: 13px; height: 13px; }
.ds-tab .tab-badge {
  min-width: 17px; height: 17px;
  padding: 0 4px;
  background: var(--c-high);
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui);
}
.ds-tab.active .tab-badge { background: var(--c-primary-light); }

/* Tab Content Area */
#ds-tab-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ds-tab-panel { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.ds-tab-panel.active { display: flex; }

/* Document Viewer */
#ds-doc-viewer {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Upload Drop Zone (center, large) */
.ds-upload-hero {
  width: 100%;
  max-width: 600px;
  border: 2px dashed var(--c-border);
  border-radius: var(--border-r-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-mid);
  background: var(--c-surface);
  box-shadow: var(--shadow-sm);
}
.ds-upload-hero:hover, .ds-upload-hero.drag-over {
  border-color: var(--c-primary-light);
  background: var(--c-primary-pale);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.ds-upload-hero-icon {
  width: 56px; height: 56px;
  background: var(--c-primary-pale);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  border: 1.5px solid rgba(59,114,212,0.2);
}
.ds-upload-hero-icon svg { width: 26px; height: 26px; color: var(--c-primary-light); }
.ds-upload-hero h2 {
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 6px;
}
.ds-upload-hero p {
  font-size: 13px;
  color: var(--c-text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.ds-upload-hero .formats {
  display: flex; justify-content: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.ds-format-pill {
  padding: 3px 9px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  background: var(--c-border-light);
  color: var(--c-text-mid);
  border: 1px solid var(--c-border);
}
.ds-upload-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0;
}
.ds-upload-divider::before, .ds-upload-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}
.ds-upload-divider span {
  font-size: 11px;
  color: var(--c-text-muted);
  font-family: var(--font-mono);
}

/* Paste Area */
.ds-paste-area {
  width: 100%;
  max-width: 600px;
  background: var(--c-surface);
  border-radius: var(--border-r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: none;
}
.ds-paste-area.visible { display: block; }
.ds-paste-area-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border-light);
  background: var(--c-surface-2);
}
.ds-paste-area-head span {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-mid);
}
.ds-paste-textarea {
  width: 100%;
  min-height: 160px;
  padding: 14px;
  border: none;
  resize: vertical;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
}
.ds-paste-textarea::placeholder { color: var(--c-text-placeholder); }

/* Document Page Renderer */
.ds-doc-page {
  width: 100%;
  max-width: 760px;
  background: var(--c-surface);
  border-radius: var(--border-r);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.ds-page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border-light);
}
.ds-page-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--c-text-muted);
  letter-spacing: 0.5px;
}
.ds-page-content {
  padding: 24px 28px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--c-text);
}
.ds-highlight {
  background: rgba(245,166,35,0.25);
  border-bottom: 2px solid var(--c-accent);
  border-radius: 2px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.ds-highlight:hover { background: rgba(245,166,35,0.45); }
.ds-highlight.critical { background: rgba(192,57,43,0.15); border-color: var(--c-critical); }
.ds-highlight.high { background: rgba(231,76,60,0.15); border-color: var(--c-high); }
.ds-highlight.low { background: rgba(39,174,96,0.12); border-color: var(--c-low); }

/* Progress Bar (for chunk processing) */
.ds-progress-wrap {
  width: 100%; max-width: 600px;
  background: var(--c-surface);
  border-radius: var(--border-r);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: none;
}
.ds-progress-wrap.visible { display: block; }
.ds-progress-label {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.ds-progress-label span { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--c-text); }
.ds-progress-label .pct { color: var(--c-primary-light); }
.ds-progress-bar {
  height: 6px;
  background: var(--c-border-light);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.ds-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-primary-light), var(--c-accent));
  border-radius: 10px;
  transition: width 0.4s ease;
  width: 0%;
}
.ds-progress-sub {
  font-size: 11px;
  color: var(--c-text-muted);
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════════════
   RIGHT PANEL — Comments
═══════════════════════════════════════════════════════════════ */
#ds-right {
  width: var(--comment-w);
  min-width: var(--comment-w);
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--t-mid), min-width var(--t-mid);
}
#ds-right.collapsed {
  width: 44px;
  min-width: 44px;
}

/* Comment Filter Bar */
#ds-comment-filters {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  background: var(--c-surface-2);
}
.ds-filter-row {
  display: flex; gap: 4px; align-items: center;
}
.ds-filter-select {
  flex: 1;
  padding: 4px 7px;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-ui);
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  cursor: pointer;
}
.ds-filter-select:focus { border-color: var(--c-primary-light); }
.ds-comment-count {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-muted);
  margin-left: auto;
}
.ds-comment-count strong { color: var(--c-text); }

/* Comment List */
#ds-comment-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Comment Card */
.ds-comment-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--border-r);
  padding: 10px 12px;
  cursor: pointer;
  transition: all var(--t-fast);
  border-left: 3px solid var(--c-border);
  box-shadow: var(--shadow-sm);
}
.ds-comment-card:hover { box-shadow: var(--shadow-md); transform: translateX(-1px); }
.ds-comment-card.active { border-color: var(--c-primary-light); box-shadow: 0 0 0 2px rgba(59,114,212,0.12); }

.ds-comment-card.crit-critical { border-left-color: var(--c-critical); }
.ds-comment-card.crit-high     { border-left-color: var(--c-high); }
.ds-comment-card.crit-medium   { border-left-color: var(--c-medium); }
.ds-comment-card.crit-low      { border-left-color: var(--c-low); }
.ds-comment-card.crit-info     { border-left-color: var(--c-info); }
.ds-comment-card.status-done   { opacity: 0.55; }
.ds-comment-card.status-rejected { opacity: 0.4; }

.ds-cc-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 5px;
}
.ds-crit-badge {
  display: inline-flex; align-items: center;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ds-crit-badge.critical { background: var(--c-critical-bg); color: var(--c-critical); }
.ds-crit-badge.high     { background: var(--c-high-bg);     color: var(--c-high); }
.ds-crit-badge.medium   { background: var(--c-medium-bg);   color: var(--c-medium); }
.ds-crit-badge.low      { background: var(--c-low-bg);      color: var(--c-low); }
.ds-crit-badge.info     { background: var(--c-info-bg);     color: var(--c-info); }

.ds-cc-tab {
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--c-text-muted);
  padding: 1px 5px;
  background: var(--c-surface-2);
  border-radius: 3px;
}
.ds-cc-page {
  font-size: 9.5px;
  color: var(--c-text-muted);
  margin-left: auto;
  font-family: var(--font-mono);
}

.ds-cc-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 4px;
  line-height: 1.3;
}
.ds-cc-original {
  font-size: 11.5px;
  color: var(--c-text-mid);
  background: var(--c-surface-2);
  border-radius: 4px;
  padding: 4px 7px;
  margin-bottom: 5px;
  font-family: var(--font-mono);
  border-left: 2px solid var(--c-high);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-cc-suggestion {
  font-size: 11.5px;
  color: var(--c-low);
  background: var(--c-low-bg);
  border-radius: 4px;
  padding: 4px 7px;
  margin-bottom: 8px;
  border-left: 2px solid var(--c-low);
  font-family: var(--font-mono);
  line-height: 1.4;
}

/* Comment Actions */
.ds-cc-actions {
  display: flex; align-items: center; gap: 4px;
  flex-wrap: wrap;
}
.ds-cc-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 7px;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  transition: all var(--t-fast);
}
.ds-cc-btn.accept  { background: var(--c-low-bg);   color: var(--c-low);   }
.ds-cc-btn.reject  { background: var(--c-high-bg);  color: var(--c-high);  }
.ds-cc-btn.done    { background: var(--c-info-bg);  color: var(--c-info);  }
.ds-cc-btn.reply   { background: var(--c-border-light); color: var(--c-text-mid); }
.ds-cc-btn.delete  { background: var(--c-critical-bg); color: var(--c-critical); margin-left: auto; }
.ds-cc-btn:hover { filter: brightness(0.92); }
.ds-cc-btn svg { width: 10px; height: 10px; }

/* Empty Comments State */
.ds-comments-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 10px;
  color: var(--c-text-muted);
  text-align: center;
  height: 100%;
}
.ds-comments-empty svg { width: 40px; height: 40px; opacity: 0.3; }
.ds-comments-empty p { font-size: 12px; line-height: 1.5; }

/* ═══════════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════════ */
.ds-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,20,40,0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-mid);
}
.ds-modal-overlay.open { opacity: 1; pointer-events: all; }

.ds-modal {
  background: var(--c-surface);
  border-radius: var(--border-r-lg);
  box-shadow: var(--shadow-pop);
  width: 90vw;
  max-width: 640px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  transform: translateY(16px);
  transition: transform var(--t-mid);
  overflow: hidden;
}
.ds-modal-overlay.open .ds-modal { transform: translateY(0); }

.ds-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border-light);
  flex-shrink: 0;
}
.ds-modal-head h2 {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
}
.ds-modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--c-text-muted);
  transition: all var(--t-fast);
}
.ds-modal-close:hover { background: var(--c-border-light); color: var(--c-text); }
.ds-modal-close svg { width: 16px; height: 16px; }

.ds-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.ds-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--c-border-light);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
  background: var(--c-surface-2);
}

/* AI Mode Cards */
.ds-ai-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.ds-ai-mode-card {
  padding: 12px;
  border: 2px solid var(--c-border);
  border-radius: var(--border-r);
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--c-surface);
}
.ds-ai-mode-card:hover { border-color: var(--c-primary-light); background: var(--c-primary-pale); }
.ds-ai-mode-card.selected {
  border-color: var(--c-primary-light);
  background: var(--c-primary-pale);
  box-shadow: 0 0 0 3px rgba(59,114,212,0.12);
}
.ds-ai-mode-card-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.ds-ai-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ds-ai-mode-card h4 {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text);
}
.ds-ai-mode-card p {
  font-size: 10.5px;
  color: var(--c-text-muted);
  line-height: 1.4;
}
.ds-ai-mode-card .tags {
  display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap;
}
.ds-ai-tag {
  font-size: 9px;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 3px;
}
.ds-ai-tag.free    { background: var(--c-low-bg);    color: var(--c-low); }
.ds-ai-tag.private { background: var(--c-low-bg);    color: var(--c-low); }
.ds-ai-tag.cost    { background: var(--c-medium-bg); color: var(--c-medium); }
.ds-ai-tag.setup   { background: var(--c-info-bg);   color: var(--c-info); }

/* API Key Input */
.ds-field {
  margin-bottom: 12px;
}
.ds-field label {
  display: block;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--c-text-mid);
  margin-bottom: 4px;
}
.ds-field input, .ds-field select, .ds-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--border-r-sm);
  font-size: 12.5px;
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  transition: border-color var(--t-fast);
}
.ds-field input:focus, .ds-field select:focus, .ds-field textarea:focus {
  border-color: var(--c-primary-light);
  box-shadow: 0 0 0 3px rgba(59,114,212,0.08);
}
.ds-field .hint {
  font-size: 10.5px;
  color: var(--c-text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

/* Full buttons */
.ds-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--border-r-sm);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  transition: all var(--t-fast);
}
.ds-btn.primary {
  background: var(--c-primary-light);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,114,212,0.25);
}
.ds-btn.primary:hover { background: var(--c-primary-mid); transform: translateY(-1px); }
.ds-btn.ghost {
  background: transparent;
  color: var(--c-text-mid);
  border: 1px solid var(--c-border);
}
.ds-btn.ghost:hover { background: var(--c-border-light); }
.ds-btn.accent {
  background: var(--c-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(245,166,35,0.25);
}
.ds-btn.accent:hover { background: var(--c-accent-dark); }
.ds-btn svg { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════════════════════════
   TEMPLATE CHECK TAB SPECIFICS
═══════════════════════════════════════════════════════════════ */
.ds-template-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  height: 100%;
  overflow-y: auto;
}
.ds-template-card {
  background: var(--c-surface);
  border-radius: var(--border-r);
  border: 2px dashed var(--c-border);
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--t-mid);
  min-height: 180px;
  justify-content: center;
}
.ds-template-card:hover, .ds-template-card.loaded {
  border-style: solid;
  border-color: var(--c-primary-light);
  background: var(--c-primary-pale);
}
.ds-template-card svg { width: 32px; height: 32px; color: var(--c-text-muted); }
.ds-template-card h4 {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text);
}
.ds-template-card p {
  font-size: 11px;
  color: var(--c-text-muted);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════
   SUMMARY TAB
═══════════════════════════════════════════════════════════════ */
.ds-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
}
.ds-stat-card {
  background: var(--c-surface);
  border-radius: var(--border-r);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border-light);
  text-align: center;
}
.ds-stat-card .num {
  font-family: var(--font-ui);
  font-size: 28px;
  font-weight: 800;
  color: var(--c-primary);
  display: block;
}
.ds-stat-card .lbl {
  font-size: 11px;
  color: var(--c-text-muted);
  font-family: var(--font-ui);
  letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════════════════════
   STATUS BAR (bottom)
═══════════════════════════════════════════════════════════════ */
#ds-status-bar {
  height: 24px;
  background: var(--c-primary);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 16px;
  flex-shrink: 0;
}
.ds-status-item {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,0.55);
}
.ds-status-item .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.ds-status-item .dot.green { background: #4ade80; box-shadow: 0 0 4px #4ade80; }
.ds-status-item .dot.yellow { background: var(--c-accent); }

/* ═══════════════════════════════════════════════════════════════
   UTILITY
═══════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Notification Toast */
.ds-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--c-text);
  color: #fff;
  padding: 9px 18px;
  border-radius: 20px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  pointer-events: none;
}
.ds-toast.show { transform: translateX(-50%) translateY(0); }
.ds-toast.success { background: var(--c-low); }
.ds-toast.error   { background: var(--c-critical); }
.ds-toast.warning { background: var(--c-medium); color: #fff; }

/* Responsive */
@media (max-width: 900px) {
  #ds-left  { display: none; }
  #ds-right { width: 280px; min-width: 280px; }
}
@media (max-width: 640px) {
  #ds-right { display: none; }
  .ds-summary-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   DOCUMENT VIEWER — Phase 2 Additions
═══════════════════════════════════════════════════════════════ */

/* Info bar above document */
.ds-doc-info-bar {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--c-primary-pale);
  border-radius: var(--border-r-sm);
  border: 1px solid rgba(59,114,212,0.15);
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.ds-doc-info-bar .doc-name {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-primary);
  flex: 1;
  min-width: 100px;
}
.ds-doc-info-bar .doc-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--c-text-muted);
  padding: 2px 7px;
  background: var(--c-surface);
  border-radius: 3px;
  border: 1px solid var(--c-border-light);
}
.ds-doc-info-bar .doc-warning {
  font-size: 10.5px;
  color: var(--c-medium);
  cursor: help;
}

/* Action bar above document pages */
.ds-doc-action-bar {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--c-low-bg);
  border-radius: var(--border-r-sm);
  border: 1px solid rgba(39,174,96,0.2);
  margin-bottom: 8px;
  gap: 10px;
  flex-wrap: wrap;
}

/* Rendered document content */
.ds-rendered-content {
  font-family: 'Instrument Sans', Georgia, serif;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--c-text);
}
.ds-rendered-content h1 { font-size: 22px; font-weight: 700; margin: 20px 0 10px; color: var(--c-primary); line-height: 1.3; font-family: var(--font-ui); }
.ds-rendered-content h2 { font-size: 18px; font-weight: 700; margin: 16px 0 8px;  color: var(--c-primary); line-height: 1.3; font-family: var(--font-ui); }
.ds-rendered-content h3 { font-size: 15px; font-weight: 600; margin: 14px 0 6px;  color: var(--c-text); font-family: var(--font-ui); }
.ds-rendered-content h4 { font-size: 13.5px; font-weight: 600; margin: 10px 0 4px; color: var(--c-text); font-family: var(--font-ui); }
.ds-rendered-content p  { margin: 0 0 10px; }
.ds-rendered-content li { margin: 3px 0 3px 20px; list-style-type: disc; }
.ds-rendered-content table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 12.5px; }
.ds-rendered-content td, .ds-rendered-content th { border: 1px solid var(--c-border); padding: 6px 10px; }
.ds-rendered-content th { background: var(--c-surface-2); font-weight: 600; }
.ds-rendered-content strong { font-weight: 700; }
.ds-rendered-content em { font-style: italic; }
.ds-rendered-content blockquote { border-left: 3px solid var(--c-primary-light); padding: 8px 14px; margin: 10px 0; background: var(--c-primary-pale); border-radius: 0 4px 4px 0; font-style: italic; }
.ds-rendered-content a { color: var(--c-primary-light); }

/* Paragraph wrapper */
.ds-para-wrap {
  position: relative;
  border-radius: 3px;
  transition: background var(--t-fast);
}
.ds-para-wrap:hover { background: rgba(59,114,212,0.03); }

/* Navigation highlight states */
.ds-para-wrap.nav-active { background: rgba(245,166,35,0.12) !important; }
.ds-para-wrap.nav-crit-critical { background: rgba(192,57,43,0.10) !important; }
.ds-para-wrap.nav-crit-high     { background: rgba(231,76,60,0.10) !important; }
.ds-para-wrap.nav-crit-medium   { background: rgba(230,126,34,0.10) !important; }
.ds-para-wrap.nav-crit-low      { background: rgba(39,174,96,0.10) !important; }

/* Nav pulse — flashes the existing mark when navigating from comment card */
@keyframes ds-nav-pulse {
  0%   { outline: 2px solid transparent; }
  25%  { outline: 3px solid #F5A623; }
  75%  { outline: 3px solid #F5A623; }
  100% { outline: 2px solid transparent; }
}
mark.ds-highlight.nav-pulse { animation: ds-nav-pulse 1.5s ease-out forwards; }

/* Issue dot (para-level indicator) */
.ds-issue-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  cursor: pointer;
  flex-shrink: 0;
}
.ds-issue-dot.crit-critical { background: var(--c-critical); }
.ds-issue-dot.crit-high     { background: var(--c-high); }
.ds-issue-dot.crit-medium   { background: var(--c-medium); }
.ds-issue-dot.crit-low      { background: var(--c-low); }

/* Slide content */
.ds-slide-content { min-height: 200px; }
.ds-slide-divider {
  text-align: center;
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--c-text-muted);
  border-top: 1px solid var(--c-border-light);
  margin: 6px 0;
  letter-spacing: 1px;
}

/* Para-level fallback highlight classes */
.ds-para-highlight-critical { background: var(--c-critical-bg) !important; }
.ds-para-highlight-high     { background: var(--c-high-bg)     !important; }
.ds-para-highlight-medium   { background: var(--c-medium-bg)   !important; }
.ds-para-highlight-low      { background: var(--c-low-bg)      !important; }

/* doc.title and subtitle classes from mammoth */
.ds-rendered-content h1.doc-title { font-size: 26px; text-align: center; margin-bottom: 6px; }
.ds-rendered-content p.doc-subtitle { text-align: center; color: var(--c-text-muted); font-size: 14px; margin-bottom: 20px; }

/* ═══════════════════════════════════════════════════════════════
   GUIDELINE REVIEW MODAL — Phase 4
═══════════════════════════════════════════════════════════════ */
.ds-rule-review-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--c-border-light);
  transition: background var(--t-fast);
}
.ds-rule-review-row:last-child { border-bottom: none; }
.ds-rule-review-row:hover { background: var(--c-surface-2); }

.ds-rule-review-check {
  display: flex;
  align-items: center;
  padding-top: 2px;
  flex-shrink: 0;
}
.ds-rule-review-check input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--c-primary-light);
  cursor: pointer;
}
.ds-rule-review-body {
  flex: 1;
  min-width: 0;
}
.ds-rule-review-text {
  font-size: 12.5px;
  color: var(--c-text);
  line-height: 1.5;
  margin-bottom: 4px;
}
.ds-rule-review-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.ds-rule-cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.ds-rule-review-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   PHASE 6 — Enhanced Comment Panel
═══════════════════════════════════════════════════════════════ */

/* Search input */
.ds-comment-search {
  width: 100%;
  padding: 5px 9px 5px 28px;
  border: 1px solid var(--c-border);
  border-radius: var(--border-r-sm);
  font-size: 11.5px;
  font-family: var(--font-ui);
  color: var(--c-text);
  background: var(--c-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='%238896A8' stroke-width='1.8'%3E%3Ccircle cx='5.5' cy='5.5' r='3.5'/%3E%3Cpath d='M8.5 8.5l2.5 2.5'/%3E%3C/svg%3E") no-repeat 8px center;
  background-size: 14px 14px;
  outline: none;
  transition: border-color var(--t-fast);
}
.ds-comment-search:focus { border-color: var(--c-primary-light); box-shadow: 0 0 0 2px rgba(59,114,212,0.08); }

/* Stats bar */
.ds-comment-stats {
  margin-bottom: 6px;
  padding: 0 2px;
}
.ds-stats-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}
.ds-stat-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
}
.ds-stat-chip.total    { background: var(--c-border-light);  color: var(--c-text-mid); }
.ds-stat-chip.open     { background: var(--c-info-bg);        color: var(--c-info); }
.ds-stat-chip.crit     { background: var(--c-high-bg);        color: var(--c-high); }
.ds-stat-chip.ai       { background: rgba(124,58,237,0.10);   color: #7C3AED; }
.ds-stat-chip.resolved { background: var(--c-low-bg);         color: var(--c-low); }

.ds-stats-progress {
  height: 3px;
  background: var(--c-border-light);
  border-radius: 10px;
  overflow: hidden;
}
.ds-stats-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--c-primary-light), var(--c-low));
  border-radius: 10px;
  transition: width 0.5s ease;
}

/* Expand button + detected badge */
.ds-cc-expand-btn {
  margin-left: auto;
  font-size: 9px;
  color: var(--c-text-muted);
  padding: 1px 4px;
  background: var(--c-border-light);
  border-radius: 3px;
  transition: all var(--t-fast);
  cursor: pointer;
  border: none;
}
.ds-cc-expand-btn:hover { background: var(--c-border); color: var(--c-text); }

.ds-cc-detected {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--c-text-muted);
  padding: 1px 5px;
  background: rgba(124,58,237,0.08);
  color: #7C3AED;
  border-radius: 3px;
}

.ds-cc-select {
  width: 13px; height: 13px;
  accent-color: var(--c-primary-light);
  cursor: pointer;
  flex-shrink: 0;
}

/* Expanded card detail section */
.ds-cc-detail {
  background: var(--c-surface-2);
  border-radius: var(--border-r-sm);
  padding: 8px 10px;
  margin: 6px 0;
  border: 1px solid var(--c-border-light);
}
.ds-cc-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 5px;
  font-size: 11px;
  line-height: 1.5;
}
.ds-cc-detail-row:last-child { margin-bottom: 0; }
.ds-cc-detail-lbl {
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-text-muted);
  min-width: 44px;
  padding-top: 1px;
  flex-shrink: 0;
}
.ds-cc-fix-code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--c-low-bg);
  color: var(--c-low);
  padding: 2px 6px;
  border-radius: 3px;
  word-break: break-word;
}
.ds-cc-copy-btn {
  font-size: 13px;
  color: var(--c-text-muted);
  padding: 1px 3px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--t-fast);
}
.ds-cc-copy-btn:hover { color: var(--c-primary-light); }

/* Multiple spelling suggestion chips (like MS Word right-click) */
.ds-cc-spell-options { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.ds-cc-spell-chip {
  background: var(--c-bg-subtle, #f0f4f8);
  border: 1px solid var(--c-border-light);
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--c-text);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.ds-cc-spell-chip:hover {
  background: var(--c-primary-light, #dbeafe);
  border-color: var(--c-primary, #3b82f6);
  color: var(--c-primary, #3b82f6);
}
.ds-cc-spell-chip.primary {
  background: var(--c-primary-light, #dbeafe);
  border-color: var(--c-primary, #3b82f6);
  color: var(--c-primary, #3b82f6);
  font-weight: 600;
}
.ds-cc-spell-chip.primary:hover { background: var(--c-primary, #3b82f6); color: #fff; }

/* Dictionary word tags in sidebar panel */
.dict-tag { display:inline-flex; align-items:center; gap:3px; background:var(--c-primary-pale); color:var(--c-primary); border:1px solid var(--c-primary-light,#c5d5ff); border-radius:4px; padding:2px 6px; font-size:11px; font-family:var(--font-ui); margin:2px; }
.dict-tag button { background:none; border:none; cursor:pointer; color:var(--c-text-muted); font-size:11px; padding:0 1px; line-height:1; }
.dict-tag button:hover { color:var(--c-danger); }

/* Rule engine capability badges */
.ds-engine-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ds-engine-badge.script { background: #e8f5e9; color: #2e7d32; }
.ds-engine-badge.lt     { background: #e3f2fd; color: #1565c0; }
.ds-engine-badge.ai     { background: #fff3e0; color: #e65100; }

/* Status label (for non-open issues) */
.ds-cc-status-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.ds-cc-status-label.status-accepted { background: var(--c-low-bg);  color: var(--c-low); }
.ds-cc-status-label.status-rejected { background: var(--c-high-bg); color: var(--c-high); }
.ds-cc-status-label.status-done     { background: var(--c-info-bg); color: var(--c-info); }
.ds-cc-status-label.status-deferred { background: var(--c-border-light); color: var(--c-text-muted); }

/* Reply thread */
.ds-cc-replies {
  margin-top: 6px;
  border-top: 1px solid var(--c-border-light);
  padding-top: 6px;
}
.ds-cc-replies-list { margin-bottom: 6px; }
.ds-reply-row {
  padding: 5px 0;
  border-bottom: 1px solid var(--c-border-light);
}
.ds-reply-row:last-child { border-bottom: none; }
.ds-reply-author {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  color: var(--c-text-mid);
  margin-bottom: 2px;
}
.ds-reply-ts {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--c-text-muted);
  font-weight: 400;
}
.ds-reply-text {
  font-size: 11.5px;
  color: var(--c-text);
  line-height: 1.5;
}
.ds-reply-input-wrap { margin-top: 4px; }
.ds-reply-textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--border-r-sm);
  font-size: 11.5px;
  font-family: var(--font-body);
  color: var(--c-text);
  resize: none;
  outline: none;
  background: var(--c-surface);
  transition: border-color var(--t-fast);
}
.ds-reply-textarea:focus { border-color: var(--c-primary-light); }

/* Expanded card state */
.ds-comment-card.expanded {
  border-left-width: 4px;
  box-shadow: var(--shadow-md);
}
.ds-comment-card.selected {
  outline: 2px solid var(--c-primary-light);
  outline-offset: 1px;
}

/* Select mode toggle active state */
#btn-select-mode.active {
  background: var(--c-primary-pale);
  color: var(--c-primary-light);
  border-color: var(--c-primary-light);
}

/* ═══════════════════════════════════════════════════════════════
   SETUP MANAGER MODAL — Phase 6 addition
═══════════════════════════════════════════════════════════════ */
.ds-setup-body { padding: 0 !important; }

.ds-setup-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border-light);
}
.ds-setup-section:last-child { border-bottom: none; }

.ds-setup-section-head {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 10px;
  letter-spacing: 0.2px;
}
.ds-setup-collapsible { cursor: pointer; user-select: none; }
.ds-setup-collapsible:hover { color: var(--c-primary-light); }

.ds-setup-option {
  padding: 10px 12px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--border-r-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--c-surface);
}
.ds-setup-option:hover { border-color: var(--c-primary-light); background: var(--c-primary-pale); }
.ds-setup-option.active { border-color: var(--c-primary-light); background: var(--c-primary-pale); box-shadow: 0 0 0 3px rgba(59,114,212,0.08); }

.ds-setup-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--c-border-light);
}
.ds-setup-status-row:last-child { border-bottom: none; }
.ds-setup-status-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--c-text);
}

.ds-status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ds-status-dot.green { background: var(--c-low);  box-shadow: 0 0 4px var(--c-low); }
.ds-status-dot.red   { background: var(--c-high); }
.ds-status-dot.grey  { background: var(--c-text-muted); }
.ds-status-dot.yellow{ background: var(--c-accent); }

/* Setup guide steps */
.ds-setup-step {
  display: flex; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--c-border-light);
  align-items: flex-start;
}
.ds-setup-step:last-child { border-bottom: none; }
.ds-step-num {
  width: 22px; height: 22px;
  background: var(--c-primary-light);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  flex-shrink: 0; margin-top: 1px;
}

/* Code block (copyable command) */
.ds-code-block {
  background: #1E293B;
  color: #94A3B8;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 8px 12px;
  border-radius: var(--border-r-sm);
  cursor: pointer;
  position: relative;
  margin: 6px 0;
  word-break: break-all;
  line-height: 1.5;
  flex: 1;
}
.ds-code-block.small { font-size: 10px; padding: 5px 8px; }
.ds-code-block:hover { background: #0F172A; }
.ds-copy-hint {
  position: absolute; top: 4px; right: 6px;
  font-size: 9px; color: rgba(148,163,184,0.6);
  font-family: var(--font-ui);
}

/* Model cards */
.ds-model-card {
  border: 1px solid var(--c-border);
  border-radius: var(--border-r-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--c-surface);
  position: relative;
  transition: all var(--t-fast);
}
.ds-model-card.installed { border-color: var(--c-low); background: var(--c-low-bg); }
.ds-model-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ds-model-card-name { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--c-text); }
.ds-model-card-desc { font-size: 11px; color: var(--c-text-muted); line-height: 1.4; margin-bottom: 6px; }
.ds-model-card-row  { display: flex; align-items: center; gap: 6px; }
.ds-model-spec { font-family: var(--font-mono); font-size: 9.5px; padding: 1px 6px; background: var(--c-border-light); color: var(--c-text-muted); border-radius: 3px; }
.ds-model-spec.speed { background: var(--c-info-bg); color: var(--c-info); }
.ds-recommended { font-size: 9px; background: var(--c-accent); color: #fff; padding: 1px 5px; border-radius: 3px; margin-left: 5px; font-family: var(--font-ui); font-weight: 700; }
.ds-installed-badge { position: absolute; top: 8px; right: 8px; font-size: 9.5px; color: var(--c-low); font-family: var(--font-ui); font-weight: 700; }

/* Model row (installed list) */
.ds-model-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--c-border-light); }
.ds-model-row:last-child { border-bottom: none; }
.ds-model-name { font-family: var(--font-mono); font-size: 11.5px; color: var(--c-text); flex: 1; }
.ds-model-size { font-family: var(--font-mono); font-size: 10.5px; color: var(--c-text-muted); }

/* ═══════════════════════════════════════════════════════════════
   PHASE 8 — Export + Summary Tab
═══════════════════════════════════════════════════════════════ */

/* Summary grid — 3 equal stat cards */
.ds-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.ds-stat-card {
  background: var(--c-surface);
  border-radius: var(--border-r);
  padding: 14px 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border-light);
  text-align: center;
}
.ds-stat-card .num {
  font-family: var(--font-ui);
  font-size: 26px;
  font-weight: 800;
  color: var(--c-primary);
  display: block;
  line-height: 1;
  margin-bottom: 4px;
}
.ds-stat-card .lbl {
  font-size: 10.5px;
  color: var(--c-text-muted);
  font-family: var(--font-ui);
  letter-spacing: 0.3px;
}

/* Score ring container */
#ds-score-ring {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Print styles for summary report */
@media print {
  #ds-header, #ds-left, #ds-right, #ds-tab-bar,
  #ds-status-bar, .ds-modal-overlay { display: none !important; }
  #ds-center { overflow: visible; }
  body { overflow: auto; }
}

/* ═══════════════════════════════════════════════════════════════
   PHASE — Bug fixes + features
═══════════════════════════════════════════════════════════════ */

/* Rules view/edit rows */
.ds-rule-view-row {
  display: flex;
  flex-direction: column;
  padding: 7px 0;
  border-bottom: 1px solid var(--c-border-light);
}
.ds-rule-view-row:last-child { border-bottom: none; }
.ds-rule-view-row:hover { background: var(--c-surface-2); }

/* Panel expand hints (shown when panel is collapsed) */
#left-expand-hint,
#right-expand-hint {
  cursor: pointer;
  background: var(--c-surface);
  transition: background var(--t-fast);
}
#left-expand-hint:hover,
#right-expand-hint:hover { background: var(--c-primary-pale); }

/* Grammar mode radio buttons in AI modal */
input[name="grammar-mode-select"] {
  accent-color: var(--c-primary-light);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   GRAMMARLY-STYLE HIGHLIGHTS + HOVER POPUP
═══════════════════════════════════════════════════════════════ */
mark.ds-highlight {
  background:    transparent;
  border-bottom: 2.5px solid;
  border-radius: 0;
  padding:       0 0 1px 0;
  cursor:        pointer;
  position:      relative;
  transition:    background var(--t-fast);
}
mark.ds-highlight:hover { background: rgba(0,0,0,0.04); }
mark.ds-highlight.critical { border-color: var(--c-critical); border-style: solid; }
mark.ds-highlight.high     { border-color: var(--c-high);     border-style: solid; }
mark.ds-highlight.medium   { border-color: var(--c-medium);   border-style: wavy; }
mark.ds-highlight.low      { border-color: var(--c-low);      border-style: dotted; }
mark.ds-highlight.info     { border-color: var(--c-info);     border-style: dotted; }

/* ── Right-click Context Menu ───────────────────────────────── */
.ds-ctx-menu {
  position: absolute;
  z-index: 100001;
  background: var(--c-bg-panel, #fff);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  padding: 4px 0;
  min-width: 178px;
  font-family: var(--font-ui);
  font-size: 13px;
}
.ds-ctx-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--c-text);
  transition: background var(--t-fast);
  white-space: nowrap;
}
.ds-ctx-item:hover { background: var(--c-bg-hover, #f1f5f9); }
.ds-ctx-icon { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }
.ds-ctx-divider { border-top: 1px solid var(--c-border-light); margin: 3px 0; }

/* ── AI Rephrase Results Panel ──────────────────────────────── */
.ds-rephrase-panel {
  position: absolute;
  z-index: 100000;
  background: var(--c-bg-panel, #fff);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  box-shadow: 0 6px 30px rgba(0,0,0,.2);
  font-family: var(--font-ui);
  font-size: 13px;
  max-width: 400px;
  animation: fadeInDown .15s ease;
}
.ds-rp-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--c-border-light);
  font-weight: 600; font-size: 12.5px; color: var(--c-text);
}
.ds-rp-close {
  background: none; border: none; cursor: pointer;
  color: var(--c-text-muted); font-size: 14px; padding: 0 2px;
  transition: color var(--t-fast);
}
.ds-rp-close:hover { color: var(--c-critical); }
.ds-rp-original {
  padding: 6px 12px; font-size: 11px; color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border-light); font-style: normal;
}
.ds-rp-original em { font-style: italic; color: var(--c-text); }
.ds-rp-label { padding: 7px 12px 3px; font-size: 11px; font-weight: 600; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ds-rp-option {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border-light);
  transition: background var(--t-fast);
}
.ds-rp-option:last-of-type { border-bottom: none; }
.ds-rp-option:hover { background: var(--c-bg-hover, #f8fafc); }
.ds-rp-opt-text { font-size: 13px; color: var(--c-text); line-height: 1.5; margin-bottom: 5px; }
.ds-rp-opt-actions { display: flex; gap: 6px; }
.ds-rp-apply {
  background: var(--c-primary, #3b82f6); color: #fff;
  border: none; border-radius: 4px; padding: 3px 10px;
  font-size: 11.5px; cursor: pointer; transition: background var(--t-fast);
}
.ds-rp-apply:hover { background: var(--c-primary-dark, #2563eb); }
.ds-rp-copy {
  background: none; border: 1px solid var(--c-border); border-radius: 4px; padding: 3px 10px;
  font-size: 11.5px; cursor: pointer; color: var(--c-text-muted); transition: background var(--t-fast);
}
.ds-rp-copy:hover { background: var(--c-bg-hover); }
.ds-rp-loading { padding: 16px 12px; color: var(--c-text-muted); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.ds-rp-error { padding: 12px; color: var(--c-critical); font-size: 12.5px; }
.ds-rp-footer { padding: 6px 12px; font-size: 10.5px; color: var(--c-text-muted); border-top: 1px solid var(--c-border-light); }
.ds-rp-footer a { color: var(--c-primary); text-decoration: none; }
.ds-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--c-border-light); border-top-color: var(--c-primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes fadeInDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Grammarly-style Hover Popup ───────────────────────────── */
#ds-hover-popup {
  position:       absolute;
  z-index:        99999;
  background:     var(--c-surface);
  border:         1px solid var(--c-border);
  border-radius:  var(--border-r);
  box-shadow:     0 6px 28px rgba(0,0,0,0.18);
  padding:        10px 12px;
  max-width:      320px;
  min-width:      200px;
  font-family:    var(--font-ui);
  pointer-events: all;
  animation:      dsp-fadein 0.12s ease;
}
@keyframes dsp-fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Top bar: dot + criticality + title + close */
.dsp-bar {
  display: flex; align-items: center; gap: 5px;
  margin-bottom: 7px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--c-border-light);
}
.dsp-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.dsp-crit-label {
  font-size: 10px; font-weight: 700; color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.4px; flex-shrink: 0;
}
.dsp-title-inline {
  font-size: 12px; font-weight: 600; color: var(--c-text);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dsp-close-btn {
  margin-left: 4px; font-size: 11px; color: var(--c-text-muted);
  background: none; border: none; cursor: pointer; padding: 1px 4px;
  border-radius: 3px; flex-shrink: 0; line-height: 1;
}
.dsp-close-btn:hover { background: var(--c-border-light); color: var(--c-text); }
/* Suggested fix row */
/* Inline diff row — orig → fix (Grammarly style) */
.dsp-diff-row {
  display: flex; align-items: center; gap: 7px; margin-bottom: 8px;
  background: #f0fdf4; border-radius: 5px; padding: 6px 8px;
  border: 1px solid #d1fae5;
}
.dsp-diff-orig {
  font-size: 12px; font-family: var(--font-mono); color: var(--c-critical);
  text-decoration: line-through; opacity: 0.75;
}
.dsp-diff-arrow {
  font-size: 13px; color: #059669; font-weight: 700; flex-shrink: 0;
}
.dsp-diff-fix {
  font-size: 12px; font-family: var(--font-mono); color: #059669; font-weight: 600;
}
/* Reason row */
.dsp-reason-row {
  font-size: 11px; color: var(--c-text-muted); margin-bottom: 7px;
  line-height: 1.4; padding: 0 1px;
}
.dsp-fix-row {
  display: flex; align-items: flex-start; gap: 6px; margin-bottom: 8px;
  background: #f0fdf4; border-radius: 5px; padding: 5px 8px;
  border: 1px solid #d1fae5;
}
.dsp-fix-label {
  font-size: 10px; font-weight: 700; color: #059669; flex-shrink: 0; margin-top: 1px;
}
.dsp-fix-text {
  font-size: 11.5px; color: var(--c-text); font-family: var(--font-mono);
  word-break: break-word;
}
/* Action buttons row */
.dsp-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.dsp-act-btn {
  font-size: 11px; font-family: var(--font-ui); font-weight: 600;
  padding: 4px 10px; border-radius: 5px; cursor: pointer; border: none;
  transition: all var(--t-fast); line-height: 1.3;
}
.dsp-accept  { background: var(--c-primary-light); color: #fff; }
.dsp-accept:hover { background: var(--c-primary-mid); }
.dsp-dict    { background: var(--c-info-bg); color: var(--c-info); border: 1px solid #bfdbfe; }
.dsp-dict:hover { background: #dbeafe; }
.dsp-view    { background: var(--c-surface-2); color: var(--c-text-mid); border: 1px solid var(--c-border); }
.dsp-view:hover { background: var(--c-primary-pale); color: var(--c-primary); }
.dsp-ignore  { background: none; color: var(--c-text-muted); border: 1px solid var(--c-border-light); }
.dsp-ignore:hover { background: var(--c-border-light); color: var(--c-text); }
/* Legacy class aliases kept for backward compat */
.dsp-head, .dsp-crit, .dsp-tab, .dsp-close, .dsp-title, .dsp-desc, .dsp-btn { }

/* ═══════════════════════════════════════════════════════════════
   TAB DOC VIEWERS (Style / Guidelines / Theory)
═══════════════════════════════════════════════════════════════ */

/* Outer wrapper — fills the panel, flexes column */
.ds-tab-doc-viewer-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Hero centering when showing upload prompt */
  align-items: center;
  justify-content: center;
}
/* When showing actual document, stop centering */
.ds-tab-doc-viewer-wrap.has-doc {
  align-items: stretch;
  justify-content: flex-start;
}

/* Inner doc viewer — same layout as #ds-doc-viewer in Grammar tab */
.ds-tab-doc-viewer-inner {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
/* Document page container inside inner viewer */
.ds-tab-doc-viewer-inner .ds-doc-page,
.ds-tab-doc-viewer-inner > * {
  max-width: 800px;
  width: 100%;
}

/* Tab filter banner — shown inside Grammar doc viewer when a doc-view tab is active */
.ds-tab-filter-banner {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border-light);
  border-radius: var(--border-r-sm);
  font-size: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Legacy class kept for backwards compat (no longer used for main layout) */
.ds-tab-doc-viewer {
  border: 1px solid var(--c-border-light);
  border-radius: var(--border-r-sm);
  max-height: 420px;
  overflow-y: auto;
  padding: 12px 16px;
  margin-bottom: 14px;
  background: var(--c-surface);
  font-size: 13px;
  line-height: 1.7;
}
/* When used as hero/upload area, allow it to fill available panel height */
.ds-tab-doc-viewer.ds-tab-hero-wrap {
  max-height: none;
  flex: 1;
}
.ds-tab-doc-viewer p,
.ds-tab-doc-viewer li { margin-bottom: 4px; }

/* ═══════════════════════════════════════════════════════════════
   TEMPLATE SIDE-BY-SIDE
═══════════════════════════════════════════════════════════════ */
#template-split-view {
  display: grid;
  grid-template-columns: 1fr 6px 1fr;
  height: calc(100vh - 130px);
  overflow: hidden;
}
.ds-split-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--c-surface);
}
.ds-split-pane.minimized { max-width: 44px; overflow: hidden; }
.ds-split-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border-light);
  flex-shrink: 0;
}
.ds-split-pane-title {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c-text);
}
.ds-split-pane-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  font-size: 13px;
  line-height: 1.7;
}
.ds-split-resize-handle {
  background: var(--c-border);
  cursor: col-resize;
  width: 6px;
  flex-shrink: 0;
  position: relative;
  transition: background var(--t-fast);
}
.ds-split-resize-handle:hover { background: var(--c-primary-light); }
.ds-split-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 40px;
  background: rgba(255,255,255,0.4);
  border-radius: 2px;
}
.ds-split-ctrl {
  font-size: 10.5px;
  padding: 1px 6px;
  background: var(--c-border-light);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 700;
}
.ds-split-ctrl:hover { background: var(--c-border); color: var(--c-text); }

/* ═══════════════════════════════════════════════════════════════
   SUGGESTIONS TAB
═══════════════════════════════════════════════════════════════ */
.ds-suggestion-card {
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--border-r-sm);
  margin-bottom: 8px;
  background: var(--c-surface);
  transition: box-shadow var(--t-fast);
}
.ds-suggestion-card:hover { box-shadow: var(--shadow-sm); }
.ds-sug-head  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ds-sug-name  { font-family: var(--font-ui); font-size: 12.5px; font-weight: 700; color: var(--c-text); }
.ds-sug-status{ font-size: 9.5px; padding: 1px 6px; border-radius: 10px; font-family: var(--font-mono); font-weight: 700; }
.ds-sug-cat   { font-size: 10.5px; color: var(--c-text-muted); margin-bottom: 3px; font-family: var(--font-mono); }
.ds-sug-desc  { font-size: 11.5px; color: var(--c-text-mid); line-height: 1.4; margin-bottom: 5px; }
.ds-sug-ref   { font-size: 10.5px; color: var(--c-primary-light); text-decoration: none; }
.ds-sug-ref:hover { text-decoration: underline; }
.ds-sug-date  { font-size: 10px; color: var(--c-text-muted); margin-top: 4px; font-family: var(--font-mono); }
.ds-sug-note  { font-size: 11px; color: var(--c-info); margin-top: 4px; background: var(--c-info-bg); padding: 4px 8px; border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════════
   BUG FIX UPDATE — Accepted changes, bullet badge, popup
═══════════════════════════════════════════════════════════════ */

/* Accepted change — green underline, visible for 4s then fades */
.ds-accepted-change {
  background: var(--c-low-bg, #f0fdf4);
  border-bottom: 2px solid var(--c-low);
  border-radius: 2px;
  padding: 0 1px;
  cursor: default;
  transition: background 1s ease, border-color 1s ease;
}
.ds-accepted-change.faded {
  background: transparent;
  border-bottom-color: transparent;
}

/* Bullet item badge in comment card */
.ds-cc-from-bullet {
  font-size: 8.5px;
  background: #EFF6FF;
  color: #3B72D4;
  padding: 1px 4px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Hover popup — ensure it NEVER appears inside document
   by using high z-index and pointer-events */
#ds-hover-popup {
  z-index: 99999 !important;
  /* Ensure stacking context is broken */
  isolation: isolate;
}

/* Fix: prevent document content area from creating stacking context
   that could trap position:fixed children */
#doc-content-area,
#ds-doc-viewer,
.ds-split-pane-content,
.ds-tab-doc-viewer,
.ds-tab-doc-viewer-wrap,
.ds-tab-doc-viewer-inner {
  transform: none !important;
  will-change: auto !important;
}

/* Theory tab — same layout as grammar tab (no special placeholder) */
#panel-theory .ds-run-check-hint,
#panel-style .ds-run-check-hint,
#panel-guidelines .ds-run-check-hint {
  display: none; /* hidden after check runs via JS */
}

/* Undo button styling */
.ds-cc-btn.undo {
  background: var(--c-medium-bg);
  color: var(--c-medium);
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════
   UNDO / REDO BUTTONS + POPUP POSITION FIX
═══════════════════════════════════════════════════════════════ */
#btn-undo, #btn-redo {
  font-size: 16px;
  font-weight: 700;
  transition: all var(--t-fast);
}
#btn-undo:disabled, #btn-redo:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
#btn-undo:not(:disabled):hover { color: var(--c-primary-light); }
#btn-redo:not(:disabled):hover { color: var(--c-primary-light); }

/* Hover popup: use absolute to avoid CSS transform trapping */
#ds-hover-popup {
  position: absolute !important;
  z-index: 99999 !important;
}
/* Prevent any parent from creating stacking context that traps the popup */
#ds-doc-viewer, #doc-content-area,
.ds-tab-panel, .ds-split-pane-content,
.ds-tab-doc-viewer-wrap, .ds-tab-doc-viewer-inner {
  transform: none !important;
  filter: none !important;
  perspective: none !important;
  will-change: auto !important;
  isolation: auto !important;
}
