/**
 * ScienceHub - Printable Lab Worksheets & Teacher Answer Keys Stylesheet
 * Supports high-fidelity screen preview and pixel-perfect @media print output.
 */

/* ==========================================================================
   Screen Modal Overlay & Dialog
   ========================================================================== */

.worksheet-modal,
.worksheet-library-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: wsFadeIn 0.25s ease-out;
}

.worksheet-modal[hidden],
.worksheet-library-modal[hidden],
.worksheet-modal.hidden,
.worksheet-library-modal.hidden {
  display: none !important;
}

@keyframes wsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.worksheet-backdrop {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.worksheet-dialog {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 920px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  color: #1e293b;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
  animation: wsSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes wsSlideUp {
  from { transform: translateY(24px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ==========================================================================
   Toolbar Header
   ========================================================================== */

.worksheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  gap: 1rem;
}

.worksheet-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.worksheet-toolbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  background: #e0e7ff;
  color: #3730a3;
}

.worksheet-toolbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.worksheet-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* Teacher Answer Key Toggle Switch */
.worksheet-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  transition: all 0.2s ease;
}

.worksheet-toggle-wrap:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.worksheet-toggle-wrap input[type="checkbox"] {
  cursor: pointer;
  width: 17px;
  height: 17px;
  accent-color: #2563eb;
}

.btn-print-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-print-action:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-print-action:active {
  transform: translateY(0);
}

.worksheet-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.worksheet-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* ==========================================================================
   Worksheet Paper & Typography
   ========================================================================== */

#worksheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem;
  background: #f1f5f9;
  -webkit-overflow-scrolling: touch;
}

.worksheet-paper {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 2.5rem;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

/* Header */
.worksheet-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.branding {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1e3a8a;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.brand-sub {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
}

.subject-badge-pill {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #e2e8f0;
  color: #1e293b;
}

.subject-badge-pill.physics { background: #dbeafe; color: #1e40af; }
.subject-badge-pill.biology { background: #dcfce7; color: #166534; }
.subject-badge-pill.chemistry { background: #fef3c7; color: #92400e; }
.subject-badge-pill.mathematics { background: #ede9fe; color: #5b21b6; }

.worksheet-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0.6rem 0 0.4rem;
  line-height: 1.3;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.82rem;
  color: #475569;
  margin-bottom: 1rem;
}

.meta-item strong {
  color: #0f172a;
}

/* Student Information Box */
.student-info-box {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 105px;
  gap: 0.75rem;
  border: 1.5px solid #0f172a;
  border-radius: 6px;
  padding: 0.65rem 0.9rem;
  align-items: center;
  background: #fafafa;
}

.info-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #0f172a;
}

.field-line {
  flex: 1;
  border-bottom: 1px solid #94a3b8;
  height: 18px;
}

.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-left: 1.5px solid #0f172a;
  padding-left: 0.75rem;
}

.score-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
}

.score-val {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
}

/* ==========================================================================
   Sections & Content Blocks
   ========================================================================== */

.worksheet-section {
  margin-top: 1.4rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 0.3rem;
  margin-bottom: 0.7rem;
}

.section-badge {
  display: inline-block;
  background: #0f172a;
  color: #ffffff;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-title h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.section-prompt {
  font-size: 0.88rem;
  line-height: 1.55;
  color: #334155;
  margin-bottom: 0.75rem;
}

/* Objectives & Procedures lists */
.objectives-list,
.procedures-list,
.teacher-notes-list {
  padding-left: 1.35rem;
  margin: 0.4rem 0 0.75rem;
  font-size: 0.86rem;
  color: #334155;
  line-height: 1.6;
}

.objectives-list li,
.procedures-list li,
.teacher-notes-list li {
  margin-bottom: 0.35rem;
}

/* Ruled Answer Lines */
.answer-ruled-lines {
  margin: 0.5rem 0 0.75rem;
}

.ruled-line {
  border-bottom: 1px dashed #94a3b8;
  height: 24px;
  margin-bottom: 6px;
}

/* Data Table */
.table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0 0.5rem;
}

.worksheet-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #ffffff;
}

.worksheet-data-table th {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  border: 1.5px solid #0f172a;
  padding: 6px 8px;
  text-align: center;
}

.worksheet-data-table td {
  border: 1px solid #475569;
  padding: 6px 8px;
  text-align: center;
  color: #1e293b;
}

.student-blank {
  font-family: monospace;
  color: #94a3b8;
  letter-spacing: 0.08em;
}

.table-footnote {
  font-size: 0.75rem;
  color: #64748b;
  font-style: italic;
  margin-top: 0.35rem;
}

/* Questions */
.worksheet-question-item {
  margin-bottom: 1.1rem;
}

.question-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #0f172a;
  margin-bottom: 0.4rem;
}

