/* Subtle study-focused hover polish. Kept separate from the main app layout CSS. */
.topnav a {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Production hardening pass: responsive polish, light mode, and overflow safety */
:root {
  text-rendering: optimizeLegibility;
}

body {
  transition: background-color .22s ease, color .22s ease;
}

button,
input,
select,
textarea {
  font: inherit;
}

img,
svg,
canvas,
iframe {
  max-width: 100%;
}

.topbar,
.section,
.hero,
.student-dashboard,
.notes-library-layout,
.notes-shell,
.modal,
.auth-card,
.glass-card,
.category-card,
.note-card,
.dash-card {
  min-width: 0;
}

.card-title,
.section-title,
.dash-card-title,
.dash-progress-name span,
.dash-list-item strong,
.notes-category-filter span,
.account-name,
.pre-auth-content h1 {
  overflow-wrap: anywhere;
  word-break: normal;
}

.primary-button,
.secondary-button,
.ghost-button,
.dash-mini-link,
.dash-tiny-btn,
.notes-category-filter,
.notes-chapter-button,
.note-chip-action {
  min-width: max-content;
  white-space: nowrap;
  touch-action: manipulation;
}

.topnav a.active,
.topnav a[aria-current="page"] {
  background: rgba(255,255,255,.13);
  border-color: rgba(255,255,255,.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 12px 28px rgba(0,0,0,.18);
}

.notes-control-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 220px) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin: 18px 0;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255,255,255,.065), rgba(255,255,255,.025));
}

.notes-search-field,
.notes-sort-field {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 850;
}

.notes-search-field input,
.notes-sort-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 15px;
  outline: none;
  padding: 10px 13px;
  color: var(--text);
  background: rgba(0,0,0,.22);
}

.notes-search-field input:focus,
.notes-sort-field select:focus {
  border-color: rgba(255,255,255,.34);
  box-shadow: 0 0 0 3px rgba(255,255,255,.06);
}

.note-card-tools {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin: -4px 0 8px;
}

.note-chip-action {
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--text-soft);
  background: rgba(255,255,255,.045);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}

.note-chip-action:hover,
.note-chip-action.active {
  color: var(--text);
  border-color: rgba(255,255,255,.28);
  background: rgba(255,255,255,.12);
  transform: translateY(-1px);
}

.premium-empty-state {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  text-align: center;
  border: 1px dashed rgba(255,255,255,.16);
  border-radius: 24px;
  color: var(--text-soft);
  background: rgba(255,255,255,.035);
}

.premium-empty-state strong {
  color: var(--text);
  font-size: 1.05rem;
}

.student-dashboard {
  width: min(100%, 1720px);
  margin-inline: auto;
  align-items: start;
}

