/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
  border: 1.5px solid transparent;
  line-height: 1;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
}
.btn-primary:hover:not(:disabled) {
  background: var(--gold-dark);
  border-color: var(--gold-dark);
  box-shadow: 0 4px 16px var(--gold-glow);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-light);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-light);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8125rem;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

/* ===== CARDS ===== */
.card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
}
.card-subtle {
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
}

/* ===== INPUTS ===== */
.input-field {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  color: var(--text);
  transition: var(--transition);
  outline: none;
}
.input-field::placeholder {
  color: var(--text-faint);
}
.input-field:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-light);
}
.input-field:hover:not(:focus) {
  border-color: var(--text-faint);
}

textarea.input-field {
  resize: vertical;
  min-height: 100px;
}

.input-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-gold {
  background: var(--gold-light);
  color: var(--gold-dark);
  border: 1px solid rgba(212,175,55,0.3);
}
.badge-green {
  background: var(--success-light);
  color: #16A34A;
}
.badge-red {
  background: var(--error-light);
  color: #DC2626;
}
.badge-blue {
  background: var(--blue-light);
  color: #2563EB;
}
.badge-gray {
  background: var(--bg-muted);
  color: var(--text-muted);
}

/* ===== TOP NAVIGATION ===== */
.topnav {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1.5px solid var(--border);
  height: var(--topnav-height);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  justify-content: center;
}
.topnav-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  height: 100%;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  border-radius: 0;
  margin: 0;
  z-index: 1;
}
.topnav-tab:hover {
  color: var(--text);
  background: transparent;
  border-bottom-color: var(--border);
}
.topnav-tab.active {
  color: var(--gold);
  font-weight: 600;
  background: transparent;
  border-bottom-color: var(--gold);
  z-index: 3;
}
.topnav-tab .tab-icon {
  width: 17px;
  height: 17px;
  opacity: 0.6;
  flex-shrink: 0;
}
.topnav-tab.active .tab-icon {
  opacity: 1;
}
/* Actions pinned to right edge */
.topnav-actions {
  position: absolute;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-logo {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.sidebar-logo span {
  color: var(--gold);
}

/* ===== SIDEBAR NEW DESIGN ===== */
.sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
}
.sb-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sb-add-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-faint);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.sb-add-btn:hover { background: var(--gold-light); color: var(--gold); }

.sb-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 12px;
}

.sb-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 7px;
  margin: 1px 6px;
  transition: var(--transition);
  user-select: none;
}
.sb-filter-row:hover { background: var(--bg-subtle); color: var(--text); }
.sb-filter-row.active { background: var(--gold-light); color: var(--gold-dark); font-weight: 600; }

.sb-empty-hint {
  padding: 14px 16px;
  font-size: 0.8125rem;
  color: var(--text-faint);
  line-height: 1.6;
}

/* Subject items */
.sb-subject-item { margin: 2px 0; }

.sb-subject-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 8px;
  border-radius: 7px;
  margin: 0 6px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  position: relative;
}
.sb-subject-row:hover { background: var(--bg-subtle); }
.sb-subject-row.active { background: var(--gold-light); }

.sb-chevron {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--text-faint);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.sb-chevron:hover { background: var(--bg-hover); color: var(--text); }
.sb-chevron.open { transform: rotate(90deg); }
.sb-chevron svg { pointer-events: none; }

.sb-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.sb-dot:hover { transform: scale(1.4); box-shadow: 0 0 0 2px var(--border); }

.sb-subject-name {
  font-size: 0.875rem;
  font-weight: 600;
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.12s;
}
.sb-subject-row:hover .sb-subject-name,
.sb-subject-row.active .sb-subject-name { color: var(--text); }

.sb-subject-actions {
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
}
.sb-subject-row:hover .sb-subject-actions { opacity: 1; }

.sb-icon-btn {
  background: none;
  border: none;
  padding: 3px 4px;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.sb-icon-btn:hover { background: var(--bg-subtle); color: var(--text); }
.sb-delete-btn:hover { color: var(--error); }

/* Units */
.sb-units-list { padding: 2px 0 4px 20px; }

.sb-unit-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 6px 1px 0;
  transition: var(--transition);
  user-select: none;
}
.sb-unit-item:hover { background: var(--bg-subtle); color: var(--text); }
.sb-unit-item.active { background: var(--gold-light); color: var(--gold-dark); font-weight: 500; }
.sb-unit-item.drag-over { background: var(--gold-light); border: 1.5px dashed var(--gold); }

.sb-unit-dash { flex-shrink: 0; color: var(--text-faint); }
.sb-unit-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-unit-count {
  font-size: 0.6875rem;
  background: var(--bg-subtle);
  border-radius: 10px;
  padding: 1px 6px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.sb-add-unit-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: var(--text-faint);
  cursor: pointer;
  border-radius: 5px;
  margin: 0 6px 0 0;
  transition: color 0.12s;
}
.sb-add-unit-btn:hover { color: var(--gold); }

/* Keep old classes for backwards compat with anything that references them */
.subject-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sidebar-add-subject { display: none; }

/* ===== RIGHT PANEL ===== */
.right-panel {
  width: var(--right-panel-width);
  min-width: var(--right-panel-width);
  background: var(--bg);
  border-left: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.panel-section-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-section-subtitle {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.up-next-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition);
  cursor: pointer;
}
.up-next-item:last-child {
  border-bottom: none;
}
.up-next-item:hover .up-next-title {
  color: var(--gold);
}
.up-next-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-top: 5px;
  flex-shrink: 0;
}
.up-next-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  transition: var(--transition);
  line-height: 1.3;
}
.up-next-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.add-reminder-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 0;
  transition: var(--transition);
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}
.add-reminder-btn:hover {
  color: var(--gold);
  border-top-color: var(--gold);
}

