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

:root {
  --glass-bg: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  --glass-blur: 20px;
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.65);
  --radius: 16px;
  --radius-sm: 10px;
}

html, body {
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  overflow-x: hidden;
}

body {
  background: #1a1a2e;
  background-image: url("bg.svg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  min-height: 100vh;
}

.bg-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(15, 23, 42, 0.3) 0%,
    rgba(30, 41, 59, 0.2) 50%,
    rgba(15, 23, 42, 0.4) 100%
  );
  z-index: 0;
  pointer-events: none;
}

/* App container */
.app {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100vh;
}

/* Glass header */
.glass-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  margin-bottom: 32px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
}

.glass-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.btn-add {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-add:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

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

.note-card {
  position: relative;
  padding: 22px 24px;
  min-height: 140px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  cursor: pointer;
  transition: all 0.25s ease;
  overflow: hidden;
}

.note-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.8;
}

.note-card[data-color="default"]::before { background: rgba(255,255,255,0.3); }
.note-card[data-color="rose"]::before { background: #f43f5e; }
.note-card[data-color="amber"]::before { background: #f59e0b; }
.note-card[data-color="emerald"]::before { background: #10b981; }
.note-card[data-color="sky"]::before { background: #0ea5e9; }
.note-card[data-color="violet"]::before { background: #8b5cf6; }

.note-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
}

.note-card .note-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card .note-excerpt {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}

.note-card .note-date {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.35);
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.95rem;
  font-weight: 300;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 28px;
  background: rgba(30, 30, 50, 0.7);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.note-title-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 4px 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.note-title-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.note-content-input {
  flex: 1;
  width: 100%;
  min-height: 200px;
  max-height: 50vh;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
  resize: vertical;
  padding: 0;
}

.note-content-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* Modal footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.color-picker {
  display: flex;
  gap: 8px;
}

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--dot-bg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-dot:hover {
  transform: scale(1.15);
}

.color-dot.active {
  border-color: rgba(255, 255, 255, 0.7);
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-save,
.btn-cancel {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-save {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-save:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-cancel {
  background: none;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-cancel:hover {
  color: var(--text-primary);
}

.btn-delete {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-delete:hover {
  color: #f43f5e;
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
}

.btn-delete.hidden {
  display: none;
}

/* Responsive */
@media (max-width: 600px) {
  .app {
    padding: 16px 12px 32px;
  }

  .glass-header {
    padding: 14px 20px;
    margin-bottom: 20px;
  }

  .notes-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .modal {
    padding: 20px;
  }
}
