/* ==========================================================================
   MD to PDF Converter - Modern Design System & Print Styles
   100% Client-Side Local Processing
   ========================================================================== */

/* Google Fonts Import (한글 폰트 지원: Pretendard, Noto Sans/Serif KR, JetBrains Mono) */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Nanum+Myeongjo:wght@400;700&family=Noto+Sans+KR:wght@300;400;500;700&family=Noto+Serif+KR:wght@400;600;700&display=swap');

:root {
  /* UI Theme Colors (App Shell) */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --surface-glass: rgba(30, 41, 59, 0.75);
  --surface-border: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-primary: #38bdf8;
  --accent-hover: #0284c7;
  --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  /* Document Preview Canvas Default */
  --canvas-bg: #475569;
  --sheet-bg: #ffffff;
  --sheet-text: #1e293b;
  --sheet-border: rgba(0, 0, 0, 0.12);
  --sheet-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.4), 0 0 1px 1px rgba(0, 0, 0, 0.05);

  /* User Customizable Document Styling Variables */
  --doc-font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  --doc-font-size: 15px;
  --doc-line-height: 1.7;
  --doc-heading-color: #0f172a;
  --doc-text-color: #334155;
  --doc-code-font: 'Fira Code', Consolas, Monaco, monospace;
  --doc-code-bg: #f1f5f9;
  --doc-code-color: #0f172a;
  --doc-border-color: #e2e8f0;
  --doc-quote-border: #38bdf8;
  --doc-quote-bg: #f8fafc;
  --doc-link-color: #0284c7;
  --doc-table-stripe: #f8fafc;
  --doc-page-padding: 20mm;

  /* Layout Constants */
  --sidebar-width: 320px;
  --header-height: 64px;
  --status-height: 36px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* Light Mode Overrides for UI Shell */
body.light-ui {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e2e8f0;
  --surface-glass: rgba(255, 255, 255, 0.85);
  --surface-border: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --canvas-bg: #cbd5e1;
}

/* Document Themes */
.theme-clean-white {
  --sheet-bg: #ffffff;
  --sheet-text: #2d3748;
  --doc-heading-color: #1a202c;
  --doc-text-color: #2d3748;
  --doc-code-bg: #f7fafc;
  --doc-border-color: #e2e8f0;
  --doc-quote-border: #3182ce;
  --doc-quote-bg: #ebf8ff;
  --doc-link-color: #3182ce;
  --doc-table-stripe: #f7fafc;
}

.theme-warm-book {
  --sheet-bg: #fdfbf7;
  --sheet-text: #3d352e;
  --doc-heading-color: #2b241e;
  --doc-text-color: #3d352e;
  --doc-code-bg: #f4efe6;
  --doc-border-color: #e7dfd1;
  --doc-quote-border: #b78a53;
  --doc-quote-bg: #fbf7ee;
  --doc-link-color: #a06b2e;
  --doc-table-stripe: #f8f4ec;
}

.theme-academic-serif {
  --sheet-bg: #ffffff;
  --sheet-text: #111827;
  --doc-heading-color: #000000;
  --doc-text-color: #111827;
  --doc-code-bg: #f3f4f6;
  --doc-border-color: #d1d5db;
  --doc-quote-border: #4b5563;
  --doc-quote-bg: #f9fafb;
  --doc-link-color: #1e40af;
  --doc-table-stripe: #f9fafb;
}

.theme-modern-slate {
  --sheet-bg: #ffffff;
  --sheet-text: #334155;
  --doc-heading-color: #0f172a;
  --doc-text-color: #334155;
  --doc-code-bg: #f1f5f9;
  --doc-border-color: #cbd5e1;
  --doc-quote-border: #0ea5e9;
  --doc-quote-bg: #f0f9ff;
  --doc-link-color: #0284c7;
  --doc-table-stripe: #f8fafc;
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 50;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Privacy Security Badge */
.security-badge {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--success-color);
  font-weight: 500;
}

