
:root {
  --bg-page: #f7faf8;
  --bg-panel: rgba(255, 255, 255, 0.86);
  --bg-soft: #eef7f0;
  --bg-elevated: #ffffff;
  --bg-muted: #f3f6f4;
  --border-soft: rgba(163, 181, 170, 0.9);
  --border-strong: #bfd1c6;
  --primary: #166534;
  --primary-strong: #0f3d23;
  --primary-soft: rgba(22, 101, 52, 0.08);
  --accent: #6aa84f;
  --accent-soft: rgba(106, 168, 79, 0.12);
  --text: #1f2937;
  --text-muted: #5f6d77;
  --shadow-soft: 0 12px 26px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 10px 24px rgba(22, 101, 52, 0.10);
  --theme-glow: rgba(22, 101, 52, 0.18);
}

body.theme-study {
  --bg-page: #f5fbf6;
  --bg-panel: rgba(255, 255, 255, 0.82);
  --primary: #1d8f4d;
  --accent: #4daf66;
  --theme-glow: rgba(32, 156, 85, 0.18);
}

body.theme-default {
  --primary: #166534;
  --accent: #6aa84f;
  --theme-glow: rgba(22, 101, 52, 0.18);
}

body {
  margin:0;
  background:
    radial-gradient(circle at top left, rgba(126, 211, 33, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg-page) 0%, #f1f6f3 100%);
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='260' viewBox='0 0 360 260'%3E%3Ctext x='40' y='150' transform='rotate(-30 40 150)' fill='%23166534' fill-opacity='.08' font-family='Poppins,sans-serif' font-size='20' font-weight='600'%3Emindmap learners%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
}

html:has(body.dark-mode)::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='260' viewBox='0 0 360 260'%3E%3Ctext x='40' y='150' transform='rotate(-30 40 150)' fill='%23ffffff' fill-opacity='.06' font-family='Poppins,sans-serif' font-size='20' font-weight='600'%3Emindmap learners%3C/text%3E%3C/svg%3E");
}

html[data-watermark="off"]::after {
  display: none;
}

/* Smooth fade effect */
.node {
  position: absolute;
}

/* Fade layer (NOT opacity) */
.node.faded::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.65); /* fade strength */
  border-radius: 8px;
  pointer-events: none;
  z-index: 1;
}

/* Node content stays below overlay */
.node-header,
.node-body,
.node-text,
.note-icon {
  position: relative;
  z-index: 0;
}

/* Menu button ABOVE fade */
.menu-btn {
  position: relative;
  z-index: 3;
}

/* Menu popup ABOVE everything */
.menu {
  position: absolute;
  z-index: 5;
}



/* ===== Note icon ===== */
.note-icon {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #69c7f5 0%, #258bd1 100%);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(37, 139, 209, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.study-stat-grid > .study-due-stat {
  min-width: 0;
  padding: 15px 12px 14px;
  border: 1px solid #dce5eb;
  border-top: 3px solid #bf665f;
  border-radius: 9px;
  background: #ffffff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(23, 43, 58, 0.035);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.study-stat-grid > .study-due-stat:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(191, 102, 95, 0.14);
}

.study-stat-grid > .study-due-stat:focus-visible {
  outline: 3px solid rgba(191, 102, 95, 0.4);
  outline-offset: 2px;
}

.study-stat-grid > .study-due-stat:disabled {
  cursor: default;
}

.note-icon:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 22px rgba(37, 139, 209, 0.36);
}

/* ===== Tooltip ===== */
.node-note {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);

  background: #374151;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;

  width: max-content;        /* ✅ key */
  max-width: 260px;          /* prevent very long lines */
  white-space: pre-wrap;
  word-break: break-word;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 9000;

  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}


/* ✅ ONLY icon hover triggers tooltip */
.note-icon:hover .node-note {
  opacity: 1;
}

#canvas {
  position: relative;
}


/* ===== Search Match Highlight ===== */
.node.search-hit {
  background: #fde68a !important;  /* soft yellow */
}

.node.has-explanation-link,
.node.has-viewmap-link,
.node.has-rich-links {
  padding-right: 32px;
}

.node.has-explanation-link::before,
.node.has-viewmap-link::before,
.node.has-rich-links::before {
  content: "";
  position: absolute;
  top: 8px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #ffffff;
  pointer-events: none;
  z-index: 2;
}

.node.has-explanation-link::before {
  background: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.node.has-viewmap-link::before {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.node.has-rich-links::before {
  background: #8b5cf6;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.18);
}

.node.important {
  box-shadow:
    0 0 0 2px #ef4444,
    0 6px 16px rgba(239,68,68,0.25);

  border-radius: 8px;
}



/* ===== Expand / Collapse All Icon ===== */
.expand-collapse-btn {
  width: 36px;
  height: 36px;
  background: #ffffff;
  border: 1px solid #a3b5aa;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
}

.expand-collapse-btn::before,
.expand-collapse-btn::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid #4b5563;
}

/* COLLAPSE STATE (default – inward corners) */
.expand-collapse-btn::before {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
}

.expand-collapse-btn::after {
  bottom: 8px;
  right: 8px;
  border-left: none;
  border-top: none;
}

/* EXPAND STATE (outward corners – FIXED & VISIBLE) */
.expand-collapse-btn.expand::before {
  top: 6px;
  left: 6px;
  border-bottom: none;
  border-right: none;
}

.expand-collapse-btn.expand::after {
  bottom: 6px;
  right: 6px;
  border-top: none;
  border-left: none;
}


.expand-collapse-btn:hover {
  background: #eef4f1;
}


/* ===== FIXED TOOLBAR ===== */
.toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  z-index: 10010;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  overflow: hidden;
}

/* ===== SCALED CONTENT ===== */
.toolbar-inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
  padding: 0 18px;
  transform-origin: left center;
}

.toolbar button,
.toolbar select,
.toolbar input[type="search"] {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.toolbar button:hover,
.toolbar select:hover,
.toolbar input[type="search"]:hover,
.toolbar button:focus-visible,
.toolbar select:focus-visible,
.toolbar input[type="search"]:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 8px 16px rgba(106, 168, 79, 0.14);
  outline: none;
}

#darkModeBtn {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(59, 130, 246, 0.10));
  border-color: rgba(250, 204, 21, 0.5);
  font-weight: 600;
}


/* ===== STUDY DASHBOARD ===== */
.study-dashboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 10030;
  background: rgba(15, 23, 42, 0.55);
}

.study-dashboard-modal,
.study-review-modal {
  position: fixed;
  z-index: 10031;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(900px, 92vw);
  max-height: 88vh;
  overflow: auto;
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid rgba(163, 181, 170, 0.95);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(244,248,245,0.96));
  color: #1b1b1b;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
  animation: dashboardSlideIn 0.2s ease-out;
}

@keyframes dashboardSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.study-review-modal {
  width: min(620px, 92vw);
  padding: 0;
  overflow: hidden auto;
  border-top: 4px solid #6aa84f;
  background: #d6e0eb;
}

.study-review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  background: linear-gradient(135deg, #f2f9f1, #f8fbff);
  border-bottom: 1px solid #e2e8e3;
}

.study-review-header h2 {
  margin: 4px 0 5px;
  font-size: 24px;
  letter-spacing: 0;
}

.study-review-header p {
  max-width: 430px;
  margin: 0;
  color: #64748b;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.study-review-header-side {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.study-review-status {
  padding: 5px 9px;
  border: 1px solid #bbdec1;
  border-radius: 999px;
  background: #eaf7ed;
  color: #166534;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.study-review-question-block,
.study-answer-grid,
.study-explanation {
  margin: 20px 24px 0;
}

.study-review-label {
  display: block;
  margin-bottom: 7px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.study-review-question-block {
  margin-top: 22px;
}

.study-review-question {
  margin: 0;
  padding: 16px 18px;
  border: 1px solid #dbe8dd;
  border-left: 4px solid #6aa84f;
  border-radius: 10px;
  background: #f7fbf7;
  color: #173322;
  line-height: 1.65;
}

.study-answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.study-answer {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  line-height: 1.5;
}

.study-answer strong {
  overflow-wrap: anywhere;
}

.wrong-answer { border-color: #fecdd3; }
.right-answer { border-color: #bbf7d0; }

.study-explanation {
  padding: 14px 16px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1e40af;
  line-height: 1.55;
}

.study-explanation p {
  margin: 0;
}

.study-review-modal .study-review-actions {
  margin-top: 24px;
  padding: 16px 24px 20px;
  border-top: 1px solid #e2e8e3;
  background: #fbfdfb;
}

.study-dashboard-modal.no-animation,
.study-review-modal.no-animation {
  animation: none;
}

.study-review-modal .study-review-actions {
  justify-content: flex-end;
}

.study-review-actions button.reviewed {
  background: #166534;
  border-color: #166534;
  color: #ffffff;
}

.study-dashboard-header,
.study-review-actions,
.study-review-row,
.study-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.study-dashboard-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
}

.study-dashboard-actions > button,
.study-dashboard-actions > .import-btn {
  box-sizing: border-box;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.study-dashboard-actions > button:not(.study-close-btn) {
  background: #166534;
  border-color: #166534;
  color: #ffffff;
  cursor: pointer;
}

.study-dashboard-actions > button:not(.study-close-btn):hover {
  background: #14532d;
  border-color: #14532d;
}

.study-dashboard-actions > .import-btn {
  background: #f8faf9;
  color: #166534;
  cursor: pointer;
}

.study-dashboard-actions > .import-btn:hover {
  background: #eef4f1;
  border-color: #6aa84f;
}

.study-dashboard-actions > button:focus-visible,
.study-dashboard-actions > .import-btn:focus-within {
  outline: 3px solid rgba(106, 168, 79, 0.3);
  outline-offset: 2px;
}

.study-dashboard-header h2,
.study-dashboard-header p,
.study-dashboard-modal h3 {
  margin-top: 0;
}

.study-dashboard-modal > .study-dashboard-header {
  flex-shrink: 0;
}

.study-dashboard-modal {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.study-dashboard-content {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(106, 168, 79, 0.4) transparent;
}

.study-dashboard-content::-webkit-scrollbar {
  width: 8px;
}

.study-dashboard-content::-webkit-scrollbar-thumb {
  background: rgba(106, 168, 79, 0.35);
  border-radius: 999px;
}

.study-dashboard-header p,
.study-muted,
.study-review-row small {
  color: #6b7280;
}

.study-close-btn,
.study-review-actions button {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.study-close-btn {
  border: 0;
  font-size: 16px;
}

.study-dashboard-actions > .study-close-btn {
  min-width: 34px;
  padding: 7px 8px;
  color: #4b5563;
}

.study-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.study-stat-grid > div {
  padding: 16px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(243, 246, 244, 0.9));
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.study-stat-grid > div:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(22, 101, 52, 0.08);
}

.study-stat-grid strong,
.study-stat-grid span {
  display: block;
}

.study-stat-grid strong {
  font-size: 22px;
  color: #166534;
}

.study-stat-grid span {
  margin-top: 4px;
  font-size: 12px;
  color: #4b5563;
}

.study-dashboard-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.study-dashboard-columns section,
.study-mistakes {
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.56), rgba(249,250,251,0.8));
  box-shadow: var(--shadow-card);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.study-dashboard-columns section:hover,
.study-mistakes:hover {
  border-color: rgba(106, 168, 79, 0.4);
  box-shadow: 0 12px 24px rgba(22, 101, 52, 0.08);
}

.study-history-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(106, 168, 79, 0.28);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(244, 251, 242, 0.96) 0%, rgba(238, 248, 255, 0.96) 100%);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.study-history-date {
  display: grid;
  gap: 6px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
}

.study-history-date input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  font: inherit;
}

.study-history-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.study-history-grid > div {
  padding: 12px 10px;
  border: 1px solid #dbe4de;
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
}

.study-history-grid strong,
.study-history-grid span {
  display: block;
}

.study-history-grid strong {
  color: #166534;
  font-size: 20px;
}

.study-history-grid span {
  margin-top: 4px;
  color: #4b5563;
  font-size: 12px;
}

.study-history-list {
  display: grid;
  gap: 8px;
}

.study-history-topic {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.study-history-topic:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.05);
}

.study-history-topic strong,
.study-history-topic small {
  display: block;
}

.study-history-topic small {
  color: #6b7280;
  margin-top: 3px;
}

.study-history-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  color: #374151;
  font-size: 12px;
  font-weight: 600;
}

.study-history-metrics span {
  padding: 4px 6px;
  border-radius: 999px;
  background: #f3f4f6;
}

.study-day-panel {
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.56), rgba(247,250,248,0.8));
  box-shadow: var(--shadow-card);
}

.study-day-header,
.study-todo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.study-day-header h3,
.study-day-header p,
.study-todo-header h4 {
  margin-top: 0;
}

.study-section-kicker {
  display: block;
  margin-bottom: 4px;
  color: #6aa84f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.study-day-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.study-day-controls button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
}

.study-day-header input,
.study-goal-grid input {
  box-sizing: border-box;
  padding: 7px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
}

.study-goal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.study-goal-grid label,
.study-goal-grid > div {
  display: grid;
  gap: 5px;
  align-content: center;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
}

.study-goal-grid strong {
  color: #166534;
  font-size: 20px;
}

.study-goal-grid span {
  font-weight: 400;
}

.study-todo-header {
  margin-top: 8px;
}

.study-todo-header h4 {
  margin-bottom: 0;
}

.study-todo-header span {
  color: #6b7280;
  font-size: 12px;
}

.study-progress-track {
  height: 7px;
  margin: 10px 0 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebe6;
}

.study-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6aa84f, #22c55e);
  transition: width 0.2s ease;
}

.study-todo-list {
  margin-top: 8px;
}

.study-todo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #eef2ef;
}

.study-todo-row label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  cursor: pointer;
}

.study-todo-row label span {
  overflow-wrap: anywhere;
}

.study-todo-actions {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
}

.study-todo-actions button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.study-todo-row .completed {
  color: #6b7280;
  text-decoration: line-through;
}

.study-mistakes-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.study-mistakes-header > div:first-child {
  min-width: 0;
}

.study-mistakes-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.study-mistakes-actions label,
.study-review-select {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
}

.study-mistakes-actions button {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  cursor: pointer;
}

.study-mistakes-actions button:not(:disabled) {
  border-color: #b94747;
  background: #b94747;
  color: #ffffff;
  font-weight: 600;
}

