*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --yellow: #fef08a;
  --bg: #f8f6f1;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body {
  font-family: "JetBrains Mono", monospace, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- Header ---- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: transparent;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-new {
  background: #1a1a1a;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  transition: opacity 0.15s;
}

.btn-new:hover { opacity: 0.8; }

/* ---- Grid ---- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1rem 2rem 2rem;
}

/* ---- Note card ---- */

.note {
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  position: relative;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: rgba(0, 0, 0, 0.4);
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}

.btn-delete:hover { color: rgba(0, 0, 0, 0.8); }

.note-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.note-body {
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.8);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- States ---- */

.loading, .empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.error-banner {
  background: #fee2e2;
  color: #991b1b;
  padding: 0.75rem 2rem;
  font-size: 0.875rem;
}

/* ---- Dialog ---- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.dialog {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  width: min(440px, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.dialog h2 {
  font-size: 1rem;
  font-weight: 600;
}

.input, .textarea {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 0.625rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus, .textarea:focus {
  border-color: #6b7280;
}

.textarea {
  resize: vertical;
  min-height: 120px;
}

/* ---- Color picker ---- */

.color-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #1a1a1a; transform: scale(1.1); }

/* ---- Dialog actions ---- */

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-cancel {
  background: none;
  border: 1px solid #e5e7eb;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  transition: background 0.15s;
}

.btn-cancel:hover { background: #f9fafb; }

.btn-save {
  background: #1a1a1a;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  transition: opacity 0.15s;
}

.btn-save:hover { opacity: 0.8; }