/* ===== MINI CALENDAR ===== */
.mini-calendar {
  background: var(--bg);
}
.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.875rem;
  font-weight: 600;
}
.mini-cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.mini-cal-nav:hover {
  color: var(--gold);
}
.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.mini-cal-day-label {
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-faint);
  padding: 4px 0;
}
.mini-cal-day {
  text-align: center;
  font-size: 0.8125rem;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}
.mini-cal-day:hover {
  background: var(--gold-light);
  color: var(--gold);
}
.mini-cal-day.today {
  background: var(--gold);
  color: #000;
  font-weight: 700;
}
.mini-cal-day.other-month {
  color: var(--text-faint);
}
.mini-cal-day.has-event::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
  margin: 1px auto 0;
}
.mini-cal-day.today.has-event::after {
  background: #000;
}
/* Selected day ring */
.mini-cal-day.selected:not(.today) {
  background: var(--bg-subtle);
  color: var(--text);
  outline: 1.5px solid var(--gold);
  outline-offset: -1px;
  font-weight: 600;
}
.mini-cal-day.today.selected {
  outline: 2px solid var(--gold-dark);
  outline-offset: -2px;
}

/* ===== MINI-CALENDAR DAY TASKS PANEL ===== */
.mini-cal-tasks {
  margin-top: 10px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  animation: fadeIn 0.15s ease;
}
.mini-cal-tasks-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 7px;
}
.mini-cal-tasks-empty {
  font-size: 0.8125rem;
  color: var(--text-faint);
  padding: 4px 0 2px;
}
.mini-cal-task-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.mini-cal-task-item:last-child { border-bottom: none; }
.mini-cal-task-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mini-cal-task-title {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-cal-task-type {
  font-size: 0.6875rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

/* ===== NOTE CARDS ===== */
.note-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 10px;
}
.note-card:hover {
  border-color: rgba(212,175,55,0.4);
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.note-icon {
  width: 38px;
  height: 38px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}
.note-info { flex: 1; min-width: 0; }
.note-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.note-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.note-meta .note-meta-sep {
  color: var(--text-faint);
  margin: 0 1px;
}
.note-time {
  font-size: 0.75rem;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== SUGGESTED CARDS ===== */
.suggested-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.suggested-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.suggested-card:hover {
  border-color: rgba(212,175,55,0.4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.suggested-tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 10px;
}
.suggested-tag-gold  { background: var(--gold-light); color: var(--gold-dark); }
.suggested-tag-red   { background: rgba(239,68,68,0.1); color: #dc2626; }
.suggested-tag-blue  { background: rgba(59,130,246,0.1); color: #2563eb; }
.suggested-tag-green { background: rgba(34,197,94,0.1); color: #16a34a; }
.suggested-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}
.suggested-subject {
  font-size: 0.8125rem;
  color: var(--text-muted);
}
/* Notes page section heading row */
.notes-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.notes-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.notes-section-action {
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
  font-weight: 500;
  text-decoration: none;
}
.notes-section-action:hover { color: var(--gold); }

/* ===== FLASHCARDS ===== */
.flashcard-scene {
  perspective: 1000px;
}
.flashcard {
  width: 100%;
  height: 200px;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.5s ease;
  cursor: pointer;
}
.flashcard.flipped {
  transform: rotateY(180deg);
}
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--bg);
}
.flashcard-face.back {
  transform: rotateY(180deg);
  background: var(--gold-subtle);
  border-color: var(--gold);
}
.flashcard-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.flashcard-face.back .flashcard-label {
  color: var(--gold-dark);
}
.flashcard-text {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 0.2s ease;
}
.modal-header {
  padding: 24px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  background: none;
  border: none;
}
.modal-close:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.modal-body {
  padding: 20px 24px;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== NOTE EDITOR ===== */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  flex-wrap: wrap;
}
.toolbar-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  background: none;
  border: 1.5px solid transparent;
  font-size: 0.8125rem;
  font-weight: 600;
}
.toolbar-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: var(--border);
}
.toolbar-btn.active {
  background: var(--gold-light);
  color: var(--gold);
  border-color: rgba(212,175,55,0.3);
}
.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}
.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.color-swatch:hover, .color-swatch.active {
  border-color: var(--text);
  transform: scale(1.15);
}
.color-swatch.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-light);
}

.scan-dropdown {
  position: relative;
}
.scan-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 20;
  display: none;
  animation: scaleIn 0.15s ease;
  overflow: hidden;
}
.scan-menu.open {
  display: block;
}
.scan-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}
.scan-menu-item:hover {
  background: var(--gold-light);
  color: var(--gold);
}

/* ===== PROGRESS BAR ===== */
.progress-bar-track {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ===== DIFFICULTY SELECTOR ===== */
.difficulty-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.difficulty-tab {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  background: var(--bg);
  transition: var(--transition);
}
.difficulty-tab:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.difficulty-tab.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #000;
  font-weight: 600;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
  max-width: 320px;
}
.toast.success { background: #16A34A; }
.toast.error { background: var(--error); }
.toast.gold { background: var(--gold-dark); color: #fff; }

/* ===== SOCIAL AUTH BUTTONS ===== */
.social-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 20px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text);
}
.social-btn:hover {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-light);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}
.empty-state-icon {
  font-size: 2.5rem;
  opacity: 0.4;
}
.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.empty-state-desc {
  font-size: 0.875rem;
  color: var(--text-faint);
  max-width: 260px;
}

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-faint);
  font-size: 0.8125rem;
  margin: 20px 0;
}
.divider-text::before, .divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== DROPDOWN SELECT ===== */
select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ===== CHIP / MULTI-SELECT ===== */
.chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  background: var(--bg);
  user-select: none;
}
.chip:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-light);
}
.chip.selected {
  background: var(--gold);
  border-color: var(--gold);
  color: #000;
  font-weight: 600;
}

