:root {
  --paper: #faf7f0;
  --paper-line: #e3ddd0;
  --ink: #26241f;
  --ink-soft: #6f6a5e;
  --margin-red: #b8503f;
  --accent: #4a6b5a;
  --card-bg: #ffffff;
  --card-border: #e8e2d3;
  --card-active: #f1ece0;
  --radius: 6px;
}

* { box-sizing: border-box; }

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

body {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  border-right: 1px solid var(--paper-line);
  background: #f3efe5;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-header {
  padding: 20px 18px 12px;
}

.brand {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 14px;
  letter-spacing: 0.01em;
}
.brand-dot { color: var(--margin-red); }

.new-btn {
  width: 100%;
  padding: 10px 12px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease;
}
.new-btn:hover { background: #3a3830; }
.new-btn-plus { font-size: 15px; line-height: 1; }

.search-row {
  padding: 0 18px 12px;
}
.search-row input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink);
}
.search-row input:focus {
  outline: none;
  border-color: var(--accent);
}

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

.note-card {
  padding: 11px 12px;
  margin: 0 0 6px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
}
.note-card:hover { background: var(--card-active); }
.note-card.active {
  background: var(--card-bg);
  border-color: var(--card-border);
  box-shadow: -3px 0 0 0 var(--margin-red) inset;
}

.note-card-title {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  margin: 0 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-card-preview {
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 4px;
}
.note-card-date {
  font-size: 10px;
  color: #a39d8c;
  letter-spacing: 0.02em;
}

.empty-state {
  padding: 30px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.7;
}
.empty-sub { color: #a39d8c; font-size: 11.5px; }

/* ---------- Editor pane ---------- */

.editor-pane {
  position: relative;
  min-width: 0;
  background: var(--paper);
}

.no-note {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #b6b09f;
  text-align: center;
  line-height: 1.8;
  font-size: 13px;
}
.no-note-mark {
  font-size: 34px;
  color: var(--margin-red);
  margin-bottom: 10px;
  opacity: 0.6;
}

.editor {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 28px 10px;
  border-bottom: 1px solid var(--paper-line);
}

.title-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 24px;
  color: var(--ink);
  min-width: 0;
}
.title-input:focus { outline: none; }
.title-input::placeholder { color: #c6c0af; }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.save-status {
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.02em;
  min-width: 46px;
  text-align: right;
}
.save-status.saving { color: var(--ink-soft); }
.save-status.error { color: var(--margin-red); }

.sync-banner {
  padding: 8px 18px;
  font-size: 11px;
  color: var(--margin-red);
  background: #fbeceb;
  border-bottom: 1px solid #f0d8d5;
  text-align: center;
}

.delete-btn {
  background: none;
  border: 1px solid var(--paper-line);
  color: var(--margin-red);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
}
.delete-btn:hover {
  background: var(--margin-red);
  color: #fff;
  border-color: var(--margin-red);
}

.paper-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  padding-left: 44px;
}
.paper-wrap::before {
  content: "";
  position: absolute;
  left: 34px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--margin-red);
  opacity: 0.35;
}

.body-input {
  width: 100%;
  height: 100%;
  border: none;
  resize: none;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent,
      transparent 30px,
      var(--paper-line) 31px
    );
  background-attachment: local;
  line-height: 31px;
  padding: 14px 28px 28px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14.5px;
  color: var(--ink);
}
.body-input:focus { outline: none; }
.body-input::placeholder { color: #c6c0af; }

.editor-footer {
  padding: 6px 28px 14px;
  text-align: right;
}
.meta-info {
  font-size: 10.5px;
  color: #a39d8c;
  letter-spacing: 0.02em;
}

/* ---------- Scrollbars ---------- */
.note-list::-webkit-scrollbar, .body-input::-webkit-scrollbar {
  width: 8px;
}
.note-list::-webkit-scrollbar-thumb, .body-input::-webkit-scrollbar-thumb {
  background: var(--paper-line);
  border-radius: 4px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--paper-line);
    max-height: 40vh;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Focus visibility ---------- */
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
