:root {
  color-scheme: light;
  --nwea-navy: #0F355C;
  --nwea-blue: #0A4F85;
  --nwea-light-blue: #EAF2F8;
  --nwea-sky: #3498DB;
  --ink: #2C3E50;
  --muted: #7F8C8D;
  --line: #BDC3C7;
  --wash: #ECF0F1;
  --panel: #FFFFFF;
  --accent: #2980B9;
  --accent-hover: #1F618D;
  --green: #27AE60;
  --amber: #D35400;
  --red: #C0392B;
  
  --font-stack: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --zoom-factor: 1;
}

* {
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

body {
  margin: 0;
  background: #F4F6F9;
  color: var(--ink);
  font-family: var(--font-stack);
  font-size: calc(16px * var(--zoom-factor));
}

button, select, input {
  font-family: inherit;
  font-size: inherit;
}

/* Shell Layout */
.shell {
  width: min(1200px, calc(100% - 30px));
  margin: 0 auto;
  padding: 20px 0 60px;
}

/* NWEA-style Student Header & Toolbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--nwea-navy);
  color: white;
  padding: 14px 24px;
  border-radius: 8px 8px 0 0;
}

.topbar-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.topbar-progress {
  font-weight: 600;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: 20px;
}

/* NWEA Interactive Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  background: #EAECEE;
  padding: 10px 24px;
  border-bottom: 2px solid var(--line);
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  gap: 6px;
  border-right: 1px solid var(--line);
  padding-right: 10px;
}

.toolbar-group:last-child {
  border-right: none;
  padding-right: 0;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--nwea-navy);
  cursor: pointer;
}

.tool-btn:hover {
  background: var(--nwea-light-blue);
}

.tool-btn.active {
  background: var(--nwea-blue);
  color: white;
  border-color: var(--nwea-blue);
}

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

/* Highlighted Selection */
.highlight-yellow {
  background-color: #F1C40F !important;
  color: black !important;
}

/* Floating Draggable Calculator */
.calc-container {
  position: absolute;
  top: 150px;
  left: 50px;
  width: 240px;
  background: #34495E;
  border: 2px solid var(--nwea-navy);
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calc-header {
  background: var(--nwea-navy);
  color: white;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: move;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.calc-close-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  margin: 0;
  line-height: 1;
}

.calc-screen {
  background: #2C3E50;
  color: #2ECC71;
  font-family: monospace;
  font-size: 1.5rem;
  text-align: right;
  padding: 12px;
  border: none;
  outline: none;
  width: 100%;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: #2C3E50;
  padding: 4px;
}

.calc-btn {
  min-height: 42px;
  background: #ECF0F1;
  border: none;
  font-weight: 700;
  font-size: 1rem;
  color: #2C3E50;
  cursor: pointer;
}

.calc-btn:hover {
  background: #BDC3C7;
}

.calc-btn.op {
  background: #F39C12;
  color: white;
}

.calc-btn.op:hover {
  background: #E67E22;
}

.calc-btn.eq {
  background: var(--nwea-sky);
  color: white;
  grid-column: span 2;
}

.calc-btn.eq:hover {
  background: #2980B9;
}

/* Floating Line Reader Guide */
.line-reader-guide {
  position: absolute;
  width: 100%;
  left: 0;
  pointer-events: none;
  z-index: 900;
  display: flex;
  flex-direction: column;
}

.line-reader-mask {
  background: rgba(0, 0, 0, 0.18);
  height: 60px;
}

.line-reader-slit {
  height: 48px;
  border-top: 2px solid var(--nwea-sky);
  border-bottom: 2px solid var(--nwea-sky);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 16px rgba(52, 152, 219, 0.2);
  pointer-events: auto;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
}

.line-reader-slit::after {
  content: '↕ Drag Guide ↕';
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--nwea-sky);
  opacity: 0.65;
}

/* Student Test Screen Card */
.test-container {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 10px 24px rgba(31, 45, 61, 0.05);
  padding: 30px 40px;
  position: relative;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.badge {
  border-radius: 20px;
  padding: 6px 14px;
  background: var(--nwea-light-blue);
  color: var(--nwea-blue);
  font-size: 0.8rem;
  font-weight: 700;
}

.badge.level {
  background: #FEF9E7;
  color: #D35400;
}

.badge.calculator {
  background: #E8F8F5;
  color: #16A085;
}

.muted-cell {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.question-area {
  margin-top: 20px;
}

.stimulus-box {
  background: #F8F9FA;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px;
  margin-bottom: 24px;
  line-height: 1.65;
  white-space: pre-line;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  line-height: 1.4;
}

.choices-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 30px;
}

.choice {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  width: 100%;
  min-height: 64px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}

.choice:hover:not(.eliminated) {
  background: var(--wash);
  border-color: var(--nwea-sky);
}

.choice .letter-box {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--wash);
  color: var(--nwea-navy);
  font-weight: 700;
}

.choice.selected {
  background: var(--nwea-light-blue) !important;
  border-color: var(--nwea-blue) !important;
  box-shadow: inset 0 0 0 1px var(--nwea-blue);
}

.choice.selected .letter-box {
  background: var(--nwea-blue);
  color: white;
}

/* Strikethrough Eliminated Option */
.choice.eliminated {
  opacity: 0.38;
  border-style: dashed;
  background: #F2F4F4;
  text-decoration: line-through;
  text-decoration-color: var(--red);
  cursor: not-allowed;
}

.choice.eliminated .letter-box {
  text-decoration: line-through;
  text-decoration-color: var(--red);
}

.submit-bar {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.nwea-btn {
  min-height: 46px;
  background: var(--nwea-blue);
  border: 1px solid var(--nwea-blue);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  padding: 0 28px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nwea-btn:hover {
  background: var(--accent-hover);
}

.nwea-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nwea-btn.secondary {
  background: #FFFFFF;
  color: var(--nwea-blue);
  border-color: var(--nwea-blue);
}

.nwea-btn.secondary:hover {
  background: var(--nwea-light-blue);
}

.nwea-btn.danger {
  background: var(--red);
  border-color: var(--red);
}

.nwea-btn.danger:hover {
  background: #922B21;
}

/* Landing Page / Dashboard Container */
.dashboard-card {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(31, 45, 61, 0.06);
  padding: 30px;
  margin-bottom: 24px;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--wash);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.card-title-row h2 {
  margin: 0;
  font-size: 1.45rem;
  color: var(--nwea-navy);
}

/* Forms Grid */
.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) auto;
  gap: 16px;
  align-items: flex-end;
  background: var(--wash);
  padding: 20px;
  border-radius: 6px;
  margin-bottom: 24px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--nwea-navy);
}

