:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --danger-color: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); min-height: 100vh; }
.hidden { display: none !important; }

/* Navbar & Search */
.navbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1.25rem; background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color); 
  position: sticky; top: 0; z-index: 100;
  gap: 0.75rem; flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.2rem; color: var(--primary-color); }
.search-container { position: relative; flex: 1; min-width: 200px; max-width: 480px; }
.search-icon { position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-container input {
  width: 100%; padding: 0.6rem 1rem 0.6rem 2.4rem; border-radius: 9999px;
  border: 1px solid var(--border-color); background-color: #f1f5f9; font-size: 0.9rem; outline: none;
}

/* Buttons */
.btn {
  padding: 0.55rem 1.1rem; border-radius: 8px; font-weight: 600; font-size: 0.88rem;
  cursor: pointer; border: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-primary { background-color: var(--primary-color); color: #ffffff; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: #e2e8f0; color: var(--text-main); }
.user-info { display: flex; align-items: center; gap: 0.6rem; }
.user-info img { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--primary-color); }

/* Main Container */
.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.auth-banner { text-align: center; padding: 3rem 1.5rem; background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border-color); max-width: 480px; margin: 2rem auto; }
.banner-icon { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 0.85rem; }

/* Note Creation Card */
.card { background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border-color); box-shadow: var(--shadow-md); padding: 1rem; }
.note-input-card { max-width: 600px; margin: 0 auto 1.5rem auto; display: flex; flex-direction: column; gap: 0.65rem; transition: background-color 0.2s; }
.note-input-card input, .note-input-card textarea, .modal-card input, .modal-card textarea {
  width: 100%; border: none; outline: none; font-size: 0.95rem; background: transparent; color: var(--text-main);
}
.note-input-card input, .modal-card input { font-weight: 600; font-size: 1.05rem; }

.note-options { display: flex; align-items: center; gap: 1rem; margin-top: 0.25rem; font-size: 0.85rem; color: var(--text-muted); }
.option-group { display: flex; align-items: center; gap: 0.4rem; background: rgba(0,0,0,0.04); padding: 0.35rem 0.6rem; border-radius: 6px; }
.option-group select { border: none; background: transparent; font-size: 0.85rem; outline: none; cursor: pointer; }
.option-group input[type="color"] { border: none; background: transparent; width: 22px; height: 22px; cursor: pointer; border-radius: 50%; }

.pin-toggle-btn { background: transparent; border: none; font-size: 1rem; color: var(--text-muted); cursor: pointer; padding: 0.3rem 0.5rem; border-radius: 6px; }
.pin-toggle-btn.pinned { color: var(--primary-color); transform: rotate(-45deg); }

.card-actions { display: flex; justify-content: flex-end; }

/* Filter Pills */
.tag-filters { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 1rem; margin-bottom: 1rem; }
.filter-pill { padding: 0.4rem 0.9rem; border-radius: 9999px; border: 1px solid var(--border-color); background: var(--card-bg); font-size: 0.85rem; font-weight: 500; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
.filter-pill.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }

/* Notes Grid */
.notes-section { margin-bottom: 2rem; }
.notes-section h3 { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.4rem; }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

.note-item {
  border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1rem;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow-sm);
  position: relative; word-break: break-word; transition: transform 0.2s, box-shadow 0.2s;
}
.note-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.note-header-line { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.4rem; }
.note-title { font-weight: 600; font-size: 1rem; }
.note-tag-badge { font-size: 0.7rem; font-weight: 600; padding: 0.2rem 0.5rem; border-radius: 9999px; background: rgba(0,0,0,0.06); }
.note-content { font-size: 0.9rem; color: var(--text-muted); white-space: pre-wrap; margin-bottom: 0.85rem; flex-grow: 1; line-height: 1.4; }

.note-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: #64748b; border-top: 1px solid rgba(0,0,0,0.06); padding-top: 0.65rem; }
.note-actions { display: flex; gap: 0.25rem; }
.icon-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 0.35rem; font-size: 0.9rem; border-radius: 4px; }
.icon-btn:hover { color: var(--primary-color); background-color: rgba(0,0,0,0.05); }
.icon-btn.delete-btn:hover { color: var(--danger-color); }
.icon-btn.pinned { color: var(--primary-color); }

/* Modal */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 200; padding: 1rem; }
.modal-card { background: var(--card-bg); border-radius: var(--radius); width: 100%; max-width: 520px; padding: 1.25rem; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 0.85rem; }
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.close-btn { background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; }

@media (max-width: 640px) {
  .search-container { order: 3; flex: 1 0 100%; }
  .notes-grid { grid-template-columns: 1fr; }
}