:root {
  --sidebar-bg: #263238;
  --sidebar-text: #eceff1;
  --sidebar-active: #37474f;
  --accent: #4fc3f7;
  --bg: #fafafa;
  --text: #212121;
  --muted: #757575;
  --border: #e0e0e0;
  --code-bg: #f0f0f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

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

/* --- サイドバー --- */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
}

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

.sidebar-header h1 {
  margin: 0;
  font-size: 1.1rem;
}

#new-note-btn {
  background: var(--accent);
  color: #263238;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

#new-note-btn:hover {
  filter: brightness(1.1);
}

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

.note-list li {
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.note-list li:hover {
  background: rgba(255, 255, 255, 0.06);
}

.note-list li.active {
  background: var(--sidebar-active);
  border-left-color: var(--accent);
}

.note-list .note-date {
  display: block;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

/* --- ワークスペース --- */

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

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.save-status {
  font-size: 0.8rem;
  color: var(--muted);
}

.delete-note-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--muted);
}

.delete-note-btn:hover {
  color: #e53935;
  border-color: #e53935;
}

.panes {
  flex: 1;
  display: flex;
  min-height: 0;
}

.editor {
  flex: 1;
  border: none;
  resize: none;
  padding: 20px;
  font-family: "Consolas", "Cascadia Code", monospace;
  font-size: 0.95rem;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
}

.editor:focus {
  outline: none;
}

.preview {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
  border-left: 1px solid var(--border);
  background: #fff;
  line-height: 1.8;
}

/* --- プレビュー内のMarkdownスタイル --- */

.preview h1,
.preview h2,
.preview h3 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.2em;
}

.preview code {
  background: var(--code-bg);
  border-radius: 3px;
  padding: 0.15em 0.4em;
  font-family: "Consolas", "Cascadia Code", monospace;
  font-size: 0.88em;
}

.preview pre {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 12px 16px;
  overflow-x: auto;
}

.preview pre code {
  background: transparent;
  padding: 0;
}

.preview blockquote {
  margin: 0.8em 0;
  padding: 0.1em 1em;
  border-left: 4px solid var(--accent);
  color: var(--muted);
  background: var(--bg);
}

.preview a {
  color: #0277bd;
}

.preview hr {
  border: none;
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .sidebar {
    width: 160px;
  }
  .panes {
    flex-direction: column;
  }
  .preview {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