.dash-card {
  transform: translateZ(0);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.dash-card:hover,
.note-card:hover,
.category-card:hover,
.glass-card:hover {
  border-color: rgba(255,255,255,.22);
  transform: translateY(-2px);
}

.dash-hero-stats {
  overflow: visible;
}

.dash-hero-stat,
.dash-list-item,
.dash-mini-widget,
.dash-quick-stat {
  min-width: 0;
}

.dash-hero-stat .dash-stat-value {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.05;
}

.dash-hero-stat .dash-stat-label,
.dash-hero-stat .dash-stat-sub,
.dash-mini-widget span,
.dash-pill,
.dash-list-item span,
.dash-list-item strong {
  min-width: 0;
}

.dash-task-form,
.dash-goal-form {
  align-items: stretch;
}

.dash-task-form input,
.dash-goal-form input,
.dash-date-button {
  min-width: 0;
}

.dash-task-item {
  gap: 12px;
}

.dash-goal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-achievements,
.dash-achievement-modal-grid {
  gap: 18px;
}

.dash-badge {
  min-width: 86px;
}

.dash-badge span,
.dash-badge small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-root.active {
  overscroll-behavior: contain;
}

.modal {
  max-width: calc(100vw - 20px);
}

.modal-body {
  overflow-wrap: anywhere;
}

body.light-mode {
  color-scheme: light;
}

body.light-mode .topbar,
body.light-mode .hero-panel,
body.light-mode .glass-card,
body.light-mode .category-card,
body.light-mode .note-card,
body.light-mode .sidebar-card,
body.light-mode .auth-card,
body.light-mode .dash-card,
body.light-mode .modal,
body.light-mode .student-tool-card,
body.light-mode .notes-category-rail,
body.light-mode .notes-content,
body.light-mode .notes-sidebar,
body.light-mode .notes-control-bar {
  background: linear-gradient(145deg, rgba(255,255,255,.96), rgba(247,247,249,.9)) !important;
  border-color: rgba(20,20,25,.13) !important;
  color: #111113 !important;
  box-shadow: 0 24px 70px rgba(18,18,24,.10);
}

body.light-mode .card-copy,
body.light-mode .lead,
body.light-mode .dash-stat-sub,
body.light-mode .dash-motivation,
body.light-mode .study-metric span,
body.light-mode .pdf-viewer-help,
body.light-mode .eyebrow,
body.light-mode .account-dropdown-subtitle {
  color: #5b5d66 !important;
}

body.light-mode .primary-button {
  background: #111113 !important;
  color: #fff !important;
}

body.light-mode .secondary-button,
body.light-mode .ghost-button,
body.light-mode .dash-mini-link,
body.light-mode .dash-tiny-btn,
body.light-mode .note-chip-action,
body.light-mode .notes-category-filter,
body.light-mode .notes-chapter-button,
body.light-mode .dash-quick-stat,
body.light-mode .dash-mini-widget,
body.light-mode .dash-list-item,
body.light-mode .dash-date-button,
body.light-mode .dash-date-popup,
body.light-mode .student-annotation,
body.light-mode .notes-search-field input,
body.light-mode .notes-sort-field select {
  background: rgba(255,255,255,.88) !important;
  border-color: rgba(20,20,25,.14) !important;
  color: #151518 !important;
}

body.light-mode input,
body.light-mode textarea,
body.light-mode select {
  color: #151518 !important;
  background-color: #fff !important;
}

body.light-mode .dash-chart-line,
body.light-mode .dash-symbol {
  color: #18181b;
  stroke: currentColor;
}

body.light-mode .dash-chart-fill {
  opacity: .55;
}

body.light-mode .pre-auth-overlay {
  background: radial-gradient(circle at top, rgba(0,0,0,.06), transparent 28%), linear-gradient(180deg, #f8f8fa, #ececef);
}

@media (max-width: 1180px) {
  .student-dashboard {
    grid-template-columns: 1fr !important;
  }

  .student-dashboard-side {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 860px) {
  html {
    scroll-padding-top: 16px;
  }

  #app {
    padding-inline: 14px !important;
  }

  .topbar {
    gap: 12px;
  }

  .topnav {
    scrollbar-width: none;
  }

  .topnav::-webkit-scrollbar {
    display: none;
  }

  .notes-control-bar,
  .dash-task-form,
  .dash-goal-form,
  .student-dashboard-side {
    grid-template-columns: 1fr !important;
  }

  .notes-library-layout {
    grid-template-columns: 1fr !important;
  }

  .notes-category-rail {
    position: relative !important;
    top: auto !important;
    max-height: none !important;
  }

  .dash-hero-stats,
  .dash-two-col,
  .dash-three-col,
  .dash-four-col,
  .dash-insight {
    grid-template-columns: 1fr !important;
  }

  .dash-hero-stat {
    border-right: 0 !important;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }

  .dash-hero-stat:last-child {
    border-bottom: 0;
  }

  .study-overview {
    grid-template-columns: 1fr !important;
  }

  .dash-chart {
    min-height: 210px;
  }
}

@media (max-width: 520px) {
  .section {
    margin-top: 18px !important;
  }

  .section-title {
    font-size: clamp(1.85rem, 11vw, 2.8rem) !important;
  }

  .category-grid,
  .notes-library-grid {
    gap: 14px !important;
  }

  .note-card,
  .category-card,
  .dash-card,
  .glass-card {
    border-radius: 22px !important;
    padding: 16px !important;
  }

  .hero-actions {
    display: flex;
    flex-wrap: wrap;
  }

  .hero-actions > *,
  .dash-goal-actions > *,
  .pdf-phone-actions > * {
    flex: 1 1 auto;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    max-width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .dash-list-item {
    grid-template-columns: auto minmax(0,1fr) !important;
  }

  .dash-task-item {
    align-items: start;
  }

  .dash-task-delete,
  .dash-goal-actions {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .dash-tiny-btn,
  .dash-task-delete {
    min-height: 36px;
  }

  .pre-auth-overlay {
    overflow-y: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

.topnav a::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 6px;
  height: 1.5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.92), rgba(255,255,255,0));
  transform: scaleX(0);
  transform-origin: center;
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.topnav a:hover::after,
.topnav a:focus-visible::after {
  transform: scaleX(1);
  opacity: 1;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.category-card,
.note-card,
.glass-card,
.metric-card,
.auth-card,
.hero-panel,
.sidebar-card,
.notes-chapter-button,
.file-row,
.notes-content,
.notes-sidebar {
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 10px 24px rgba(0,0,0,0.18);
}

.category-card:hover {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.07), 0 18px 40px rgba(0,0,0,0.22);
}

.notes-chapter-button:hover,
.notes-chapter-button.active {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05), 0 10px 22px rgba(0,0,0,0.18);
}

.glass-card:hover,
.metric-card:hover,
.auth-card:hover,
.hero-panel:hover,
.sidebar-card:hover,
.notes-content:hover,
.notes-sidebar:hover,
.file-row:hover {
  border-color: rgba(255,255,255,0.16);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.05), 0 18px 42px rgba(0,0,0,0.18);
}

.flashcard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  perspective: 1200px;
  max-width: 760px;
  margin: 0 auto;
}

.flashcard-grid .flashcard:not(:first-child) {
  display: none;
}

.flashcard-chapter-tabs {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 10px;
  margin: 0 0 20px;
}

.flashcard-chapter-tabs .ghost-button {
  white-space: nowrap;
}

.flashcard-chapter-tabs .ghost-button.active {
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.flashcard-chapter-tabs span {
  opacity: .7;
  margin-left: 6px;
}

.flashcard-player {
  display: grid;
  place-items: center;
  gap: 18px;
  max-width: 760px;
  margin: 0 auto;
  perspective: 1200px;
}

.flashcard {
  width: 100%;
  min-height: 240px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  perspective: 1200px;
}

.flashcard-single {
  max-width: 720px;
  min-height: clamp(300px, 44vw, 430px);
}

.flashcard-inner {
  position: relative;
  display: block;
  width: 100%;
  min-height: 240px;
  transform-style: preserve-3d;
  transition: transform 420ms cubic-bezier(.2,.75,.25,1);
}

.flashcard-single .flashcard-inner,
.flashcard-single .flashcard-face {
  min-height: clamp(300px, 44vw, 430px);
}

.flashcard.is-flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: clamp(20px, 5vw, 34px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 26px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,0.10), transparent 34%),
    linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.025));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 20px 50px rgba(0,0,0,0.25);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: clamp(1.05rem, 3.3vw, 1.45rem);
  line-height: 1.35;
  font-weight: 800;
}

.flashcard-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 80% 20%, rgba(113, 210, 255, 0.13), transparent 34%),
    linear-gradient(145deg, rgba(255,255,255,0.10), rgba(255,255,255,0.035));
}

.flashcard:hover .flashcard-face,
.flashcard:focus-visible .flashcard-face {
  border-color: rgba(255,255,255,0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 24px 58px rgba(0,0,0,0.32);
}

.flashcard-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

.flashcard-count {
  min-width: 78px;
  text-align: center;
  color: rgba(255,255,255,0.72);
  font-size: .95rem;
  font-weight: 800;
}

.flashcard-controls button:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.note-reader-section {
  width: calc(100vw - clamp(24px, 4vw, 64px));
  max-width: 1680px;
  margin-left: calc(50% - 50vw + clamp(12px, 2vw, 32px));
  margin-right: 0;
}

.note-reader-heading {
  align-items: flex-end;
  gap: 18px;
}

.note-reader-actions,
.note-font-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.note-font-controls {
  padding: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  background: rgba(255,255,255,0.035);
}

.note-font-controls .ghost-button {
  padding: 8px 13px;
  min-width: 48px;
  border-radius: 999px;
  white-space: nowrap;
}

.note-reader-section .notes-shell {
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: clamp(16px, 2vw, 28px);
  align-items: start;
}

.note-reader-section .notes-sidebar {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 116px);
  overflow-y: auto;
}

.note-reader-section .notes-content {
  min-height: 68vh;
  padding: clamp(24px, 3vw, 42px);
  background: rgba(13,13,14,0.92);
  border-color: rgba(255,255,255,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), 0 18px 48px rgba(0,0,0,0.24);
}

.note-reader-section .notes-content:hover {
  background: rgba(13,13,14,0.92);
  border-color: rgba(255,255,255,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), 0 18px 48px rgba(0,0,0,0.24);
}

