:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1b1a18;
  --muted: #6d6a63;
  --faint: #96928a;
  --border: #e3e0d9;
  --accent: #2f5d8a;
  --accent-soft: #e8eef5;
  --danger: #a33a32;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1b1e24;
    --surface-2: #22262d;
    --text: #e9e7e2;
    --muted: #9d9a93;
    --faint: #7b786f;
    --border: #2a2f38;
    --accent: #86b0dd;
    --accent-soft: #22303f;
    --danger: #e08a80;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--muted);
  background: var(--surface);
}

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 18px 14px;
}

.brand {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* ---------- buttons ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 7px 12px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .btn--primary { color: #10161d; }
}

.btn--primary:hover { filter: brightness(1.08); }

.btn--ghost {
  color: var(--muted);
  border-color: var(--border);
}

.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

.btn--danger {
  color: var(--danger);
  border-color: var(--border);
}

.btn--danger:hover { background: var(--surface-2); }

.btn--danger.is-armed {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}

/* ---------- search ---------- */

.search {
  position: relative;
  padding: 0 18px 12px;
}

.search input {
  width: 100%;
  padding: 9px 34px 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 14px;
}

.search input::placeholder { color: var(--faint); }

.search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.search__hint {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* ---------- list ---------- */

.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 10px 16px;
}

.list__empty {
  padding: 22px 10px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.note {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.note + .note { margin-top: 2px; }

.note:hover { background: var(--surface-2); }

.note[aria-current="true"] { background: var(--accent-soft); }

.note__title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note__preview {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note__time {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--faint);
}

.sidebar__foot {
  border-top: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 12px;
  color: var(--faint);
}

/* ---------- pane / editor ---------- */

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

.pane__empty {
  margin: auto;
  padding: 32px;
  max-width: 400px;
  text-align: center;
  color: var(--muted);
}

.pane__empty-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.pane__empty-text { margin: 0; font-size: 13.5px; }

.editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 34px 26px;
}

.editor[hidden] { display: none; }

.editor__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 34px;
}

.editor__back { display: none; }

.status {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--faint);
  transition: color 200ms ease;
}

.status.is-saving { color: var(--muted); }

.status.is-error { color: var(--danger); }

.editor__title {
  margin: 18px 0 2px;
  font-size: 25px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.editor__meta {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--faint);
}

.editor__text {
  flex: 1;
  min-height: 240px;
  width: 100%;
  padding: 0;
  border: 0;
  resize: none;
  background: transparent;
  font-size: 15.5px;
  line-height: 1.75;
  tab-size: 2;
}

.editor__text:focus { outline: none; }

.editor__tip {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--faint);
}

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    border-right: 0;
    height: 100dvh;
  }

  .pane {
    height: 100dvh;
    background: var(--bg);
  }

  .app[data-view="list"] .pane { display: none; }
  .app[data-view="editor"] .sidebar { display: none; }

  .editor { padding: 14px 20px 22px; }
  .editor__back { display: inline-block; }
  .editor__title { margin-top: 14px; font-size: 22px; }
  .search__hint { display: none; }
  .search input { padding-right: 12px; }
}