.study-mistakes-actions button:not(:disabled):hover {
  border-color: #963737;
  background: #963737;
}

.study-mistakes-actions button:disabled {
  border-color: #d7dde2;
  background: #f1f3f5;
  color: #84909a;
  cursor: not-allowed;
  opacity: 1;
}

.study-mistakes-header span {
  color: #6b7280;
  font-size: 12px;
}

.study-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin: 12px 0 8px;
}

.study-filter-grid label {
  display: grid;
  gap: 4px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
}

.study-filter-grid select {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  font: inherit;
  font-weight: 400;
}

.study-list-row {
  padding: 8px 0;
  border-bottom: 1px solid #eef2ef;
}

.study-review-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid #eef2ef;
}

.study-review-select {
  padding-top: 2px;
}

.study-review-row > div:first-child {
  min-width: 0;
}

.study-review-row strong,
.study-review-row small {
  display: block;
  line-height: 1.4;
}

.study-review-row strong {
  overflow-wrap: anywhere;
}

.study-review-actions {
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.study-review-question {
  padding: 16px;
  border-left: 4px solid #6aa84f;
  background: #e8eef5;
  color: #1e293b;
  line-height: 1.6;
}

.study-answer,
.study-explanation {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
}

.wrong-answer { background: #fff1f2; color: #9f1239; }
.right-answer { background: #f0fdf4; color: #166534; }
.study-explanation { background: #eff6ff; color: #1e40af; line-height: 1.5; }
.study-empty { color: #6b7280; font-size: 13px; }

body.dark-mode .study-dashboard-modal,
body.dark-mode .study-review-modal {
  background: #182431;
  color: #e5e7eb;
  border-color: #46544b;
  box-shadow: 0 20px 50px rgba(2, 6, 23, 0.5);
}

body.dark-mode .study-review-modal {
  background: #425d77;
}

body.dark-mode .study-review-header {
  background: linear-gradient(135deg, #253447, #202d38);
  border-color: #405247;
}

body.dark-mode .study-review-header p,
body.dark-mode .study-review-label {
  color: #b9c8bd;
}

body.dark-mode .study-review-status {
  background: #29415a;
  border-color: #52785b;
  color: #bbf7d0;
}

body.dark-mode .study-review-question {
  background: #2a4056;
  border-color: #46604d;
  color: #e5eee8;
}

body.dark-mode .study-review-modal .study-review-actions {
  background: #202f40;
  border-color: #405247;
}

body.dark-mode .study-explanation {
  border-color: #365d83;
}

body.dark-mode .study-dashboard-overlay {
  background: rgba(2, 8, 18, 0.72);
}

body.dark-mode .study-dashboard-header p,
body.dark-mode .study-muted,
body.dark-mode .study-review-row small,
body.dark-mode .study-empty,
body.dark-mode .study-mistakes-header span,
body.dark-mode .study-todo-header span {
  color: #aebdb3;
}

body.dark-mode .study-dashboard-columns section,
body.dark-mode .study-mistakes,
body.dark-mode .study-day-panel {
  background: #243548;
  border-color: #405247;
  box-shadow: none;
}

body.dark-mode .study-stat-grid > div {
  background: #243548;
  border-color: #405247;
  box-shadow: none;
}

body.dark-mode .study-stat-grid strong,
body.dark-mode .study-history-grid strong,
body.dark-mode .study-goal-grid strong {
  color: #9bd27d;
}

body.dark-mode .study-stat-grid span,
body.dark-mode .study-history-grid span,
body.dark-mode .study-history-date,
body.dark-mode .study-filter-grid label,
body.dark-mode .study-goal-grid label,
body.dark-mode .study-goal-grid > div {
  color: #b9c8bd;
}

body.dark-mode .study-history-card {
  background: #213447;
  border-color: #46604d;
  box-shadow: none;
}

body.dark-mode .study-history-grid > div,
body.dark-mode .study-history-topic {
  background: #2a3c50;
  border-color: #405247;
}

body.dark-mode .study-history-topic strong,
body.dark-mode .study-review-row strong,
body.dark-mode .study-todo-row,
body.dark-mode .study-list-row {
  color: #e5eee8;
}

body.dark-mode .study-history-topic small {
  color: #aebdb3;
}

body.dark-mode .study-history-metrics {
  color: #d3e0d6;
}

body.dark-mode .study-history-metrics span {
  background: #33495f;
}

body.dark-mode .study-review-question {
  color: #1b1b1b;
}

body.dark-mode .study-stat-grid > div,
body.dark-mode .study-close-btn,
body.dark-mode .study-review-actions button {
  background: #2d4053;
  color: #e5e7eb;
  border-color: #526258;
}

body.dark-mode .study-review-actions button.reviewed {
  background: #4f9ac2;
  border-color: #4f9ac2;
  color: #102015;
}

body.dark-mode .study-dashboard-actions > button:not(.study-close-btn) {
  background: #4f9ac2;
  border-color: #4f9ac2;
  color: #102015;
}

body.dark-mode .study-dashboard-actions > button:not(.study-close-btn):hover {
  background: #6cb8e2;
  border-color: #6cb8e2;
}

body.dark-mode .study-dashboard-actions > .import-btn {
  background: #2d4053;
  color: #b7e0a2;
  border-color: #526258;
}

body.dark-mode .study-dashboard-actions > .import-btn:hover {
  background: #3a5267;
  border-color: #4f9ac2;
}

body.dark-mode .study-dashboard-actions > .study-close-btn {
  color: #e5e7eb;
}

body.dark-mode .study-dashboard-columns section,
body.dark-mode .study-mistakes {
  border-color: #46544b;
}

body.dark-mode .study-history-card {
  background: linear-gradient(135deg, rgba(35, 57, 78, 0.9) 0%, rgba(20, 30, 38, 0.9) 100%);
  border-color: #51695d;
}

body.dark-mode .study-history-date {
  color: #cbd5e1;
}

body.dark-mode .study-history-date input {
  background: #2d4053;
  color: #e5e7eb;
  border-color: #526258;
}

body.dark-mode .study-history-grid > div {
  background: #2d4053;
  border-color: #526258;
}

body.dark-mode .study-history-grid strong {
  color: #b7e0a2;
}

body.dark-mode .study-history-topic {
  background: rgba(45, 64, 83, 0.7);
  border-color: #526258;
}

body.dark-mode .study-history-topic small {
  color: #cbd5e1;
}

body.dark-mode .study-history-metrics span {
  background: rgba(107, 114, 128, 0.25);
  color: #e5e7eb;
}

body.dark-mode .study-day-panel {
  border-color: #46544b;
}

body.dark-mode .study-day-header input,
body.dark-mode .study-goal-grid input {
  background: #2d4053;
  color: #e5e7eb;
  border-color: #526258;
}

body.dark-mode .study-day-controls button {
  background: #2d4053;
  color: #e5e7eb;
  border-color: #526258;
}

body.dark-mode .study-todo-row,
body.dark-mode .study-review-row,
body.dark-mode .study-list-row {
  border-color: #35463b;
}

body.dark-mode .study-todo-actions button {
  background: #2d4053;
  color: #e5e7eb;
  border-color: #526258;
}

body.dark-mode .study-todo-row .completed {
  color: #8fa196;
}

body.dark-mode .study-progress-track {
  background: #3c5265;
}

body.dark-mode .study-goal-grid label,
body.dark-mode .study-goal-grid > div {
  color: #cbd5e1;
}

body.dark-mode .study-filter-grid label {
  color: #cbd5e1;
}

body.dark-mode .study-filter-grid select {
  background: #2d4053;
  color: #e5e7eb;
  border-color: #526258;
}

body.dark-mode .study-review-question {
  background: #314b64;
  color: #e5edf5;
}

body.dark-mode .wrong-answer {
  background: #42252b;
  color: #fecdd3;
}

body.dark-mode .right-answer {
  background: #24415a;
  color: #bbf7d0;
}

body.dark-mode .study-explanation {
  background: #1e3448;
  color: #bfdbfe;
}

.study-review-modal {
  border: 1px solid #b8c7d6;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28), 0 0 0 4px rgba(148, 163, 184, 0.12);
}

.study-review-header {
  padding: 18px 20px 15px;
}

.study-review-header h2 {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.study-review-status {
  box-shadow: 0 4px 12px rgba(22, 101, 52, 0.08);
}

.study-review-question-block,
.study-answer-grid,
.study-explanation {
  margin-left: 20px;
  margin-right: 20px;
}

.study-review-question {
  font-size: 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48), 0 8px 18px rgba(71, 85, 105, 0.08);
}

.study-answer {
  min-height: 76px;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(71, 85, 105, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.study-answer:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(71, 85, 105, 0.12);
}

.study-explanation {
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.06);
}

.study-review-modal .study-review-actions {
  gap: 10px;
  margin-top: 16px;
  padding: 12px 20px 14px;
}

.study-review-modal .study-review-actions button {
  min-height: 38px;
  padding: 8px 13px;
  font-weight: 600;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.study-review-modal .study-review-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}

.study-review-modal .study-review-actions button.save {
  background: #166534;
  border-color: #166534;
  color: #ffffff;
}

body.dark-mode .study-review-modal {
  border-color: #6a8299;
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.58), 0 0 0 4px rgba(125, 211, 252, 0.08);
}

body.dark-mode .study-review-status {
  box-shadow: 0 4px 12px rgba(2, 6, 23, 0.2);
}

body.dark-mode .study-review-question {
  border-color: #7690aa;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 18px rgba(2, 6, 23, 0.18);
}

body.dark-mode .study-answer {
  box-shadow: 0 6px 14px rgba(2, 6, 23, 0.16);
}

body.dark-mode .study-review-modal .study-review-actions button.save {
  background: #4f9ac2;
  border-color: #4f9ac2;
  color: #071521;
}

.study-review-modal {
  border: 1px solid #d8e0ea;
  border-top: 0;
  background: #f8fafc;
  color: #172033;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
}

.study-review-header {
  background: #ffffff;
  border-bottom: 1px solid #e5eaf0;
}

.study-review-header h2 {
  color: #172033;
}

.study-review-header p {
  color: #687587;
}

.study-review-status {
  background: #eef8f1;
  border-color: #b8dec3;
  color: #17663a;
}

.study-review-question-block,
.study-answer-grid,
.study-explanation {
  margin-left: 20px;
  margin-right: 20px;
}

.study-review-question-block {
  margin-top: 18px;
}

.study-review-question {
  border: 1px solid #d7e2ee;
  border-left: 4px solid #4f86c6;
  background: #ffffff;
  color: #223049;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.wrong-answer {
  background: #fff7f8;
  border-color: #f3b6c1;
  color: #8f1d34;
}

.right-answer {
  background: #f3fbf6;
  border-color: #9bd7af;
  color: #17663a;
}

.study-explanation {
  background: #ffffff;
  border-color: #d7e2ee;
  color: #223049;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.study-review-modal .study-review-actions {
  background: #ffffff;
  border-top: 1px solid #e5eaf0;
}

.study-review-modal .study-review-actions button.save {
  background: #2578a9;
  border-color: #2578a9;
  color: #ffffff;
}

body.dark-mode .study-review-modal {
  background: #0f1825;
  color: #e8eef7;
  border-color: #2f4258;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
}

body.dark-mode .study-review-header {
  background: #162333;
  border-bottom-color: #2a3d52;
}

body.dark-mode .study-review-header h2 {
  color: #edf4ff;
}

body.dark-mode .study-review-header p {
  color: #aab8c9;
}

body.dark-mode .study-review-label {
  color: #aab8c9;
}

body.dark-mode .study-review-status {
  background: #18392d;
  border-color: #34745d;
  color: #b9f3ce;
}

body.dark-mode .study-review-question {
  background: #17283a;
  border-color: #38526c;
  border-left-color: #6aa9dd;
  color: #e8eef7;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

body.dark-mode .wrong-answer {
  background: #351b25;
  border-color: #934357;
  color: #ffd6dd;
}

body.dark-mode .right-answer {
  background: #173329;
  border-color: #3f8b68;
  color: #c6f6d7;
}

body.dark-mode .study-explanation {
  background: #17283a;
  border-color: #38526c;
  color: #dbeafe;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

body.dark-mode .study-review-modal .study-review-actions {
  background: #162333;
  border-top-color: #2a3d52;
}

body.dark-mode .study-review-modal .study-review-actions button.save {
  background: #5aa6d1;
  border-color: #5aa6d1;
  color: #06131d;
}

@media (max-width: 700px) {
  .study-review-header,
  .study-review-modal .study-review-actions {
    padding-left: 18px;
    padding-right: 18px;
  }

  .study-review-question-block,
  .study-answer-grid,
  .study-explanation {
    margin-left: 18px;
    margin-right: 18px;
  }

  .study-answer-grid {
    grid-template-columns: 1fr;
  }

  .study-review-modal .study-review-actions button {
    flex: 1 1 140px;
  }
}

@media (max-width: 700px) {
  .study-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .study-dashboard-columns { grid-template-columns: 1fr; }
  .study-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .study-goal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .study-dashboard-header { align-items: flex-start; flex-direction: column; }
  .study-dashboard-actions { width: 100%; flex-wrap: wrap; }
  .study-day-header { align-items: flex-start; flex-direction: column; }
  .study-mistakes-header { align-items: flex-start; flex-direction: column; }
  .study-mistakes-actions { width: 100%; flex-wrap: wrap; }
  .study-review-actions { width: 100%; justify-content: flex-start; }
  .study-history-topic { align-items: flex-start; flex-direction: column; }
  .study-history-metrics { justify-content: flex-start; }
}

/* ===== Canvas ===== */
#canvas {
  position:relative;
  min-height:100vh;
  background:
    linear-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.1) 1px, transparent 1px),
    #f3f3f3;
  background-size: 28px 28px, 28px 28px, auto;
}

/* ===== STUDY DASHBOARD POLISH ===== */
.study-dashboard-modal {
  width: min(1120px, 94vw);
  max-height: 90vh;
  padding: 24px 28px 20px;
  border-color: #d7e1e8;
  border-radius: 14px;
  background: #f5f8fa;
  color: #172b3a;
  box-shadow: 0 28px 90px rgba(14, 35, 49, 0.28);
}

.study-dashboard-header {
  align-items: flex-start;
  padding: 0 0 18px;
  border-bottom: 1px solid #dce5eb;
}

.study-dashboard-header h2 {
  margin: 3px 0 4px;
  color: #152b3b;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.25;
}

.study-dashboard-header p {
  margin: 0;
  color: #647789;
  font-size: 13px;
}

.study-dashboard-modal .study-section-kicker {
  color: #23806d;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.study-dashboard-content {
  padding: 2px 2px 4px;
}

.study-stat-grid {
  gap: 12px;
  margin: 18px 0 20px;
}

.study-stat-grid > div {
  min-width: 0;
  padding: 15px 12px 14px;
  border-color: #dce5eb;
  border-radius: 9px;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(23, 43, 58, 0.035);
  text-align: left;
}

.study-stat-grid > div:nth-child(2) { border-top: 3px solid #27836d; }
.study-stat-grid > div:nth-child(3) { border-top: 3px solid #4e83b6; }
.study-stat-grid > div:nth-child(4) { border-top: 3px solid #c28a35; }
.study-stat-grid > div:nth-child(5) { border-top: 3px solid #bf665f; }

.study-stat-grid strong {
  color: #172b3a;
  font-size: 25px;
  line-height: 1.15;
}

.study-stat-grid span {
  margin-top: 6px;
  color: #687b8b;
  font-size: 11px;
  line-height: 1.35;
}

.study-dashboard-columns {
  gap: 14px;
  margin-bottom: 14px;
}

.study-dashboard-columns section,
.study-mistakes,
.study-day-panel {
  padding: 17px 18px;
  border: 1px solid #dce5eb;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(23, 43, 58, 0.035);
}

.study-dashboard-columns section:hover,
.study-mistakes:hover {
  border-color: #c8d7df;
  box-shadow: 0 5px 14px rgba(23, 43, 58, 0.06);
}

.study-dashboard-modal h3 {
  display: flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid #36876b;
  color: #26765e;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.study-list-row,
.study-history-topic,
.study-review-row {
  border-color: #e8eef2;
}

.study-list-row {
  padding: 10px 0;
  color: #344a59;
  font-size: 13px;
}

.study-list-row strong {
  color: #a6574f;
  font-size: 11px;
}

.study-history-card {
  gap: 10px;
  padding: 12px;
  border-color: #e1e9ee;
  border-radius: 8px;
  background: #f7fafb;
  box-shadow: none;
}

.study-history-grid > div,
.study-history-topic {
  border-color: #e2e9ee;
  border-radius: 7px;
  background: #ffffff;
}

.study-history-grid > div { padding: 10px 8px; }
.study-history-grid strong { color: #2c6e79; }

.study-review-row {
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 2px;
}

.study-review-row strong {
  color: #263d4d;
  font-size: 13px;
  line-height: 1.5;
}

.study-review-row small {
  margin-top: 5px;
  color: #748595;
  font-size: 11px;
}

.study-review-actions button,
.study-mistakes-actions button {
  border-color: #cbd8e0;
  border-radius: 6px;
  background: #ffffff;
  color: #315267;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
}

.study-review-actions button:hover {
  border-color: #7cae9e;
  background: #f0f7f5;
}

.study-review-modal {
  width: min(700px, 92vw);
  max-height: 90vh;
  border: 1px solid #d8e2e9;
  border-radius: 14px;
  background: #f5f8fa;
  color: #172b3a;
  box-shadow: 0 28px 90px rgba(14, 35, 49, 0.32);
}

.study-review-header {
  align-items: center;
  padding: 21px 24px 18px;
  background: #ffffff;
  border-bottom-color: #e1e9ee;
}

.study-review-header h2 {
  margin: 4px 0 5px;
  color: #172b3a;
  font-size: 22px;
  font-weight: 700;
}

.study-review-header p {
  color: #718393;
}

.study-review-status {
  padding: 6px 10px;
  border-color: #c5e2d4;
  background: #eff8f3;
  color: #287455;
  box-shadow: none;
}

.study-review-question-block {
  margin-top: 20px;
}

.study-review-label {
  color: #718393;
  font-size: 10px;
  letter-spacing: 0.07em;
}

.study-review-question {
  padding: 18px 19px;
  border: 1px solid #dbe5eb;
  border-left: 4px solid #3d8a7a;
  border-radius: 8px;
  background: #ffffff;
  color: #233b4c;
  font-size: 15px;
  line-height: 1.7;
  box-shadow: 0 4px 12px rgba(23, 43, 58, 0.04);
}

.study-answer-grid { gap: 12px; }

.study-answer {
  min-height: 84px;
  padding: 15px 16px;
  border-radius: 8px;
  box-shadow: none;
}

.wrong-answer {
  border-color: #edc3c7;
  border-left: 3px solid #c65c61;
  background: #fff8f7;
  color: #853f43;
}

.right-answer {
  border-color: #c5dfd0;
  border-left: 3px solid #398567;
  background: #f5faf7;
  color: #28694f;
}

.study-explanation {
  padding: 15px 16px;
  border-color: #dce5eb;
  border-radius: 8px;
  background: #ffffff;
  color: #344e60;
  box-shadow: none;
}

.study-review-modal .study-review-actions {
  margin-top: 20px;
  padding: 15px 24px 18px;
  border-top-color: #e1e9ee;
  background: #ffffff;
}

.study-review-modal .study-review-actions button {
  min-height: 39px;
  border-radius: 6px;
  color: #3e5667;
}

.study-review-modal .study-review-actions button.save {
  border-color: #26765e;
  background: #26765e;
  color: #ffffff;
}

.study-review-modal .study-review-actions button.save:hover {
  background: #1d624d;
}

body.dark-mode .study-dashboard-modal {
  background: #172534;
  color: #e7eef3;
  border-color: #34495a;
}

body.dark-mode .study-dashboard-header {
  border-color: #34495a;
}

body.dark-mode .study-dashboard-header h2,
body.dark-mode .study-dashboard-modal h3,
body.dark-mode .study-review-row strong,
body.dark-mode .study-list-row {
  color: #e7eef3;
}

body.dark-mode .study-dashboard-header p,
body.dark-mode .study-stat-grid span,
body.dark-mode .study-review-row small {
  color: #a9bac8;
}

body.dark-mode .study-dashboard-columns section,
body.dark-mode .study-mistakes,
body.dark-mode .study-day-panel,
body.dark-mode .study-stat-grid > div {
  border-color: #34495a;
  background: #203344;
  box-shadow: none;
}

body.dark-mode .study-stat-grid strong { color: #eff6fa; }
body.dark-mode .study-history-card { background: #1b2c3b; border-color: #34495a; }
body.dark-mode .study-history-grid > div,
body.dark-mode .study-history-topic { background: #24394a; border-color: #3a5060; }
body.dark-mode .study-list-row strong { color: #f0a19a; }
body.dark-mode .study-review-actions button,
body.dark-mode .study-mistakes-actions button { background: #263b4d; color: #dce8ef; border-color: #40596b; }

body.dark-mode .study-review-modal {
  background: #172534;
  color: #e7eef3;
  border-color: #34495a;
}

body.dark-mode .study-review-header,
body.dark-mode .study-review-modal .study-review-actions {
  background: #1d3040;
  border-color: #34495a;
}

body.dark-mode .study-review-header h2 { color: #eff6fa; }
body.dark-mode .study-review-header p,
body.dark-mode .study-review-label { color: #a9bac8; }
body.dark-mode .study-review-status { background: #1d3b34; border-color: #376b58; color: #b8e7d0; }

body.dark-mode .study-review-question,
body.dark-mode .study-explanation {
  border-color: #3a5060;
  background: #203344;
  color: #e0eaf0;
}

body.dark-mode .study-review-question { border-left-color: #67b19e; }
body.dark-mode .wrong-answer { background: #3a2930; border-color: #70464d; border-left-color: #d2777b; color: #f0c7ca; }
body.dark-mode .right-answer { background: #203a34; border-color: #3e6a56; border-left-color: #69b38e; color: #c9ead7; }
body.dark-mode .study-review-modal .study-review-actions button { background: #263b4d; color: #dce8ef; border-color: #40596b; }
body.dark-mode .study-review-modal .study-review-actions button.save { background: #34856c; border-color: #34856c; color: #ffffff; }

@media (max-width: 700px) {
  .study-dashboard-modal {
    width: 96vw;
    max-height: 92vh;
    padding: 18px 15px 14px;
    border-radius: 11px;
  }

  .study-dashboard-header { gap: 12px; }
  .study-dashboard-actions { gap: 6px; }
  .study-dashboard-actions > button,
  .study-dashboard-actions > .import-btn { flex: 0 0 auto; justify-content: center; }
  .study-stat-grid { gap: 8px; }
  .study-stat-grid > div { padding: 12px 10px; }
  .study-dashboard-columns section,
  .study-mistakes,
  .study-day-panel { padding: 14px; }
  .study-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .study-review-row { grid-template-columns: 18px minmax(0, 1fr); }
  .study-review-row .study-review-actions { grid-column: 2; justify-content: flex-start; }
  .study-review-modal { width: 94vw; max-height: 92vh; }
}

@media (max-width: 420px) {
  .study-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .study-dashboard-header h2 { font-size: 20px; }
  .study-review-header { padding: 17px 16px 14px; }
  .study-review-question-block,
  .study-answer-grid,
  .study-explanation { margin-left: 16px; margin-right: 16px; }
  .study-review-modal .study-review-actions { padding: 12px 16px 15px; }
  .study-review-header-side { flex-direction: column-reverse; align-items: flex-end; gap: 7px; }
}
#canvas {
  margin-top: 64px;
  min-height: calc(100vh - 64px);
}


.toolbar button,
.toolbar select,
.toolbar input[type="search"] {
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #a3b5aa;
}


svg {
  position:absolute;
  top:0;
  left:0;
  pointer-events:none;
}

.connector-toggle {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #8faadc;
  color: #3b5bdb;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.connector-toggle:hover {
  background: #edf2ff;
}
.node.drop-child {
  box-shadow: inset 0 0 0 3px #22c55e;
}


.node.drop-before {
  box-shadow: inset 0 3px 0 #3b82f6;
}

.node.drop-after {
  box-shadow: inset 0 -3px 0 #3b82f6;
}

.node.drop-child {
  box-shadow: inset 0 0 0 3px #22c55e !important;
}

.node.drop-before {
  box-shadow: inset 0 3px 0 #3b82f6 !important;
}

.node.drop-after {
  box-shadow: inset 0 -3px 0 #3b82f6 !important;
}

body.dark-mode .node.drop-child {
  box-shadow: inset 0 0 0 3px #4ade80 !important;
}

body.dark-mode .node.drop-before {
  box-shadow: inset 0 3px 0 #60a5fa !important;
}

body.dark-mode .node.drop-after {
  box-shadow: inset 0 -3px 0 #60a5fa !important;
}

.node.dragging {
  opacity: 0.4;
}



.node.dragging {
  opacity: 0.6;
  cursor: grabbing;
  z-index: 5000;
}


/* ===== Nodes ===== */
.node {
  position: absolute;
  padding: 10px 14px 10px 14px;
  padding-right: 34px;
  border-radius: 14px;
  font-size: 14px;
  white-space: nowrap;
  width: max-content;
  color: #17352a;
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.12));
  background-color: color-mix(in srgb, var(--node-color, #e6f2e9) 80%, #334155);
  border: 1px solid rgba(76, 113, 91, 0.42);
  box-shadow: 0 8px 18px rgba(31, 70, 48, 0.12);
  cursor: grab;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
  overflow: visible;
  z-index: 1;
}

.node:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(31, 70, 48, 0.18);
  border-color: rgba(22, 101, 52, 0.68);
  filter: saturate(1.08);
  z-index: 3;
}

.node.has-note {
  border-color: rgba(76, 113, 91, 0.42);
  box-shadow: 0 8px 18px rgba(31, 70, 48, 0.12);
}

.node.menu-open {
  z-index: 10000 !important;
}

/* ===== Inline Edit Polish ===== */
.node-text {
  cursor: text;
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-block;
  line-height: 1.4;
}

.node.has-note .node-text {
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
}

.node-note-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(139, 92, 246, 0.12));
  border: 1px solid rgba(59, 130, 246, 0.22);
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.node.quiz-hidden {
  border-style: dashed;
}

.node.quiz-hidden .node-text {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  letter-spacing: 1px;
}
.node-text[contenteditable="true"] {
  display: inline-block;     /* 🔑 critical */
  background-color: #ffffff;
  color: #17352a;
  padding: 4px 8px;

  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(106,168,79,0.6);

  outline: none;
  line-height: 1.4;

  caret-color: red;          /* ✅ NOW WORKS */
}

.node.has-note .node-text[contenteditable="true"] {
  background-color: #ffffff;
  color: #17352a;
}

/* prevent ugly resize handles / artifacts */
.node-text[contenteditable="true"]:focus {
  border: none;
}

.import-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, #ffffff 0%, #f4faf5 100%);
  color: #1b1b1b;
  border: 1px dashed #a3b5aa;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.import-btn:hover {
  background: #eef4f1;
  border-color: #6aa84f;
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(106, 168, 79, 0.12);
}





.node-header {
  display:grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap:8px;
  align-items:center;
  position: relative;
  z-index: 2;
  min-width: 0;
}

.node-header > .node-body {
  display:flex;
  align-items:center;
  gap:6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
}

.node-header .node-text,
.node-header .node-note-pill,
.node-header .exam-badge-group,
.node-header .quiz-badge-group {
  flex-shrink: 0;
}

.menu-btn {
  background:none;
  border:none;
  color:#3b7d5a;
  font-size:16px;
  cursor:pointer;
  position: relative;
  z-index: 10;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 2px;
  flex-shrink: 0;
  justify-self: end;
}

.menu-btn:hover {
  background: rgba(22, 101, 52, 0.06);
}

.menu-btn.quiz-disabled {
  visibility: hidden;
  pointer-events: none;
}

/* ===== POPUP ANIMATION ===== */
@keyframes slideOutFromNode {
  0% {
    opacity: 0;
    margin-top: 12px;
  }
  100% {
    opacity: 1;
    margin-top: 0;
  }
}

/* ===== Menu ===== */
.menu {
  position:absolute;
  top:34px;
  right:0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border:1px solid rgba(163, 181, 170, 0.9);
  border-radius:12px;
  width:max-content;
  min-width:110px;
  max-width:190px;
  display:none;
  z-index: 3000;
  animation: slideOutFromNode 0.2s ease-out forwards;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.menu button {
  all:unset;
  display:block;
  width:100%;
  box-sizing:border-box;
  padding:10px 12px;
  cursor:pointer;
  white-space:nowrap;
  color:#1b1b1b;
  transition: background 0.18s ease, color 0.18s ease;
}

.menu button:hover {
  background: linear-gradient(180deg, #eefaf0 0%, #eaf2ee 100%);
  color: #166534;
}
/* ===== Floating Note Editor ===== */
.note-editor {
  position: absolute;
  width: 420px;
  background: #ffffff;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  z-index: 9000;
  box-sizing: border-box;
  animation: slideOutFromNode 0.25s ease-out forwards;
}

/* Header */
.note-editor-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1b1b1b;
}

/* Textarea */
.note-editor-textarea {
  width: 100%;
  min-height: min(440px, max(180px, calc(100vh - 260px)));
  resize: vertical;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #9fb5aa;
  font-family: Segoe UI, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  box-sizing: border-box;
  white-space: pre-wrap;
}

.note-editor-textarea:focus {
  border-color: #6aa84f;
  box-shadow: 0 0 0 2px rgba(106,168,79,0.35);
  outline: none;
}

/* Actions */
.note-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.note-editor-actions button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #a3b5aa;
  background: #ffffff;
  cursor: pointer;
  font-size: 13px;
}

.note-editor-actions button:hover {
  background: #eef4f1;
}

.note-editor-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== IMPORTANT NOTICE ===== */
.important-notice-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 99999;
  width: min(420px, calc(100vw - 32px));
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  overflow: hidden;
  border: 1px solid #e7c978;
  border-top: 4px solid #d97706;
  border-radius: 16px;
  background: #ffffff;
  color: #1f2937;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  cursor: default;
  animation: importantNoticeIn 0.2s ease-out;
}

@keyframes importantNoticeIn {
  from { opacity: 0; transform: translate(-50%, -47%) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.important-notice-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 22px 24px 18px;
  background: linear-gradient(135deg, #fffaf0, #fffdf7);
  border-bottom: 1px solid #f1e4bd;
}

.important-notice-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 12px;
  background: #fff1c7;
  font-size: 23px;
}

.important-notice-kicker {
  display: block;
  margin-bottom: 3px;
  color: #b45309;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.important-notice-header h3 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0;
}

.important-notice-body {
  padding: 20px 24px 4px;
}

.important-notice-body > p {
  margin: 0 0 14px;
  color: #475569;
  font-size: 14px;
  line-height: 1.55;
}

.important-notice-callout {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid #f0d88e;
  border-radius: 10px;
  background: #fffbeb;
  color: #713f12;
  font-size: 13px;
  line-height: 1.45;
}

.important-notice-callout strong {
  color: #92400e;
  font-size: 12px;
  text-transform: uppercase;
}

.important-notice-actions {
  padding: 20px 24px 24px;
}

.important-notice-actions button {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #166534;
  border-radius: 8px;
  background: #166534;
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.important-notice-actions button:disabled {
  border-color: #87948b;
  background: #87948b;
  cursor: not-allowed;
  transform: none;
}

.important-notice-actions button:hover {
  background: #14532d;
  transform: translateY(-1px);
}

.important-notice-actions button:disabled:hover {
  background: #87948b;
  transform: none;
}

#backupWarningCountdown {
  display: block;
  margin-top: 9px;
  color: #5f6d77;
  font-size: 12px;
  text-align: center;
}

/* ===== API KEY PROMPT ===== */
.api-key-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 99999;
  width: min(460px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  border: 1px solid #cbded0;
  border-top: 4px solid #6aa84f;
  border-radius: 16px;
  background: #ffffff;
  color: #1b1b1b;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);
  cursor: default;
  animation: apiKeyPromptIn 0.2s ease-out;
}

@keyframes apiKeyPromptIn {
  from { opacity: 0; transform: translate(-50%, -47%) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.api-key-content {
  padding: 24px;
}

.api-key-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin-bottom: 22px;
}

.api-key-kicker {
  display: block;
  margin-bottom: 3px;
  color: #6aa84f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.api-key-header h2 {
  margin: 0 0 5px;
  font-size: 21px;
  letter-spacing: 0;
}

.api-key-header p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}

.api-key-close {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 16px;
}

.api-key-close:hover,
.api-key-close:focus-visible {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #1f2937;
  outline: none;
}

.api-key-option {
  padding: 14px;
  border: 1px solid #d9e8dc;
  border-radius: 12px;
  background: #f7fbf7;
}

.api-key-whatsapp {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border: 0;
  border-radius: 8px;
  background: #25d366;
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.api-key-whatsapp:hover {
  background: #1fba59;
  transform: translateY(-1px);
}

.api-key-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.api-key-divider::before,
.api-key-divider::after {
  height: 1px;
  flex: 1;
  background: #e2e8f0;
  content: "";
}

.api-key-field label {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.api-key-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #b9cbbd;
  border-radius: 9px;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.api-key-input-wrap:focus-within {
  border-color: #6aa84f;
  box-shadow: 0 0 0 3px rgba(106, 168, 79, 0.18);
}

.api-key-input-wrap input {
  min-width: 0;
  flex: 1;
  padding: 11px 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #1f2937;
  font: inherit;
  font-size: 14px;
}

.api-key-input-wrap button {
  margin-right: 5px;
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  background: #eef4f1;
  color: #166534;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.api-key-field small {
  display: block;
  margin-top: 8px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.4;
}

.api-key-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.api-key-actions button {
  padding: 9px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.api-key-actions .cancel {
  background: #ffffff;
  color: #475569;
}

.api-key-actions .save {
  border-color: #166534;
  background: #166534;
  color: #ffffff;
}

.api-key-actions button:hover {
  filter: brightness(0.96);
}

/* ===== POINTER ARROW FOR NOTE EDITOR ===== */
.note-editor::after {
  content: "";
  position: absolute;
  top: 12px;
  border-style: solid;
  display: none;
}
.note-editor.arrow-left::after {
  display: block;
  left: -8px;
  border-width: 8px 8px 8px 0;
  border-color: transparent #ffffff transparent transparent;
}
.note-editor.arrow-right::after {
  display: block;
  right: -8px;
  border-width: 8px 0 8px 8px;
  border-color: transparent transparent transparent #ffffff;
}

.youtube-editor {
  position: fixed;
  width: 300px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  padding: 12px;
  z-index: 9000;
  font-family: sans-serif;
  animation: slideOutFromNode 0.25s ease-out forwards;
}

.youtube-editor-header {
  font-weight: 600;
  margin-bottom: 8px;
}

.youtube-input {
  width: 90%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  margin-bottom: 10px;
  outline: none;
}

.youtube-input:focus {
  border-color: #3b7d5a;
}

.youtube-editor-actions {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.youtube-editor-actions button {
  flex: 1;
  padding: 6px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.youtube-editor-actions .open {
  background: #e53935;
  color: white;
}

.youtube-editor-actions .save {
  background: #3b7d5a;
  color: white;
}

.youtube-editor-actions .remove {
  background: #777;
  color: white;
}

.youtube-editor-actions .cancel {
  background: #ddd;
}


.note-viewer-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 8px;
}

.note-viewer-header button {
  border: none;
  background: transparent;
  cursor: pointer;
}

/* ===== NOTE VIEWER (PROFESSIONAL UI) ===== */
.note-viewer {
  position: absolute;
  width: 720px;
  background: linear-gradient(180deg, #f8fbf6 0%, #eef7ee 100%);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow:
    0 16px 36px rgba(15, 23, 42, 0.14),
    0 2px 8px rgba(76, 141, 82, 0.08);
  z-index: 9000;
  font-family: "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  animation: slideOutFromNode 0.25s ease-out forwards;
}

/* ===== HEADER ===== */
.note-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

/* ===== POINTER ARROW FOR NOTE VIEWER ===== */
.note-viewer::before,
.note-viewer::after {
  content: "";
  position: absolute;
  top: 12px;
  border-style: solid;
  display: block;
}
/* Default (box on the right, pointing left) */
.note-viewer.arrow-left::before {
  left: -9px;
  border-width: 9px 9px 9px 0;
  border-color: transparent #e5e7eb transparent transparent; 
}
.note-viewer.arrow-left::after {
  left: -8px;
  border-width: 8px 8px 8px 0;
  border-color: transparent #f9fafb transparent transparent;
  margin-top: 1px;
}
/* Flipped (box on the left, pointing right) */
.note-viewer.arrow-right::before {
  right: -9px;
  border-width: 9px 0 9px 9px;
  border-color: transparent transparent transparent #e5e7eb;
}
.note-viewer.arrow-right::after {
  right: -8px;
  border-width: 8px 0 8px 8px;
  border-color: transparent transparent transparent #f9fafb;
  margin-top: 1px;
}

.note-viewer-header span {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  letter-spacing: 0.01em;
}

.note-viewer-actions {
  display: flex;
  gap: 4px;
}

/* ===== HEADER BUTTONS ===== */
.note-viewer-header button {
  border: none;
  background: transparent;
  cursor: pointer;

  font-size: 16px;
  color: #9ca3af;

  border-radius: 6px;
  padding: 2px 6px;
  transition: all 0.2s;
}

.note-viewer-header button:hover {
  background: #e5e7eb;
  color: #111827;
}

/* ===== BODY ===== */
.note-viewer-body {
  font-size: 14px;
  color: #374151;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 10px 10px 4px;
  background: rgba(240, 247, 238, 0.9);
  border: 1px solid rgba(119, 156, 116, 0.22);
  border-radius: 12px;
}

.note-viewer-body .search-match {
  background-color: orange;
  border-radius: 4px;
  padding: 0 2px;
}

.node.active-hit {
  transform: scale(1.05);
  z-index: 999;
}

.note-editor-hint {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 10px;
  line-height: 1.4;
}
.note-viewer-body h1,
.note-viewer-body h2,
.note-viewer-body h3,
.note-viewer-body h4,
.note-viewer-body h5,
.note-viewer-body h6 {
  margin: 0 0 8px;
  font-weight: 700;
}

.note-viewer-body h1 { font-size: 20px; }
.note-viewer-body h2 { font-size: 18px; }
.note-viewer-body h3 { font-size: 16px; }

.note-viewer-body blockquote {
  margin: 8px 0;
  padding: 10px 12px;
  border-left: 4px solid #d1d5db;
  background: #f3f4f6;
  color: #1f2937;
}

.note-viewer-body ul,
.note-viewer-body ol {
  margin: 4px 0;
  padding-left: 20px;
}

.note-viewer-body li {
  margin: 0 0 1px 0;
  line-height: 1.25;
}

.note-viewer-body code {
  background: rgba(15, 23, 42, 0.05);
  color: #111827;
  padding: 2px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.note-viewer-body pre {
  margin: 12px 0;
  padding: 12px;
  background: #111827;
  color: #f8fafc;
  overflow-x: auto;
  border-radius: 10px;
}

.note-viewer-body a {
  color: #3d7a3d;
  text-decoration: underline;
}

.node.active-hit .node-text {
  background-color: orange;   /* 🟠 orange text */
  font-weight: 600;
}


@keyframes flashNode {
  0% { transform: scale(0.95); opacity: 0.6; }
  100% { transform: scale(1.05); opacity: 1; }
}

@media (max-width: 768px) {

  .toolbar {
    height: auto;
    padding: 8px;
  }

  .toolbar-inner {
    flex-wrap: wrap;
    width: 100%;
    transform: none !important;
    gap: 6px;
  }

  .toolbar button,
  .toolbar select,
  .toolbar input[type="search"] {
    font-size: 12px;
    padding: 6px 8px;
  }

  .toolbar input[type="search"] {
    flex: 1;
    min-width: 120px;
  }
}

@media (max-width: 768px) {
  .note-editor {
    width: min(90vw, 560px);
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    left: 5vw !important;
    top: 80px !important;
  }

  .note-editor-textarea {
    min-height: min(440px, max(100px, calc(100vh - 400px)));
  }

  .note-viewer {
    width: 720px;
  }
}


.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, #f7faf8 0%, #eef3f1 100%);
  border: 1px solid rgba(163, 181, 170, 0.9);
  border-radius: 18px;
  padding: 5px 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75);
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  width: 140px;
  color: #1f2937;
}

#searchCount {
  font-size: 12px;
  color: #374151;
  min-width: 42px;
  text-align: center;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(106, 168, 79, 0.08);
}

.search-box button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  padding: 3px 5px;
  border-radius: 8px;
  color: #374151;
}

.search-box button:hover {
  color: #111827;
  background: rgba(22, 101, 52, 0.05);
}

#quizModeBtn.active {
  background: #dff5ea;
  border-color: #6aa84f;
}

.toolbar-inner {
  overflow-x: auto; 
  flex-wrap: nowrap;
}

/* ===== NODE BODY ===== */
.node-body {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

/* ===== BADGE (LIKE YOUR IMAGE) ===== */
.exam-badge {
  position: absolute;
  
  right: -10px;

  background: #38bdf8;
  color: white;

  font-size: 10px;
  font-weight: 600;

  padding: 2px 6px;
  border-radius: 10px;

  cursor: pointer;
  white-space: nowrap;

  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.exam-badge-group {
  position: absolute;
  top: -18px;   /* 🔼 moved higher */
  right: -8px;

  display: flex;
  gap: 4px;
}


/* special count badge */
.count-badge {
  background: #6366f1; /* purple */
}

.exam-popup {
position: absolute;  top: 80px;
  right: 20px;

  background: #ffffff;
  border-radius: 10px;
  padding: 12px;

  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 9000;

  width: 220px;
  animation: slideOutFromNode 0.25s ease-out forwards;
}

.exam-popup-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
}

.exam-popup-header button {
  border: none;
  background: transparent;
  cursor: pointer;
}

.exam-popup-body {
  font-size: 13px;
  line-height: 1.5;
}

.exam-badge {
  pointer-events: auto;   /* ✅ IMPORTANT */
  z-index: 10;            /* ✅ above node */
}

.node-body {
  position: relative;
  z-index: 1;
}

/* ===== FILTER BUTTON ===== */
#filterBtn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #a3b5aa;
  background: #ffffff;
  cursor: pointer;
}

/* ===== DROPDOWN PANEL (FIXED POSITION) ===== */
.filter-dropdown-menu {
  position: fixed;   /* 🔥 KEY CHANGE */

  width: 220px;
  max-height: 260px;
  overflow-y: auto;

  background: #ffffff;
  border-radius: 10px;
  padding: 10px;

  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  z-index: 10020;

  font-size: 13px;
  animation: slideOutFromNode 0.25s ease-out forwards;
}

/* hidden */
.hidden {
  display: none;
}

/* title */
.filter-title {
  font-weight: 600;
  margin-bottom: 6px;
}

/* group */
.filter-group {
  margin-top: 8px;
}

.filter-group b {
  display: block;
  margin-bottom: 4px;
  color: #374151;
}

/* checkbox rows */
.filter-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.filter-group label:hover {
  background: #f3f4f6;
}

/* ===== EXAM TEST RUNNER ===== */
.test-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99998;
}

.exam-test-modal {
  position: fixed;
  inset: 28px;
  z-index: 99999;
  background: #ffffff;
  color: #111827;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.exam-test-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.exam-test-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.exam-test-header div {
  font-size: 13px;
  color: #6b7280;
}

.exam-test-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exam-test-header-actions button,
.exam-test-footer button,
.exam-section-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  border-radius: 7px;
  padding: 7px 10px;
  cursor: pointer;
  font-family: inherit;
}

#examTimer {
  min-width: 82px;
  text-align: center;
  color: #dc2626;
  font-weight: 700;
}

.exam-section-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
}

.exam-section-btn.active {
  background: #dff5ea;
  border-color: #6aa84f;
  color: #166534;
}

.exam-test-body {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: 0;
  flex: 1;
}

.exam-question-palette {
  border-right: 1px solid #e5e7eb;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 8px;
  overflow: auto;
  background: #f8fafc;
}

.exam-question-chip.review {
  background: #fef3c7 !important;
  border-color: #f59e0b !important;
  color: #92400e !important;
}

.exam-question-panel {
  padding: 22px;
  overflow: auto;
}

.exam-question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #6b7280;
  font-size: 12px;
  margin-bottom: 12px;
}

.exam-question-panel h3 {
  margin: 0 0 18px;
  font-size: 18px;
  line-height: 1.55;
}

.exam-options {
  display: grid;
  gap: 10px;
}

.exam-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 11px;
  cursor: pointer;
  line-height: 1.45;
}

.exam-option:hover {
  background: #f8fafc;
}

.exam-option.correct {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
  font-weight: 600;
}

.exam-option.wrong {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
  text-decoration: line-through;
}

.exam-explanation {
  display: none;
  margin-top: 16px;
  padding: 12px;
  border-left: 4px solid #22c55e;
  background: #f0fdf4;
  color: #15803d;
  border-radius: 5px;
  line-height: 1.55;
}

.exam-test-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
}

.exam-test-footer > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .exam-test-modal {
    inset: 8px;
  }

  .exam-test-header,
  .exam-test-footer {
    align-items: flex-start;
  }

  .exam-test-header,
  .exam-test-body {
    display: block;
  }

  .exam-question-palette {
    display: flex;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
  }

  .exam-question-chip {
    min-width: 36px;
  }
}

/* hide toolbar horizontal scrollbar */
.toolbar-inner::-webkit-scrollbar {
  height: 0px;
}

.toolbar-inner {
  scrollbar-width: none;   /* Firefox */
}

/* ================= DARK MODE ================= */
body.dark-mode {
  --bg-page: #0f1720;
  --bg-panel: rgba(18, 24, 30, 0.82);
  --bg-soft: #132127;
  --bg-elevated: #1a252d;
  --bg-muted: #18252c;
  --border-soft: rgba(90, 110, 120, 0.9);
  --border-strong: #3a4a52;
  --primary: #8fd084;
  --primary-strong: #d8f7d0;
  --primary-soft: rgba(143, 208, 132, 0.12);
  --accent: #7dd3fc;
  --accent-soft: rgba(125, 211, 252, 0.12);
  --text: #e6f1ef;
  --text-muted: #b4c4c2;
  --shadow-soft: 0 12px 28px rgba(2, 6, 23, 0.35);
  --shadow-card: 0 12px 28px rgba(15, 23, 42, 0.24);
  background: linear-gradient(180deg, #0f1720 0%, #111c24 100%);
  color: var(--text);
}

body.dark-mode #canvas {
  background:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    #262626;
  background-size: 28px 28px, 28px 28px, auto;
}

body.dark-mode .toolbar {
  background: rgba(18, 24, 30, 0.82);
  border-bottom: 1px solid var(--border-soft);
}

body.dark-mode .toolbar button,
body.dark-mode .toolbar select,
body.dark-mode .toolbar input[type="search"] {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #e0e0e0;
}

body.dark-mode .toolbar button:hover {
  background: #333;
}

body.dark-mode .node {
  background: var(--node-color, #2a2a2a);
  box-shadow: 0 0 0 1px #444;
}

body.dark-mode .node.important {
  box-shadow:
    0 0 0 2px red,
    0 0 0 4px rgba(245, 158, 11, 0.22),
    0 6px 16px rgba(245, 158, 11, 0.25);
  border: 1px solid rgba(251, 191, 36, 0.65);
}

body.dark-mode .node-text,
body.dark-mode .menu-btn,
body.dark-mode .note-icon {
  color: #1b1b1b;
}

body.dark-mode .node-text[contenteditable="true"] {
  background-color: #1e1e1e;
  color: #e0e0e0;
}

body.dark-mode .node.faded::after {
  background: rgba(18, 18, 18, 0.65);
}

body.dark-mode .menu {
  background: #1e1e1e;
  border-color: #333;
}

body.dark-mode .menu button {
  color: #e0e0e0;
}

body.dark-mode .menu button:hover {
  background: #333;
}

body.dark-mode .note-viewer, 
body.dark-mode .note-editor, 
body.dark-mode .youtube-editor,
body.dark-mode .exam-popup,
body.dark-mode .filter-dropdown-menu,
body.dark-mode .exam-test-modal {
  background: #1a261f;
  border-color: #395744;
  color: #e0e0e0;
  box-shadow: 0 16px 36px rgba(10, 19, 16, 0.4), 0 2px 8px rgba(91, 148, 98, 0.12);
}

body.dark-mode .note-viewer-header span,
body.dark-mode .note-editor-header,
body.dark-mode .youtube-editor-header,
body.dark-mode .exam-popup-header,
body.dark-mode .filter-title {
  color: #ffffff;
}

body.dark-mode .note-viewer-body,
body.dark-mode .exam-popup-body {
  color: #e5f5ea;
  background: #1e3129;
  border-color: rgba(129, 177, 127, 0.28);
}

body.dark-mode .note-viewer {
  background: linear-gradient(180deg, #202c35 0%, #172229 100%);
  border-color: rgba(105, 199, 245, 0.32);
  box-shadow: 0 18px 42px rgba(2, 8, 12, 0.58), 0 2px 10px rgba(37, 139, 209, 0.16);
}

body.dark-mode .note-viewer.arrow-left::before {
  border-color: transparent #435763 transparent transparent;
}

body.dark-mode .note-viewer.arrow-left::after {
  border-color: transparent #202c35 transparent transparent;
}

body.dark-mode .note-viewer.arrow-right::before {
  border-color: transparent transparent transparent #435763;
}

body.dark-mode .note-viewer.arrow-right::after {
  border-color: transparent transparent transparent #202c35;
}

body.dark-mode .note-viewer-body {
  color: #dcecf2;
  background: rgba(12, 24, 31, 0.58);
  border-color: rgba(105, 199, 245, 0.2);
}

body.dark-mode .note-viewer-body blockquote {
  background: #263841;
  border-left-color: #55aee6;
  color: #dcecf2;
}

body.dark-mode .note-viewer-body code {
  background: rgba(105, 199, 245, 0.12);
  color: #bfe8fa;
}

body.dark-mode .note-viewer-body pre {
  background: #0d171d;
  color: #dcecf2;
}

body.dark-mode .note-viewer-body a {
  color: #69c7f5;
}

body.dark-mode .note-viewer-header button:hover {
  background: rgba(105, 199, 245, 0.14);
  color: #ffffff;
}

body.dark-mode .note-editor-textarea {
  background: #303030;
  color: #eaf9ef;
  border-color: #4f6c5e;
}

body.dark-mode .note-editor-actions button,
body.dark-mode .youtube-editor-actions button.cancel,
body.dark-mode .note-viewer-header button,
body.dark-mode .exam-popup-header button,
body.dark-mode .exam-test-header-actions button,
body.dark-mode .exam-test-footer button,
body.dark-mode .exam-section-btn {
  background: #20372d;
  color: #eaf9ef;
  border-color: #4b665b;
}

body.dark-mode .note-editor-actions button:hover,
body.dark-mode .youtube-editor-actions button.cancel:hover,
body.dark-mode .note-viewer-header button:hover,
body.dark-mode .exam-popup-header button:hover,
body.dark-mode .exam-test-header-actions button:hover,
body.dark-mode .exam-test-footer button:hover,
body.dark-mode .exam-section-btn:hover {
  background: #333;
  color: #fff;
}

body.dark-mode .note-editor {
  border-color: #484848;
  background: #262626;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

body.dark-mode .note-editor-textarea,
body.dark-mode .note-editor-textarea:focus {
  border-color: #565656;
}

body.dark-mode .note-editor-textarea:focus {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

body.dark-mode .note-editor-actions button {
  border-color: #565656;
  background: #383838;
}

body.dark-mode .note-editor-actions button:hover {
  border-color: #686868;
  background: #414141;
}

body.dark-mode .api-key-modal {
  background: #1e1e1e;
  border-color: #405247;
  color: #e5eee8;
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.55);
}

body.dark-mode .api-key-header p,
body.dark-mode .api-key-field small {
  color: #aebdb3;
}

body.dark-mode .api-key-close:hover,
body.dark-mode .api-key-close:focus-visible {
  border-color: #526258;
  background: #2d4053;
  color: #ffffff;
}

body.dark-mode .api-key-option {
  border-color: #405247;
  background: #243548;
}

body.dark-mode .api-key-divider {
  color: #8fa196;
}

body.dark-mode .api-key-divider::before,
body.dark-mode .api-key-divider::after,
body.dark-mode .api-key-actions {
  border-color: #405247;
}

body.dark-mode .api-key-field label {
  color: #d3e0d6;
}

body.dark-mode .api-key-input-wrap {
  border-color: #526258;
  background: #2d4053;
}

body.dark-mode .api-key-input-wrap input {
  color: #e5eee8;
}

body.dark-mode .api-key-input-wrap button {
  background: #33495f;
  color: #bbf7d0;
}

body.dark-mode .api-key-actions .cancel {
  background: #2d4053;
  color: #e5e7eb;
  border-color: #526258;
}

body.dark-mode .important-notice-modal {
  background: #1e2521;
  border-color: #80652b;
  color: #e5eee8;
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.55);
}

body.dark-mode .important-notice-header {
  background: linear-gradient(135deg, #332b1b, #28271f);
  border-color: #584a2a;
}

body.dark-mode .important-notice-icon {
  background: #59471f;
}

body.dark-mode .important-notice-kicker {
  color: #fbbf24;
}

body.dark-mode .important-notice-body > p {
  color: #cbd5d0;
}

body.dark-mode .important-notice-callout {
  border-color: #80652b;
  background: #352d1d;
  color: #f5d889;
}

body.dark-mode .important-notice-callout strong {
  color: #fbbf24;
}

body.dark-mode .exam-test-header,
body.dark-mode .exam-section-tabs,
body.dark-mode .exam-test-footer,
body.dark-mode .exam-question-palette {
  border-color: #333;
}

body.dark-mode .exam-question-palette {
  background: #181818;
}

body.dark-mode .exam-option {
  background: #242424;
  border-color: #444;
}

body.dark-mode .exam-option:hover {
  background: #303030;
}

body.dark-mode .search-box {
  background: #2d4053;
}

body.dark-mode .search-box input {
  color: #e0e0e0;
}

body.dark-mode #searchCount {
  color: #aaa;
}

body.dark-mode .search-box button {
  color: #e0e0e0;
}

body.dark-mode .connector-toggle {
  background: #1e1e1e;
  border-color: #555;
  color: #8faadc;
}

body.dark-mode .connector-toggle:hover {
  background: #33495f;
}

body.dark-mode svg path {
  stroke: #6aa84f;
}

body.dark-mode .note-viewer.arrow-left::before {
  border-color: transparent #333 transparent transparent; 
}
body.dark-mode .note-viewer.arrow-left::after {
  border-color: transparent #1e1e1e transparent transparent;
}
body.dark-mode .note-viewer.arrow-right::before {
  border-color: transparent transparent transparent #333;
}
body.dark-mode .note-viewer.arrow-right::after {
  border-color: transparent transparent transparent #1e1e1e;
}

body.dark-mode .note-editor.arrow-left::after {
  border-color: transparent #1e1e1e transparent transparent;
}
body.dark-mode .note-editor.arrow-right::after {
  border-color: transparent transparent transparent #1e1e1e;
}

body.dark-mode .youtube-input {
  background: #2d4053;
  border-color: #444;
  color: #e0e0e0;
}

body.dark-mode .expand-collapse-btn {
  background: #2d4053;
  border-color: #444;
}
body.dark-mode .expand-collapse-btn::before,
body.dark-mode .expand-collapse-btn::after {
  border-color: #ccc;
}
body.dark-mode .expand-collapse-btn:hover {
  background: #33495f;
}

body.dark-mode .import-btn {
  background: #2d4053;
  color: #e0e0e0;
  border-color: #444;
}
body.dark-mode .import-btn:hover {
  background: #33495f;
  border-color: #4f9ac2;
}

/* ===== QUIZ PYQ TAG ===== */
.quiz-pyq-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  vertical-align: baseline;
}
body.dark-mode .quiz-pyq-tag {
  background: #451a03;
  color: #fde68a;
  border-color: #78350f;
}

/* ===== NODE QUIZ BADGE ===== */
.quiz-badge-group {
  display: inline-block;
  margin-left: 6px;
}
.quiz-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #e6f2ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.quiz-badge-dropdown {
  font-size: 11px;
  line-height: 1;
}

.node-quiz-menu {
  position: absolute;
  z-index: 10001;
  min-width: 180px;
  max-width: 260px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
  overflow: hidden;
}

.node-quiz-menu button {
  all: unset;
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  color: #1e3a8a;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-quiz-menu button:hover {
  background: #e6f2ff;
}

body.dark-mode .node-quiz-menu {
  background: #1e293b;
  border-color: #0b1220;
}

body.dark-mode .node-quiz-menu button {
  color: #93c5fd;
}

body.dark-mode .node-quiz-menu button:hover {
  background: #26354d;
}
body.dark-mode .quiz-badge {
  background: #1e293b;
  color: #93c5fd;
  border-color: #0b1220;
}

/* ===== QUIZ PAGINATION GRID ===== */
button.quiz-nav-btn,
button.exam-question-chip,
.quiz-nav-btn,
.exam-question-chip {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}
button.quiz-nav-btn:hover,
button.exam-question-chip:hover,
.quiz-nav-btn:hover,
.exam-question-chip:hover {
  background: #f3f4f6 !important;
}
button.quiz-nav-btn.visited,
button.exam-question-chip.visited,
.quiz-nav-btn.visited,
.exam-question-chip.visited {
  background: #ede9fe !important;
  border-color: #a78bfa !important;
  color: #3730a3 !important;
}
button.quiz-nav-btn.answered,
button.exam-question-chip.answered,
.quiz-nav-btn.answered,
.exam-question-chip.answered {
  background: #dcfce3 !important;
  border-color: #86efac !important;
  color: #166534 !important;
}
button.quiz-nav-btn.active,
button.exam-question-chip.active,
.quiz-nav-btn.active,
.exam-question-chip.active {
  border-color: #3b82f6 !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.3) !important;
}

.ai-quiz-wrapper {
  resize: both;
  min-width: 320px;
  min-height: 360px;
}

#aiQuizOverlay {
  background: rgba(15, 23, 42, 0.42) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.study-review-modal {
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border: 2px solid #6aa84f;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}

.study-review-overlay {
  z-index: 10032;
  background: rgba(15, 23, 42, 0.76);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#studyReviewModal {
  z-index: 10033;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.38);
}

body.dark-mode .study-review-modal {
  border-color: #82c66b;
}

.study-review-header {
  padding: 16px 20px 12px;
}

.study-review-question-block,
.study-answer-grid,
.study-explanation {
  margin: 0 16px;
}

.study-review-question-block {
  margin-top: 6px;
}

.study-review-label {
  margin-bottom: 4px;
}

.study-review-question {
  padding: 9px 12px;
  border-radius: 8px;
  line-height: 1.5;
  box-shadow: none;
}

.study-answer-grid {
  gap: 6px;
}

.study-answer {
  min-height: 0;
  justify-content: flex-start;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: none;
}

.study-answer:hover {
  transform: none;
  box-shadow: none;
}

.study-explanation {
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: none;
}

.study-review-modal .study-review-actions {
  gap: 8px;
  margin-top: 8px;
  padding: 8px 16px 10px;
}

@media (max-width: 700px) {
  .study-review-header {
    padding: 14px 14px 10px;
  }

  .study-review-question-block,
  .study-answer-grid,
  .study-explanation {
    margin-right: 12px;
    margin-left: 12px;
  }

  .study-review-modal .study-review-actions {
    padding-right: 12px;
    padding-left: 12px;
  }
}

#aiQuizModal.ai-quiz-wrapper {
  background: #f5faf7;
  color: #1d3327;
  border: 1px solid #b8cdbd;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(22, 54, 36, 0.28), 0 4px 14px rgba(15, 23, 42, 0.12);
}

#aiQuizModal .note-editor-header {
  margin: 0;
  padding: 16px 20px !important;
  background: linear-gradient(135deg, #e5f1e8 0%, #f8fcf9 100%);
  border-bottom: 1px solid #c7d9cc !important;
  color: #173b27;
}

#aiQuizTitle {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

#toggleQuizLangBtn,
#quizModeSelect {
  border-color: #a9c2b0 !important;
  background: #ffffff !important;
  color: #31563d !important;
}

#toggleQuizLangBtn:hover,
#quizModeSelect:hover {
  border-color: #4f8a61 !important;
  background: #f0f8f2 !important;
}

#quizModeBadge,
#aiQuizTimer {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  box-sizing: border-box;
}

#aiQuizTimer {
  padding: 5px 10px;
  border: 1px solid #f2b4b4;
  border-radius: 999px;
  background: #fff4f4;
  color: #b42318 !important;
  font-size: 14px !important;
}

#quizNavGrid {
  padding: 12px 20px !important;
  background: #edf5ef;
  border-bottom: 1px solid #c7d9cc !important;
}

#aiQuizModal > div:nth-of-type(3) {
  padding: 20px !important;
}

.ai-quiz-wrapper .quiz-question-container {
  padding: 18px;
  background: #ffffff;
  border: 1px solid #d4e2d7;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(31, 70, 48, 0.07);
}

.ai-quiz-wrapper .quiz-question-container > p {
  color: #183b28;
}

.ai-quiz-wrapper .quiz-opt-label {
  margin-bottom: 8px !important;
  padding: 10px 12px !important;
  border: 1px solid #e0ebe2;
  background: #f8fbf9;
  color: #294635;
}

.ai-quiz-wrapper .quiz-opt-label:hover {
  border-color: #8fba9a;
  background: #eef8f0;
}

.ai-quiz-wrapper .quiz-opt-label:has(input:checked) {
  border-color: #4f9662;
  background: #e3f3e6;
  box-shadow: 0 0 0 2px rgba(79, 150, 98, 0.14);
}

.ai-quiz-wrapper .quiz-opt-label input {
  accent-color: #287244;
}

.ai-quiz-wrapper .explanation {
  background: #eaf7ed !important;
  border-left-color: #2f9e55 !important;
  color: #216b38 !important;
}

#aiQuizModal > .note-editor-actions {
  padding: 14px 20px !important;
  background: #edf5ef;
  border-top: 1px solid #c7d9cc !important;
}

.ai-quiz-wrapper .note-editor-actions button {
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 9px;
  font-weight: 700;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.ai-quiz-wrapper .note-editor-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(31, 70, 48, 0.14);
}

#exportAiQuizBtn {
  background: #27834a !important;
  border-color: #1e6b3c !important;
}

#submitAiQuizBtn {
  background: #1f6f3e !important;
  border-color: #185b32 !important;
}

body:not(.dark-mode) #submitAiQuizBtn {
  background: #1f6f3e !important;
  border-color: #185b32 !important;
  color: #ffffff !important;
}

body:not(.dark-mode) #submitAiQuizBtn:hover:not(:disabled) {
  background: #14532d !important;
  border-color: #104225 !important;
  color: #ffffff !important;
}