/* ===== GRAMMAR SUGGESTION ===== */
.suggestion-item {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: var(--transition);
}
.suggestion-item:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-xs);
}
.suggestion-type {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.suggestion-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.suggestion-fix {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--success);
  margin-top: 4px;
}
.highlight-grammar { background: rgba(239,68,68,0.15); border-bottom: 2px solid var(--error); border-radius: 2px; }
.highlight-spelling { background: rgba(59,130,246,0.12); border-bottom: 2px solid var(--blue); border-radius: 2px; }
.highlight-clarity { background: rgba(245,158,11,0.12); border-bottom: 2px solid var(--warning); border-radius: 2px; }
.highlight-ai { background: rgba(168,85,247,0.12); border-bottom: 2px solid #A855F7; border-radius: 2px; }
.highlight-ai { background: rgba(212,175,55,0.15); border-bottom: 2px solid var(--gold); border-radius: 2px; }

/* ===== CONTEXT MENU ===== */
.context-menu {
  position: fixed;
  z-index: 300;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 188px;
  overflow: hidden;
  animation: scaleIn 0.12s ease;
  transform-origin: top left;
}
.context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
}
.context-item:hover {
  background: var(--gold-light);
  color: var(--gold);
}
.context-item.danger { color: var(--text-secondary); }
.context-item.danger:hover {
  background: var(--error-light);
  color: var(--error);
}
.context-divider {
  height: 1px;
  background: var(--border);
  margin: 3px 0;
}

/* ===== SEARCH MODAL ===== */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  animation: fadeIn 0.15s ease;
}
.search-modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1.5px solid var(--border);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
  animation: scaleIn 0.18s ease;
}
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.search-input-row svg { color: var(--text-muted); flex-shrink: 0; }
.search-input-main {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  background: transparent;
}
.search-input-main::placeholder { color: var(--text-faint); }
.search-close-btn {
  color: var(--text-faint);
  font-size: 1.125rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
  background: none;
  border: none;
  line-height: 1;
}
.search-close-btn:hover { background: var(--bg-muted); color: var(--text); }
.search-results-list { max-height: 360px; overflow-y: auto; }
.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-subtle);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--gold-light); }
.search-result:hover .search-result-title { color: var(--gold); }
.search-result-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.search-result-title { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.search-result-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
.search-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9375rem;
}

/* ===== PROFILE MODAL ===== */
.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.profile-card {
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 0.2s ease;
}
.profile-header {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 20px;
  background: linear-gradient(180deg, var(--gold-subtle) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}
.profile-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  background: none;
  border: none;
  font-size: 1.125rem;
}
.profile-close:hover { background: var(--bg-muted); color: var(--text); }
.profile-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gold-light);
  border: 3px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold-dark);
  margin-bottom: 12px;
  box-shadow: 0 0 0 4px var(--gold-subtle);
}
.profile-name { font-size: 1.125rem; font-weight: 700; margin-bottom: 2px; }
.profile-email { font-size: 0.875rem; color: var(--text-muted); }
.profile-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--border);
  padding: 0 16px;
}
.profile-tab {
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  transition: var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.profile-tab:hover { color: var(--text); }
.profile-tab.active { color: var(--gold); border-bottom-color: var(--gold); font-weight: 600; }
.profile-tab-content { padding: 20px 24px; }
.profile-tab-pane { display: none; }
.profile-tab-pane.active { display: block; }
.settings-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
  margin-top: 20px;
}
.settings-section-label:first-child { margin-top: 0; }
.theme-options {
  display: flex;
  gap: 8px;
}
.theme-option {
  flex: 1;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}
