:root {
  --bg-color: #22252a;
  --card-bg: #2d3036;
  --sidebar-bg: #1c1e22;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --primary-color: #5c6784;
  --primary-hover: #48526e;
  --accent-color: #d1b464;
  /* dull gold for star */
  --border-color: #3b3f46;
  --danger: #cf6679;
  --success: #6ba87a;
  --compact-p-y: 8px;
  --compact-p-x: 12px;
  --border-radius: 6px;
  --nav-height: 50px;
  --gold-text: #E6D088;
  --title-color: #ffffff;
}

[data-theme="light"] {
  --bg-color: #f1f5f9;
  --card-bg: #ffffff;
  --sidebar-bg: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --accent-color: #bfa150;
  --border-color: #cbd5e1;
  --danger: #ef4444;
  --success: #10b981;
  --gold-text: #d49500;
  --title-color: #1e293b;
}

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

@font-face {
  font-family: 'Sacramento';
  src: url('../fonts/Sacramento-Regular.ttf') format('truetype');
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.4;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Smooth Theme Transitions */
.sidebar, .topbar-mobile, .note-card, .filters-bar, .modal-content, .toast, input, select, textarea, .form-control, .card-bg, .note-textarea, .tag {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.welcome-text {
  color: var(--gold-text);
}

a {
  color: var(--primary-color);
  text-decoration: none;
}

a:hover {
  color: var(--text-main);
}

ul {
  list-style: none;
}

/* Utilities */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: var(--primary-color);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-block {
  display: block;
  width: 100%;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.text-center {
  text-align: center;
}

.d-flex {
  display: flex;
}

.justify-content-between {
  justify-content: space-between;
}

.align-items-center {
  align-items: center;
}

.gap-2 {
  gap: 8px;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mb-1 {
  margin-bottom: 8px;
}

/* Inputs */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.form-control,
input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}

.form-control:focus,
input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.input-icon {
  position: relative;
}

.input-icon i {
  position: absolute;
  left: 10px;
  top: 10px;
  color: var(--text-muted);
}

.input-icon input {
  padding-left: 32px;
}

/* Auth Layout */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

.auth-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.auth-header {
  text-align: center;
  margin-bottom: 20px;
}

.auth-header h2 {
  font-size: 20px;
  margin: 8px 0 4px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 12px;
}

.brand-icon {
  color: var(--primary-color);
}

.auth-links {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
}

/* Sidebar & Mobile Topbar */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 950;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 220px;
  background: var(--sidebar-bg);
  padding: 16px;
  transform: translateX(0);
  transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
  z-index: 1000;
  border-right: 1px solid var(--border-color);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 24px;
}

.sidebar-nav li {
  margin-bottom: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--text-muted);
  border-radius: var(--border-radius);
  transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--primary-color);
  color: #fff;
}

.nav-divider {
  background: var(--border-color);
  height: 1px;
  margin: 12px 0;
}

.mobile-close {
  display: none;
  position: absolute;
  right: 16px;
  top: 16px;
  font-size: 20px;
  color: var(--text-main);
}

.topbar-mobile {
  display: none;
  background: var(--sidebar-bg);
  height: var(--nav-height);
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 900;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 20px;
  cursor: pointer;
}

.topbar-title {
  margin-left: 16px;
  font-weight: 600;
  font-size: 16px;
}

/* Main Content */
/* Note Card layout Compact */
.note-list {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.floating-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(45deg, #d1b464, #f4e29f);
  box-shadow: 0 4px 15px rgba(209, 180, 100, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #1c1e22;
  z-index: 900;
  transition: transform 0.2s;
}

.floating-btn:hover {
  transform: scale(1.05);
  color: #000;
}

.gold-shine {
  font-family: 'Sacramento', cursive;
  font-size: 45px;
  background-image: linear-gradient(65deg, #d1b464, #342d19, #ffe397, #d1b464);
  background-size: 200% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: shine 3s linear infinite;
  font-weight: 800;
}

[data-theme="light"] .gold-shine {
  background-image: linear-gradient(65deg, #d49500, #5c4200, #f8c950, #d49500);
}

@keyframes shine {
  to {
    background-position: 200% center;
  }
}

.note-list {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.note-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  padding: 12px;
  position: relative;
}

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

.note-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.tag {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
}

.star-btn {
  background: none;
  border: none;
  color: var(--gold-text);
  font-size: 16px;
  cursor: pointer;
  margin-left: 5px;
  transition: color 0.2s;
}

.star-btn.active {
  color: var(--accent-color);
}

/* Filters area */
.filters-bar {
  background: var(--card-bg);
  padding: 12px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.filter-item {
  flex: 1;
  min-width: 120px;
}

.filter-item select,
.filter-item input {
  padding: 2px 8px;
  font-size: 11px;
  height: 26px;
}

.compact-filters {
  padding: 8px 12px;
}

.compact-filters .filter-item {
  min-width: 80px;
}

.compact-filters .filter-item input::placeholder {
  color: var(--text-muted);
}

/* Note Editor */
.editor-toolbar {
  background: var(--sidebar-bg);
  padding: 8px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.editor-toolbar select,
.editor-toolbar input {
  width: auto;
  font-size: 12px;
  padding: 4px;
  height: 26px;
}

.switch-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--danger);
  transition: .4s;
  border-radius: 18px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 1px;
  background-color: #fff;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--success);
}

input:checked+.slider:before {
  transform: translateX(16px);
  background-color: #fff;
}

.readonly-switch {
  pointer-events: none;
}

.note-textarea {
  width: 100%;
  min-height: 400px;
  background: var(--card-bg);
  border: none;
  color: var(--text-main);
  font-family: monospace;
  padding: 16px;
  resize: vertical;
  line-height: 1.5;
  font-size: 14px;
}

.note-textarea:focus {
  outline: none;
}

/* Modal & Toast Base */
/* Toasts */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--card-bg);
  border-left: 4px solid var(--primary-color);
  padding: 12px 16px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  width: 280px;
}

.toast.toast-show {
  transform: translateX(0);
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--card-bg);
  width: 90%;
  max-width: 400px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  transform: translateY(-20px);
  transition: transform 0.3s ease;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
}

.modal-body {
  padding: 16px;
  font-size: 13px;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Mobile Reponsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .mobile-close {
    display: block;
  }

  .topbar-mobile {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 12px;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-item {
    width: 100%;
  }
}