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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f6f8fa;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #24292e;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  z-index: 10;
}

.logo {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #ccc;
}

#theme-select {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #555;
  background: #333;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

#theme-select:focus {
  border-color: #58a6ff;
}

/* ── Main split layout ── */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.divider {
  width: 1px;
  background: #e1e4e8;
  flex-shrink: 0;
}

.panel-header {
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #586069;
  background: #f1f3f5;
  border-bottom: 1px solid #e1e4e8;
  flex-shrink: 0;
}

/* ── Editor ── */
.editor {
  flex: 1;
  padding: 20px;
  font-family: 'SFMono-Regular', 'Cascadia Code', Consolas, 'Liberation Mono', monospace;
  font-size: 14px;
  line-height: 1.65;
  border: none;
  outline: none;
  resize: none;
  background: #fff;
  color: #24292e;
  overflow-y: auto;
  tab-size: 2;
}

.editor::placeholder {
  color: #bbb;
}

/* ── Preview ── */
.preview {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  background: #fff;
}

.preview.markdown-body {
  font-size: 15px;
}

/* ── Export bar ── */
.export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: #fff;
  border-top: 1px solid #e1e4e8;
  flex-shrink: 0;
  gap: 16px;
  box-shadow: 0 -1px 4px rgba(0,0,0,0.06);
}

.export-settings {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.export-settings label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #586069;
  white-space: nowrap;
}

.export-settings input[type="number"] {
  width: 72px;
  padding: 4px 8px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
  outline: none;
  color: #24292e;
}

.export-settings input[type="number"]:focus {
  border-color: #0969da;
  box-shadow: 0 0 0 2px rgba(9,105,218,0.15);
}

.export-settings input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 2px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

/* ── Download button ── */
.download-btn {
  padding: 8px 22px;
  background: #2ea44f;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.download-btn:hover:not(:disabled) {
  background: #2c974b;
}

.download-btn:active:not(:disabled) {
  background: #298e46;
}

.download-btn:disabled {
  background: #94d3a2;
  cursor: not-allowed;
}

/* ── Theme: github-dark ── */
body.theme-github-dark .editor {
  background: #0d1117;
  color: #e6edf3;
}

body.theme-github-dark .preview {
  background: #0d1117;
}

body.theme-github-dark .panel-header {
  background: #161b22;
  color: #8b949e;
  border-color: #30363d;
}

body.theme-github-dark .divider {
  background: #30363d;
}

body.theme-github-dark .export-bar {
  background: #161b22;
  border-color: #30363d;
}

body.theme-github-dark .export-settings label {
  color: #8b949e;
}

body.theme-github-dark .export-settings input[type="number"] {
  background: #0d1117;
  color: #e6edf3;
  border-color: #30363d;
}

/* ── Theme: github-light - stronger headings ── */
body.theme-github-light .preview.markdown-body h1,
body.theme-github-light .preview.markdown-body h2,
body.theme-github-light .preview.markdown-body h3,
body.theme-github-light .preview.markdown-body h4 {
  color: #0d1117;
  font-weight: 700;
}

body.theme-github-light .preview.markdown-body h1 {
  font-size: 2em;
  font-weight: 800;
  border-bottom: 2px solid #24292f;
  padding-bottom: 8px;
}

body.theme-github-light .preview.markdown-body h2 {
  font-size: 1.5em;
  border-left: 4px solid #57606a;
  padding-left: 12px;
  border-bottom: none;
}

/* ── Theme: minimal ── */
body.theme-minimal .preview.markdown-body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #111;
  line-height: 1.8;
}

body.theme-minimal .preview.markdown-body h1,
body.theme-minimal .preview.markdown-body h2,
body.theme-minimal .preview.markdown-body h3,
body.theme-minimal .preview.markdown-body h4 {
  color: #111;
  font-weight: 700;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

body.theme-minimal .preview.markdown-body h1 {
  font-size: 2em;
  font-weight: 800;
  border-bottom: 2px solid #111;
  padding-bottom: 8px;
}

body.theme-minimal .preview.markdown-body h2 {
  font-size: 1.4em;
  border-left: 4px solid #555;
  padding-left: 12px;
  border-bottom: none;
}

body.theme-minimal .preview.markdown-body h3 {
  font-size: 1.15em;
}

/* ── Hidden export container ── */
#export-container {
  position: fixed;
  left: -99999px;
  top: 0;
  pointer-events: none;
}
