:root {
  color-scheme: dark;
  --bg: #080b11;
  --panel: #101722;
  --panel-2: #151f2d;
  --text: #edf4ff;
  --muted: #93a4b8;
  --line: #243244;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, .35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(139,92,246,.22), transparent 35%), var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(16, 23, 34, .86);
  backdrop-filter: blur(18px);
  padding: max(18px, env(safe-area-inset-top)) 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.eyebrow { color: var(--accent-2); margin: 0 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .16em; }
h1 { margin: 0; font-size: 34px; letter-spacing: -.05em; }

.icon-button, .button, .chip {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
  color: var(--text);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.icon-button:hover, .button:hover, .chip:hover { transform: translateY(-1px); border-color: rgba(139,92,246,.7); }
.icon-button { width: 46px; height: 46px; font-size: 28px; line-height: 1; }
.primary { background: linear-gradient(135deg, var(--accent), #5b21b6); border-color: transparent; }
.button { padding: 10px 14px; font-weight: 700; }
.button.ghost { background: rgba(255,255,255,.04); }
.button.danger { color: #ffd7de; border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.1); }
.button.full { width: 100%; }

.search-wrap span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.search-wrap input, .title-input, .tags-input, .body-input, .check-item input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  background: rgba(8, 11, 17, .76);
  color: var(--text);
  border-radius: 16px;
}
.search-wrap input { padding: 13px 14px; }
.search-wrap input:focus, .title-input:focus, .tags-input:focus, .body-input:focus, .check-item input[type="text"]:focus { border-color: var(--accent); }

.filter-row { display: flex; gap: 8px; }
.chip { padding: 8px 12px; color: var(--muted); }
.chip.active { color: var(--text); border-color: rgba(34,211,238,.55); background: rgba(34,211,238,.09); }

.notes-list { display: flex; flex-direction: column; gap: 10px; overflow: auto; padding-right: 2px; }
.note-card {
  text-align: left;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.035);
  color: var(--text);
}
.note-card.active { border-color: var(--accent); background: rgba(139,92,246,.15); }
.note-card h3 { margin: 0 0 7px; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.tag { border: 1px solid rgba(147,164,184,.3); border-radius: 999px; padding: 2px 7px; }

.editor { padding: clamp(18px, 4vw, 48px); display: flex; min-width: 0; }
.editor-pane, .empty-state {
  width: min(880px, 100%);
  margin: auto;
  background: rgba(16,23,34,.62);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.editor-pane { padding: clamp(18px, 4vw, 38px); }
.empty-state { text-align: center; padding: 54px 26px; }
.empty-state .sigil { font-size: 52px; margin-bottom: 12px; }
.empty-state h2 { font-size: clamp(26px, 5vw, 48px); letter-spacing: -.055em; margin: 0 auto 12px; max-width: 660px; }
.empty-state p { color: var(--muted); margin: 0 auto 24px; max-width: 440px; line-height: 1.6; }
.hidden { display: none !important; }

.editor-actions { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.title-input { font-size: clamp(32px, 6vw, 58px); font-weight: 800; letter-spacing: -.06em; border: 0; background: transparent; padding: 0; border-radius: 0; }
.tags-input { margin: 18px 0; padding: 12px 14px; }
.body-input { min-height: 50vh; padding: 18px; resize: vertical; line-height: 1.65; }

.checklist-editor { display: flex; flex-direction: column; gap: 12px; }
.checklist-items { display: flex; flex-direction: column; gap: 10px; }
.check-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.check-item input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.check-item input[type="text"] { padding: 12px 14px; }
.check-item input[type="checkbox"]:checked + input[type="text"] { text-decoration: line-through; color: var(--muted); }
.check-item button { width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line); background: rgba(251,113,133,.09); color: var(--danger); }

.statusbar { margin-top: 18px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.import-help {
  margin-top: 18px;
  color: var(--muted);
  border: 1px dashed rgba(147,164,184,.34);
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
}
.import-help strong { color: var(--text); }

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { padding: 14px; }
  .body-input { min-height: 34vh; }
}
