html, body {
  color: #333;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  font-family: Helvetica, arial, freesans, clean, sans-serif;
  font-size: 1em;
  line-height: 1.5em;
  background-color: #fff;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

h1, h2, h3, h4, h5, h6, p {
  font-size: 1em;
  margin: 0;
  padding: 0;
  font-weight: normal;
}

p {
  margin: 1em;
}

a:link, a:visited, a:hover, a:active {
  text-decoration: none;
}

img {
  border: none;
}

/* App layout: sidebar + main */
#app-layout {
  display: flex;
  flex: 1;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 260px;
  min-width: 200px;
  max-width: 400px;
  background: #1f2428;
  color: #e6edf3;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #2c3138;
  flex-shrink: 0;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #2c3138;
  background: #1a1e22;
}

#sidebar-title {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
}

#sidebar-new-btn {
  background: #2ea043;
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

#sidebar-new-btn:hover {
  background: #3fb950;
}

#sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 13px;
  color: #c9d1d9;
  transition: background 0.1s;
  position: relative;
}

.sidebar-item:hover {
  background: #2c3138;
}

.sidebar-item.active {
  background: #2d4f7c;
  color: #fff;
}

.sidebar-item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 6px;
}

.sidebar-item-actions {
  display: none;
  gap: 2px;
}

.sidebar-item:hover .sidebar-item-actions,
.sidebar-item.active .sidebar-item-actions {
  display: flex;
}

.sidebar-item-actions button {
  background: transparent;
  border: none;
  color: #8b949e;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.sidebar-item-actions button:hover {
  background: #444c56;
  color: #fff;
}

.sidebar-item-actions button.delete:hover {
  background: #6e2b2b;
  color: #ff7b72;
}

.sidebar-empty {
  padding: 16px;
  text-align: center;
  color: #6e7681;
  font-size: 12px;
}

/* Main area */
#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  width: 100%;
  background-color: #444;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

header a:link, header a:hover, header a:visited, header a:active {
  color: #fff;
}

header a:hover {
  text-decoration: underline;
}

#menu-items {
  display: flex;
  align-items: center;
  width: 100%;
}

#reset-button, #copy-button, #export-button {
  margin-left: 16px;
}

#save-button {
  margin-left: 16px;
  background: #2ea043;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

#save-button:hover {
  background: #3fb950;
}

#save-button.saved {
  background: #444;
}

#sync-button {
  margin-left: auto;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

header input[type="checkbox"] {
  vertical-align: middle;
  margin-right: 4px;
  margin-top: 0;
}

footer {
  padding: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: transparent;
}

#container {
  flex-grow: 1;
  overflow: hidden;
  width: 100%;
  margin: 0 auto;
  background-color: #fff;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
}

#editor-wrapper, #editor {
  height: 100%;
}

#preview-wrapper {
  padding: 8px 16px 16px 16px;
}

.column {
  width: 50%;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  vertical-align: top;
}

#preview.column {
  overflow-y: scroll;
  white-space: normal;
}

.markdown-body .mermaid {
  overflow-x: auto;
  padding: 16px;
  text-align: center;
}

.markdown-body .mermaid svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.markdown-body .mermaid-error {
  color: #cf222e;
  white-space: pre-wrap;
  text-align: left;
}

[data-theme="dark"] .markdown-body .mermaid-error {
  color: #ff7b72;
}

.split-container {
  display: flex;
  height: 100%;
  width: 100%;
}

.editor-pane, .preview-pane {
  height: 100%;
}

.split-divider {
  width: 5px;
  background: #ccc;
  cursor: col-resize;
  z-index: 1;
}

.split-divider.hover {
  background: #999;
}

.split-divider.active {
  background: #666;
}

/* Dark theme overrides */
[data-theme="dark"] html, [data-theme="dark"] body {
  background-color: #212830;
  color: #e6edf3;
}

[data-theme="dark"] header {
  background-color: #333;
  color: #e6edf3;
}

[data-theme="dark"] #container {
  background-color: #212830;
  border-bottom: 1px solid #1f2d3a;
}

[data-theme="dark"] .split-divider {
  background: #30363d;
}

[data-theme="dark"] .split-divider.hover {
  background: #444c56;
}

[data-theme="dark"] .split-divider.active {
  background: #768390;
}
