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

body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
  font-family: Tahoma, Verdana, sans-serif;
  font-size: 11px;
}

/* ==== Editor container ==== */
.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  background: var(--sz-color-window, #fff);
}

/* ==== Line numbers ==== */
.line-numbers {
  flex-shrink: 0;
  padding: 4px 0;
  background: var(--sz-color-button-face, #f0f0f0);
  border-right: 1px solid var(--sz-color-button-shadow, #a0a0a0);
  color: var(--sz-color-gray-text, #888);
  font-family: 'Lucida Console', 'Courier New', Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  text-align: right;
  user-select: none;
  overflow: hidden;
  min-width: 40px;
  cursor: default;
}

.line-numbers.hidden {
  display: none;
}

.line-number {
  padding: 0 8px 0 8px;
  white-space: nowrap;
}

.line-number.current {
  color: var(--sz-color-window-text, #000);
  font-weight: bold;
  background: rgba(0, 0, 0, 0.04);
}

/* ==== Editor wrapper (textarea + highlight overlay) ==== */
.editor-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.editor-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 4px;
  font-family: 'Lucida Console', 'Courier New', Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  tab-size: 4;
  -moz-tab-size: 4;
  color: transparent;
  caret-color: var(--sz-color-window-text, #000);
  background: transparent;
  z-index: 2;
  overflow: auto;
  white-space: pre;
}

.editor-input::selection {
  background: var(--sz-color-highlight, #0078d7);
  color: transparent;
}

.editor-input::-moz-selection {
  background: var(--sz-color-highlight, #0078d7);
  color: transparent;
}

.editor-input.word-wrap {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.editor-input.no-wrap {
  white-space: pre;
  overflow-x: auto;
}

/* Syntax highlight overlay */
.editor-highlight {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 4px;
  border: none;
  font-family: 'Lucida Console', 'Courier New', Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  tab-size: 4;
  -moz-tab-size: 4;
  color: var(--sz-color-window-text, #000);
  background: var(--sz-color-window, #fff);
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  white-space: pre;
  word-wrap: normal;
}

.editor-highlight.word-wrap {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.editor-highlight code {
  display: block;
  font: inherit;
  color: inherit;
}

/* Current line highlight */
.current-line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.4em;
  background: rgba(0, 0, 0, 0.04);
  pointer-events: none;
  z-index: 0;
}

/* Long line marker */
.long-line-marker {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  border-right: 1px solid rgba(128, 128, 128, 0.4);
  pointer-events: none;
  z-index: 5;
}

.long-line-marker.visible {
  display: block;
}

/* ==== Whitespace rendering ==== */
.ws-space,
.ws-tab {
  position: relative;
}

.ws-space::before {
  content: '\00B7';
  position: absolute;
  left: 0;
  color: rgba(128, 128, 128, 0.5);
  pointer-events: none;
  width: 100%;
  text-align: center;
}

.ws-tab::before {
  content: '\2192';
  position: absolute;
  left: 0;
  color: rgba(128, 128, 128, 0.5);
  pointer-events: none;
}

.ws-cr,
.ws-lf,
.ws-crlf {
  position: relative;
  display: inline;
}

.ws-cr::before {
  content: '\21A9';
  color: rgba(128, 128, 128, 0.4);
  font-size: 0.85em;
}

.ws-lf::before {
  content: '\21B5';
  color: rgba(128, 128, 128, 0.4);
  font-size: 0.85em;
}

.ws-crlf::before {
  content: '\21B5';
  color: rgba(128, 128, 128, 0.4);
  font-size: 0.85em;
}

/* ==== Status bar ==== */
.status-bar {
  display: flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--sz-color-button-face);
  border-top: 1px solid var(--sz-color-button-shadow);
  font-size: 11px;
  color: var(--sz-color-button-text);
  flex-shrink: 0;
  user-select: none;
  gap: 4px;
}

.status-section {
  white-space: nowrap;
  padding: 0 6px;
}

.status-section:not(:last-child):not(.status-modified) {
  border-right: 1px solid var(--sz-color-button-shadow);
}

.status-spacer {
  flex: 1;
}

.status-section.clickable {
  cursor: default;
}

.status-section.clickable:hover {
  background: var(--sz-color-highlight);
  color: var(--sz-color-highlight-text);
}

.status-pos { min-width: 100px; }
.status-sel { min-width: 60px; }
.status-modified { color: var(--sz-color-highlight, #c00); font-weight: bold; }

/* ==== Settings rows ==== */
.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
}

.settings-row select {
  padding: 2px 4px;
  font-size: 11px;
}

.settings-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}

/* ==== Font dialog extras ==== */
.font-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.font-row label {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
}

.font-row select,
.font-row input[type="number"] {
  padding: 2px 4px;
  font-size: 11px;
}

.font-row select {
  width: 180px;
}

.font-row input[type="number"] {
  width: 60px;
}

.font-style-checks {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 11px;
}

.font-style-checks label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}

.font-preview {
  border: 1px inset var(--sz-color-button-shadow);
  background: var(--sz-color-window);
  color: var(--sz-color-window-text);
  padding: 8px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  overflow: hidden;
  font-family: 'Lucida Console', 'Courier New', Consolas, monospace;
}

/* ==== Find/Replace panel (non-modal) ==== */
.find-replace-panel {
  display: none;
  position: fixed;
  top: 28px;
  right: 4px;
  z-index: 1500;
  background: var(--sz-color-button-face);
  border: 2px outset var(--sz-color-button-shadow);
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.25);
  min-width: 380px;
  font-size: 11px;
}

.find-replace-panel.visible {
  display: block;
}

.find-replace-title {
  background: var(--sz-color-highlight);
  color: var(--sz-color-highlight-text);
  padding: 3px 8px;
  font-weight: bold;
  font-size: 11px;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.find-replace-title .fr-close {
  cursor: default;
  padding: 0 4px;
  font-size: 13px;
  line-height: 1;
}

.find-replace-title .fr-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.find-replace-body {
  padding: 8px;
}

.fr-field {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  gap: 6px;
}

.fr-field label {
  min-width: 60px;
  text-align: right;
}

.fr-field input[type="text"],
.fr-field input[type="number"] {
  flex: 1;
  padding: 2px 4px;
  font-size: 11px;
}

.fr-options {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 10px;
}

.fr-options label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: default;
}

.fr-buttons {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 4px;
}

.fr-buttons button {
  min-width: 72px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: default;
}

.fr-status {
  font-size: 10px;
  color: var(--sz-color-gray-text);
  margin-top: 4px;
  min-height: 14px;
}

/* ==== Code Folding ==== */
.fold-marker {
  display: inline-block;
  width: 12px;
  font-size: 8px;
  text-align: center;
  cursor: default;
  color: var(--sz-color-gray-text, #999);
  vertical-align: middle;
  margin-right: 2px;
  user-select: none;
}

.fold-marker:hover {
  color: var(--sz-color-highlight, #0078d7);
}

.fold-marker.collapsed {
  color: var(--sz-color-highlight, #0078d7);
}

.fold-badge {
  color: var(--sz-color-gray-text, #999);
  background: rgba(128, 128, 128, 0.1);
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 2px;
  font-size: 0.85em;
  padding: 0 4px;
  margin-left: 4px;
}

.folded-content {
  opacity: 0.3;
}

.line-number.folded-line {
  opacity: 0.3;
}

/* ==== Bookmarks ==== */
.bookmark-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sz-color-highlight, #0078d7);
  vertical-align: middle;
  margin-right: 2px;
}

/* ==== Minimap ==== */
.minimap {
  flex-shrink: 0;
  width: 80px;
  position: relative;
  background: var(--sz-color-button-face, #f4f4f4);
  border-left: 1px solid var(--sz-color-button-shadow, #a0a0a0);
  overflow: hidden;
  cursor: default;
}

.minimap.hidden {
  display: none;
}

.minimap canvas {
  display: block;
}

.minimap-viewport {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(0, 120, 215, 0.15);
  border: 1px solid rgba(0, 120, 215, 0.4);
  pointer-events: none;
}

/* ==== Drop Overlay ==== */
.drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 120, 215, 0.15);
  border: 3px dashed var(--sz-color-highlight, #0078d7);
  z-index: 100;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  font-weight: bold;
  color: var(--sz-color-highlight, #0078d7);
  pointer-events: none;
}

.drop-overlay.visible {
  display: flex;
}

/* ==== Stats grid (Text Statistics dialog) ==== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  font-size: 11px;
  padding: 4px 0;
}
.stats-grid .stats-label { opacity: 0.7; }
.stats-grid .stats-value { font-weight: bold; text-align: right; }

/* ==== Auto-complete dropdown ==== */
.ac-dropdown {
  position: absolute;
  z-index: 1000;
  background: var(--sz-color-window, #fff);
  border: 1px solid var(--sz-color-button-shadow, #a0a0a0);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.15);
  max-height: 160px;
  overflow-y: auto;
  min-width: 120px;
  font-family: 'Lucida Console', 'Courier New', Consolas, monospace;
  font-size: 12px;
}
.ac-item {
  padding: 2px 8px;
  cursor: default;
  white-space: nowrap;
}
.ac-item.selected, .ac-item:hover {
  background: var(--sz-color-highlight, #0078d7);
  color: var(--sz-color-highlight-text, #fff);
}

/* ==== Split View ==== */
.editor-wrapper.split-active {
  display: flex;
  flex-direction: column;
  --split-top: 50%;
}
.editor-wrapper.split-active > .editor-highlight,
.editor-wrapper.split-active > .editor-input:not(.split-editor) {
  height: var(--split-top) !important;
  flex: none;
  position: relative;
}
.split-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}
.split-divider {
  height: 5px;
  background: var(--sz-color-button-face, #e0e0e0);
  border-top: 1px solid var(--sz-color-button-shadow);
  border-bottom: 1px solid var(--sz-color-button-shadow);
  cursor: ns-resize;
  flex-shrink: 0;
  z-index: 10;
}
.split-editor {
  flex: 1;
  position: relative !important;
  height: auto !important;
}

/* ==== Print styles ==== */
@media print {
  .qat,
  .ribbon-tabs,
  .ribbon-panel,
  .backstage,
  .status-bar,
  .find-replace-panel,
  .dialog-overlay,
  .long-line-marker {
    display: none !important;
  }

  .editor-container {
    overflow: visible !important;
  }

  .editor-input {
    display: none !important;
  }

  .editor-highlight {
    position: static !important;
    overflow: visible !important;
    color: #000 !important;
    background: #fff !important;
  }

  .line-numbers {
    color: #888 !important;
    background: #f8f8f8 !important;
    border-right: 1px solid #ccc !important;
  }
}