.notes-library-layout {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: clamp(16px, 2.2vw, 28px);
  align-items: start;
}

.notes-category-rail {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 18px 48px rgba(0,0,0,0.22);
}

.notes-category-filter {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  background: rgba(255,255,255,0.035);
  color: rgba(255,255,255,0.78);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  padding-left: calc(14px + (var(--note-cat-depth, 0) * 18px));
}

.notes-category-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-left: calc(var(--note-cat-depth, 0) * 8px);
  width: calc(100% - (var(--note-cat-depth, 0) * 8px));
}

.notes-category-row .notes-category-filter {
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 12px;
}

.notes-category-row.no-children {
  padding-left: 42px;
}

.notes-category-arrow {
  flex: 0 0 34px;
  width: 34px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  background: rgba(255,255,255,0.045);
  color: rgba(255,255,255,0.78);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.notes-category-arrow:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.1);
}

.notes-category-arrow.is-empty {
  opacity: .55;
  cursor: default;
}

.notes-category-filter.is-main-category {
  border-color: rgba(255,255,255,0.18);
  background: linear-gradient(135deg, rgba(255,255,255,0.105), rgba(255,255,255,0.045));
  color: #fff;
}

.notes-category-filter.is-subcategory {
  margin-left: calc(var(--note-cat-depth, 0) * 8px);
  width: calc(100% - (var(--note-cat-depth, 0) * 8px));
}

.notes-category-row.is-main-category .notes-category-filter {
  border-color: rgba(255,255,255,0.18);
  background: linear-gradient(135deg, rgba(255,255,255,0.105), rgba(255,255,255,0.045));
  color: #fff;
}

.notes-category-filter:hover,
.notes-category-filter.active,
.notes-category-row.active .notes-category-filter {
  color: #fff;
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.11);
}

.notes-category-filter span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-category-filter em {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.075);
  color: rgba(255,255,255,0.78);
  font-style: normal;
  font-size: 12px;
  line-height: 1;
}

.notes-category-filter strong {
  flex: 0 0 auto;
  font-size: 12px;
  color: rgba(255,255,255,0.62);
}

.notes-library-grid {
  align-items: stretch;
}

.note-reader-section .note-content-copy {
  font-size: calc(clamp(1rem, 1.45vw, 1.12rem) * var(--note-font-scale, 1));
  line-height: 1.9;
  max-width: none;
  color: rgba(255,255,255,0.86);
}

.note-reader-section .note-content-copy strong {
  font-weight: 950;
  color: #fff;
}

.note-sized-text {
  font-size: var(--note-inline-size) !important;
  line-height: 1.45;
}

.note-expander {
  margin: 12px 0 16px;
}

.note-expander summary {
  cursor: pointer;
  color: #fff;
  font-weight: 950;
  list-style-position: outside;
}

.note-expander-body {
  margin-top: 12px;
  padding-left: 18px;
}

.note-dot {
  display: inline-grid;
  place-items: center;
  width: 1.2em;
  margin-right: .28em;
  color: #fff;
  font-weight: 900;
}

.note-dot.hollow {
  font-size: .95em;
}

.chapter-content-canvas {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
}

.chapter-public-image-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.chapter-public-image-layer img {
  position: absolute;
  display: block;
  max-width: calc(100% - 18px);
  height: auto;
  border-radius: 12px;
  object-fit: contain;
  image-rendering: auto;
  box-shadow: 0 18px 44px rgba(0,0,0,.2);
}

.chapter-content-canvas .note-content-copy {
  position: relative;
  z-index: 1;
}

.active-chapter-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 14px 0 22px;
}

.chapter-image-display {
  position: relative;
  display: block;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,.04);
  box-shadow: 0 18px 45px rgba(0,0,0,.22);
  min-height: 220px;
}

.chapter-image-display img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  max-height: 420px;
  object-fit: cover;
  transform-origin: center center;
  display: block;
}

#nfy-admin-overlay .a-chapter-image-card {
  border: 1px solid var(--aborder);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,.05);
}

#nfy-admin-overlay .a-chapter-image-preview {
  position: relative;
  display: block;
  width: 100%;
  height: 104px;
  padding: 0;
  border: 0;
  background: rgba(0,0,0,.22);
  cursor: pointer;
  overflow: hidden;
}

#nfy-admin-overlay .a-chapter-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .18s ease, filter .18s ease;
}

#nfy-admin-overlay .a-chapter-image-preview:hover img {
  transform: scale(1.04);
  filter: brightness(1.08);
}

#nfy-admin-overlay .a-chapter-image-preview span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.62);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

#nfy-admin-overlay .a-chapter-image-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 8px;
}

.chapter-pdf-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--aborder);
  border-radius: 14px;
  background: rgba(255,255,255,.045);
}

.chapter-pdf-chip span {
  min-width: 0;
  flex: 1 1 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,.84);
  font-weight: 800;
  font-size: 13px;
}

.chapter-image-modal {
  width: min(1180px, calc(100vw - 24px));
}

.chapter-image-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chapter-image-zoom-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(255,255,255,.045);
  color: rgba(255,255,255,.82);
  font-weight: 800;
}

.chapter-image-zoom-label input {
  width: min(220px, 44vw);
}

.chapter-image-stage {
  min-height: min(68vh, 720px);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 22px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.07), transparent 30%),
    rgba(255,255,255,.035);
  overflow: hidden;
  display: grid;
  place-items: center;
  touch-action: none;
}

.chapter-image-frame {
  position: relative;
  max-width: 86%;
  max-height: 86%;
  transform-origin: center center;
  cursor: grab;
  touch-action: none;
  will-change: transform;
}

.chapter-image-frame:active {
  cursor: grabbing;
}

.chapter-image-frame img {
  display: block;
  max-width: min(900px, 82vw);
  max-height: min(620px, 62vh);
  object-fit: contain;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: 0 26px 80px rgba(0,0,0,.5);
  user-select: none;
}

.chapter-image-resize-handle {
  position: absolute;
  right: -11px;
  bottom: -11px;
  width: 26px;
  height: 26px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.35);
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(255,255,255,.9) 47% 53%, transparent 55%),
    rgba(255,255,255,.16);
  cursor: nwse-resize;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
}

#nfy-admin-overlay .a-range-with-value {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(260px, 100%);
}

#nfy-admin-overlay .a-range-with-value .a-range-input {
  width: min(190px, 42vw);
}

#nfy-admin-overlay .a-range-with-value span {
  min-width: 46px;
  text-align: right;
  color: rgba(255,255,255,0.82);
  font-weight: 800;
  font-size: 12px;
}