body.dark-mode #aiQuizModal.ai-quiz-wrapper {
  background:
    radial-gradient(circle at 100% 0%, rgba(56, 92, 125, 0.28), transparent 34%),
    linear-gradient(145deg, #111923 0%, #17232e 52%, #0e151d 100%);
  color: #e3f0e6;
  border-color: #465b70;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(125, 211, 252, 0.08);
}

body.dark-mode #aiQuizModal .note-editor-header,
body.dark-mode #aiQuizModal > .note-editor-actions {
  background: linear-gradient(135deg, #202d3b 0%, #18232e 100%);
  border-color: #465b70 !important;
  color: #e5edf5;
}

body.dark-mode #aiQuizModal > div:nth-of-type(3) {
  background: rgba(8, 14, 22, 0.3);
}

body.dark-mode #toggleQuizLangBtn,
body.dark-mode #quizModeSelect {
  background: #263b52 !important;
  border-color: #4a6952 !important;
  color: #d9ebdd !important;
}

body.dark-mode #quizNavGrid {
  background: linear-gradient(180deg, #1d2b39, #17222d);
  border-color: #465b70 !important;
}

body.dark-mode .ai-quiz-wrapper .quiz-question-container {
  background: linear-gradient(145deg, #263544, #202c39);
  border-color: #4b647b;
  box-shadow: 0 10px 24px rgba(2, 6, 12, 0.3), inset 0 1px 0 rgba(186, 220, 239, 0.06);
}

body.dark-mode .ai-quiz-wrapper .quiz-question-container > p,
body.dark-mode .ai-quiz-wrapper .quiz-opt-label {
  color: #e3f0e6;
}

body.dark-mode .ai-quiz-wrapper .quiz-opt-label {
  background: rgba(38, 52, 66, 0.92);
  border-color: #465d72;
}

body.dark-mode .ai-quiz-wrapper .quiz-opt-label:hover,
body.dark-mode .ai-quiz-wrapper .quiz-opt-label:has(input:checked) {
  background: #30465a;
  border-color: #7dd3fc;
  box-shadow: 0 0 0 2px rgba(125, 211, 252, 0.14);
}

body.dark-mode .ai-quiz-wrapper .explanation {
  background: #203d54 !important;
  color: #a9e1b2 !important;
}

@media (max-width: 768px) {
  #aiQuizModal.ai-quiz-wrapper {
    width: calc(100vw - 24px) !important;
    height: calc(100vh - 92px) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    left: 12px !important;
    top: 76px !important;
  }

  #aiQuizModal .note-editor-header {
    padding: 13px 14px !important;
  }

  #aiQuizModal > div:nth-of-type(3),
  #aiQuizModal > .note-editor-actions {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}

