:root {
  color-scheme: light;
  --ink: #111118;
  --paper: #f7f1e6;
  --sand: #efe3d2;
  --terra: #d88f6a;
  --sage: #5e7c73;
  --charcoal: #1d232b;
  --fog: rgba(255, 255, 255, 0.6);
  --shadow: 0 24px 60px rgba(15, 20, 28, 0.16);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #fff1d6 0%, #f2e6d5 40%, #e3d6c5 80%);
  color: var(--ink);
  font-family: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
}

.page {
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem clamp(0.8rem, 2.5vw, 1.6rem);
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  grid-template-areas: "sidebar main";
  gap: 0.9rem;
}

.shell .sidebar-panel {
  grid-area: sidebar;
}

.shell .main-panel {
  grid-area: main;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.panel {
  background: #fff8ef;
  border-radius: var(--radius-xl);
  padding: 1.1rem;
  border: 1px solid #ecdcc7;
  box-shadow: var(--shadow);
}

.sidebar-new-note {
  width: 100%;
  margin-bottom: 0.8rem;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.search-row input {
  width: 100%;
  border: 1px solid #e6d4bc;
  border-radius: var(--radius-md);
  padding: 0.55rem 0.7rem;
  background: #fff;
  font-size: 0.9rem;
}

.sidebar-meta {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8a7f6f;
  margin-bottom: 0.5rem;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 60vh;
  overflow-y: auto;
}

.notes-list.loading {
  opacity: 0.7;
  pointer-events: none;
}

.note-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.note-item:hover {
  border-color: #e6d4bc;
  box-shadow: 0 6px 14px rgba(51, 33, 21, 0.08);
}

.note-item.active {
  border-color: var(--terra);
  box-shadow: 0 8px 16px rgba(216, 143, 106, 0.2);
}

.note-title {
  font-weight: 600;
  color: #3f342b;
  font-size: 0.95rem;
}

.note-preview {
  font-size: 0.8rem;
  color: #6f6358;
  line-height: 1.4;
}

.note-meta {
  font-size: 0.72rem;
  color: #9a8b7a;
}

.load-more {
  width: 100%;
  margin-top: 0.8rem;
}

.editor-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.editor-header input {
  font-size: 1.2rem;
  font-weight: 600;
  border: none;
  border-bottom: 1px solid #ecdcc7;
  padding: 0.35rem 0.1rem 0.6rem;
  background: transparent;
  color: #2f2620;
}

.editor-header input:focus {
  outline: none;
  border-color: var(--terra);
}

.editor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  font-size: 0.8rem;
  color: #7b6f63;
}

#noteBody {
  flex: 1;
  width: 100%;
  border: 1px solid #e6d4bc;
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 1rem;
  background: #fff;
  resize: vertical;
  line-height: 1.5;
  min-height: 300px;
}

#noteBody:focus {
  outline: none;
  border-color: var(--terra);
}

.tags-row input {
  width: 100%;
  border: 1px solid #e6d4bc;
  border-radius: var(--radius-md);
  padding: 0.55rem 0.7rem;
  background: #fff;
  font-size: 0.9rem;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
}

.editor-empty {
  position: absolute;
  inset: 1.1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 248, 239, 0.96);
  border: 1px dashed #e6d4bc;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
  gap: 0.6rem;
  padding: 2rem;
}

.editor-empty.active {
  display: flex;
}

.editor-empty h2 {
  margin: 0;
  font-size: 1.3rem;
}

.editor-empty p {
  margin: 0;
  font-size: 0.9rem;
  color: #7b6f63;
}

.primary-button {
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--charcoal);
  color: #fff8ef;
  cursor: pointer;
  font-size: 0.85rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(24, 33, 44, 0.2);
}

.ghost-button {
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: #f1e3cf;
  color: #5a4c40;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.ghost-button:hover {
  background: #e6d4bc;
  color: #3f342b;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 960px) {
  .page {
    min-height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.7rem;
    padding: 0.9rem clamp(0.8rem, 3vw, 1.2rem);
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "sidebar";
  }

  .panel {
    padding: 1rem;
  }

  .notes-list {
    max-height: 40vh;
  }
}
