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

:root {
  --sidebar-width: 260px;
  --color-bg: #f5f5f5;
  --color-sidebar-bg: #1e1e2e;
  --color-sidebar-text: #cdd6f4;
  --color-sidebar-active: #313244;
  --color-sidebar-hover: #2a2a3c;
  --color-accent: #89b4fa;
  --color-danger: #f38ba8;
  --color-border: #ddd;
  --color-text: #333;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
}

.app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.page-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.page-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  gap: 8px;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}

.page-item:hover {
  background: var(--color-sidebar-hover);
}

.page-item.active {
  background: var(--color-sidebar-active);
  border-left-color: var(--color-accent);
}

.page-item-title {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 2px 0;
  min-width: 0;
}

.page-item-title:focus {
  outline: none;
  cursor: text;
  border-bottom: 1px solid var(--color-accent);
}

.page-item-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.page-item:hover .page-item-actions {
  opacity: 1;
}

.page-item-actions button {
  background: none;
  border: none;
  color: var(--color-sidebar-text);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  border-radius: 3px;
  line-height: 1;
  opacity: 0.6;
}

.page-item-actions button:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.page-item-actions button.btn-delete:hover {
  color: var(--color-danger);
}

/* ── Buttons ── */

.btn {
  border: none;
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.15s;
}

.btn-add {
  background: var(--color-accent);
  color: #1e1e2e;
  width: 28px;
  height: 28px;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-add:hover {
  filter: brightness(1.1);
}

.btn-nav {
  background: white;
  border: 1px solid var(--color-border);
  padding: 8px 16px;
  color: var(--color-text);
}

.btn-nav:hover:not(:disabled) {
  background: #eee;
}

.btn-nav:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Main content ── */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-area {
  flex: 1;
  padding: 0;
  overflow-y: auto;
}

.editor-area .placeholder {
  color: #999;
  font-size: 15px;
  margin-top: 40px;
  text-align: center;
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  border-top: 1px solid var(--color-border);
  background: white;
}

.page-indicator {
  font-size: 14px;
  color: #666;
}

/* ── Editor toolbar ── */

.editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: white;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.toolbar-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.2;
}

.toolbar-btn:hover {
  background: #f0f0f0;
}

.toolbar-btn.active {
  background: #e0e0e0;
  border-color: #ccc;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 4px;
}

/* ── Editor content / ProseMirror ── */

.editor-content {
  padding: 24px 32px;
  flex: 1;
}

.editor-content .ProseMirror {
  outline: none;
  min-height: 300px;
  font-size: 16px;
  line-height: 1.6;
}

.editor-content .ProseMirror h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

.editor-content .ProseMirror h2 {
  font-size: 1.5em;
  margin: 0.75em 0;
}

.editor-content .ProseMirror h3 {
  font-size: 1.17em;
  margin: 0.83em 0;
}

.editor-content .ProseMirror p {
  margin: 0.5em 0;
}

.editor-content .ProseMirror ul,
.editor-content .ProseMirror ol {
  padding-left: 1.5em;
  margin: 0.5em 0;
}

.editor-content .ProseMirror blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 1em;
  margin: 0.5em 0;
  color: #666;
}

.editor-content .ProseMirror pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 12px 16px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.5em 0;
}

.editor-content .ProseMirror code {
  background: #f0f0f0;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

.editor-content .ProseMirror pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.editor-content .ProseMirror img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.editor-content .ProseMirror a {
  color: var(--color-accent);
  text-decoration: underline;
}

.editor-area .placeholder {
  padding: 32px;
}