@media (max-width: 640px) {
  .flashcard-grid {
    gap: 14px;
  }

  .flashcard,
  .flashcard-inner,
  .flashcard-face {
    min-height: 210px;
  }

  .flashcard-single,
  .flashcard-single .flashcard-inner,
  .flashcard-single .flashcard-face {
    min-height: 300px;
  }

  .flashcard-chapter-tabs {
    overflow-x: visible;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
}

@media (max-width: 900px) {
  .notes-library-layout {
    grid-template-columns: 1fr;
  }

  .notes-category-rail {
    position: static;
  }

  .note-reader-section {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
  }

  .note-reader-heading {
    align-items: flex-start;
  }

  .note-reader-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .note-reader-section .notes-shell {
    grid-template-columns: 1fr;
  }

  .note-reader-section .notes-sidebar {
    position: static;
    max-height: none;
  }

  .chapter-image-stage {
    min-height: 58vh;
  }

  .chapter-image-frame img {
    max-width: 78vw;
    max-height: 54vh;
  }

  .chapter-image-toolbar {
    align-items: stretch;
  }

  .chapter-image-zoom-label {
    width: 100%;
    justify-content: space-between;
  }
}

#nfy-admin-overlay .a-nav-item {
  position: relative;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}

#nfy-admin-overlay .a-nav-item::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 6px;
  height: 1.5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.88), rgba(255,255,255,0));
  transform: scaleX(0);
  opacity: 0;
  transition: transform .15s ease, opacity .15s ease;
}

#nfy-admin-overlay .a-nav-item:hover::after {
  transform: scaleX(1);
  opacity: 1;
}

#nfy-admin-overlay .note-editor-field {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 14px;
  background:
    radial-gradient(circle at 12% 0%, rgba(255,255,255,0.07), transparent 34%),
    rgba(255,255,255,0.035);
}

body.chapter-editor-lock {
  overflow: hidden;
}

#nfy-admin-overlay .note-editor-field.chapter-editor-fullscreen {
  position: fixed;
  inset: 12px;
  z-index: 100002;
  display: flex;
  flex-direction: column;
  padding: 18px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255,255,255,0.08), transparent 34%),
    rgba(9,9,10,0.98);
  box-shadow: 0 30px 90px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,255,255,.1);
}

#nfy-admin-overlay .note-editor-field.chapter-editor-fullscreen .note-editor-toolbar {
  flex: 0 0 auto;
}

#nfy-admin-overlay .note-editor-field.chapter-editor-fullscreen .chapter-editor-stage {
  flex: 1 1 auto;
  min-height: 0 !important;
  max-height: none;
}

#nfy-admin-overlay .note-editor-field.chapter-editor-fullscreen .chapter-editor-textarea {
  min-height: 100% !important;
  max-height: none;
  height: 100%;
  font-size: 17px !important;
}

#nfy-admin-overlay .note-editor-field.chapter-editor-fullscreen .note-editor-bottom-row {
  flex: 0 0 auto;
}

#nfy-admin-overlay .note-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

#nfy-admin-overlay .note-editor-toolbar .a-btn {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 12px;
  font-weight: 900;
}

#nfy-admin-overlay .latex-editor-open-btn {
  border-color: rgba(255,255,255,0.22) !important;
  background: linear-gradient(135deg, rgba(255,255,255,0.16), rgba(255,255,255,0.06)) !important;
  color: #fff !important;
}

#nfy-admin-overlay .note-font-select-label {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-left: 4px;
}

#nfy-admin-overlay .note-size-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#nfy-admin-overlay .note-size-trigger {
  min-width: 92px;
  min-height: 36px;
  border-radius: 14px;
  padding: 7px 32px 7px 12px;
  background:
    linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.72) 50%) calc(100% - 18px) 15px / 6px 6px no-repeat,
    linear-gradient(135deg, rgba(255,255,255,0.72) 50%, transparent 50%) calc(100% - 13px) 15px / 6px 6px no-repeat,
    linear-gradient(180deg, rgba(255,255,255,0.105), rgba(255,255,255,0.05));
  border: 1px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.94);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 10px 24px rgba(0,0,0,0.12);
}

#nfy-admin-overlay .note-size-trigger:hover,
#nfy-admin-overlay .note-size-trigger:focus {
  border-color: rgba(255,255,255,0.28);
  background-color: rgba(255,255,255,0.08);
  outline: none;
}

#nfy-admin-overlay .note-size-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100000;
  display: none;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  gap: 6px;
  width: 142px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  background: rgba(18,18,19,0.98);
  box-shadow: 0 18px 46px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.07);
}

#nfy-admin-overlay .note-size-menu.open {
  display: grid;
}

#nfy-admin-overlay .note-size-menu button {
  min-height: 32px;
  border-radius: 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.92);
  font-weight: 800;
}

#nfy-admin-overlay .note-size-menu button:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.22);
}

#nfy-admin-overlay .chapter-editor-stage {
  position: relative;
  min-height: min(52vh, 520px) !important;
  max-height: 62vh;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 18px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.035));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

#nfy-admin-overlay .chapter-editor-textarea {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: min(52vh, 520px) !important;
  max-height: 62vh;
  resize: vertical;
  padding: 18px !important;
  border: 0 !important;
  border-radius: 18px !important;
  font-family: "Inter", "Manrope", system-ui, sans-serif !important;
  font-size: clamp(14px, 1.45vw, 16px) !important;
  line-height: 1.75 !important;
  letter-spacing: 0 !important;
  color: rgba(255,255,255,0.92) !important;
  background: transparent !important;
  box-shadow: none !important;
}

#nfy-admin-overlay .chapter-editor-stage:focus-within {
  border-color: rgba(255,255,255,0.28) !important;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06), inset 0 1px 0 rgba(255,255,255,0.08);
}

#nfy-admin-overlay .chapter-editor-image-layer {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  min-height: 100%;
  will-change: transform;
}

#nfy-admin-overlay .chapter-editor-image-layer .card-copy {
  position: absolute;
  left: 18px;
  bottom: 16px;
  margin: 0;
  color: rgba(255,255,255,.42);
  font-size: 12px;
}

#nfy-admin-overlay .chapter-editor-image-item {
  position: absolute;
  min-width: 80px;
  max-width: calc(100% - 24px);
  border-radius: 14px;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  box-shadow: 0 18px 42px rgba(0,0,0,.3);
  outline: 1px solid rgba(255,255,255,.18);
  outline-offset: 3px;
}

#nfy-admin-overlay .chapter-editor-image-item.is-moving {
  cursor: grabbing;
  outline-color: rgba(255,255,255,.55);
  z-index: 5;
}