.theme-option:hover { border-color: var(--gold); }
.theme-option.active {
  border-color: var(--gold);
  background: var(--gold-light);
}
.theme-option-icon { font-size: 1.25rem; margin-bottom: 4px; }
.theme-option-label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }
.plan-card {
  background: var(--gold-subtle);
  border: 1.5px solid rgba(212,175,55,0.25);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.plan-name {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.plan-detail { font-size: 0.8125rem; color: var(--text-muted); }
.cancel-btn {
  width: 100%;
  padding: 10px;
  border: 1.5px solid var(--error-light);
  border-radius: var(--radius);
  color: var(--error);
  background: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 12px;
}
.cancel-btn:hover { background: var(--error-light); border-color: var(--error); }
.profile-signout {
  width: 100%;
  padding: 12px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-top: 1px solid var(--border);
  transition: var(--transition);
}
.profile-signout:hover { color: var(--error); background: var(--error-light); }

/* ===== NOTABILITY TOOLBAR ===== */
.notability-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;   /* center the tool strip */
  gap: 0;
  padding: 0;
  background: var(--bg);
  border-bottom: none;
  overflow: hidden;          /* clip outside the scroll track */
  flex-shrink: 0;
  user-select: none;
  position: relative;
  z-index: 20;
  height: 52px;
}

/* Scrollable inner strip — centered, shows ~5 tools, swipe for more */
.nb-scroll-track {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;           /* Firefox */
  padding: 6px 20px;
  max-width: 340px;                /* shows ~5 tools before scrolling */
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.nb-scroll-track::-webkit-scrollbar { display: none; }
.nb-scroll-track > * { scroll-snap-align: start; flex-shrink: 0; }
.nb-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.nb-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}
.nb-btn {
  width: 38px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition-fast);
  background: none;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  position: relative;
}
.nb-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.nb-btn.active {
  background: var(--gold-light);
  border-color: rgba(212,175,55,0.35);
  color: var(--gold-dark);
}
.nb-btn svg { pointer-events: none; }
.nb-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
  outline: none;
  background: var(--c, #111);
}
.nb-color-swatch:hover, .nb-color-swatch.active {
  border-color: white;
  box-shadow: 0 0 0 2px var(--c, #111);
  transform: scale(1.18);
}
.nb-width {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition-fast);
}
.nb-width:hover { background: var(--bg-subtle); }
.nb-width.active {
  background: var(--gold-light);
  border-color: rgba(212,175,55,0.35);
}
.nb-width-line {
  background: var(--text);
  border-radius: 4px;
  width: 18px;
}
.pen-indicator {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

/* ===== NOTE SHEET (editor in center) ===== */
.note-sheet-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.note-sheet-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1.5px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.note-title-edit {
  flex: 1;
  font-size: 1.0625rem;
  font-weight: 700;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  color: var(--text);
  letter-spacing: -0.01em;
}
.note-title-edit::placeholder { color: var(--text-faint); }
.note-autosave {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-faint);
  flex-shrink: 0;
}
.note-autosave-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.note-canvas-wrap {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 12px;
  margin: 10px 12px 10px;
}
.note-canvas-wrap.template-blank { background: white; }
.note-canvas-wrap.template-lined {
  background-image: repeating-linear-gradient(
    transparent 0px, transparent 31px,
    #e5e7eb 31px, #e5e7eb 32px
  );
  background-attachment: local;
  background-position: 0 48px;
}
.note-canvas-wrap.template-grid {
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: local;
}
.note-canvas-wrap.template-dots {
  background-image: radial-gradient(circle, #cbd5e1 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 12px 12px;
  background-attachment: local;
}
.note-canvas-wrap.template-cornell {
  background-image:
    linear-gradient(90deg, #e5e7eb 1px, transparent 1px),
    repeating-linear-gradient(transparent 0px, transparent 31px, #e5e7eb 31px, #e5e7eb 32px);
  background-size: 200px 100%, 100% 32px;
  background-position: 0 0, 0 64px;
  background-attachment: local;
}
.note-canvas-wrap.template-slide {
  background: white;
  outline: 2px solid var(--border);
  outline-offset: -2px;
}
#drawing-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  /* height is set entirely by JS (_setCanvasHeight) — no CSS height here */
  touch-action: none;
  display: block;
}
.text-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  /* min-height is kept in sync with canvas height by JS; text grows the layer */
  min-height: 100%;
  height: auto;
  padding: 28px 40px;
  font-size: 1rem;
  line-height: 1.75;
  color: #1a1a1a; /* always dark — canvas stays light even in dark mode */
  pointer-events: none;
  overflow-y: auto;
  font-family: var(--font);
  z-index: 2;
}
.text-layer.active {
  pointer-events: all;
  outline: none;
  cursor: text;
}
/* Keep selection readable on the always-light canvas */
.text-layer ::selection,
.text-layer::selection {
  background: rgba(212, 175, 55, 0.35);
  color: #1a1a1a;
}
body.dark-mode .text-layer ::selection,
body.dark-mode .text-layer::selection {
  background: rgba(212, 175, 55, 0.4);
  color: #1a1a1a;
}
/* Restore list styling inside the note editor */
.text-layer ul {
  list-style-type: disc;
  padding-left: 24px;
  margin: 4px 0;
}
.text-layer ol {
  list-style-type: decimal;
  padding-left: 24px;
  margin: 4px 0;
}
.text-layer li {
  margin: 2px 0;
  line-height: 1.75;
}
.text-layer:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

/* template selector dropdown */
.template-dropdown-wrap { position: relative; }
.template-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 30;
  overflow: hidden;
  display: none;
  animation: scaleIn 0.15s ease;
}
.template-dropdown-menu.open { display: block; }
.template-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
}
.template-option:hover { background: var(--gold-light); color: var(--gold); }
.template-option.active { color: var(--gold); font-weight: 600; }