button.quiz-nav-btn.correct,
button.exam-question-chip.correct,
.quiz-nav-btn.correct,
.exam-question-chip.correct {
  background: #22c55e !important;
  border-color: #16a34a !important;
  color: white !important;
}
button.quiz-nav-btn.wrong,
button.exam-question-chip.wrong,
.quiz-nav-btn.wrong,
.exam-question-chip.wrong {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
  color: white !important;
}

button.quiz-nav-btn.active,
button.exam-question-chip.active,
.quiz-nav-btn.active,
.exam-question-chip.active {
  position: relative;
  z-index: 1;
}

button.quiz-nav-btn.active.correct,
button.exam-question-chip.active.correct,
.quiz-nav-btn.active.correct,
.exam-question-chip.active.correct,
button.quiz-nav-btn.active.wrong,
button.exam-question-chip.active.wrong,
.quiz-nav-btn.active.wrong,
.exam-question-chip.active.wrong {
  box-shadow: 0 0 0 3px #3b82f6 !important;
}

body.dark-mode .quiz-nav-btn,
body.dark-mode .exam-question-chip {
  background: #2a2a2a;
  border-color: #444;
  color: #e0e0e0;
}
body.dark-mode .quiz-nav-btn:hover,

body:not(.dark-mode) .quiz-nav-btn.active,
body:not(.dark-mode) .exam-question-chip.active {
  border: 2px solid #2563eb !important;
  background: #dbeafe !important;
  color: #1e3a8a !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.24), 0 0 14px rgba(37, 99, 235, 0.2) !important;
}