#nfy-admin-overlay .chapter-editor-image-item img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  pointer-events: none;
  image-rendering: auto;
  object-fit: contain;
  transform: translateZ(0);
}

#nfy-admin-overlay .chapter-editor-image-remove {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(16,16,17,.95);
  color: #fff;
  font-weight: 950;
  cursor: pointer;
}

#nfy-admin-overlay .chapter-editor-image-handle {
  position: absolute;
  right: -11px;
  bottom: -11px;
  width: 26px;
  height: 26px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.38);
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(255,255,255,.9) 47% 53%, transparent 55%),
    rgba(20,20,22,.92);
  cursor: nwse-resize;
}

#nfy-admin-overlay .note-editor-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

#nfy-admin-overlay .note-editor-bottom-row .note-editor-help {
  margin: 0;
}

#nfy-admin-overlay .a-inline-image-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.065);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

#nfy-admin-overlay .a-inline-image-upload input {
  display: none;
}

#nfy-admin-overlay .note-editor-help {
  margin-top: 8px;
  color: rgba(255,255,255,0.48);
  font-size: 11px;
  line-height: 1.5;
}

.latex-modal {
  width: min(1440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

.latex-modal-shell {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

.latex-modal-header h3 {
  margin-bottom: 4px;
}

.latex-editor-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 18px;
}

.latex-editor-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
}

.latex-editor-topbar select,
.latex-editor-topbar button,
.latex-editor-actions button {
  min-height: 38px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  background: rgba(255,255,255,0.075);
  color: rgba(255,255,255,0.94);
  padding: 0 12px;
  font-weight: 800;
}

.latex-editor-topbar select {
  min-width: 170px;
}

.latex-editor-topbar .a-btn-primary {
  margin-left: auto;
  color: #0b0b0b;
  background: linear-gradient(135deg, #ffffff, #d8d8d8);
}

.latex-editor-topbar select option {
  background: #151515;
  color: #fff;
}

.latex-editor-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.latex-editor-grid {
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(360px, 1.15fr);
  gap: 16px;
}

.latex-toolbox,
.latex-workspace {
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 18px;
  background:
    radial-gradient(circle at 14% 0%, rgba(255,255,255,0.07), transparent 30%),
    rgba(255,255,255,0.035);
  padding: 14px;
}

.latex-group + .latex-group {
  margin-top: 12px;
}

.latex-group label,
.latex-workspace label {
  display: block;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.58);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.latex-search-group input {
  width: min(520px, 100%);
  min-height: 42px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 13px;
  background: rgba(0,0,0,0.26);
  color: rgba(255,255,255,0.94);
  padding: 0 14px;
  font-weight: 800;
  outline: none;
}

.latex-search-group input:focus {
  border-color: rgba(255,255,255,0.34);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.06);
}

.latex-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 3px;
}

.latex-button-row button {
  min-height: 34px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: rgba(255,255,255,0.075);
  color: #fff;
  padding: 0 10px;
  font-weight: 800;
  white-space: nowrap;
}

.latex-package-row button {
  font-size: 12px;
  color: rgba(255,255,255,0.88);
}

.latex-button-row button[hidden] {
  display: none;
}

.latex-button-row button:hover,
.latex-editor-actions button:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.24);
}

#latex-editor-input {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  background: rgba(0,0,0,0.24);
  color: rgba(255,255,255,0.94);
  padding: 14px;
  font: 15px/1.7 Consolas, "SFMono-Regular", monospace;
}

.latex-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.latex-preview {
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.07), rgba(255,255,255,0.025)),
    rgba(0,0,0,0.22);
  padding: 18px;
}

.latex-preview-panel .note-latex-render {
  font-size: clamp(22px, 2.1vw, 34px);
}

.latex-empty-preview {
  color: rgba(255,255,255,0.42);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
}

.note-latex {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  color: rgba(255,255,255,0.94);
  font-family: Georgia, "Times New Roman", serif;
}

.note-latex-block {
  display: flex;
  justify-content: center;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  background: rgba(255,255,255,0.045);
}

.note-latex-render {
  font-size: 1.22em;
  overflow-x: auto;
  max-width: 100%;
}

.note-latex code {
  display: none;
}

.latex-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 .16em;
  line-height: 1.05;
}

.latex-frac span:first-child {
  border-bottom: 1px solid currentColor;
  padding: 0 .24em .12em;
}

.latex-frac span:last-child {
  padding-top: .12em;
}

.latex-root {
  display: inline-flex;
  align-items: flex-start;
  gap: .08em;
}

.latex-root span {
  border-top: 1px solid currentColor;
  padding: 0 .18em;
}

.latex-symbol,
.latex-op {
  display: inline-block;
  margin: 0 .08em;
}

.latex-op {
  font-family: Georgia, "Times New Roman", serif;
  font-style: normal;
}

.latex-empty {
  display: inline-block;
  width: .72em;
  height: .72em;
  margin: 0 .06em;
  vertical-align: -.08em;
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: .14em;
  background: rgba(255,255,255,0.08);
}

.latex-size-small {
  font-size: .82em;
}

.latex-size-large {
  font-size: 1.18em;
}

.latex-size-larger {
  font-size: 1.34em;
}

.latex-size-huge {
  font-size: 1.58em;
}

.latex-unknown {
  opacity: .72;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: .8em;
}

.latex-text {
  font-family: Inter, system-ui, sans-serif;
}

.latex-set {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  text-shadow: 0 0 0 currentColor;
}

.latex-button-row button {
  font-feature-settings: "ss01" 1;
}

.latex-cal {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  letter-spacing: .03em;
}

.latex-package {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  font-family: Inter, system-ui, sans-serif;
  font-size: .76em;
  font-weight: 900;
}

.latex-item {
  display: inline-block;
  margin-right: .34em;
}

.latex-hat {
  display: inline-block;
  position: relative;
  padding-top: .18em;
}

.latex-hat::before {
  content: "^";
  position: absolute;
  left: 50%;
  top: -.42em;
  transform: translateX(-50%);
  font-size: .82em;
}

.latex-over {
  display: inline-block;
  border-top: 1px solid currentColor;
  padding: .04em .12em 0;
}

.latex-vector::before {
  content: "→";
  display: block;
  height: 0;
  transform: translateY(-.95em);
  text-align: right;
  font-size: .72em;
}

.latex-binom {
  border-left: 1px solid currentColor;
  border-right: 1px solid currentColor;
  padding: 0 .18em;
}