/* ===== CALENDAR DAY EVENTS ===== */
.cal-day-events {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  animation: fadeIn 0.2s ease;
}
.cal-day-header {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.cal-event {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.cal-event:last-of-type { border-bottom: none; }
.cal-event:hover { color: var(--gold); }
.cal-event-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.cal-event-name { flex: 1; font-weight: 500; }
.cal-event-type { font-size: 0.6875rem; color: var(--text-faint); }
.cal-add-event {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px 0;
  margin-top: 2px;
  transition: var(--transition);
}
.cal-add-event:hover { color: var(--gold); }

/* ===== SIDEBAR (CLEAN) ===== */
.sidebar-subjects-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 16px 16px 6px;
}
.sidebar-empty-hint {
  padding: 20px 16px;
  font-size: 0.8125rem;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.5;
}
.sidebar-add-unit {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 16px 5px 36px;
  font-size: 0.8125rem;
  color: var(--text-faint);
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-add-unit:hover { color: var(--gold); }

/* ===== EMPTY NOTE STATE ===== */
.notes-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
  gap: 16px;
}
.notes-empty-icon {
  width: 80px;
  height: 80px;
  background: var(--gold-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.notes-empty-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.notes-empty-desc {
  font-size: 0.9375rem;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.5;
}

/* ===== WELCOME STATE — subject quick-start chips ===== */
.welcome-subjects {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.welcome-subjects-label {
  font-size: 0.8125rem;
  color: var(--text-faint);
}
.welcome-subject-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 400px;
}
.welcome-subject-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.welcome-subject-chip:hover {
  border-color: var(--gold);
  background: var(--gold-subtle);
  color: var(--gold-dark);
}
.welcome-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== DARK MODE ===== */
/* html.dark-mode fires immediately from the inline theme-guard script in <head>
   (before stylesheets load), so variables are dark from first paint — no white flash. */
html.dark-mode,
body.dark-mode {
  --bg: #1a1a1a;
  --bg-subtle: #222222;
  --bg-muted: #2a2a2a;
  --text: #f0f0f0;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;
  --border: #333333;
  --border-subtle: #2a2a2a;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}
/* Note canvas stays light grey in dark mode — paper should always be light */
body.dark-mode .note-canvas-wrap.template-blank   { background: #f2f2f2; }
body.dark-mode .note-canvas-wrap.template-lined   { background-color: #f2f2f2; background-image: repeating-linear-gradient(transparent 0px, transparent 31px, #d1d5db 31px, #d1d5db 32px); }
body.dark-mode .note-canvas-wrap.template-grid    { background-color: #f2f2f2; background-image: linear-gradient(#d1d5db 1px, transparent 1px), linear-gradient(90deg, #d1d5db 1px, transparent 1px); }
body.dark-mode .note-canvas-wrap.template-dots    { background-color: #f2f2f2; background-image: radial-gradient(circle, #b0b7c3 1px, transparent 1px); }
body.dark-mode .note-canvas-wrap.template-cornell { background-color: #f2f2f2; background-image: linear-gradient(90deg, #d1d5db 1px, transparent 1px), repeating-linear-gradient(transparent 0px, transparent 31px, #d1d5db 31px, #d1d5db 32px); background-size: 200px 100%, 100% 32px; }
body.dark-mode .note-canvas-wrap.template-slide   { background: #f2f2f2; }
body.dark-mode .nb-tool-dropdown { background: var(--bg); border-color: var(--border); }
body.dark-mode .task-item { border-color: var(--border); }
body.dark-mode .overdue-alert { border-color: rgba(239,68,68,0.35); }

/* ===== RENAME INLINE INPUT ===== */
.note-rename-input {
  background: var(--bg);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  width: 100%;
  box-shadow: 0 0 0 3px var(--gold-light);
}

/* ===== TEXT LAYER (canvas overlay) ===== */
#note-text-layer {
  pointer-events: none; /* canvas gets events by default */
}
#note-text-layer.active {
  pointer-events: auto;
}

/* ===== TEXT FORMAT TOOLBAR (nb-select) ===== */
.nb-select {
  height: 32px;
  padding: 0 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
}
.nb-select:focus, .nb-select:hover { border-color: var(--gold); }
.nb-select-sm { width: 50px; }
/* Text bar: second row beneath the tool strip, centred pill */
.notability-toolbar { flex-direction: column; height: auto; padding: 6px 12px; }
.notability-toolbar .nb-scroll-track { flex-shrink: 0; }

.nb-text-bar {
  display: none;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  padding: 5px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  max-width: 90vw;
  margin-top: 4px;
  margin-bottom: 2px;
}
.nb-text-bar.visible { display: flex; }
.nb-text-bar::-webkit-scrollbar { display: none; }

/* ===== LASSO ACTIONS MENU ===== */
.lasso-actions {
  position: fixed;
  z-index: 900;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lasso-action-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 8px 6px;
}
.lasso-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  transition: var(--transition-fast);
  font-family: var(--font);
}
.lasso-btn:hover { background: var(--bg-subtle); color: var(--text); }
.lasso-btn.danger { color: var(--error); }
.lasso-btn.danger:hover { background: var(--error-light); }
.lasso-btn.cancel { color: var(--text-faint); font-size: 0.8125rem; }

/* ===== MOVE SELECTION DRAG ===== */
.move-selection-drag {
  position: fixed;
  z-index: 800;
  cursor: grab;
  border: 1.5px dashed rgba(212,175,55,0.8);
  border-radius: 4px;
  user-select: none;
}
.move-selection-drag:active { cursor: grabbing; }

/* ===== ACHIEVEMENT BANNER ===== */
.achievement-banner {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: linear-gradient(135deg, var(--gold) 0%, #b8960c 100%);
  color: #000;
  border-radius: var(--radius);
  padding: 14px 24px;
  box-shadow: 0 8px 32px rgba(212,175,55,0.5);
  transition: top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 300px;
  max-width: 440px;
}
.achievement-banner.visible { top: 20px; }
.achievement-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
}
.achievement-banner-icon { font-size: 2rem; }
.achievement-banner-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.8;
}
.achievement-banner-name {
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.achievement-banner-pts {
  margin-left: auto;
  font-size: 1.25rem;
  font-weight: 800;
}

/* ===== ACHIEVEMENTS MODAL ===== */
.achievements-modal {
  background: var(--bg);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.achievements-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 24px 16px;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}
.achievements-title {
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
}
.achievements-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.achievements-close {
  background: none;
  border: none;
  font-size: 1.125rem;
  cursor: pointer;
  color: var(--text-faint);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.achievements-close:hover { color: var(--text); background: var(--bg-subtle); }
.achievements-list {
  overflow-y: auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.achievement-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-subtle);
  transition: var(--transition-fast);
}
.achievement-item.unlocked {
  background: var(--gold-light);
  border-color: rgba(212,175,55,0.3);
}
.achievement-item.locked { opacity: 0.5; }
.achievement-icon { font-size: 1.5rem; flex-shrink: 0; }
.achievement-info { flex: 1; }
.achievement-name {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 2px;
}
.achievement-desc { font-size: 0.8125rem; color: var(--text-muted); }
.achievement-pts {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-faint);
  flex-shrink: 0;
}
.achievement-pts.earned { color: var(--gold-dark); }

/* ===== TOGGLE SWITCH ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--gold);
  border-radius: 12px;
  transition: 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:not(:checked) + .toggle-track { background: var(--border); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(18px); }

/* ===== DRAWING CANVAS ===== */
#drawing-canvas {
  position: absolute;
  top: 0; left: 0;
  display: block;
  z-index: 1;
  cursor: crosshair;
  touch-action: none;
}

/* ===== LASSO CANVAS (sits above drawing canvas) ===== */
#lasso-canvas {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 5;
  touch-action: none;
}
#lasso-canvas.select-active { pointer-events: auto; }

/* ===== TOOL DROPDOWNS ===== */
.nb-tool-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.nb-tool-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 12px;
  min-width: 160px;
  z-index: 100;
  animation: scaleIn 0.15s ease;
  transform-origin: top center;
}
.nb-tool-dropdown.open {
  display: block;
}
.nb-dd-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.nb-dd-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.nb-dd-widths {
  display: flex;
  gap: 4px;
}
.nb-eraser-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  transition: var(--transition-fast);
  width: 100%;
}
.nb-eraser-mode:hover { border-color: var(--gold); color: var(--gold); }
.nb-eraser-mode.active {
  background: var(--gold-light);
  border-color: rgba(212,175,55,0.35);
  color: var(--gold-dark);
  font-weight: 600;
}

/* ===== PAGE NUMBER DISPLAY ===== */
/* ===== NOTE IMAGE LAYER ===== */
#note-images-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* layer itself transparent — wrappers opt in */
  z-index: 7;           /* above lasso(5), below text-layer(8) */
}
.note-image-wrapper {
  position: absolute;
  pointer-events: auto;
  cursor: grab;
  border-radius: 6px;
  /* Subtle drop-shadow so image floats above the page */
  filter: drop-shadow(0 2px 10px rgba(0,0,0,0.12));
  transition: filter 0.12s;
}
.note-image-wrapper:active { cursor: grabbing; }
.note-image-wrapper.selected {
  filter: drop-shadow(0 4px 16px rgba(212,175,55,0.35));
}
.note-image-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  pointer-events: none;
  user-select: none;
}