body:not(.dark-mode) .quiz-nav-btn.active.correct,
body:not(.dark-mode) .exam-question-chip.active.correct {
  background: #22c55e !important;
  border-color: #2563eb !important;
}

body:not(.dark-mode) .quiz-nav-btn.active.wrong,
body:not(.dark-mode) .exam-question-chip.active.wrong {
  background: #ef4444 !important;
  border-color: #2563eb !important;
}

body:not(.dark-mode) .quiz-nav-btn.active.correct,
body:not(.dark-mode) .exam-question-chip.active.correct,
body:not(.dark-mode) .quiz-nav-btn.active.wrong,
body:not(.dark-mode) .exam-question-chip.active.wrong {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.42), 0 0 14px rgba(37, 99, 235, 0.24) !important;
}
body.dark-mode .exam-question-chip:hover {
  background: #333;
}
body.dark-mode .quiz-nav-btn.visited,
body.dark-mode .exam-question-chip.visited {
  background: #312e81;
  border-color: #4338ca;
  color: #e0e7ff;
}

#nodeQuizEditorOverlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(5px);
}

#nodeQuizEditor.quiz-editor-modal {
  position: fixed;
  inset: 24px;
  z-index: 100001;
  display: flex;
  flex-direction: column;
  width: auto;
  height: auto;
  max-height: none;
  overflow: hidden;
  padding: 0;
  border: 1px solid #cbd9cf;
  border-radius: 12px;
  background: #f4f7f5;
  color: #1d2a22;
  box-shadow: 0 28px 90px rgba(6, 20, 12, 0.34);
  animation: quizEditorEnter 180ms ease-out both;
}

