.editor-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  background-color: var(--bg-app);
  min-height: 0;
  gap: 16px;
}

/* Pages container for paginated mode */
.pages-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 0;
}

.editor-page-wrapper {
  max-width: 816px;
  width: 816px;
  display: flex;
  flex-direction: column;
  /* Support zoom transforms */
  transform-origin: top center;
  
  background: white;
  min-height: 1056px;
  height: 1056px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

/* Page number display */
.page-number-display {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10pt;
  color: #666;
  pointer-events: none;
  z-index: 5;
}

/* Ruler styles removed */

/* Each page in the document */
.editor-page {
  background: transparent;
  min-height: 1056px; 
  padding: var(--page-padding-y) var(--page-padding-x);
  outline: none;
  font-size: 11pt;
  line-height: 1.15; /* Match Word default (1.08-1.15) */
  color: #000;
  cursor: text;
  position: relative;
  box-sizing: border-box;
}

/* Editor page content inside wrapper (paginated mode) */
.editor-page-wrapper .editor-page {
  height: calc(1056px - 144px); /* Page height minus top+bottom padding */
  min-height: calc(1056px - 144px);
  overflow: hidden;
  flex: 1;
}

/* Make content editable in paginated pages */
.editor-page-wrapper .editor-page[contenteditable="true"] {
  cursor: text;
}

/* Text styles for paginated mode */
.editor-page p {
  margin: 0;
  margin-bottom: 8pt; /* Reduced from 10pt to match Word closer */
}

/* Empty paragraphs should collapse */
.editor-page p:empty {
  margin-bottom: 0;
  min-height: 0;
}

.editor-page h1 { font-size: 24pt; font-weight: 600; margin-bottom: 12pt; color: #111; }
.editor-page h2 { font-size: 18pt; font-weight: 600; margin-bottom: 8pt; margin-top: 16pt; color: #333; }
.editor-page h3 { font-size: 14pt; font-weight: 600; margin-bottom: 6pt; margin-top: 12pt; color: #444; }

/* Hyperlinks */
.editor-page a.docx-hyperlink,
#editor a.docx-hyperlink {
  color: #0066cc;
  text-decoration: underline;
  cursor: pointer;
  position: relative;
}

.editor-page a.docx-hyperlink:hover,
#editor a.docx-hyperlink:hover {
  color: #004499;
}

.editor-page a.docx-hyperlink:hover::after,
#editor a.docx-hyperlink:hover::after {
  content: 'Ctrl+click to open';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
  margin-bottom: 4px;
}

.editor-page table {
  border-collapse: collapse;
  width: 100%;
  margin: 12pt 0;
}

.editor-page td, .editor-page th {
  border: 1px solid #d1d5db;
  padding: 8px;
  vertical-align: top;
}

.editor-page th {
  background-color: #f3f4f6;
  font-weight: 600;
}

/* For single-page continuous editing mode (default) */
#editor {
  background: transparent;
  min-height: 1056px; 
  flex: 1;
  padding: var(--page-padding-y) var(--page-padding-x);
  outline: none;
  font-size: 11pt;
  line-height: 1.5;
  color: #000;
  cursor: text;
  position: relative;
  z-index: 10;
}

.doc-header, .doc-footer {
  position: absolute;
  left: var(--page-padding-x);
  right: var(--page-padding-x);
  height: 36px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.9em;
  opacity: 0.7;
  pointer-events: none;
  z-index: 20;
}

.doc-header {
  top: 36px;
}

.doc-footer {
  bottom: 36px;
}

#editor p {
  margin: 0;
  margin-bottom: 10pt; /* Paragraph spacing */
}

#editor h1 { font-size: 24pt; font-weight: 600; margin-bottom: 12pt; color: #111; }
#editor h2 { font-size: 18pt; font-weight: 600; margin-bottom: 8pt; margin-top: 16pt; color: #333; }
#editor h3 { font-size: 14pt; font-weight: 600; margin-bottom: 6pt; margin-top: 12pt; color: #444; }

#editor table {
  border-collapse: collapse;
  width: 100%;
  margin: 12pt 0;
}

#editor table.docx-table {
  width: auto;
  min-width: 50%;
}

#editor td, #editor th {
  border: 1px solid #d1d5db;
  padding: 8px;
  vertical-align: top;
}

#editor th {
  background-color: #f3f4f6;
  font-weight: 600;
}

#editor .table-cell-active {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

/* Page break styling - creates visual page separation like separate paper pages */
#editor hr.page-break {
    border: none;
    height: 32px; /* Height of the gray gap between pages */
    margin: 0;
    padding: 0;
    /* Creates a larger gap to simulate page separation */
    margin-top: var(--page-padding-y); /* Match bottom padding - end of page 1 */
    margin-bottom: var(--page-padding-y); /* Match top padding - start of page 2 */
    position: relative;
    display: block;
    background-color: var(--bg-app);
    /* Shadow at bottom of "page 1" and top of "page 2" */
    box-shadow: 
        inset 0 8px 8px -6px rgba(0,0,0,0.12),
        inset 0 -8px 8px -6px rgba(0,0,0,0.12);
    /* Extend beyond the editor padding to reach the edges */
    margin-left: calc(-1 * var(--page-padding-x));
    margin-right: calc(-1 * var(--page-padding-x));
    padding-left: var(--page-padding-x);
    padding-right: var(--page-padding-x);
}

/* Page break label */
#editor hr.page-break::after {
    content: '— Page Break —';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    color: #9ca3af;
    background: var(--bg-app);
    padding: 2px 12px;
    border-radius: 4px;
    z-index: 1;
    white-space: nowrap;
}

.find-highlight {
    background: #fef08a;
}

.find-highlight.current {
    background: #fb923c;
}

#editor img {
    max-width: 100%;
}

.image-wrapper {
    display: inline-block;
    position: relative;
    max-width: 100%;
}

.image-wrapper.selected {
    outline: 2px solid #2563eb;
}

.image-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border: 1px solid #2563eb;
    border-radius: 2px;
    display: none;
    z-index: 2;
}

.image-wrapper.selected .image-handle {
    display: block;
}

.status-bar {
  height: 32px;
  background-color: var(--bg-paper);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