/* Dotted gold selection border */
.note-image-selection {
  display: none;
  position: absolute;
  inset: -3px;
  border: 2px dashed var(--gold);
  border-radius: 9px;
  pointer-events: none;
  animation: imgSelectionAppear 0.12s ease-out;
}
.note-image-wrapper.selected .note-image-selection { display: block; }
@keyframes imgSelectionAppear {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* Corner resize handles */
.note-image-handle {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gold);
  box-shadow: 0 1px 5px rgba(0,0,0,0.18);
  pointer-events: auto;
  z-index: 1;
  transition: transform 0.1s, box-shadow 0.1s;
}
.note-image-handle:hover {
  transform: scale(1.25);
  box-shadow: 0 2px 8px rgba(212,175,55,0.5);
}
.note-image-handle-nw { top: -7px;    left: -7px;    cursor: nw-resize; }
.note-image-handle-ne { top: -7px;    right: -7px;   cursor: ne-resize; }
.note-image-handle-se { bottom: -7px; right: -7px;   cursor: se-resize; }
.note-image-handle-sw { bottom: -7px; left: -7px;    cursor: sw-resize; }

/* Make text layer sit above image layer for typing */
#note-text-layer { z-index: 8; }

/* ===== SCROLL-TO-TOP BUTTON (replaces old page counter) ===== */
.scroll-top-btn {
  position: sticky;
  bottom: 18px;
  float: right;
  margin-right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.scroll-top-btn:hover {
  background: var(--gold-subtle);
  border-color: var(--gold);
  color: var(--gold);
}
/* Unit filter breadcrumb */
.unit-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 18px;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.unit-filter-bar .filter-crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-light);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  color: var(--gold-dark);
  font-weight: 600;
  font-size: 0.8125rem;
}
.unit-filter-bar .filter-clear {
  cursor: pointer;
  opacity: 0.7;
  font-size: 0.75rem;
  margin-left: 4px;
}
.unit-filter-bar .filter-clear:hover { opacity: 1; }

/* ===== GOLD BURST ANIMATION ===== */
/* ===== TASK COMPLETION — BORDER SHIMMER ===== */
/* Shimmer ring: a fixed overlay that traces the task's border */
.task-border-shimmer {
  position: fixed;
  border-radius: var(--radius, 10px);
  border: 2.5px solid var(--gold);
  pointer-events: none;
  z-index: 9000;
  animation: borderShimmerIn 0.22s ease-out forwards;
  box-shadow:
    0 0 10px 3px rgba(212,175,55,0.55),
    inset 0 0 8px 2px rgba(212,175,55,0.18);
}
.task-border-shimmer.dissolving {
  animation: borderShimmerOut 0.28s ease-in forwards;
}
@keyframes borderShimmerIn {
  0%   { opacity: 0; box-shadow: 0 0 0 0 rgba(212,175,55,0); }
  40%  { opacity: 1; }
  100% { opacity: 1; box-shadow: 0 0 14px 5px rgba(212,175,55,0.6), inset 0 0 8px 2px rgba(212,175,55,0.2); }
}
@keyframes borderShimmerOut {
  to   { opacity: 0; box-shadow: 0 0 0 0 rgba(212,175,55,0); transform: scale(1.04); }
}

