:root {
  --bg: #0a0a10;
  --bg-panel: #141420;
  --bg-input: #0f0f18;
  --text: #ecedf2;
  --text-dim: #8f90a0;
  --accent: #ff7a5c;
  --accent-soft: rgba(255, 122, 92, 0.12);
  --danger: #e45a5a;
  --border: #262634;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

code, pre {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

button {
  cursor: pointer;
  font: inherit;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 500;
}
button:hover { border-color: var(--accent); }
button.primary {
  background: var(--accent);
  color: #121212;
  border-color: var(--accent);
}
button.primary:hover { filter: brightness(1.08); }
button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
button.danger:hover { background: var(--danger); color: white; }

/* Sidebar */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  max-height: 100vh;
}
.sidebar h1 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.sidebar__actions { display: flex; gap: 8px; }
.sidebar__actions button { width: 100%; }

#post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#post-list li { margin: 0; }
#post-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  padding: 10px 12px;
  line-height: 1.3;
}
#post-list button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
#post-list .post-title {
  display: block;
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#post-list .post-date {
  color: var(--text-dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
}

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
#preview-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
#preview-link:hover { text-decoration: underline; }
#build-output {
  margin: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  font-size: 11px;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--text-dim);
}
#build-output:empty { display: none; }

/* Editor pane */
.editor {
  padding: 28px 32px;
  max-width: 960px;
  width: 100%;
  overflow-x: hidden;
}

.empty {
  color: var(--text-dim);
  padding-top: 60px;
  text-align: center;
  font-size: 15px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.field { display: block; margin-bottom: 14px; }
.field--wide { grid-column: 1 / -1; }

.field > span,
.field__label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.field input,
.field textarea {
  display: block;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field input[readonly] {
  color: var(--text-dim);
  cursor: default;
}
.field textarea {
  resize: vertical;
  font-family: inherit;
}

#body-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
}

.hint {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}
.hint code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
#status {
  margin-left: auto;
  font-size: 13px;
  min-height: 1.2em;
}
#status.ok { color: var(--accent); }
#status.error { color: var(--danger); }

/* Force Toast UI Editor into the dark theme */
.toastui-editor-defaultUI {
  border: none !important;
}
.toastui-editor-md-splitter { background: var(--border) !important; }
.toastui-editor-defaultUI-toolbar {
  background: var(--bg-panel) !important;
  border-bottom: 1px solid var(--border) !important;
}
.toastui-editor-main,
.toastui-editor-md-container,
.toastui-editor-ww-container {
  background: var(--bg-input) !important;
}
.toastui-editor-contents,
.ProseMirror,
.toastui-editor {
  color: var(--text) !important;
  background: var(--bg-input) !important;
}
.toastui-editor-contents p,
.toastui-editor-contents li,
.ProseMirror p,
.ProseMirror li { color: var(--text) !important; }
.toastui-editor-md-preview { background: var(--bg-panel) !important; }
.toastui-editor-mode-switch {
  background: var(--bg-panel) !important;
  border-top: 1px solid var(--border) !important;
}
.toastui-editor-mode-switch .tab-item {
  background: transparent !important;
  color: var(--text-dim) !important;
  border-color: var(--border) !important;
}
.toastui-editor-mode-switch .tab-item.active {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}