.latex-matrix {
  display: inline-flex;
  align-items: center;
  position: relative;
  padding: 0 .58em;
  margin: 0 .2em;
  border: 0;
}

.latex-matrix::before,
.latex-matrix::after {
  content: "";
  position: absolute;
  top: -.1em;
  bottom: -.1em;
  width: .34em;
  border-color: currentColor;
  border-style: solid;
}

.latex-matrix::before {
  left: 0;
  border-width: 2px 0 2px 2px;
  border-radius: .16em 0 0 .16em;
}

.latex-matrix::after {
  right: 0;
  border-width: 2px 2px 2px 0;
  border-radius: 0 .16em .16em 0;
}

.latex-matrix-pmatrix::before,
.latex-matrix-pmatrix::after {
  width: .42em;
  border-radius: 999px;
}

.latex-matrix-vmatrix::before,
.latex-matrix-vmatrix::after,
.latex-matrix-tabular::before,
.latex-matrix-tabular::after {
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 0;
}

.latex-matrix-vmatrix::before,
.latex-matrix-tabular::before {
  border-width: 0 0 0 2px;
}

.latex-matrix-vmatrix::after,
.latex-matrix-tabular::after {
  border-width: 0 2px 0 0;
}

.latex-matrix table {
  border-collapse: collapse;
}

.latex-matrix td {
  padding: .18em .36em;
  text-align: center;
}

.latex-cases {
  display: inline-flex;
  align-items: center;
  gap: .14em;
}

.latex-case-brace {
  font-size: 2.4em;
  line-height: .9;
}

.latex-cases table {
  border-collapse: collapse;
}

.latex-cases td {
  padding: .14em .32em;
}

.latex-environment {
  display: inline-flex;
  align-items: flex-start;
  gap: .7em;
  padding: .5em .7em;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: .7em;
  background: rgba(255,255,255,0.055);
}

.latex-environment > span:first-child {
  color: rgba(255,255,255,0.58);
  font-family: Inter, system-ui, sans-serif;
  font-size: .68em;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.latex-list-env .latex-item {
  display: block;
  margin: .12em 0;
}

@media (max-width: 820px) {
  .latex-editor-grid {
    grid-template-columns: 1fr;
  }
}

#nfy-admin-overlay .a-note-category-editor {
  margin: 0 0 18px;
  padding: 12px;
  border: 1px solid var(--aborder);
  border-radius: 16px;
  background: rgba(255,255,255,0.035);
}

#nfy-admin-overlay .a-note-category-editor input[type="text"],
#nfy-admin-overlay .a-note-category-editor select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--aborder);
  border-radius: 12px;
  background: rgba(255,255,255,0.055);
  color: var(--atext);
}

#nfy-admin-overlay .a-note-category-editor select option {
  background: #121212;
  color: #fff;
}

#nfy-admin-overlay .a-note-maincategory-row {
  background: rgba(255,255,255,0.07) !important;
  border-color: rgba(255,255,255,0.16) !important;
}

#nfy-admin-overlay .a-note-subcategory-row {
  position: relative;
}

#nfy-admin-overlay .a-note-subcategory-row::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: rgba(255,255,255,0.22);
}

@media (min-width: 1024px) {
  #nfy-admin-overlay #a-panel-notes .a-cat-layout {
    grid-template-columns: minmax(280px, 0.85fr) minmax(560px, 1.55fr);
    align-items: start;
  }

  #nfy-admin-overlay #a-panel-notes .a-cat-form-panel {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}

@media (max-width: 720px) {
  #nfy-admin-overlay .chapter-editor-textarea {
    min-height: 46vh !important;
    font-size: 15px !important;
  }

  #nfy-admin-overlay .note-editor-toolbar .a-btn {
    flex: 1 1 auto;
  }
}

/* Pre-auth landing overlay */
body.preauth-lock {
  overflow: hidden !important;
}

.pre-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 200000;
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: clamp(20px, 3vw, 48px);
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 28%, rgba(255,255,255,0.1), transparent 30%),
    radial-gradient(circle at 15% 16%, rgba(255,255,255,0.045), transparent 22%),
    radial-gradient(circle at 84% 72%, rgba(255,255,255,0.055), transparent 24%),
    linear-gradient(135deg, #030303 0%, #0b0c0d 38%, #101113 68%, #050505 100%);
  color: #fff;
  opacity: 1;
  visibility: visible;
  transition: opacity 360ms ease, visibility 360ms ease;
  animation: preAuthFade 520ms ease both;
  caret-color: transparent;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.pre-auth-overlay * {
  caret-color: transparent;
}

.pre-auth-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-root.active {
  z-index: 200010 !important;
}

.pre-auth-overlay::before {
  content: "";
  position: absolute;
  inset: -18%;
  background-image:
    linear-gradient(rgba(255,255,255,0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at center, black 0%, transparent 72%);
  opacity: 0.38;
}

.pre-auth-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 0 38%, rgba(0,0,0,0.62) 84%);
  pointer-events: none;
}

.pre-auth-content {
  position: relative;
  z-index: 3;
  width: min(1180px, 100%);
  text-align: center;
  transform: scale(0.92);
  transform-origin: center center;
}

.pre-auth-logo {
  display: block;
  width: clamp(64px, 7vw, 92px);
  height: clamp(64px, 7vw, 92px);
  margin: 0 auto 26px;
  border-radius: 21px;
  filter: drop-shadow(0 20px 38px rgba(0,0,0,0.6));
}

.pre-auth-kicker {
  width: fit-content;
  margin: 0 auto 20px;
  padding: 10px 28px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  background: rgba(255,255,255,0.055);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 14px 34px rgba(0,0,0,0.32);
  color: rgba(255,255,255,0.92);
  font-size: clamp(12px, 1.1vw, 17px);
  line-height: 1;
  letter-spacing: 0.34em;
}

.pre-auth-content h1 {
  margin: 0;
  font-family: Inter, Manrope, system-ui, sans-serif;
  font-size: clamp(70px, 10.8vw, 148px);
  font-weight: 900;
  line-height: 0.86;
  letter-spacing: 0;
  color: #f7f7f7;
  text-shadow:
    0 2px 0 rgba(255,255,255,0.22),
    0 22px 44px rgba(0,0,0,0.62);
}

.pre-auth-subtitle {
  max-width: 760px;
  margin: 30px auto 34px;
  color: rgba(255,255,255,0.8);
  font-size: clamp(17px, 2vw, 25px);
  line-height: 1.38;
}

.pre-auth-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 24px;
  margin: 0 auto;
}