@keyframes quizEditorEnter {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#nodeQuizEditor .quiz-editor-header {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 28px;
  padding: 16px 54px 16px 22px;
  border-bottom: 1px solid #d9e2dc;
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(25, 53, 35, 0.05);
}

#nodeQuizEditor .quiz-editor-heading {
  min-width: 180px;
}

#nodeQuizEditor .quiz-editor-kicker {
  display: block;
  margin-bottom: 3px;
  color: #47805a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

#nodeQuizEditor .quiz-editor-heading h2 {
  margin: 0;
  color: #1c3325;
  font-size: 19px;
  line-height: 1.25;
}

#nodeQuizEditor .quiz-editor-settings {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(130px, 0.8fr) minmax(160px, 1fr);
  flex: 1;
  gap: 10px;
  max-width: 760px;
}

#nodeQuizEditor .quiz-editor-settings > label,
#nodeQuizEditor .quiz-editor-bilingual > label,
#nodeQuizEditor .quiz-editor-correct-answer,
#nodeQuizEditor .quiz-editor-pyq {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 6px;
  color: #53645a;
  font-size: 11px;
  font-weight: 700;
}

#nodeQuizEditor input,
#nodeQuizEditor textarea,
#nodeQuizEditor select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid #ccd8d0;
  border-radius: 6px;
  background: #fff;
  color: #1d2a22;
  font: 400 13px/1.45 'Poppins', sans-serif;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

#nodeQuizEditor input,
#nodeQuizEditor select {
  height: 36px;
  padding: 0 10px;
}

#nodeQuizEditor textarea {
  min-height: 72px;
  padding: 9px 10px;
  resize: vertical;
}

#nodeQuizEditor input:focus,
#nodeQuizEditor textarea:focus,
#nodeQuizEditor select:focus {
  outline: none;
  border-color: #368354;
  box-shadow: 0 0 0 3px rgba(54, 131, 84, 0.14);
}

#nodeQuizEditor .quiz-editor-time-field small {
  color: #839087;
  font-size: 10px;
  font-weight: 400;
}

#nodeQuizEditor .quiz-editor-input-suffix {
  position: relative;
}

#nodeQuizEditor .quiz-editor-input-suffix input {
  padding-right: 38px;
}

#nodeQuizEditor .quiz-editor-input-suffix > span {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: #839087;
  font-size: 11px;
  font-weight: 500;
}

#nodeQuizEditor .quiz-editor-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid #d8e1db;
  border-radius: 6px;
  background: #f7faf8;
  color: #526158;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

#nodeQuizEditor .quiz-editor-close:hover {
  background: #edf4ef;
  color: #1d6c3b;
}

