:root {
  --bg-color: #0b1120;
  --card-bg: #1e293b;
  --card-dark: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --success: #22c55e;
  --danger: #ef4444;
  --border-color: #334155;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  padding: 1.5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.75rem;
}

#stats-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-item {
  font-size: 0.95rem;
  background: var(--card-bg);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.hidden {
  display: none !important;
}

button {
  background: var(--card-bg);
  border: 1px solid var(--accent);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

button:hover {
  background: #334155;
  border-color: var(--accent-hover);
}

.secondary-btn {
  background: transparent;
  border-color: #475569;
}

.action-btn-outline {
  width: 100%;
  margin-top: 1rem;
  background: transparent;
  border: 2px dashed #475569;
}

.action-btn-outline:hover {
  border-color: var(--accent);
}

#topics-list, #options-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.feedback-box {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
}
.feedback-box.correct { background: rgba(34, 197, 94, 0.2); border: 1px solid var(--success); }
.feedback-box.incorrect { background: rgba(239, 68, 68, 0.2); border: 1px solid var(--danger); }

/* --- Modals & Scroll Controls --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(5px);
  padding: 1rem;
}

.modal-content {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 16px;
  text-align: center;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 40px rgba(0,0,0,0.85);
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-sizing: border-box;
}

/* Custom Scrollbar */
.modal-content::-webkit-scrollbar {
  width: 8px;
}
.modal-content::-webkit-scrollbar-track {
  background: var(--card-dark);
  border-radius: 8px;
}
.modal-content::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 8px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

/* Obvious, nicely positioned modal close button */
.modal-close-btn {
  background: #334155;
  border: 1px solid #64748b;
  color: #f8fafc;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  transform: scale(1.08);
}

.profile-dialog {
  width: 90%;
  max-width: 420px;
}

.parent-dialog {
  width: 95%;
  max-width: 680px;
  text-align: left;
}

.profile-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin: 1.5rem 0;
}

.profile-select-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 1rem 1.25rem;
  background: var(--card-dark);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.profile-select-btn:hover {
  border-color: var(--accent);
  background: var(--card-bg);
}

/* Keypad */
#pin-input {
  width: 140px;
  letter-spacing: 12px;
  font-size: 1.8rem;
  text-align: center;
  padding: 0.5rem;
  margin-bottom: 1rem;
  background: var(--card-dark);
  border: 2px solid var(--border-color);
  color: var(--accent);
  border-radius: 8px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 240px;
  margin: 0 auto 1rem;
}

.keypad button {
  padding: 1rem 0;
  font-size: 1.3rem;
  font-weight: bold;
  border-radius: 10px;
}

.keypad button.warn { color: var(--danger); border-color: var(--danger); }
.keypad button.accent { background: var(--accent); color: var(--bg-color); border-color: var(--accent); }

