/* ==========================================================================
   VS Code Syntax-Highlighted Layered Editor + Markdown / JSON / CSV Preview
   ========================================================================== */

.editor-pane {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--editor-bg);
  overflow: hidden;
}

.editor-gutter {
  width: 54px;
  flex-shrink: 0;
  padding: 16px 10px 16px 6px;
  background: var(--editor-gutter-bg);
  border-right: 1px solid var(--border);
  color: var(--editor-gutter-text);
  font-family: var(--font-mono);
  font-size: var(--editor-font-size, 14px);
  line-height: 1.65;
  text-align: right;
  user-select: none;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.editor-gutter.is-hidden {
  display: none;
}

.gutter-line {
  height: calc(var(--editor-font-size, 14px) * 1.65);
}

.gutter-line.is-active {
  color: var(--text);
  font-weight: 700;
}

.editor-surface {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Synchronized Transparent Textarea over Syntax-Colored <pre> */
.editor-highlight,
.editor-textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 16px 20px;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: var(--editor-font-size, 14px);
  line-height: 1.65;
  tab-size: 2;
  letter-spacing: 0;
  word-spacing: 0;
  overflow: auto;
  white-space: pre;
  word-wrap: normal;
}

.editor-surface.is-wrap .editor-highlight,
.editor-surface.is-wrap .editor-textarea {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.editor-highlight {
  z-index: 1;
  pointer-events: none;
  background: transparent;
  color: var(--editor-text);
}

.editor-textarea {
  z-index: 2;
  background: transparent;
  color: transparent;
  caret-color: var(--editor-caret);
}

.editor-textarea::selection {
  background: var(--editor-selection);
  color: transparent;
}

/* Authentic VS Code Token Classes */
.tok-comment  { color: var(--tok-comment); font-style: italic; }
.tok-string   { color: var(--tok-string); }
.tok-keyword  { color: var(--tok-keyword); font-weight: 600; }
.tok-control  { color: var(--tok-control); font-weight: 600; }
.tok-function { color: var(--tok-function); }
.tok-type     { color: var(--tok-type); }
.tok-number   { color: var(--tok-number); }
.tok-property { color: var(--tok-property); }
.tok-tag      { color: var(--tok-tag); }
.tok-attr     { color: var(--tok-attr); }
.tok-heading  { color: var(--tok-heading); font-weight: 700; }
.tok-bold     { color: var(--tok-bold); font-weight: 700; }
.tok-link     { color: var(--tok-link); text-decoration: underline; }
.tok-code     { color: var(--tok-code); }

/* ---------- Live Preview Pane (Markdown / HTML / SVG / JSON / CSV) ---------- */
.preview-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 24px 28px;
}

.preview-pane.is-full {
  border-left: none;
}

.preview-inner {
  max-width: 820px;
  margin: 0 auto;
  color: var(--text);
  line-height: 1.7;
  font-size: 0.96rem;
}

.preview-inner h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.025em; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.preview-inner h2 { font-size: 1.4rem; font-weight: 750; margin: 24px 0 10px; }
.preview-inner h3 { font-size: 1.15rem; font-weight: 700; margin: 18px 0 8px; }
.preview-inner p { margin: 0 0 14px; }
.preview-inner a { color: var(--accent); text-decoration: underline; }
.preview-inner ul, .preview-inner ol { margin: 0 0 14px; padding-left: 24px; }
.preview-inner li { margin: 4px 0; }
.preview-inner li.md-task { list-style: none; margin-left: -20px; display: flex; align-items: center; gap: 8px; }
.preview-inner blockquote {
  margin: 0 0 16px;
  padding: 10px 16px;
  border-left: 4px solid var(--accent);
  background: var(--surface-container);
  border-radius: 0 12px 12px 0;
  color: var(--muted);
}
.preview-inner hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
.preview-inner code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-container);
}

.md-pre {
  position: relative;
  margin: 0 0 16px;
  padding: 30px 16px 14px;
  border-radius: 16px;
  background: var(--editor-bg);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
}

.md-pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.md-pre-lang {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}

.md-table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.md-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.md-table-wrap th,
.md-table-wrap td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.md-table-wrap th {
  background: var(--surface-container);
  font-weight: 700;
}

.preview-iframe {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
}

.json-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.json-status.is-valid { background: rgba(16, 185, 129, 0.16); color: var(--success); }
.json-status.is-invalid { background: rgba(220, 38, 38, 0.16); color: var(--danger); }