.pre-auth-card {
  min-height: 214px;
  padding: 24px 18px 22px;
  border: 1px solid rgba(255,255,255,0.19);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.035)),
    rgba(18,18,19,0.56);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 18px 55px rgba(0,0,0,0.32);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.pre-auth-card:hover {
  border-color: rgba(255,255,255,0.42);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.13), rgba(255,255,255,0.045)),
    rgba(18,18,19,0.66);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 20px 60px rgba(255,255,255,0.055), 0 18px 55px rgba(0,0,0,0.34);
}

.pre-card-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.055));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 12px 28px rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.94);
  line-height: 1;
}

.pre-card-icon svg {
  width: 34px;
  height: 34px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 9px rgba(255,255,255,0.22));
}

.pre-card-icon rect {
  fill: none;
}

.pre-auth-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 1.1;
  color: #fff;
}

.pre-auth-card p {
  margin: 0 auto 12px;
  max-width: 160px;
  color: rgba(255,255,255,0.78);
  font-size: 14px;
  line-height: 1.55;
}

.pre-auth-card p:last-child {
  margin-bottom: 0;
}

.pre-auth-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 36px;
}

.pre-auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: min(240px, 44vw);
  min-height: 64px;
  padding: 0 34px;
  border-radius: 14px;
  font-size: clamp(18px, 2vw, 23px);
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, color 180ms ease;
}

.pre-auth-primary {
  border: 1px solid rgba(255,255,255,0.86);
  background: linear-gradient(180deg, #fff, #e8e8e8);
  color: #111;
  box-shadow: 0 18px 45px rgba(255,255,255,0.12), 0 18px 48px rgba(0,0,0,0.4);
}

.pre-auth-outline {
  border: 1px solid rgba(255,255,255,0.46);
  background: rgba(255,255,255,0.025);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 18px 48px rgba(0,0,0,0.32);
}

.pre-auth-button:hover {
  border-color: rgba(255,255,255,0.9);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.08), 0 20px 58px rgba(0,0,0,0.42);
}

.pre-auth-doodles {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
}

.landing-doodle {
  position: absolute;
  width: var(--doodle-size, 120px);
  opacity: var(--doodle-opacity, 0.23);
  transform: translate(-50%, -50%) rotate(var(--doodle-rotate, 0deg));
  filter: grayscale(1) brightness(1.08) drop-shadow(0 0 18px rgba(255,255,255,0.035));
  mix-blend-mode: screen;
  user-select: none;
  -webkit-user-drag: none;
}

.d-notebook { left: 8.5%; top: 13%; --doodle-size: clamp(92px, 10vw, 165px); --doodle-rotate: -18deg; --doodle-opacity: .2; }
.d-pencil { left: 23.5%; top: 17%; --doodle-size: clamp(70px, 7.6vw, 126px); --doodle-rotate: 42deg; --doodle-opacity: .22; }
.d-pen-left { left: 5.5%; top: 43%; --doodle-size: clamp(62px, 6.4vw, 108px); --doodle-rotate: 28deg; --doodle-opacity: .2; }
.d-backpack { left: 9.5%; top: 66%; --doodle-size: clamp(96px, 10.5vw, 182px); --doodle-rotate: 6deg; --doodle-opacity: .19; }
.d-book { left: 8%; top: 90%; --doodle-size: clamp(86px, 9.5vw, 158px); --doodle-rotate: -18deg; --doodle-opacity: .18; }
.d-pencil-case { left: 79%; top: 11%; --doodle-size: clamp(94px, 10.8vw, 178px); --doodle-rotate: 13deg; --doodle-opacity: .18; }
.d-paperclip { left: 93%; top: 22%; --doodle-size: clamp(42px, 4.6vw, 74px); --doodle-rotate: 28deg; --doodle-opacity: .28; }
.d-star-left { left: 17%; top: 19%; --doodle-size: clamp(28px, 3vw, 48px); --doodle-rotate: -8deg; --doodle-opacity: .24; }
.d-star-right { left: 74.5%; top: 29%; --doodle-size: clamp(35px, 4vw, 62px); --doodle-rotate: 8deg; --doodle-opacity: .2; }
.d-clipboard { left: 90%; top: 44%; --doodle-size: clamp(106px, 11vw, 190px); --doodle-rotate: 17deg; --doodle-opacity: .18; }
.d-pen-right { left: 92%; top: 66%; --doodle-size: clamp(66px, 7vw, 118px); --doodle-rotate: 24deg; --doodle-opacity: .2; }
.d-holder { left: 88%; top: 90%; --doodle-size: clamp(94px, 10vw, 168px); --doodle-rotate: -6deg; --doodle-opacity: .13; }
.d-ruler { left: 52%; top: 69%; --doodle-size: clamp(80px, 8vw, 138px); --doodle-rotate: 28deg; --doodle-opacity: .055; z-index: 1; }
.d-eraser { left: 77%; top: 87%; --doodle-size: clamp(40px, 4.5vw, 68px); --doodle-rotate: -20deg; --doodle-opacity: .22; }
.d-squiggle { left: 17%; top: 36%; --doodle-size: clamp(58px, 6vw, 100px); --doodle-rotate: 4deg; --doodle-opacity: .24; }
.d-ring-a { left: 61%; top: 74%; --doodle-size: clamp(24px, 2.5vw, 42px); --doodle-opacity: .085; }
.d-ring-b { left: 33%; top: 31%; --doodle-size: clamp(18px, 2vw, 34px); --doodle-opacity: .08; }
.d-ring-c { left: 71%; top: 57%; --doodle-size: clamp(18px, 1.9vw, 32px); --doodle-opacity: .08; }
.d-ring-d { left: 12%; top: 32%; --doodle-size: clamp(16px, 1.8vw, 30px); --doodle-opacity: .075; }
.d-ring-e { left: 88%; top: 52%; --doodle-size: clamp(18px, 1.9vw, 32px); --doodle-opacity: .08; }
.d-ring-f { left: 42%; top: 18%; --doodle-size: clamp(16px, 1.7vw, 28px); --doodle-opacity: .07; }
.d-ring-g { left: 57%; top: 86%; --doodle-size: clamp(16px, 1.7vw, 28px); --doodle-opacity: .065; }
.d-dot-a { left: 21%; top: 25%; --doodle-size: 7px; --doodle-opacity: .32; }
.d-dot-b { left: 82%; top: 64%; --doodle-size: 6px; --doodle-opacity: .29; }
.d-dot-c { left: 64%; top: 15%; --doodle-size: 7px; --doodle-opacity: .3; }
.d-dot-d { left: 86%; top: 34%; --doodle-size: 6px; --doodle-opacity: .27; }
.d-dot-e { left: 14%; top: 82%; --doodle-size: 7px; --doodle-opacity: .25; }
.d-dot-f { left: 6%; top: 29%; --doodle-size: 6px; --doodle-opacity: .23; }
.d-dot-g { left: 29%; top: 47%; --doodle-size: 5px; --doodle-opacity: .19; z-index: 1; }
.d-dot-h { left: 50%; top: 12%; --doodle-size: 6px; --doodle-opacity: .2; }
.d-dot-i { left: 69%; top: 30%; --doodle-size: 6px; --doodle-opacity: .22; }
.d-dot-j { left: 94%; top: 77%; --doodle-size: 7px; --doodle-opacity: .25; }
.d-dot-k { left: 34%; top: 86%; --doodle-size: 6px; --doodle-opacity: .2; }
.d-dot-l { left: 78%; top: 16%; --doodle-size: 5px; --doodle-opacity: .18; }
.d-star-mid { left: 36%; top: 73%; --doodle-size: clamp(24px, 2.8vw, 44px); --doodle-rotate: 17deg; --doodle-opacity: .08; z-index: 1; }
.d-paperclip-mid { left: 67%; top: 38%; --doodle-size: clamp(38px, 4vw, 64px); --doodle-rotate: -22deg; --doodle-opacity: .075; z-index: 1; }
.d-eraser-mid { left: 42%; top: 86%; --doodle-size: clamp(34px, 3.8vw, 60px); --doodle-rotate: 18deg; --doodle-opacity: .09; z-index: 1; }
.d-highlight-a { left: 38%; top: 10%; --doodle-size: clamp(46px, 4.4vw, 76px); --doodle-rotate: -12deg; --doodle-opacity: .18; }
.d-squiggle-b { left: 83%; top: 77%; --doodle-size: clamp(60px, 6.5vw, 106px); --doodle-rotate: -16deg; --doodle-opacity: .12; }