#nodeQuizEditor .quiz-editor-question-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 22px;
  overscroll-behavior: contain;
  scrollbar-color: #a9beb0 transparent;
  scrollbar-width: thin;
}

#nodeQuizEditor .quiz-editor-question {
  min-width: 0;
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid #d9e3dc;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(31, 59, 41, 0.035);
}

#nodeQuizEditor .quiz-editor-question legend {
  padding: 0 8px;
  color: #31543d;
  font-size: 13px;
  font-weight: 700;
}

#nodeQuizEditor .quiz-editor-question legend span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  margin-right: 5px;
  place-items: center;
  border-radius: 50%;
  background: #e6f2e9;
  color: #267044;
  font-size: 10px;
}

#nodeQuizEditor .quiz-editor-bilingual {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#nodeQuizEditor .quiz-editor-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 15px 0 7px;
  color: #344b3b;
  font-size: 12px;
  font-weight: 700;
}

#nodeQuizEditor .quiz-editor-section-title span {
  color: #85938a;
  font-size: 10px;
  font-weight: 500;
}

#nodeQuizEditor .quiz-editor-option-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}

#nodeQuizEditor .quiz-editor-option-row textarea {
  min-height: 48px;
}

#nodeQuizEditor .quiz-editor-option-index {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid #d5e1d8;
  border-radius: 5px;
  background: #f2f7f3;
  color: #3c684a;
  font-size: 10px;
  font-weight: 700;
}

#nodeQuizEditor .quiz-editor-icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #78867d;
  font-size: 19px;
  cursor: pointer;
}

#nodeQuizEditor .quiz-editor-icon-button:hover:not(:disabled) {
  border-color: #f0c8c3;
  background: #fff2f0;
  color: #bd4438;
}

#nodeQuizEditor .quiz-editor-question-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 14px;
  margin-top: 12px;
}

#nodeQuizEditor .quiz-editor-correct-answer {
  width: min(180px, 100%);
}

#nodeQuizEditor .quiz-editor-pyq {
  flex: 1;
  min-width: 170px;
}

#nodeQuizEditor .quiz-editor-text-button {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #267044;
  font: 600 11px 'Poppins', sans-serif;
  cursor: pointer;
}

#nodeQuizEditor .quiz-editor-text-button:hover:not(:disabled) {
  background: #eef6f0;
}

#nodeQuizEditor .quiz-editor-text-button.quiz-editor-danger-button {
  margin-left: auto;
  color: #a14e47;
}

#nodeQuizEditor .quiz-editor-text-button.quiz-editor-danger-button:hover:not(:disabled) {
  background: #fff1ef;
}

#nodeQuizEditor button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

#nodeQuizEditor .quiz-editor-explanation {
  margin-top: 12px;
  border-top: 1px solid #edf1ee;
}

#nodeQuizEditor .quiz-editor-explanation summary {
  padding: 10px 0 7px;
  color: #52645a;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

#nodeQuizEditor .quiz-editor-explanation summary span {
  margin-left: 5px;
  color: #8b978f;
  font-size: 10px;
  font-weight: 400;
}

#nodeQuizEditor .quiz-editor-question-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  border-top: 1px solid #edf1ee;
}

#nodeQuizEditor .quiz-editor-question-footer > span {
  color: #8a968e;
  font-size: 10px;
}

#nodeQuizEditor .quiz-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  border-top: 1px solid #d9e2dc;
  background: #fff;
}

#nodeQuizEditor .quiz-editor-footer > div {
  display: flex;
  gap: 8px;
}

#nodeQuizEditor .quiz-editor-footer button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  font: 600 12px 'Poppins', sans-serif;
  cursor: pointer;
}

#nodeQuizEditor .quiz-editor-add-question {
  border: 1px dashed #89ad94;
  background: #f4faf5;
  color: #267044;
}

#nodeQuizEditor .quiz-editor-add-question:hover {
  border-color: #378454;
  background: #eaf5ed;
}

#nodeQuizEditor .quiz-editor-cancel {
  border: 1px solid #d3ddd6;
  background: #fff;
  color: #536158;
}

#nodeQuizEditor .quiz-editor-save {
  border: 1px solid #267044;
  background: #267044;
  color: #fff;
  box-shadow: 0 2px 5px rgba(38, 112, 68, 0.18);
}

#nodeQuizEditor .quiz-editor-save:hover {
  border-color: #1b5e36;
  background: #1b5e36;
}

body.dark-mode #nodeQuizEditor.quiz-editor-modal {
  border-color: #484848;
  background: #262626;
  color: #e0e0e0;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

body.dark-mode #nodeQuizEditor .quiz-editor-header,
body.dark-mode #nodeQuizEditor .quiz-editor-footer {
  border-color: #454545;
  background: #202020;
  box-shadow: none;
}

body.dark-mode #nodeQuizEditor .quiz-editor-heading h2,
body.dark-mode #nodeQuizEditor .quiz-editor-question legend,
body.dark-mode #nodeQuizEditor .quiz-editor-section-title {
  color: #f0f0f0;
}

body.dark-mode #nodeQuizEditor .quiz-editor-kicker {
  color: #aeb7c0;
}

body.dark-mode #nodeQuizEditor .quiz-editor-settings > label,
body.dark-mode #nodeQuizEditor .quiz-editor-bilingual > label,
body.dark-mode #nodeQuizEditor .quiz-editor-correct-answer,
body.dark-mode #nodeQuizEditor .quiz-editor-pyq,
body.dark-mode #nodeQuizEditor .quiz-editor-explanation summary {
  color: #c2c2c2;
}

body.dark-mode #nodeQuizEditor .quiz-editor-question {
  border-color: #454545;
  background: #303030;
  box-shadow: none;
}

body.dark-mode #nodeQuizEditor input,
body.dark-mode #nodeQuizEditor textarea,
body.dark-mode #nodeQuizEditor select {
  border-color: #565656;
  background: #242424;
  color: #e0e0e0;
}

body.dark-mode #nodeQuizEditor input:focus,
body.dark-mode #nodeQuizEditor textarea:focus,
body.dark-mode #nodeQuizEditor select:focus {
  border-color: #7d9db8;
  box-shadow: 0 0 0 3px rgba(103, 151, 190, 0.18);
}

body.dark-mode #nodeQuizEditor .quiz-editor-option-index {
  border-color: #565656;
  background: #3b3b3b;
  color: #e0e0e0;
}

body.dark-mode #nodeQuizEditor .quiz-editor-question legend span {
  background: #3b3b3b;
  color: #e0e0e0;
}

body.dark-mode #nodeQuizEditor .quiz-editor-explanation,
body.dark-mode #nodeQuizEditor .quiz-editor-question-footer {
  border-color: #484848;
}

body.dark-mode #nodeQuizEditor .quiz-editor-close,
body.dark-mode #nodeQuizEditor .quiz-editor-cancel {
  border-color: #565656;
  background: #383838;
  color: #e0e0e0;
}

body.dark-mode #nodeQuizEditor .quiz-editor-close:hover {
  border-color: #686868;
  background: #414141;
  color: #ffffff;
}

body.dark-mode #nodeQuizEditor .quiz-editor-add-question {
  border-color: #656565;
  background: #303030;
  color: #d7d7d7;
}

body.dark-mode #nodeQuizEditor .quiz-editor-add-question:hover {
  border-color: #858585;
  background: #383838;
}

body.dark-mode #nodeQuizEditor .quiz-editor-save {
  border-color: #5f94bd;
  background: #386c94;
  color: #ffffff;
  box-shadow: none;
}

body.dark-mode #nodeQuizEditor .quiz-editor-save:hover {
  border-color: #78acd4;
  background: #477fa8;
}

body.dark-mode #nodeQuizEditor .quiz-editor-text-button {
  color: #c3c3c3;
}

body.dark-mode #nodeQuizEditor .quiz-editor-text-button:hover:not(:disabled) {
  background: #3b3b3b;
}

body.dark-mode #nodeQuizEditor .quiz-editor-danger-button {
  color: #e39a93;
}

body.dark-mode #nodeQuizEditor .quiz-editor-icon-button:hover:not(:disabled),
body.dark-mode #nodeQuizEditor .quiz-editor-text-button.quiz-editor-danger-button:hover:not(:disabled) {
  border-color: #71433f;
  background: #3b2b2a;
  color: #f0aaa3;
}

@media (max-width: 760px) {
  #nodeQuizEditor.quiz-editor-modal {
    inset: 10px;
  }

  #nodeQuizEditor .quiz-editor-header {
    align-items: flex-start;
    padding: 14px 48px 14px 16px;
  }

  #nodeQuizEditor .quiz-editor-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex-basis: 100%;
  }

  #nodeQuizEditor .quiz-editor-name-field {
    grid-column: 1 / -1;
  }

  #nodeQuizEditor .quiz-editor-question-list {
    padding: 12px;
  }

  #nodeQuizEditor .quiz-editor-bilingual {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  #nodeQuizEditor .quiz-editor-question {
    padding: 12px;
  }

  #nodeQuizEditor .quiz-editor-option-row {
    grid-template-columns: 24px minmax(0, 1fr) 30px;
  }

  #nodeQuizEditor .quiz-editor-option-row textarea[data-language="hi"] {
    grid-column: 2;
  }

  #nodeQuizEditor .quiz-editor-icon-button {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  #nodeQuizEditor .quiz-editor-footer {
    padding: 10px 12px;
  }
}

@media (max-width: 420px) {
  #nodeQuizEditor .quiz-editor-settings {
    grid-template-columns: 1fr;
  }

  #nodeQuizEditor .quiz-editor-name-field {
    grid-column: auto;
  }

  #nodeQuizEditor .quiz-editor-footer button {
    padding: 0 10px;
  }
}
body.dark-mode .quiz-nav-btn.answered,
body.dark-mode .exam-question-chip.answered {
  background: #064e3b;
  border-color: #059669;
  color: #a7f3d0;
}
body.dark-mode .quiz-nav-btn.active,
body.dark-mode .exam-question-chip.active {
  border-color: #3b82f6;
  background: #1e3a8a;
  color: #bfdbfe;
}
body.dark-mode .quiz-nav-btn.correct,
body.dark-mode .exam-question-chip.correct {
  background: #15803d;
  border-color: #166534;
  color: white;
}
body.dark-mode .quiz-nav-btn.wrong,
body.dark-mode .exam-question-chip.wrong {
  background: #b91c1c;
  border-color: #991b1b;
  color: white;
}

body.dark-mode .quiz-nav-btn.active,
body.dark-mode .exam-question-chip.active {
  border: 2px solid #67e8f9 !important;
  background: #075985 !important;
  color: #ecfeff !important;
  box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.38), 0 0 14px rgba(34, 211, 238, 0.28) !important;
}

body.dark-mode .quiz-nav-btn.active.correct,
body.dark-mode .exam-question-chip.active.correct {
  background: #15803d !important;
  border-color: #67e8f9 !important;
}

body.dark-mode .quiz-nav-btn.active.wrong,
body.dark-mode .exam-question-chip.active.wrong {
  background: #b91c1c !important;
  border-color: #67e8f9 !important;
}

body.dark-mode .quiz-nav-btn.active.correct,
body.dark-mode .exam-question-chip.active.correct,
body.dark-mode .quiz-nav-btn.active.wrong,
body.dark-mode .exam-question-chip.active.wrong {
  box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.55), 0 0 14px rgba(34, 211, 238, 0.34) !important;
}

body.dark-mode .exam-question-chip.review {
  background: #78350f !important;
  border-color: #b45309 !important;
  color: #fde68a !important;
}

.study-review-modal {
  width: min(700px, 92vw);
  max-height: 90vh;
  border: 1px solid #d8e2e9;
  border-radius: 14px;
  background: #f5f8fa;
  box-shadow: 0 28px 90px rgba(14, 35, 49, 0.32);
}

.study-review-header { padding: 21px 24px 18px; }
.study-review-question-block { margin: 20px 24px 0; }
.study-answer-grid,
.study-explanation { margin: 20px 24px 0; }
.study-review-label { margin-bottom: 7px; }
.study-review-question { padding: 18px 19px; line-height: 1.7; }
.study-answer-grid { gap: 12px; }
.study-answer { min-height: 84px; padding: 15px 16px; }
.study-explanation { padding: 15px 16px; }
.study-review-modal .study-review-actions { box-sizing: border-box; margin-top: 20px; padding: 15px 24px 18px; }

@media (max-width: 700px) {
  .study-review-header { padding: 17px 18px 14px; }
  .study-review-question-block { margin: 18px 18px 0; }
  .study-answer-grid,
  .study-explanation { margin: 18px 18px 0; }
  .study-review-modal .study-review-actions { margin-top: 16px; padding: 12px 18px 15px; }
}

@media (max-width: 420px) {
  .study-review-header { padding: 14px 16px 12px; }
  .study-review-question-block { margin: 12px 16px 0; }
  .study-answer-grid,
  .study-explanation { margin: 12px 16px 0; }
  .study-review-question { padding: 14px 15px; }
  .study-answer { min-height: 64px; padding: 11px 12px; }
  .study-explanation { padding: 11px 12px; }
  .study-review-modal .study-review-actions { margin-top: 12px; padding: 10px 16px 12px; }
}

.study-review-question { font-weight: 700; }
.study-review-modal .wrong-answer strong { font-weight: 400; }
.study-review-modal .study-explanation {
  border-color: #d2e4d7;
  background: #eff7f1;
  color: #344e3d;
}

body.dark-mode .study-review-modal .study-explanation {
  border-color: #3e6653;
  background: #203a31;
  color: #d6e9dc;
}

body.dark-mode .study-dashboard-overlay {
  background: rgba(10, 10, 10, 0.62);
}

body.dark-mode .study-dashboard-modal {
  border-color: #484848;
  background: #262626;
  color: #e4e4e4;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.34);
}

body.dark-mode .study-dashboard-header {
  border-color: #414141;
}

body.dark-mode .study-dashboard-header h2,
body.dark-mode .study-dashboard-modal h3 {
  color: #63bd91;
}

body.dark-mode .study-dashboard-modal h3 {
  border-left-color: #63bd91;
}

body.dark-mode .study-dashboard-modal .study-section-kicker {
  color: #63bd91;
}

body.dark-mode .study-review-modal .study-section-kicker {
  color: #63bd91;
}

body.dark-mode .study-dashboard-header p,
body.dark-mode .study-muted,
body.dark-mode .study-empty,
body.dark-mode .study-mistakes-header span,
body.dark-mode .study-todo-header span {
  color: #b8b8b8;
}

