:root {
  --bg: #1e1e1e;
  --bg-alt: #262626;
  --border: #3a3a3a;
  --text: #e8e8e8;
  --text-dim: #999;
  --accent: #7aa2f7;
}

* { box-sizing: border-box; }

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

#app {
  display: flex;
  height: calc(100vh - 32px);
}

button {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
}
button:hover { background: #333; }

input, textarea {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  display: flex;
  gap: 6px;
  padding: 10px;
}
.sidebar-header input { flex: 1; padding: 8px; }
.note-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.note-list li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.note-list li:hover { background: var(--bg-alt); }
.note-list li.active { background: #2b3f66; }
.note-list .note-title { font-weight: 600; display: block; }
.note-list .note-date { font-size: 12px; color: var(--text-dim); }
.note-list mark { background: #7aa2f7; color: #000; }

/* Editor */
.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.title-input {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  padding: 8px;
  border: none;
  background: transparent;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.save-status { font-size: 12px; color: var(--text-dim); width: 60px; }

.toolbar { display: flex; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--border); }

#contentArea {
  flex: 1;
  border: none;
  resize: none;
  padding: 16px;
  font-size: 16px;
  line-height: 1.6;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
#contentArea:focus { outline: none; }

.preview { flex: 1; padding: 16px; overflow-y: auto; line-height: 1.6; }
.preview a { color: var(--accent); }
.preview.new-link { color: #f7768e; }
.hidden { display: none !important; }

/* Pomodoro */
.pomodoro {
  width: 200px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.clock { font-size: 14px; color: var(--text-dim); }
.pomodoro-time { font-size: 40px; font-variant-numeric: tabular-nums; }
.pomodoro-controls { display: flex; gap: 6px; }
.pomodoro-settings { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.pomodoro-settings input { width: 50px; padding: 2px 4px; }
.pomodoro-mode { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }

.menu-toggle {
  display: none;
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
}

.app-footer {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.app-footer a { color: var(--accent); }

/* History modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
.modal-content {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: min(600px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.revision-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.revision-list li { padding: 8px; border-bottom: 1px solid var(--border); cursor: pointer; }
.revision-list li:hover { background: #333; }
.revision-preview { display: flex; flex-direction: column; gap: 10px; }
.revision-preview-actions { display: flex; gap: 6px; }
#revisionContent { white-space: pre-wrap; overflow-y: auto; max-height: 50vh; }

/* Mobile */
@media (max-width: 768px) {
  #app { height: calc(100dvh - 32px); }
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 20% 0 0;
    z-index: 15;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .pomodoro {
    width: auto;
    flex-direction: row;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .pomodoro-time { font-size: 24px; }
  #app { flex-direction: column; }
  .editor-pane { order: 1; }
  .pomodoro { order: 2; }
}
