/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #0f172a;
  background: #f8fafc;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.container { max-width: 1120px; margin: 0 auto; padding: 0 32px; }
.page { min-height: 100vh; display: flex; flex-direction: column; }
.section { padding: 48px 0; }

/* ── Navigation ── */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 60px;
  background: #ffffff; border-bottom: 1px solid #e2e8f0;
  position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; color: #0f172a; letter-spacing: -0.02em; }

/* ── Typography ── */
h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; }
.text-muted { color: #64748b; font-size: 0.875rem; }
.text-subtle { color: #94a3b8; font-size: 0.8rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  font-size: 0.875rem; font-weight: 500; font-family: inherit;
  border-radius: 5px; border: 1px solid transparent;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap; text-decoration: none;
}
.btn-primary { background: #0f172a; color: #fff; border-color: #0f172a; }
.btn-primary:hover { background: #1e293b; border-color: #1e293b; }
.btn-secondary { background: #ffffff; color: #0f172a; border-color: #e2e8f0; }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 7px 13px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-close {
  background: transparent; border: none; font-size: 1.5rem;
  color: #64748b; cursor: pointer; padding: 0; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: background 0.15s;
}
.btn-close:hover { background: #f1f5f9; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.85rem; font-weight: 500; color: #0f172a; }

input, textarea {
  width: 100%; padding: 10px 14px;
  font-size: 0.9rem; font-family: inherit;
  color: #0f172a; background: #ffffff;
  border: 1px solid #e2e8f0; border-radius: 5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
textarea { resize: vertical; }

/* ── Search ── */
.search-container { margin-bottom: 32px; }
.search-input {
  max-width: 600px;
  padding: 12px 16px;
  font-size: 1rem;
  background: #ffffff;
  border: 2px solid #e2e8f0;
}
.search-input:focus {
  border-color: #3b82f6;
}

/* ── Notes Grid ── */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.note-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  transition: box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
  position: relative;
}
.note-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}

.note-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.note-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 8px;
  line-height: 1.3;
}

.note-card-content {
  color: #64748b;
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 12px;
  max-height: 100px;
  overflow: hidden;
  position: relative;
}

.note-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #f1f5f9;
  color: #64748b;
}

.note-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.note-card-date {
  font-size: 0.75rem;
  color: #94a3b8;
}

.note-card-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #64748b;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  font-size: 0.9rem;
}
.btn-icon:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.btn-icon.danger:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ── Modal ── */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: #ffffff;
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #e2e8f0;
}

/* ── States ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 16px;
  text-align: center;
}

.empty-icon {
  font-size: 4rem;
  opacity: 0.3;
}

.alert {
  padding: 14px 18px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-size: 0.875rem;
}
.alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .nav { padding: 0 16px; }
  .notes-grid { grid-template-columns: 1fr; }
  .search-input { max-width: 100%; }
}