.security-dot {
  width: 7px;
  height: 7px;
  background-color: var(--success-color);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success-color);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  outline: none;
  user-select: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border-color: var(--surface-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.45);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border-color: var(--surface-border);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-icon-only {
  padding: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
}

/* App Main Container (Sidebar + Canvas) */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Settings Sidebar */
.settings-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), margin-left 0.3s;
  z-index: 40;
}

.settings-sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

/* Custom Scrollbar */
.sidebar-scroll::-webkit-scrollbar,
.preview-container::-webkit-scrollbar,
.editor-textarea::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb,
.preview-container::-webkit-scrollbar-thumb,
.editor-textarea::-webkit-scrollbar-thumb {
  background: var(--surface-border);
  border-radius: 999px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover,
.preview-container::-webkit-scrollbar-thumb:hover,
.editor-textarea::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* Settings Groups & Controls */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.group-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-size: 0.8rem;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-val-tag {
  font-size: 0.75rem;
  color: var(--accent-primary);
  font-family: var(--doc-code-font);
  font-weight: 500;
}

/* Form inputs */
select.form-control,
input[type="text"].form-control,
input[type="number"].form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select.form-control:focus,
input[type="text"].form-control:focus,
input[type="number"].form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Range Slider */
.slider-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
  transition: transform 0.15s, background-color 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #ffffff;
}

/* Segmented Buttons / Radio Group */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 4px;
  background-color: var(--bg-primary);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
}

.segment-btn {
  padding: 0.4rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.segment-btn:hover {
  color: var(--text-main);
}

.segment-btn.active {
  background-color: var(--bg-secondary);
  color: var(--accent-primary);
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Checkbox Toggle Switch */
.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.35rem 0;
}

.toggle-item span {
  font-size: 0.8rem;
  color: var(--text-main);
}

.toggle-switch {
  position: relative;
  width: 38px;
  height: 20px;
  background-color: var(--bg-tertiary);
  border-radius: 999px;
  transition: background-color 0.2s;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-switch input:checked + .toggle-slider {
  transform: translateX(18px);
}

.toggle-switch:has(input:checked) {
  background-color: var(--accent-primary);
}

/* Workspace Main Area */
.workspace-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background-color: var(--canvas-bg);
}

/* Workspace Sub-Toolbar */
.sub-toolbar {
  height: 48px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 30;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-info-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info-tag .file-icon {
  color: var(--accent-primary);
}

.view-mode-tabs {
  display: flex;
  background-color: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--surface-border);
}

.view-tab-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: calc(var(--radius-sm) - 2px);
  transition: all 0.15s;
}

.view-tab-btn.active {
  background: var(--bg-tertiary);
  color: var(--text-main);
  font-weight: 600;
}

/* Zoom Controls */
.zoom-control {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-primary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.btn-zoom {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
}

.btn-zoom:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
}

.zoom-level-text {
  font-size: 0.75rem;
  font-family: var(--doc-code-font);
  min-width: 42px;
  text-align: center;
  color: var(--text-main);
}

/* Content Views Container */
.views-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  overflow: hidden;
}

/* Markdown Source Editor (Split or Single view) */
.editor-pane {
  flex: 1;
  display: none;
  flex-direction: column;
  background-color: #0b1120;
  border-right: 1px solid var(--surface-border);
  position: relative;
}

.editor-pane.visible {
  display: flex;
}