/* Perimeter particles — each starts on an edge and shoots outward */
.border-burst-particle {
  position: fixed;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9001;
  animation: borderParticleOut 0.48s ease-out var(--delay, 0s) forwards;
}
@keyframes borderParticleOut {
  0%   { transform: translate(-50%, -50%) rotate(var(--angle)) translateX(0)              scale(1);   opacity: 1; }
  70%  { opacity: 0.7; }
  100% { transform: translate(-50%, -50%) rotate(var(--angle)) translateX(var(--travel))  scale(0);   opacity: 0; }
}

/* ===== OVERDUE ALERT ===== */
.overdue-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--error-light);
  border: 1.5px solid rgba(239,68,68,0.25);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  color: var(--error);
  font-size: 0.875rem;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

/* ===== TASK OVERDUE BADGE ===== */
.task-overdue-badge {
  display: inline-block;
  background: var(--error-light);
  color: var(--error);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: 8px;
  vertical-align: middle;
}

/* ===== TASK COMPLETE BUTTON (no checkmark — circle only) ===== */
.task-complete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-faint);
  transition: var(--transition-fast);
  border: none;
  background: none;
}
.task-complete-btn:hover {
  color: var(--gold);
  background: var(--gold-light);
}

/* ===== ACHIEVEMENT ICON (text abbr styled as badge) ===== */
.achievement-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold-light);
  color: var(--gold-dark);
  font-size: 0.6875rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.achievement-item.unlocked .achievement-icon {
  background: var(--gold);
  color: #000;
}
.achievement-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.2);
  color: #000;
  font-size: 0.75rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

/* ===== THEME OPTION ICON (SVG-based, no emoji) ===== */
.theme-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  margin-bottom: 4px;
  color: var(--text-secondary);
}
.theme-option:hover .theme-option-icon,
.theme-option.active .theme-option-icon {
  color: var(--gold-dark);
}

/* ===================================================
   RESILIENCE SYSTEM — Error Boundary, UI States,
   Skeleton Loaders, Form Persistence
   =================================================== */

/* ---- Skeleton shimmer ---- */
@keyframes sk-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.sk-line, .sk-circle, .sk-card {
  background: linear-gradient(90deg,
    var(--bg-muted) 25%,
    var(--border-subtle) 50%,
    var(--bg-muted) 75%
  );
  background-size: 600px 100%;
  animation: sk-shimmer 1.4s infinite linear;
  border-radius: var(--radius-xs);
}
/* Skeleton row (list variant) */
.sk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.sk-row:last-child { border-bottom: none; }
.sk-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-line { height: 10px; }
.sk-line-lg    { height: 13px; }
.sk-line-sm    { height: 9px; }
.sk-line-title { height: 16px; margin-bottom: 8px; }
.sk-line-body  { height: 11px; }
/* Skeleton card (card variant) */
.sk-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sk-card .sk-line {
  background: linear-gradient(90deg,
    var(--bg-muted) 25%,
    var(--border-subtle) 50%,
    var(--bg-muted) 75%
  );
  background-size: 600px 100%;
  animation: sk-shimmer 1.4s infinite linear;
}

/* ---- Shared state wrapper ---- */
.st-state-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 10px;
}
.st-state-icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  margin-bottom: 4px;
}
.st-state-icon--error { background: var(--error-light); }
.st-state-emoji { font-size: 2rem; line-height: 1; margin-bottom: 4px; }
.st-state-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.st-state-body {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
  max-width: 280px;
  line-height: 1.5;
}
.st-state-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 6px 0 0;
}
.st-state-empty .st-state-title { color: var(--text-muted); }
/* Retry button */
.st-retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.st-retry-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-subtle, rgba(212,175,55,0.06));
}
/* Spinner */
.st-spinner {
  animation: spin 0.8s linear infinite;
  display: flex; align-items: center; justify-content: center;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Inline component error ---- */
.st-component-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--error-light);
  background: var(--error-light);
  font-size: 0.8125rem;
  color: var(--error);
}
.st-component-error button {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--error);
  background: transparent;
  color: var(--error);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.st-component-error button:hover { background: var(--error); color: #fff; }

/* ---- Full-page error boundary overlay ---- */
#st-error-boundary-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.dark-mode #st-error-boundary-overlay {
  background: rgba(10,10,10,0.92);
}
.st-eb-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.st-eb-icon { margin-bottom: 4px; }
.st-eb-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.st-eb-body {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}
.st-eb-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.st-eb-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  background: var(--gold);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}
.st-eb-btn-primary:hover { background: var(--gold-dark); }
.st-eb-btn-ghost {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.st-eb-btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }
.st-eb-details {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-faint);
  text-align: left;
  width: 100%;
}
.st-eb-details summary { cursor: pointer; color: var(--text-muted); margin-bottom: 8px; }
.st-eb-details pre {
  background: var(--bg-muted);
  border-radius: var(--radius-xs);
  padding: 10px;
  overflow: auto;
  max-height: 140px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.6875rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ---- Form persistence ---- */
.st-draft-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.3s;
  margin-right: 8px;
}
.st-draft-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