.error-text {
  color: var(--danger);
  margin-bottom: 0.8rem;
  font-weight: 600;
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group input, .form-group select {
  background: var(--card-dark);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Parent Cards */
.parent-child-card {
  background: var(--card-dark);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.parent-child-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.parent-child-header h4 {
  margin: 0;
  font-size: 1.15rem;
}

.parent-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-box {
  background: var(--card-bg);
  padding: 0.75rem;
  border-radius: 8px;
  text-align: center;
}

.metric-box span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.metric-box strong {
  font-size: 1.2rem;
  color: var(--accent);
}

.parent-controls-row {
  display: flex;
  gap: 0.75rem;
}

/* Loot / 3D Flip Card */
.card-scene {
  width: 250px;
  height: 350px;
  perspective: 1000px;
  margin: 1.5rem auto;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
  cursor: pointer;
  border-radius: 14px;
}

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

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
}

.card-back {
  background: radial-gradient(circle, #1e293b 0%, #090d16 100%);
  border: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card-back .vault-logo {
  font-size: 4rem;
  filter: drop-shadow(0 0 15px rgba(56, 189, 248, 0.6));
}

.card-back span {
  margin-top: 1rem;
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.card-front {
  background: #000;
  transform: rotateY(180deg);
  display: flex;
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Binder Header & Cards */
.binder-header {
  margin-top: 2rem;
  margin-bottom: 1.5rem;
  background: var(--card-bg);
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.binder-header h2 { margin: 0 0 0.4rem 0; }
#binder-progress-text { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: var(--card-dark);
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

#binder-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.4s ease;
}

#inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.binder-card {
  position: relative !important;
  aspect-ratio: 1 / 1.4;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
  cursor: pointer;
  background: #111827;
  z-index: 1;
}

.binder-card:hover {
  transform: translateY(-8px) scale(1.15);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.9);
  z-index: 10;
}

.binder-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.binder-card.legendary { box-shadow: 0 0 16px rgba(245, 158, 11, 0.6); }
.binder-card.rare { box-shadow: 0 0 14px rgba(168, 85, 247, 0.5); }

.binder-card.stacked {
  box-shadow: 
    -4px -4px 0 0 #1e293b,
    -4px -4px 0 1px #475569,
    -8px -8px 0 0 #0f172a,
    -8px -8px 0 1px #334155,
    0 10px 25px rgba(0, 0, 0, 0.75);
}

.card-count-badge {
  position: absolute !important;
  bottom: 8px;
  right: 8px;
  background: #f59e0b;
  color: #000;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 9999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
  border: 1.5px solid #fff;
  z-index: 5;
  pointer-events: none;
}

.binder-card.unowned {
  position: relative !important;
  cursor: default;
  background: radial-gradient(circle, #1e293b 0%, #090d16 100%);
  border: 2px dashed var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0.65;
}

.binder-card.unowned:hover { transform: none; opacity: 0.85; }
.binder-card.unowned .vault-logo { font-size: 2.2rem; filter: grayscale(100%) opacity(40%); }

.slot-number {
  position: absolute !important;
  top: 8px;
  left: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 1px;
}

.unowned-label {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  color: #64748b;
  text-transform: uppercase;
}

/* Card Inspect Modal */
.inspect-wrapper {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.inspect-wrapper img {
  max-height: 80vh;
  width: auto;
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.inspect-close-btn {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  border: 2px solid var(--accent);
  color: #f8fafc;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
}

/* Deck Containers */
.deck-container {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
}

.deck-header {
  margin-bottom: 1.25rem;
}

.deck-header h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.35rem;
}

.deck-header .subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.deck-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.module-card {
  background: var(--card-dark);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
}

.module-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.module-card-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.module-meta-badge {
  font-size: 0.75rem;
  background: #334155;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  color: var(--text-muted);
}

.units-table {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.unit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.unit-info strong {
  display: block;
  font-size: 0.95rem;
}

.unit-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.unit-actions {
  display: flex;
  gap: 0.5rem;
}

/* Quiz Styles */
.quiz-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.quiz-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.question-prompt {
  font-size: 1.3rem;
  line-height: 1.5;
  margin: 1rem 0 1.5rem 0;
}

/* Tutorial Dialog */
.tutorial-dialog {
  width: 90%;
  max-width: 650px;
  text-align: left;
}

.rules-box {
  background: var(--card-dark);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.rules-box h4 {
  margin: 0 0 0.5rem 0;
  color: var(--accent);
}

.rules-box ul {
  margin: 0;
  padding-left: 1.25rem;
}

.rules-box li {
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.example-box {
  background: rgba(56, 189, 248, 0.08);
  border: 1px dashed var(--accent);
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.example-box h4 {
  margin: 0 0 0.5rem 0;
  color: var(--accent);
}

.example-box p {
  margin: 0;
  font-size: 0.95rem;
  font-style: italic;
}

/* Exam Tool Dock */
.exam-tool-dock {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tool-btn {
  background: var(--card-dark);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  border-color: var(--accent);
  background: #1e293b;
}

.tool-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.calc-indicator {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.calc-indicator.non-calc {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Dedicated Direct Entry Answer Box */
.direct-entry-container {
  background: var(--card-dark);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 1rem;
}

.direct-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#direct-answer-input {
  font-size: 1.2rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  border: 2px solid var(--border-color);
  background: #0f172a;
  color: #ffffff;
  width: 220px;
}

#direct-answer-input:focus {
  outline: none;
  border-color: var(--accent);
}

.unit-tag {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.submit-ans-btn {
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

/* Floating Window Framework */
.floating-window {
  position: fixed;
  z-index: 900;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
  user-select: none;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.floating-window.ghost {
  opacity: 0.35 !important;
}

.window-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.85rem;
  background: #0f172a;
  border-bottom: 1px solid #334155;
  cursor: grab;
}

.window-header:active {
  cursor: grabbing;
}

.window-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e2e8f0;
}

.window-actions {
  display: flex;
  gap: 0.35rem;
}

.win-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.win-btn:hover {
  background: #334155;
  color: #fff;
}

/* Scientific Calculator Styles */
.calc-body {
  padding: 0.75rem;
}

#calc-display {
  width: 100%;
  box-sizing: border-box;
  background: #090d16;
  border: 1px solid #334155;
  color: #38bdf8;
  font-family: monospace;
  font-size: 1.35rem;
  text-align: right;
  padding: 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.6rem;
}

.calc-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.calc-btn {
  padding: 0.6rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #273549;
  color: #f8fafc;
  cursor: pointer;
}

.calc-btn:hover {
  filter: brightness(1.15);
}

.calc-btn:active {
  transform: translateY(1px);
}

.calc-btn.fn {
  background: #1e293b;
  color: #93c5fd;
  font-size: 0.85rem;
}

.calc-btn.op {
  background: #334155;
  color: #38bdf8;
}

.calc-btn.op-clear {
  background: #7f1d1d;
  color: #fca5a5;
  border-color: #991b1b;
}

.calc-btn.op-equal {
  background: #0284c7;
  color: #fff;
  border-color: #0369a1;
}

/* Scratchpad Styles */
.pad-tab-bar {
  display: flex;
  align-items: center;
  background: #0f172a;
  border-bottom: 1px solid #334155;
  padding: 0.35rem 0.65rem;
  gap: 0.5rem;
}

.pad-tab {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

.pad-tab.active {
  background: #334155;
  color: #fff;
  font-weight: 600;
}

.tool-btn-sm {
  background: #334155;
  border: none;
  color: #e2e8f0;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.pad-body {
  padding: 0.5rem;
  background: #090d16;
}

#scratchpad-canvas {
  background: #0f172a;
  border: 1px dashed #334155;
  border-radius: 6px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

#scratchpad-textarea {
  width: 100%;
  height: 260px;
  box-sizing: border-box;
  background: #0f172a;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
}

/* Weak-Spot Workout Banner */
.weak-spots-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.15), rgba(249, 115, 22, 0.15));
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

/* Worked Solution Card in Feedback */
.worked-solution-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px dashed #38bdf8;
  border-radius: 8px;
  padding: 1rem;
  margin: 0.85rem 0;
  text-align: left;
}

.worked-solution-card h4 {
  margin: 0 0 0.4rem 0;
  color: #38bdf8;
  font-size: 0.95rem;
}

.worked-solution-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e2e8f0;
}

/* Interactive Workspace Container */
.interactive-workspace-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 1.25rem 0;
  background: #090d16;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 1rem;
}

/* Venn Diagram Manipulative */
.venn-svg {
  max-width: 100%;
  height: auto;
  user-select: none;
}

.venn-universe-rect {
  fill: #0f172a;
  stroke: #475569;
  stroke-width: 2;
  rx: 8;
  cursor: pointer;
  transition: fill 0.15s ease;
}

.venn-universe-rect:hover {
  fill: #1e293b;
}

.venn-universe-rect.shaded {
  fill: rgba(56, 189, 248, 0.35) !important;
}

.venn-region-path {
  fill: #1e293b;
  stroke: #38bdf8;
  stroke-width: 2.5;
  cursor: pointer;
  transition: all 0.15s ease;
}

.venn-region-path:hover {
  fill: rgba(56, 189, 248, 0.3);
}

.venn-region-path.shaded {
  fill: rgba(56, 189, 248, 0.75) !important;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.5));
}

.venn-label {
  fill: #e2e8f0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

/* Coordinate Graph Manipulative */
.graph-svg {
  max-width: 100%;
  height: auto;
  user-select: none;
  cursor: crosshair;
}

.graph-grid-line {
  stroke: #1e293b;
  stroke-width: 1;
}

.graph-axis-line {
  stroke: #94a3b8;
  stroke-width: 2.2;
}

.graph-axis-tick {
  stroke: #64748b;
  stroke-width: 1.5;
}

.graph-axis-text {
  fill: #94a3b8;
  font-size: 11px;
  font-family: monospace;
  pointer-events: none;
}

.graph-plotted-point {
  fill: #38bdf8;
  stroke: #ffffff;
  stroke-width: 2;
  cursor: pointer;
  filter: drop-shadow(0 0 6px #38bdf8);
  transition: transform 0.1s ease;
}

.graph-plotted-point:hover {
  transform: scale(1.3);
  fill: #f59e0b;
}

.graph-point-label {
  fill: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  font-family: monospace;
  pointer-events: none;
}

/* Viewport Scrolling Fixes */
html, body {
  overflow-y: auto !important;
  min-height: 100vh;
  height: auto !important;
}

main {
  overflow-y: visible !important;
  padding-bottom: 5rem !important;
}

#quiz-card {
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 4rem;
}

/* Constrain Manipulative Workspace Height */
.interactive-workspace-container {
  max-height: 360px;
  padding: 0.75rem;
  overflow: hidden;
}

.venn-svg {
  max-height: 320px;
  width: auto;
  max-width: 100%;
  display: block;
  margin: 0 auto;
}

.graph-svg {
  max-height: 320px;
  width: auto;
  max-width: 100%;
  display: block;
  margin: 0 auto;
}

/* Sticky Action Bar (Always Visible Above Fold) */
#manipulative-action-bar {
  position: sticky;
  bottom: 0;
  background: rgba(11, 17, 32, 0.95);
  backdrop-filter: blur(8px);
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border-color, #334155);
  border-radius: 0 0 10px 10px;
  z-index: 50;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.4);
}

/* Periodic Table Styling */
.ptable-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: #0f172a;
  border-bottom: 1px solid #334155;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
  margin-right: 0.2rem;
}

.ptable-filter-chip {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ptable-filter-chip:hover {
  background: #334155;
  color: #fff;
}

.ptable-filter-chip.active {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
  font-weight: 600;
}

.ptable-body {
  padding: 0.75rem;
  background: #090d16;
  max-height: 480px;
  overflow-y: auto;
}

.ptable-grid {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 3px;
  user-select: none;
  min-width: 600px;
}

.ptable-cell {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 2px;
  text-align: center;
  cursor: pointer;
  transition: all 0.1s ease;
  min-height: 38px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ptable-cell:hover {
  border-color: #38bdf8;
  transform: scale(1.08);
  z-index: 10;
  background: #273549;
}

.ptable-cell.selected {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.2);
}

.ptable-cell.dimmed {
  opacity: 0.25;
}

.cell-mass {
  font-size: 7.5px;
  color: #94a3b8;
  line-height: 1;
}

.cell-sym {
  font-size: 11px;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.1;
}

.cell-num {
  font-size: 7px;
  color: #38bdf8;
  line-height: 1;
}

/* Category highlights */
.ptable-cell.cat-alkali { border-color: #ef4444; background: rgba(239, 68, 68, 0.15); }
.ptable-cell.cat-halogen { border-color: #10b981; background: rgba(16, 185, 129, 0.15); }
.ptable-cell.cat-noble { border-color: #a855f7; background: rgba(168, 85, 247, 0.15); }
.ptable-cell.cat-transition { border-color: #f59e0b; background: rgba(245, 158, 11, 0.12); }

/* Element Inspector */
.element-inspector {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
}

.inspector-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 52px;
  height: 64px;
  background: #1e293b;
  border: 2px solid #38bdf8;
  border-radius: 6px;
  padding: 4px;
  box-sizing: border-box;
}

.mass-number { font-size: 10px; color: #94a3b8; font-weight: 600; }
.elem-symbol { font-size: 20px; font-weight: 800; color: #ffffff; }
.atomic-number { font-size: 10px; color: #38bdf8; font-weight: 700; }

.inspector-details h4 {
  margin: 0 0 0.35rem 0;
  font-size: 1.1rem;
  color: #f8fafc;
}

.inspector-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.inspector-stats-row strong {
  color: #38bdf8;
}

/* Formula Sheet Styling */
.formula-body {
  padding: 0.85rem;
  background: #090d16;
  max-height: 420px;
  overflow-y: auto;
}

.formula-category {
  margin-bottom: 1.25rem;
}

.formula-category h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: #38bdf8;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.formula-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: #0f172a;
  border: 1px solid #1e293b;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
}

.formula-item span {
  color: #94a3b8;
}

.formula-item strong {
  color: #f8fafc;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
}

/* Zoom & Scaling Toolkit */
.zoom-btn {
  font-weight: 700 !important;
  font-family: monospace;
  font-size: 0.85rem !important;
  padding: 0.15rem 0.45rem !important;
}

/* Maximized Window Layout */
.floating-window.maximized {
  top: 35px !important;
  left: 2.5vw !important;
  right: auto !important;
  width: 95vw !important;
  max-width: 1200px !important;
  max-height: 90vh !important;
  z-index: 950 !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.85);
}

.floating-window.maximized .ptable-body {
  max-height: calc(90vh - 130px) !important;
}

.floating-window.maximized .formula-body {
  max-height: calc(90vh - 110px) !important;
}

/* Periodic Table Scaling */
#ptable-window {
  --ptable-scale: 1;
}

.ptable-grid {
  min-width: calc(680px * var(--ptable-scale, 1));
}

.ptable-cell {
  min-height: calc(44px * var(--ptable-scale, 1));
  padding: calc(2.5px * var(--ptable-scale, 1));
}

.cell-mass {
  font-size: calc(8.5px * var(--ptable-scale, 1));
}

.cell-sym {
  font-size: calc(13px * var(--ptable-scale, 1));
}

.cell-num {
  font-size: calc(8px * var(--ptable-scale, 1));
}

.element-inspector {
  padding: calc(0.75rem * var(--ptable-scale, 1)) calc(1rem * var(--ptable-scale, 1));
}

.inspector-badge {
  width: calc(56px * var(--ptable-scale, 1));
  height: calc(70px * var(--ptable-scale, 1));
}

.mass-number { font-size: calc(11px * var(--ptable-scale, 1)); }
.elem-symbol { font-size: calc(23px * var(--ptable-scale, 1)); }
.atomic-number { font-size: calc(11px * var(--ptable-scale, 1)); }

.inspector-details h4 {
  font-size: calc(1.15rem * var(--ptable-scale, 1));
}

.inspector-stats-row {
  font-size: calc(0.92rem * var(--ptable-scale, 1));
}

/* Formula Sheet Scaling */
#formulas-window {
  --formula-scale: 1;
}

.formula-category h4 {
  font-size: calc(0.95rem * var(--formula-scale, 1));
}

.formula-item {
  font-size: calc(0.92rem * var(--formula-scale, 1));
  padding: calc(0.45rem * var(--formula-scale, 1)) calc(0.65rem * var(--formula-scale, 1));
}

.formula-item strong {
  font-size: calc(1.02rem * var(--formula-scale, 1));
}

/* Mini-Guide Modal Scaling */
#tutorial-modal {
  --tutorial-scale: 1;
}

.tutorial-dialog {
  max-width: 680px;
}

.tutorial-dialog p {
  font-size: calc(1.05rem * var(--tutorial-scale, 1)) !important;
}

.tutorial-dialog .rules-box,
.tutorial-dialog .example-box {
  font-size: calc(0.95rem * var(--tutorial-scale, 1));
}

.tutorial-dialog h4 {
  font-size: calc(1rem * var(--tutorial-scale, 1));
}

/* Floating Window Flex & Dynamic Resizing */
.floating-window {
  display: flex !important;
  flex-direction: column !important;
  min-width: 280px;
  min-height: 180px;
  max-width: 98vw;
  max-height: 94vh;
}

.window-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.ptable-body,
.formula-body {
  max-height: none !important;
  flex: 1;
  min-height: 0;
}

/* Corner Resize Handle */
.window-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: se-resize;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.window-resize-handle::after {
  content: "";
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
}

.window-resize-handle:hover::after {
  border-color: #38bdf8;
  width: 10px;
  height: 10px;
}

/* Fix: Guarantee hidden floating windows always collapse */
.hidden,
.floating-window.hidden {
  display: none !important;
}

/* Global / Dashboard Tool Dock */
.dashboard-tools-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--card-dark, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.dashboard-tools-bar .tools-heading {
  font-size: 0.9rem;
  font-weight: 700;
  color: #94a3b8;
  margin-right: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Parent Curriculum Deck Manager */
.curriculum-module-card {
  background: #0f172a;
  border: 1px solid var(--border-color, #334155);
  border-radius: 10px;
  padding: 1.1rem;
}

.curriculum-module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
}

.curriculum-module-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
}

.curriculum-module-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.deck-focus-toggle-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 600;
  transition: all 0.15s ease;
}

.deck-focus-toggle-btn.is-focus {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #34d399;
}

.deck-focus-toggle-btn.is-vault {
  background: rgba(148, 163, 184, 0.15);
  border-color: #64748b;
  color: #94a3b8;
}

.tier-select-dropdown {
  background: #1e293b;
  border: 1px solid #475569;
  color: #cbd5e1;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}

.curriculum-units-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem;
}

.curriculum-unit-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #182234;
  border: 1px solid #273549;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
}

.curriculum-unit-toggle-item.is-active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.curriculum-unit-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: #334155;
  color: #cbd5e1;
}

.curriculum-unit-badge.set-text {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

/* Offline Vault & Data Saver Controls */
.vault-tools-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color, #334155);
  margin: 0 0.5rem;
}

.vault-gauge-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #0f172a;
  border: 1px solid #334155;
  color: #cbd5e1;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.vault-gauge-btn:hover {
  border-color: #38bdf8;
  color: #fff;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

/* Data-Saver Segmented Pill Switch */
.data-mode-toggle {
  display: flex;
  background: #090d16;
  border: 1px solid #334155;
  border-radius: 9999px;
  padding: 2px;
  margin-left: auto;
}

.mode-pill {
  background: transparent;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-pill.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Offline Vault Modal */
.vault-dialog {
  max-width: 780px !important;
  width: 90vw;
}

.vault-overview-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.vault-stat-metric {
  display: flex;
  flex-direction: column;
}

.vault-stat-metric .metric-label {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.vault-stat-metric strong {
  font-size: 1.15rem;
  color: #f8fafc;
}

.vault-action-cluster {
  display: flex;
  gap: 0.6rem;
}

.vault-packs-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 380px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.vault-pack-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  transition: border-color 0.15s ease;
}

.vault-pack-item.cached {
  border-color: rgba(56, 189, 248, 0.3);
}

.vault-pack-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.vault-pack-info strong {
  font-size: 0.95rem;
  color: #f8fafc;
}

.vault-pack-meta {
  font-size: 0.8rem;
  color: #94a3b8;
}

.vault-pack-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Grouped Dashboard Toolbar */
.dashboard-tools-bar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 1rem;
}

.tools-left-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.system-right-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  flex-wrap: wrap;
}

/* Update indicator on vault button */
.status-dot.update {
  background: #f59e0b !important;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8) !important;
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

.vault-update-badge {
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Dynamic Weak-Spot Banner States */
.weak-spots-banner.locked-state {
  margin-top: 1.25rem !important;
  margin-bottom: 0 !important;
  background: rgba(15, 23, 42, 0.6) !important;
  border: 1px dashed #334155 !important;
  opacity: 0.85;
}

.weak-spots-banner.active-top-state {
  margin-top: 0 !important;
  margin-bottom: 1.25rem !important;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), rgba(15, 23, 42, 0.9)) !important;
  border: 1px solid rgba(245, 158, 11, 0.5) !important;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.15);
}