select, input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
  background: white;
}

.sync-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.sync-status[data-state="ok"] {
  color: var(--green);
}

.sync-status[data-state="error"] {
  color: var(--red);
}

/* Tabs Navigation */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--line);
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 20px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: var(--nwea-blue);
  border-bottom: 3px solid var(--nwea-blue);
  background: white;
}

/* RIT Growth Chart container */
.chart-container {
  height: 320px;
  background: #F8F9F9;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  margin: 18px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* RIT Table Layouts */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  margin-bottom: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: #F2F4F4;
  color: var(--nwea-navy);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.78rem;
}

tr:last-child td {
  border-bottom: none;
}

/* Badges for status */
.text-ok { color: var(--green); font-weight: 700; }
.text-bad { color: var(--red); font-weight: 700; }
.text-warn { color: var(--amber); font-weight: 700; }

/* Grid Cards for metrics */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px;
  background: white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
}

.metric-card span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.metric-card strong {
  display: block;
  font-size: 1.6rem;
  color: var(--nwea-navy);
}

.metric-card p {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Detailed Weakness Panels */
.weakness-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.program-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 14px;
}

.program-card h4 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  color: var(--nwea-blue);
}

.program-steps {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.55;
  font-size: 0.88rem;
}

/* Korean Parent Report Styling */
.parent-report-card {
  border: 2px solid var(--nwea-navy);
  border-radius: 8px;
  padding: 30px;
  background: #FFFFFF;
  margin-top: 30px;
}

.report-header {
  border-bottom: 3px double var(--nwea-navy);
  padding-bottom: 18px;
  margin-bottom: 24px;
  text-align: center;
}

.report-header h3 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  color: var(--nwea-navy);
  text-transform: uppercase;
}

.report-header p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.report-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: var(--nwea-light-blue);
  padding: 16px;
  border-radius: 6px;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.report-section {
  margin-bottom: 24px;
}

.report-section h4 {
  border-left: 5px solid var(--nwea-blue);
  padding-left: 10px;
  margin: 0 0 12px;
  font-size: 1.15rem;
  color: var(--nwea-navy);
}

.report-section p {
  line-height: 1.6;
  margin: 0 0 12px;
}

/* Draggable handle cursor adjustments */
.calc-header:active {
  cursor: grabbing;
}

/* Audio Play button speaker style */
.audio-speaker-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.8rem;
  color: var(--nwea-sky);
  padding: 4px;
  margin-bottom: 12px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.audio-speaker-btn:hover {
  background: var(--nwea-light-blue);
}

.question-media {
  margin: 14px 0 6px;
  text-align: center;
}

.question-media img,
.question-media svg {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #FFFFFF;
}

.question-media figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

/* Hidden Utility */
[hidden] {
  display: none !important;
}

/* Responsive Overrides */
@media (max-width: 768px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
  
  .weakness-grid {
    grid-template-columns: 1fr;
  }
  
  .report-meta {
    grid-template-columns: 1fr 1fr;
  }
  
  .topbar {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}

/* ==================== PRINT STYLESHEET ==================== */
@media print {
  body {
    background: #FFFFFF;
    color: #000000;
    font-size: 12pt;
  }
  
  .shell {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  
  /* Hide all interactive components during print */
  .topbar, 
  .toolbar, 
  .calc-container, 
  .line-reader-guide, 
  .dashboard-card:not(.print-container), 
  .submit-bar, 
  .tabs, 
  .setup-grid, 
  .nwea-btn, 
  .badges,
  .screen-only {
    display: none !important;
  }
  
  /* parent report printing adjustments */
  .parent-report-card {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }
  
  .report-header {
    border-bottom: 2px solid #000000 !important;
  }
  
  .report-meta {
    background: #F2F4F4 !important;
    border: 1px solid #BDC3C7 !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  th {
    background: #E5E7E9 !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  .table-wrap {
    border-color: #000000 !important;
  }
  
  td, th {
    border-bottom-color: #000000 !important;
  }
  
  /* Page break rules for clean A4 printing */
  .report-section {
    page-break-inside: avoid;
  }
  
  .parent-report-card {
    page-break-after: always;
  }
}