body.dark-mode .study-dashboard-columns section,
body.dark-mode .study-mistakes,
body.dark-mode .study-day-panel,
body.dark-mode .study-stat-grid > div,
body.dark-mode .study-stat-grid > .study-due-stat {
  border-color: #454545;
  background: #303030;
  box-shadow: none;
}

body.dark-mode .study-stat-grid > .study-due-stat {
  border-top: 3px solid #d17b78;
  color: #e4e4e4;
}

body.dark-mode .study-stat-grid > .study-due-stat:hover:not(:disabled) {
  background: #383030;
  box-shadow: 0 8px 18px rgba(209, 123, 120, 0.12);
}

body.dark-mode .study-stat-grid > .study-due-stat:focus-visible {
  outline-color: rgba(209, 123, 120, 0.5);
}

body.dark-mode .study-stat-grid > div:nth-child(1) { border-top: 3px solid #858585; }
body.dark-mode .study-stat-grid > div:nth-child(2) { border-top: 3px solid #4daf8a; }
body.dark-mode .study-stat-grid > div:nth-child(3) { border-top: 3px solid #6ea8dc; }
body.dark-mode .study-stat-grid > div:nth-child(4) { border-top: 3px solid #d3a14c; }
body.dark-mode .study-stat-grid > div:nth-child(5) { border-top: 3px solid #d17b78; }

body.dark-mode .study-stat-grid strong {
  color: #e8e8e8;
}

body.dark-mode .study-stat-grid span,
body.dark-mode .study-history-date,
body.dark-mode .study-history-grid span,
body.dark-mode .study-filter-grid label,
body.dark-mode .study-mistakes-actions label,
body.dark-mode .study-review-select {
  color: #bdbdbd;
}

body.dark-mode .study-list-row,
body.dark-mode .study-review-row,
body.dark-mode .study-todo-row {
  border-color: #454545;
  color: #dedede;
}

body.dark-mode .study-list-row strong {
  color: #e05252;
}

body.dark-mode .study-review-row strong {
  color: #e5e5e5;
}

body.dark-mode .study-review-row small {
  color: #b3b3b3;
}

.copy-node-overlay {
  position: fixed;
  inset: 0;
  z-index: 100020;
  background: rgba(15, 24, 19, 0.58);
  backdrop-filter: blur(3px);
}

.copy-node-dialog {
  position: fixed;
  z-index: 100021;
  top: 50%;
  left: 50%;
  width: min(440px, calc(100vw - 32px));
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  padding: 22px;
  border: 1px solid #cbd9cf;
  border-radius: 10px;
  background: #ffffff;
  color: #1f2937;
  box-shadow: 0 24px 70px rgba(10, 30, 17, 0.28);
  animation: copyNodeDialogIn 150ms ease-out both;
}

@keyframes copyNodeDialogIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.copy-node-dialog-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-right: 28px;
}

.copy-node-dialog-icon {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #cfe3d4;
  border-radius: 8px;
  background: #eff7f1;
  color: #287447;
  font-size: 19px;
}

.copy-node-dialog-heading h2 {
  margin: 1px 0 3px;
  color: #1d3325;
  font-size: 17px;
  line-height: 1.35;
}

.copy-node-dialog-heading p {
  margin: 0;
  color: #69766d;
  font-size: 12px;
}

.copy-node-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #637168;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.copy-node-close:hover {
  border-color: #dce8df;
  background: #f3f8f4;
  color: #22663b;
}

.copy-node-summary {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 20px 0 17px;
  padding: 12px 14px;
  border-left: 3px solid #4c9a66;
  border-radius: 0 6px 6px 0;
  background: #f3f8f4;
}

.copy-node-summary-label {
  color: #68786d;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.copy-node-summary strong {
  overflow-wrap: anywhere;
  color: #203a29;
  font-size: 13px;
}

.copy-node-summary > span:last-child {
  color: #718076;
  font-size: 11px;
}

.copy-node-destination-label {
  display: block;
  margin-bottom: 6px;
  color: #33473a;
  font-size: 12px;
  font-weight: 700;
}

.copy-node-destination {
  display: block;
  width: 100%;
  height: 42px;
  box-sizing: border-box;
  padding: 0 11px;
  border: 1px solid #c9d7ce;
  border-radius: 6px;
  background: #fff;
  color: #1f2937;
  font: 400 13px 'Poppins', sans-serif;
}

.copy-node-destination:focus-visible {
  outline: 3px solid rgba(54, 131, 84, 0.18);
  border-color: #368354;
}

.copy-node-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.copy-node-dialog-actions button {
  min-width: 88px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid #d2ddd5;
  border-radius: 6px;
  background: #ffffff;
  color: #526157;
  font: 600 12px 'Poppins', sans-serif;
  cursor: pointer;
}

.copy-node-dialog-actions button:hover:not(:disabled) {
  background: #f1f6f2;
}

.copy-node-dialog-actions .copy-node-confirm {
  border-color: #267044;
  background: #267044;
  color: #ffffff;
}

.copy-node-dialog-actions .copy-node-confirm:hover:not(:disabled) {
  border-color: #1b5e36;
  background: #1b5e36;
}

.copy-node-dialog-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.dark-mode .copy-node-dialog {
  border-color: #484848;
  background: #262626;
  color: #e0e0e0;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

body.dark-mode .copy-node-dialog-heading h2,
body.dark-mode .copy-node-summary strong,
body.dark-mode .copy-node-destination-label {
  color: #f0f0f0;
}

body.dark-mode .copy-node-dialog-heading p,
body.dark-mode .copy-node-summary-label,
body.dark-mode .copy-node-summary > span:last-child {
  color: #bdbdbd;
}

body.dark-mode .copy-node-dialog-icon {
  border-color: #555;
  background: #353535;
  color: #dedede;
}

body.dark-mode .copy-node-summary {
  border-color: #777;
  background: #303030;
  color: #dedede;
}

body.dark-mode .copy-node-close,
body.dark-mode .copy-node-dialog-actions button:not(.copy-node-confirm) {
  border-color: #565656;
  background: #383838;
  color: #e0e0e0;
}

body.dark-mode .copy-node-close:hover,
body.dark-mode .copy-node-dialog-actions button:not(.copy-node-confirm):hover {
  border-color: #686868;
  background: #414141;
  color: #ffffff;
}

body.dark-mode .copy-node-destination {
  border-color: #565656;
  background: #303030;
  color: #e0e0e0;
}

body.dark-mode .copy-node-destination:focus-visible {
  outline-color: rgba(255, 255, 255, 0.12);
  border-color: #888;
}

body.dark-mode .copy-node-dialog-actions .copy-node-confirm {
  border-color: #5f94bd;
  background: #386c94;
  color: #ffffff;
}

body.dark-mode .copy-node-dialog-actions .copy-node-confirm:hover:not(:disabled) {
  border-color: #78acd4;
  background: #477fa8;
}

@media (max-width: 480px) {
  .copy-node-dialog {
    padding: 18px;
  }
}

body.dark-mode .study-history-card {
  border-color: #454545;
  background: #2b2b2b;
}

body.dark-mode .study-history-grid > div,
body.dark-mode .study-history-topic {
  border-color: #484848;
  background: #353535;
}

body.dark-mode .study-history-grid strong {
  color: #d0d0d0;
}

body.dark-mode .study-history-topic strong {
  color: #e5e5e5;
}

body.dark-mode .study-history-topic small,
body.dark-mode .study-history-metrics {
  color: #bcbcbc;
}

body.dark-mode .study-history-metrics span {
  background: #484848;
}

body.dark-mode .study-history-date input,
body.dark-mode .study-day-header input,
body.dark-mode .study-filter-grid select {
  border-color: #565656;
  background: #383838;
  color: #e2e2e2;
  color-scheme: dark;
}

body.dark-mode .study-day-controls button,
body.dark-mode .study-todo-actions button,
body.dark-mode .study-review-actions button,
body.dark-mode .study-mistakes-actions button {
  border-color: #565656;
  background: #383838;
  color: #dedede;
}

body.dark-mode .study-mistakes-actions button:not(:disabled) {
  border-color: #c65050;
  background: #a93838;
  color: #fff7f7;
}

body.dark-mode .study-mistakes-actions button:not(:disabled):hover {
  border-color: #e06464;
  background: #bd4444;
}

body.dark-mode .study-mistakes-actions button:disabled {
  border-color: #4c4c4c;
  background: #363636;
  color: #a0a0a0;
}

body.dark-mode .study-dashboard-actions > button:not(.study-close-btn) {
  border: 1px solid #398a69;
  background: #286b50;
  color: #f4fff8;
}

body.dark-mode .study-dashboard-actions > button:not(.study-close-btn):hover {
  border-color: #55a883;
  background: #347d60;
}

body.dark-mode .study-dashboard-actions > .import-btn {
  border: 1px dashed #64796d;
  background: #2b3530;
  color: #d5eadc;
}

body.dark-mode .study-dashboard-actions > .import-btn:hover,
body.dark-mode .study-day-controls button:hover,
body.dark-mode .study-todo-actions button:hover,
body.dark-mode .study-review-actions button:hover {
  border-color: #7fa68e;
  background: #36463d;
}

body.dark-mode .study-mistakes-actions button:not(:disabled):hover {
  border-color: #e06464;
  background: #8f2929;
}

body.dark-mode .study-dashboard-actions > .study-close-btn {
  border: 1px solid #565656;
  background: #353535;
  color: #dedede;
}

body.dark-mode .study-progress-track {
  background: #484848;
}

body.dark-mode .study-review-modal {
  border-color: #484848;
  background: #262626;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.36);
}

body.dark-mode .study-review-header,
body.dark-mode .study-review-modal .study-review-actions {
  border-color: #414141;
  background: #2b2b2b;
}

body.dark-mode .study-review-status {
  border-color: #34745d;
  background: #18392d;
  color: #b9f3ce;
  box-shadow: none;
}

body.dark-mode .study-review-question,
body.dark-mode .study-review-modal .study-explanation {
  border-color: #4a4a4a;
  background: #303030;
  box-shadow: none;
}

body.dark-mode .study-review-question {
  border-left-color: #4daf8a;
}

body.dark-mode .study-review-modal .wrong-answer,
body.dark-mode .study-review-modal .right-answer {
  border-color: #505050;
  background: #343434;
}

body.dark-mode .study-review-modal .wrong-answer {
  border-color: #934357;
  border-left: 3px solid #d2777b;
  background: #351b25;
  color: #ffd6dd;
}

body.dark-mode .study-review-modal .right-answer {
  border-color: #3f8b68;
  border-left: 3px solid #69b38e;
  background: #173329;
  color: #c6f6d7;
}

body.dark-mode .study-review-modal .study-review-actions button,
body.dark-mode .study-review-modal .study-close-btn {
  border-color: #565656;
  background: #383838;
}

body.dark-mode .study-review-modal .study-review-actions button.save {
  border-color: #398a69;
  background: #286b50;
  color: #f4fff8;
}

body.dark-mode .study-review-modal .study-review-actions button.save:hover {
  border-color: #55a883;
  background: #347d60;
}

body.dark-mode .study-review-modal .study-review-actions button:hover,
body.dark-mode .study-review-modal .study-close-btn:hover {
  border-color: #777777;
  background: #414141;
}

body.dark-mode #filterBtn {
  border-color: #444444;
  background: #2a2a2a;
  color: #e0e0e0;
}

body.dark-mode #filterBtn:hover,
body.dark-mode #filterBtn:focus-visible {
  border-color: #666666;
  background: #333333;
  color: #e0e0e0;
}

.note-viewer {
  box-sizing: border-box;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  gap: 12px;
  padding: 16px;
  border: 1px solid #d9dee3;
  border-radius: 14px;
  background: #f5f6f7;
  box-shadow: 0 16px 40px rgba(23, 31, 39, 0.16);
}

.note-viewer-header {
  gap: 12px;
  margin-bottom: 0;
}

.note-viewer-header span {
  min-width: 0;
  color: #28333d;
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.note-viewer-body {
  min-height: 0;
  overflow: auto;
  padding: 15px 17px;
  border: 1px solid #e0e4e8;
  border-radius: 10px;
  background: #ffffff;
  color: #37414a;
  font-size: 15px;
  line-height: 1.7;
  scrollbar-color: #c5cbd1 transparent;
  scrollbar-width: thin;
}

.note-viewer-body h1,
.note-viewer-body h2,
.note-viewer-body h3,
.note-viewer-body h4,
.note-viewer-body h5,
.note-viewer-body h6 {
  margin: 0 0 10px;
  line-height: 1.4;
}

.note-viewer-body li {
  margin-bottom: 4px;
  line-height: 1.55;
}

.note-viewer-body blockquote {
  border-left-color: #c6cbd0;
  background: #f3f4f5;
  color: #3d454d;
}

.note-viewer-body code {
  background: #f0f1f2;
  color: #313a42;
}

.note-viewer-body pre {
  background: #25282b;
}

.note-viewer-header button {
  color: #66717a;
}

.note-viewer-header button:hover {
  background: #e8ebee;
  color: #29333c;
}

body.dark-mode .note-viewer {
  border-color: #484848;
  background: #262626;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.52);
}

body.dark-mode .note-viewer-header span {
  color: #ededed;
}

body.dark-mode .note-viewer-body {
  border-color: #484848;
  background: #303030;
  color: #dedede;
  scrollbar-color: #686868 transparent;
}

body.dark-mode .note-viewer-body blockquote {
  border-left-color: #777777;
  background: #393939;
  color: #dedede;
}

body.dark-mode .note-viewer-body code {
  background: #414141;
  color: #eeeeee;
}

body.dark-mode .note-viewer-body pre {
  background: #222222;
  color: #dedede;
}

body.dark-mode .note-viewer-header button {
  color: #c4c4c4;
}

body.dark-mode .note-viewer-header button:hover {
  border-color: #626262;
  background: #3a3a3a;
  color: #f0f0f0;
}

body.dark-mode .note-viewer.arrow-left::before {
  border-color: transparent #484848 transparent transparent;
}

body.dark-mode .note-viewer.arrow-left::after {
  border-color: transparent #262626 transparent transparent;
}

body.dark-mode .note-viewer.arrow-right::before {
  border-color: transparent transparent transparent #484848;
}

body.dark-mode .note-viewer.arrow-right::after {
  border-color: transparent transparent transparent #262626;
}
