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

:root {
  --c0:  #000000;
  --c1:  #111111;
  --c2:  #1a1a1a;
  --c3:  #222222;
  --c4:  #2e2e2e;
  --c5:  #3a3a3a;
  --c6:  #444444;
  --c7:  #555555;
  --c8:  #666666;
  --c9:  #888888;
  --c10: #aaaaaa;
  --c11: #cccccc;
  --c12: #e0e0e0;
  --c13: #f0f0f0;
  --c14: #ffffff;
}

html, body { height: 100%; }

body {
  background: var(--c1);
  color: var(--c12);
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 44px;
  border-bottom: 1px solid var(--c4);
  flex-shrink: 0;
}

.logo {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--c14);
}

.wordcount {
  font-size: 11px;
  color: var(--c7);
  letter-spacing: 0.05em;
}

.share-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: none;
  border: 1px solid var(--c5);
  color: var(--c9);
  padding: 3px 10px;
  border-radius: 2px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: color 0.1s, border-color 0.1s;
}

.share-btn:hover { color: var(--c14); border-color: var(--c8); }

.toolbar {
  display: flex;
  gap: 2px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--c4);
  background: var(--c2);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.tb-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: none;
  border: 1px solid transparent;
  color: var(--c8);
  padding: 3px 8px;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
  letter-spacing: 0.03em;
}

.tb-btn:hover { color: var(--c14); border-color: var(--c5); }

.sep {
  width: 1px;
  background: var(--c4);
  margin: 4px 4px;
  flex-shrink: 0;
}

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane + .pane { border-left: 1px solid var(--c4); }

.pane-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c6);
  padding: 6px 16px;
  border-bottom: 1px solid var(--c3);
  background: var(--c2);
  flex-shrink: 0;
}

textarea {
  flex: 1;
  width: 100%;
  background: var(--c1);
  color: var(--c11);
  border: none;
  outline: none;
  resize: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 1.8;
  padding: 20px;
  caret-color: var(--c14);
}

textarea::placeholder { color: var(--c5); }
textarea::selection { background: var(--c5); }

.preview {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
  background: var(--c1);
  font-family: 'IBM Plex Serif', serif;
  font-size: 14px;
  line-height: 1.8;
  color: var(--c10);
}

.preview::-webkit-scrollbar { width: 4px; }
.preview::-webkit-scrollbar-track { background: transparent; }
.preview::-webkit-scrollbar-thumb { background: var(--c4); }

.preview h1, .preview h2, .preview h3,
.preview h4, .preview h5, .preview h6 {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  color: var(--c14);
  margin: 1.6em 0 0.5em;
  line-height: 1.3;
}

.preview h1 { font-size: 1.6em; border-bottom: 1px solid var(--c4); padding-bottom: 0.4em; }
.preview h2 { font-size: 1.25em; }
.preview h3 { font-size: 1.05em; color: var(--c12); }
.preview h4, .preview h5, .preview h6 { font-size: 0.95em; color: var(--c9); }

.preview p { margin: 0.7em 0; }
.preview strong { color: var(--c13); font-weight: 600; }
.preview em { color: var(--c11); font-style: italic; }

.preview a { color: var(--c12); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--c6); }
.preview a:hover { color: var(--c14); text-decoration-color: var(--c9); }

.preview code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.84em;
  background: var(--c3);
  color: var(--c12);
  padding: 0.15em 0.4em;
  border-radius: 2px;
}

.preview pre {
  background: var(--c2);
  border: 1px solid var(--c4);
  border-radius: 3px;
  padding: 14px 18px;
  overflow-x: auto;
  margin: 1em 0;
}

.preview pre code {
  background: none;
  padding: 0;
  color: var(--c10);
  font-size: 0.9em;
  line-height: 1.7;
}

.preview blockquote {
  border-left: 2px solid var(--c6);
  margin: 1em 0;
  padding: 0.3em 1em;
  color: var(--c8);
}

.preview ul, .preview ol { padding-left: 1.4em; margin: 0.7em 0; }
.preview li { margin: 0.25em 0; }
.preview li::marker { color: var(--c6); }

.preview table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 0.9em; font-family: 'IBM Plex Mono', monospace; }
.preview th { color: var(--c12); font-weight: 500; padding: 7px 12px; border-bottom: 1px solid var(--c6); text-align: left; }
.preview td { padding: 6px 12px; border-bottom: 1px solid var(--c3); }

.preview hr { border: none; border-top: 1px solid var(--c4); margin: 2em 0; }
.preview img { max-width: 100%; border-radius: 2px; }

@media (max-width: 640px) {
  .main { flex-direction: column; }
  .pane + .pane { border-left: none; border-top: 1px solid var(--c4); }
}