.pre-auth-image-doodles::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(820px, 78vw);
  height: min(410px, 44vh);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.045), transparent 68%);
  filter: blur(8px);
  opacity: .8;
}

@keyframes preAuthFade {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 980px) {
  .pre-auth-overlay {
    align-items: start;
    overflow-y: auto;
  }

  .pre-auth-content {
    padding: 18px 0 24px;
  }

  .pre-auth-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 680px;
  }

  .pre-auth-card:last-child {
    grid-column: 1 / -1;
    max-width: 320px;
    width: 100%;
    justify-self: center;
  }
}

@media (max-width: 620px) {
  .pre-auth-overlay {
    padding: 18px 14px;
  }

  .pre-auth-logo {
    margin-bottom: 14px;
  }

  .pre-auth-kicker {
    padding: 8px 18px;
    letter-spacing: 0.24em;
  }

  .pre-auth-content h1 {
    font-size: clamp(58px, 18vw, 86px);
  }

  .pre-auth-subtitle {
    margin: 18px auto 20px;
    font-size: 16px;
  }

  .pre-auth-subtitle br {
    display: none;
  }

  .pre-auth-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .pre-auth-card,
  .pre-auth-card:last-child {
    min-height: auto;
    max-width: none;
    padding: 17px 16px;
  }

  .pre-card-icon {
    width: 46px;
    height: 46px;
    margin-bottom: 12px;
    font-size: 23px;
  }

  .pre-auth-card h2 {
    margin-bottom: 8px;
    font-size: 16px;
  }

  .pre-auth-card p {
    max-width: 280px;
    margin-bottom: 6px;
    font-size: 13px;
  }

  .pre-auth-actions {
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
  }

  .pre-auth-button {
    width: 100%;
    min-width: 0;
    min-height: 54px;
    font-size: 18px;
  }

  .pre-auth-doodles {
    opacity: 0.25;
  }
}

/* Final production overrides: keep these last so older rules cannot re-break mobile/light mode. */
.notes-control-bar {
  display: grid !important;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 220px) auto;
}

.note-card,
.category-card,
.dash-card,
.glass-card,
.modal {
  max-width: 100%;
}

.dash-list-item,
.dash-mini-widget,
.dash-quick-stat,
.notes-category-filter,
.notes-chapter-button {
  min-width: 0;
}

.dash-list-item strong,
.dash-list-item span,
.dash-mini-widget span,
.dash-progress-name span,
.card-title,
.card-copy {
  overflow-wrap: anywhere;
}

body.light-mode .topbar,
body.light-mode .hero-panel,
body.light-mode .glass-card,
body.light-mode .category-card,
body.light-mode .note-card,
body.light-mode .dash-card,
body.light-mode .modal,
body.light-mode .notes-control-bar,
body.light-mode .notes-category-rail,
body.light-mode .notes-content,
body.light-mode .notes-sidebar {
  background: linear-gradient(145deg, rgba(255,255,255,.97), rgba(246,247,249,.92)) !important;
  border-color: rgba(18,18,24,.14) !important;
  color: #111113 !important;
}

body.light-mode .secondary-button,
body.light-mode .ghost-button,
body.light-mode .dash-mini-link,
body.light-mode .dash-tiny-btn,
body.light-mode .note-chip-action,
body.light-mode .notes-category-filter,
body.light-mode .notes-chapter-button,
body.light-mode .dash-list-item,
body.light-mode .dash-mini-widget,
body.light-mode .dash-quick-stat,
body.light-mode input,
body.light-mode textarea,
body.light-mode select {
  background: rgba(255,255,255,.92) !important;
  border-color: rgba(18,18,24,.15) !important;
  color: #151518 !important;
}

body.light-mode .card-copy,
body.light-mode .dash-stat-sub,
body.light-mode .dash-motivation,
body.light-mode .eyebrow {
  color: #5a5d66 !important;
}

@media (max-width: 860px) {
  .student-dashboard,
  .student-dashboard-side,
  .notes-library-layout,
  .notes-control-bar,
  .dash-hero-stats,
  .dash-two-col,
  .dash-three-col,
  .dash-four-col,
  .dash-task-form,
  .dash-goal-form,
  .dash-insight {
    grid-template-columns: 1fr !important;
  }

  .notes-category-rail {
    position: relative !important;
    top: auto !important;
    max-height: none !important;
  }

  .dash-hero-stat {
    border-right: 0 !important;
  }
}

@media (max-width: 520px) {
  .primary-button,
  .secondary-button,
  .ghost-button,
  .dash-tiny-btn,
  .dash-task-delete {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .dash-task-delete,
  .dash-goal-actions {
    grid-column: 1 / -1;
    justify-self: stretch;
  }
}