/* ---- 404 page ---- */
.pg-404 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  background: var(--bg);
  gap: 16px;
}
.pg-404-code {
  font-size: 7rem;
  font-weight: 800;
  line-height: 1;
  color: var(--gold);
  letter-spacing: -4px;
  margin: 0;
}
.pg-404-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.pg-404-body {
  font-size: 0.9375rem;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.6;
  margin: 0;
}
.pg-404-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== TEXT BAR COLOUR PICKER ===== */
.txt-color-wrap {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.txt-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  transition: transform 0.12s;
}
.txt-color-wrap:hover .txt-color-dot { transform: scale(1.15); }
.txt-color-popup {
  display: none;
  position: fixed;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 12px;
  z-index: 9999;
  animation: scaleIn 0.15s ease;
  transform-origin: top center;
}
.txt-color-popup.open { display: block; }

/* ===== RIGHT PANEL COLLAPSE ===== */
.rp-content { display: flex; flex-direction: column; gap: 24px; flex: 1; overflow-y: auto; padding: 20px 16px; }
.rp-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  border: none; background: transparent;
  color: var(--text-faint); cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.rp-collapse-btn:hover { background: var(--bg-subtle); color: var(--text); }

/* Expand tab — hidden by default, visible when collapsed */
.rp-expand-tab {
  display: none;
  align-items: center; justify-content: center;
  width: 100%; height: 48px;
  border: none; background: transparent;
  color: var(--text-faint); cursor: pointer;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.rp-expand-tab:hover { color: var(--gold); }

/* Collapsed state */
.dashboard-shell.rp-collapsed {
  --right-panel-width: 36px;
}
.dashboard-shell.rp-collapsed .right-panel {
  padding: 0;
  overflow: hidden;
  align-items: center;
  border-left-color: var(--border);
}
.dashboard-shell.rp-collapsed .rp-content { display: none; }
.dashboard-shell.rp-collapsed .rp-expand-tab { display: flex; }

/* Smooth transition */
.right-panel { transition: width 0.22s ease, min-width 0.22s ease; }

/* ===== LANDING PAGE ===== */
.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.landing-logo {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.landing-logo span { color: var(--gold); }

.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 72px 24px 56px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}
.landing-icon {
  width: 72px;
  height: 72px;
  background: var(--gold-subtle, #fffbeb);
  border: 1.5px solid var(--gold);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  box-shadow: 0 0 28px var(--gold-glow, rgba(212,175,55,0.25));
}
.landing-headline {
  font-size: clamp(1.875rem, 5vw, 2.625rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 14px;
}
.landing-sub {
  font-size: 1.0625rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 36px;
  max-width: 500px;
}
.landing-ctas {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 14px;
}
.landing-fine {
  font-size: 0.8125rem;
  color: var(--text-faint);
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 64px;
  width: 100%;
}
.lf-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg, 14px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lf-card:hover {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-light);
}
.lf-icon {
  width: 34px;
  height: 34px;
  background: var(--gold-subtle, #fffbeb);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  margin-bottom: 2px;
}
.lf-label { font-size: 0.9375rem; font-weight: 700; color: var(--text); }
.lf-desc  { font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5; }

.landing-footer-cta {
  text-align: center;
  padding: 48px 24px 72px;
  border-top: 1px solid var(--border-subtle);
}

/* ===== PRICING CARDS (onboarding step 12) ===== */
.pricing-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 0 auto;
  text-align: left;
}
.pricing-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  padding: 20px 18px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}
.pricing-card:hover { border-color: var(--gold); }
.pricing-card-featured {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-light);
}
.pricing-card-selected {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 4px var(--gold-light) !important;
}
.pricing-badge-pill {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #000;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 99px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.pricing-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.pricing-price {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.03em;
}
.pricing-period { font-size: 0.875rem; font-weight: 400; color: var(--text-muted); }
.pricing-select-btn { margin-top: 4px; width: 100%; justify-content: center; }

.pricing-details {
  margin-top: 4px;
  font-size: 0.8125rem;
}
.pricing-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  padding: 4px 0;
  user-select: none;
  list-style: none;
}
.pricing-details summary::-webkit-details-marker { display: none; }
.pricing-details summary::before { content: '▸ '; font-size: 0.7rem; }
details[open] .pricing-details summary::before,
.pricing-details[open] summary::before { content: '▾ '; }
.pricing-feature-list {
  list-style: none;
  padding: 8px 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

@media (max-width: 600px) {
  .pricing-cards { grid-template-columns: 1fr; }
}

/* ===== PLAN LOCK SHIELD ===== */
/* Legacy — kept so old references don't crash; no longer injected */
.plan-lock-shield { display: none; }

/* ── Lock strip: integrated bottom banner inside a card ── */
.feature-lock-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 10px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 0.8125rem;
  color: var(--text-muted);
  pointer-events: none;
}
.feature-lock-strip strong { color: var(--text); }

/* ===== APPLE SIGN-IN BUTTON ===== */
.social-btn-apple {
  background: #000;
  color: #fff;
  border-color: #000;
}
.social-btn-apple:hover {
  background: #111;
  border-color: #111;
}

/* ===== PLAN-FREE: remove gold glow when subscription is cancelled ===== */
body.plan-free .header-plan-badge {
  background: var(--bg-subtle) !important;
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
}
body.plan-free .task-border-shimmer { display: none !important; }
body.plan-free .badge-gold:not(.header-plan-badge) { /* leave other gold badges alone */ }
/* Profile subscription tab badge */
body.plan-free #ptab-subscription .plan-name .badge-gold {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-color: var(--border);
}
body.plan-free #ptab-subscription .plan-detail::after {
  content: ' · Subscription cancelled';
  color: var(--error, #ef4444);
  font-weight: 500;
}