.editor-header {
  height: 32px;
  background: #070d19;
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.editor-textarea {
  flex: 1;
  width: 100%;
  padding: 1.25rem;
  background: transparent;
  color: #e2e8f0;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--doc-code-font);
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Document Preview Canvas */
.preview-pane {
  flex: 1;
  position: relative;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem 5rem 1rem;
}

/* The Paper Sheet (Simulates A4 / Print Canvas) */
.document-sheet-wrapper {
  transform-origin: top center;
  transition: transform 0.15s ease-out;
  display: flex;
  justify-content: center;
}

.document-sheet {
  background-color: var(--sheet-bg);
  color: var(--sheet-text);
  box-shadow: var(--sheet-shadow);
  border-radius: 2px;
  box-sizing: border-box;
  position: relative;
  transition: background-color 0.2s, color 0.2s;
  min-height: 297mm; /* Standard A4 height */
  width: 210mm;      /* Standard A4 width */
  padding: var(--doc-page-padding);
}

/* Letter format variant */
.document-sheet.format-letter {
  width: 8.5in;
  min-height: 11in;
}

/* A3 format variant */
.document-sheet.format-a3 {
  width: 297mm;
  min-height: 420mm;
}

/* Document Header & Footer Decorations (Screen Preview & Print) */
.doc-header-banner {
  border-bottom: 1px solid var(--doc-border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #64748b;
  display: none;
}

.doc-header-banner.active {
  display: flex;
}

.doc-footer-banner {
  border-top: 1px solid var(--doc-border-color);
  padding-top: 0.75rem;
  margin-top: 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #64748b;
  display: none;
}

.doc-footer-banner.active {
  display: flex;
}

/* Markdown Rendered Content Styles */
.markdown-body {
  font-family: var(--doc-font-family);
  font-size: var(--doc-font-size);
  line-height: var(--doc-line-height);
  color: var(--doc-text-color);
  word-break: break-word;
}

.markdown-body > *:first-child {
  margin-top: 0 !important;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: var(--doc-heading-color);
  font-weight: 700;
  line-height: 1.35;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  page-break-after: avoid;
  break-after: avoid;
}

.markdown-body h1 {
  font-size: 2.1em;
  border-bottom: 2px solid var(--doc-border-color);
  padding-bottom: 0.35em;
  margin-top: 0.5em;
}

.markdown-body h2 {
  font-size: 1.6em;
  border-bottom: 1px solid var(--doc-border-color);
  padding-bottom: 0.25em;
}

.markdown-body h3 {
  font-size: 1.3em;
}

.markdown-body h4 {
  font-size: 1.1em;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body table,
.markdown-body pre {
  margin-bottom: 1em;
}

.markdown-body p {
  line-height: inherit;
}

.markdown-body a {
  color: var(--doc-link-color);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-body strong {
  font-weight: 700;
  color: var(--doc-heading-color);
}

.markdown-body em {
  font-style: italic;
}

.markdown-body blockquote {
  padding: 0.75em 1.25em;
  margin: 1em 0;
  border-left: 4px solid var(--doc-quote-border);
  background-color: var(--doc-quote-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--doc-text-color);
  page-break-inside: avoid;
  break-inside: avoid;
}

.markdown-body blockquote > *:last-child {
  margin-bottom: 0;
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
  padding-left: 1.75em;
}

.markdown-body li {
  margin-bottom: 0.35em;
  line-height: inherit;
}

.markdown-body li > p {
  margin-bottom: 0.35em;
}

/* Task Lists (Checklists) */
.markdown-body ul.contains-task-list {
  list-style: none;
  padding-left: 0.5em;
}

.markdown-body .task-list-item {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
}

.markdown-body .task-list-item input[type="checkbox"] {
  accent-color: var(--accent-primary);
  margin-top: 0.2em;
}

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0;
  font-size: 0.95em;
  page-break-inside: avoid;
  break-inside: avoid;
}

.markdown-body th,
.markdown-body td {
  padding: 0.65em 0.85em;
  border: 1px solid var(--doc-border-color);
  text-align: left;
}

.markdown-body th {
  background-color: var(--doc-table-stripe);
  font-weight: 700;
  color: var(--doc-heading-color);
}

.markdown-body tr:nth-child(even) td {
  background-color: var(--doc-table-stripe);
}

/* Inline Code */
.markdown-body code:not(pre code) {
  font-family: var(--doc-code-font);
  font-size: 0.88em;
  background-color: var(--doc-code-bg);
  color: #be185d;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--doc-border-color);
}

/* Code Blocks */
.markdown-body pre {
  background-color: var(--doc-code-bg);
  border: 1px solid var(--doc-border-color);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-family: var(--doc-code-font);
  font-size: 0.88em;
  line-height: 1.55;
  page-break-inside: avoid;
  break-inside: avoid;
}

.markdown-body pre code {
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  padding: 0;
  border: none;
  color: var(--doc-code-color);
}

/* Horizontal Rule */
.markdown-body hr {
  border: 0;
  height: 2px;
  background-color: var(--doc-border-color);
  margin: 2em 0;
}

/* Images */
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 0.5em 0;
  page-break-inside: avoid;
  break-inside: avoid;
}

/* Drag & Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  border: 3px dashed var(--accent-primary);
  margin: 1rem;
  border-radius: var(--radius-lg);
}

.drop-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.drop-icon {
  width: 64px;
  height: 64px;
  background: rgba(56, 189, 248, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-size: 2rem;
  animation: bounce 1.5s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.drop-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.drop-subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Empty State / Welcome Splash */
.empty-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  max-width: 520px;
  margin: 2rem auto;
  border: 2px dashed var(--surface-border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-size: 2rem;
  margin-bottom: 1.25rem;
}

.empty-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.empty-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.empty-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Bottom Status Bar */
.app-statusbar {
  height: var(--status-height);
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  z-index: 50;
  flex-shrink: 0;
}

.status-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-stat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.status-stat-item strong {
  color: var(--text-main);
  font-weight: 600;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 50px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  padding: 0.65rem 1rem;
  background: #1e293b;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.82rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s, transform 0.3s;
}

.toast.toast-success {
  border-left: 4px solid var(--success-color);
}

.toast.toast-info {
  border-left: 4px solid var(--accent-primary);
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Modal Popup (Help/Shortcuts) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 520px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1rem;
  color: var(--text-main);
  font-weight: 700;
}

.modal-content {
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.modal-content ul {
  padding-left: 1.2rem;
  margin-top: 0.5rem;
}

.modal-content li {
  margin-bottom: 0.4rem;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--surface-border);
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   PRINT OPTIMIZATION ENGINE (@media print)
   Critical for preserving fonts, colors, layouts & crisp vector text
   ========================================================================== */
@page {
  size: A4 portrait;
  margin: 15mm 15mm 15mm 15mm;
}

@media print {
  /* Hide all UI elements, toolbars, sidebar, modals */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    height: auto !important;
    overflow: visible !important;
    font-size: var(--doc-font-size) !important;
  }

  .app-header,
  .settings-sidebar,
  .sub-toolbar,
  .app-statusbar,
  .editor-pane,
  .drop-overlay,
  .empty-placeholder,
  .toast-container,
  .modal-backdrop,
  .no-print {
    display: none !important;
  }

  .app-body,
  .workspace-area,
  .views-wrapper,
  .preview-pane,
  .document-sheet-wrapper {
    display: block !important;
    position: static !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    transform: none !important;
    background: transparent !important;
  }

  /* Target the sheet */
  .document-sheet {
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    min-height: auto !important;
    background: transparent !important;
    color: var(--sheet-text) !important;
  }

  /* Force browsers to print exact background colors and graphics */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Page break rules to prevent ugly breaks inside tables, headings, code */
  .markdown-body h1,
  .markdown-body h2,
  .markdown-body h3 {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .markdown-body pre,
  .markdown-body blockquote,
  .markdown-body table,
  .markdown-body tr,
  .markdown-body img {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .markdown-body p {
    orphans: 3;
    widows: 3;
  }

  /* Clean URLs for print: do not print href attributes after links */
  .markdown-body a {
    text-decoration: underline !important;
    color: var(--doc-link-color) !important;
  }
}