/* Answer Key Styling */
.answer-key-box {
  background: #f0fdf4;
  border: 1.5px solid #16a34a;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  margin-top: 0.5rem;
}

.key-badge {
  display: inline-block;
  background: #16a34a;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.key-text {
  font-size: 0.84rem;
  color: #14532d;
  font-style: italic;
  line-height: 1.5;
  margin: 0;
}

.answer-key-cell {
  color: #15803d;
  font-style: italic;
}

/* By default, hide answer key content */
#worksheet-modal:not(.show-answer-key) .answer-key-content,
#worksheet-modal:not(.show-answer-key) .answer-key-cell {
  display: none !important;
}

#worksheet-modal.show-answer-key .student-blank {
  display: none !important;
}

/* Teacher Notes Section */
.teacher-notes-section {
  background: #fffbeb;
  border: 1px dashed #d97706;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.teacher-notes-section .section-title {
  border-bottom: 1.5px solid #d97706;
}

.teacher-notes-section .section-badge {
  background: #d97706;
}

/* Footer */
.worksheet-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.85rem;
  margin-top: 2rem;
  font-size: 0.72rem;
  color: #64748b;
}

/* Prominent button inside experiment info and simulation layout */
.btn-worksheet {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1.5px solid var(--accent-primary, #4f6ef7);
  color: var(--accent-primary, #4f6ef7);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-worksheet:hover {
  background: var(--accent-primary, #4f6ef7);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-worksheet .btn-icon {
  font-size: 1rem;
}

.experiment-info-actions {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   Always-Visible Action Buttons (Canvas & Subject Headers)
   ========================================================================== */

.canvas-worksheet-btn {
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1.5px solid var(--accent-primary, #4f6ef7) !important;
  color: var(--accent-primary, #4f6ef7) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
  white-space: nowrap !important;
}

.canvas-worksheet-btn:hover {
  background: var(--accent-primary, #4f6ef7) !important;
  color: #ffffff !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 10px rgba(79, 110, 247, 0.3) !important;
}

[data-theme="dark"] .canvas-worksheet-btn {
  background: rgba(24, 28, 46, 0.95) !important;
  color: #93b4ff !important;
  border-color: #4f6ef7 !important;
}

[data-theme="dark"] .canvas-worksheet-btn:hover {
  background: #4f6ef7 !important;
  color: #ffffff !important;
}

.subject-worksheets-btn {
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  padding: 6px 16px !important;
  border-radius: 999px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  background: var(--bg-card, #ffffff) !important;
  border: 1.5px solid var(--accent-primary, #4f6ef7) !important;
  color: var(--accent-primary, #4f6ef7) !important;
  box-shadow: var(--shadow-xs, 0 1px 2px rgba(0, 0, 0, 0.05)) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.subject-worksheets-btn:hover {
  background: var(--accent-primary, #4f6ef7) !important;
  color: #ffffff !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.25) !important;
}

.page-header-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Ensure experiment info action buttons are permanently visible even if info-body is collapsed */
.experiment-info-actions {
  display: flex !important;
  align-items: center !important;
  gap: 0.6rem !important;
  margin-top: 0.75rem !important;
  padding-top: 0.6rem !important;
  border-top: 1px solid var(--border-color, #e0e4ef) !important;
  flex-wrap: wrap !important;
}

.experiment-info.collapsed .experiment-info-actions {
  margin-top: 0.6rem !important;
  padding-top: 0.6rem !important;
  border-top: 1px dashed var(--border-color, #e0e4ef) !important;
}

.btn-library-action {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.btn-library-action:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
}

/* ==========================================================================
   Centralized Worksheets Library & Catalog
   ========================================================================== */

.worksheet-library-dialog {
  max-width: 1080px;
  width: 95%;
  max-height: 90vh;
  border-radius: 16px;
  background: var(--bg-card, #ffffff);
  color: var(--text-primary, #1e293b);
  border: 1px solid var(--border-color, #e0e4ef);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.worksheet-library-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.worksheet-library-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color, #e0e4ef);
}

.worksheet-library-desc {
  font-size: 0.95rem;
  color: var(--text-secondary, #4a5068);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.worksheet-library-filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.worksheet-filter-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.worksheet-filter-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #8a90a8);
  min-width: 65px;
}

.worksheet-filter-btn {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-color, #e0e4ef);
  background: var(--bg-tertiary, #edf0f7);
  color: var(--text-secondary, #4a5068);
  cursor: pointer;
  transition: all 0.18s ease;
}

.worksheet-filter-btn:hover {
  border-color: var(--accent-primary, #4f6ef7);
  color: var(--accent-primary, #4f6ef7);
}

.worksheet-filter-btn.active {
  background: var(--accent-primary, #4f6ef7);
  border-color: var(--accent-primary, #4f6ef7);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 110, 247, 0.3);
}

.worksheet-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.worksheet-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e0e4ef);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.06));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.worksheet-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
  border-color: var(--border-hover, #c8cee0);
}

.worksheet-card-physics {
  border-top: 4px solid var(--accent-physics, #4f6ef7);
}

.worksheet-card-biology {
  border-top: 4px solid var(--accent-biology, #22c55e);
}

.worksheet-card-chemistry {
  border-top: 4px solid var(--accent-chemistry, #f97316);
}

.worksheet-card-mathematics {
  border-top: 4px solid var(--accent-mathematics, #e040fb);
}

.worksheet-card-header {
  margin-bottom: 0.75rem;
}

.worksheet-card-badges {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.subject-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-physics {
  background: rgba(79, 110, 247, 0.12);
  color: var(--accent-physics, #4f6ef7);
}

.badge-biology {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-biology, #22c55e);
}

.badge-chemistry {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-chemistry, #f97316);
}

.badge-mathematics {
  background: rgba(224, 64, 251, 0.12);
  color: var(--accent-mathematics, #e040fb);
}

.grade-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  background: var(--bg-tertiary, #f1f5f9);
  color: var(--text-secondary, #475569);
}

.time-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.22rem 0.5rem;
  border-radius: 6px;
  color: var(--text-muted, #64748b);
}

.worksheet-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.worksheet-card-standard {
  font-size: 0.76rem;
  color: var(--text-muted, #64748b);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.standard-pill {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-tertiary, #e2e8f0);
  color: var(--text-secondary, #334155);
}

.worksheet-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary, #4a5068);
  line-height: 1.45;
  margin-bottom: 0.6rem;
}

.worksheet-card-targets {
  font-size: 0.8rem;
  color: var(--text-secondary, #475569);
  margin: 0 0 1rem 1.1rem;
  padding: 0;
  line-height: 1.4;
}

.worksheet-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color, #e0e4ef);
}

.ws-card-action-btn {
  width: 100%;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ws-card-action-btn.ws-key-btn {
  border-color: rgba(234, 179, 8, 0.6);
  color: #b45309;
  background: rgba(234, 179, 8, 0.05);
}

.ws-card-action-btn.ws-key-btn:hover {
  background: #fef3c7;
  border-color: #d97706;
  color: #92400e;
}

.ws-card-action-btn.ws-sim-btn {
  background: var(--accent-primary, #4f6ef7);
  border-color: var(--accent-primary, #4f6ef7);
  color: #ffffff;
}

.ws-card-action-btn.ws-sim-btn:hover {
  background: var(--accent-hover, #3b5ae0);
  border-color: var(--accent-hover, #3b5ae0);
}

.worksheet-library-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted, #8a90a8);
}

.worksheet-library-empty .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.worksheet-library-empty h4 {
  font-size: 1.1rem;
  color: var(--text-primary, #1e293b);
  margin-bottom: 0.4rem;
}

.worksheet-library-empty p {
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

/* Dark Mode Overrides for Library & Cards */
[data-theme="dark"] .worksheet-library-dialog {
  background: var(--bg-card, #181c2e);
  color: var(--text-primary, #eceef5);
  border-color: var(--border-color, #262b40);
}

[data-theme="dark"] .worksheet-card {
  background: var(--bg-secondary, #151827);
  border-color: var(--border-color, #262b40);
}

[data-theme="dark"] .worksheet-card-title {
  color: var(--text-primary, #eceef5);
}

[data-theme="dark"] .worksheet-filter-btn {
  background: var(--bg-tertiary, #1e2236);
  color: var(--text-secondary, #a8adc4);
  border-color: var(--border-color, #262b40);
}

[data-theme="dark"] .worksheet-card-targets,
[data-theme="dark"] .worksheet-card-desc {
  color: var(--text-secondary, #a8adc4);
}

[data-theme="dark"] .grade-badge,
[data-theme="dark"] .standard-pill {
  background: var(--bg-tertiary, #1e2236);
  color: var(--text-secondary, #a8adc4);
}

[data-theme="dark"] .ws-card-action-btn.ws-key-btn {
  border-color: rgba(234, 179, 8, 0.4);
  color: #fbbf24;
  background: rgba(234, 179, 8, 0.08);
}

[data-theme="dark"] .ws-card-action-btn.ws-key-btn:hover {
  background: rgba(234, 179, 8, 0.2);
  color: #fef08a;
}

[data-theme="dark"] .worksheet-library-empty h4 {
  color: var(--text-primary, #eceef5);
}

/* ==========================================================================
   @media print Rules (Pixel-Perfect B&W High-Contrast Ink-Friendly Output)
   ========================================================================== */

@media print {
  @page {
    size: letter portrait;
    margin: 8mm 10mm;
  }

  /* 1. Hide everything on the page except the worksheet container */
  body * {
    visibility: hidden !important;
  }

  #worksheet-modal,
  #worksheet-modal * {
    visibility: visible !important;
  }

  /* 2. Position the modal as the full printed page */
  #worksheet-modal {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    display: block !important;
    overflow: visible !important;
    z-index: 999999 !important;
  }

  /* 3. Hide interactive modal chrome elements */
  .worksheet-backdrop,
  .worksheet-toolbar,
  .worksheet-close-btn,
  .table-footnote,
  .btn-worksheet,
  .canvas-worksheet-btn,
  .subject-worksheets-btn,
  .worksheet-library-modal,
  .worksheet-library-dialog,
  .feedback-floating-btn,
  .toast-container,
  .back-to-top {
    display: none !important;
    visibility: hidden !important;
  }

  /* 4. Reset dialog and content wrappers to transparent flat sheet */
  .worksheet-dialog {
    position: static !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  #worksheet-content {
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
  }

  .worksheet-paper {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    max-width: 100% !important;
  }

  /* 5. Pure black and white ink-friendly typography */
  body,
  .worksheet-paper,
  .worksheet-title,
  p,
  td,
  th,
  li,
  span,
  h2,
  h4 {
    color: #000000 !important;
    background: #ffffff !important;
  }

  .worksheet-header {
    border-bottom: 2px solid #000000 !important;
  }

  .student-info-box {
    border: 2px solid #000000 !important;
    background: #ffffff !important;
  }

  .field-line {
    border-bottom: 1px solid #000000 !important;
  }

  .score-box {
    border-left: 2px solid #000000 !important;
  }

  .section-title {
    border-bottom: 1.5px solid #000000 !important;
  }

  .section-badge {
    background: #000000 !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .subject-badge-pill {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  /* 6. Clean high-contrast tables */
  .worksheet-data-table {
    border: 1.5px solid #000000 !important;
  }

  .worksheet-data-table th {
    border: 1.5px solid #000000 !important;
    background: #f1f5f9 !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .worksheet-data-table td {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    background: #ffffff !important;
  }

  /* 7. Ruled answer lines for student handwriting */
  .ruled-line {
    border-bottom: 1px dashed #444444 !important;
    height: 22px !important;
    margin-bottom: 6px !important;
  }

  /* 8. Page break management */
  .worksheet-section,
  .worksheet-question-item,
  .table-wrap,
  .student-info-box,
  .teacher-notes-section {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* 9. Answer Key display states */
  #worksheet-modal:not(.show-answer-key) .answer-key-content,
  #worksheet-modal:not(.show-answer-key) .answer-key-cell {
    display: none !important;
  }

  #worksheet-modal.show-answer-key .student-blank {
    display: none !important;
  }

  #worksheet-modal.show-answer-key .answer-key-box {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
    color: #000000 !important;
    padding: 6px 10px !important;
  }

  #worksheet-modal.show-answer-key .key-badge {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-weight: 700 !important;
  }

  #worksheet-modal.show-answer-key .key-text {
    color: #000000 !important;
    font-style: italic !important;
  }

  #worksheet-modal.show-answer-key .teacher-notes-section {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
  }
}
