/* ==========================================================================
   IDEALOGY ENTERPRISE CSS v2.0 (ITCSS Architecture)
   Standards: WCAG 2.2 AA, W3C Reflow, WAI-ARIA APG
   Unified 2026-10-22 — dedupe: nav / @font-face / Mizan / sticky / chw / orphan rules
   ========================================================================== */
@layer reset, base, layout, components, utilities;

/* ---------- 1. SETTINGS ---------- */
:root {
  --ideal-primary: #0052CC; --ideal-primary-dark: #0747A6; --ideal-primary-bg: #DEEBFF;
  --ideal-success: #16a34a; --ideal-success-bg: #ecfdf5;
  --ideal-warning: #d97706; --ideal-warning-bg: #fffbeb;
  --ideal-danger: #dc2626;  --ideal-danger-bg: #fef2f2;
  --ideal-text: #111111; --ideal-muted: #6b7280;
  --ideal-border: #dfe1e6; --ideal-bg: #f5f5f5; --ideal-surface: #ffffff;
  --ideal-radius: 6px; --ideal-tap: 44px;
  --ideal-space-1: 0.25rem; --ideal-space-2: 0.5rem; --ideal-space-3: 0.75rem;
  --ideal-space-4: 1rem; --ideal-space-5: 1.5rem; --ideal-space-6: 2rem;
}

/* ---------- 2. RESET ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box !important; }
  html, body { margin: 0; padding: 0; max-width: 100vw; overflow-x: hidden; }
  body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.55; color: var(--ideal-text); background: var(--ideal-bg); }
  h1, h2, h3, h4 { margin: 0 0 0.5rem 0; font-weight: 600; line-height: 1.3; }
  a { color: var(--ideal-primary); text-decoration: none; }
  a:hover { text-decoration: underline; }
  :focus-visible { outline: 2px solid var(--ideal-primary); outline-offset: 2px; }
}

/* ---------- 3. LAYOUT ---------- */
@layer layout {
  .page-content, .ideal-wrap, .wrap, .container { width: 100%; max-width: 1140px; margin: 0 auto; padding: var(--ideal-space-4); }
  @media (min-width: 768px) { .page-content, .ideal-wrap, .wrap, .container { padding: var(--ideal-space-6); } }
  .panel, .card, .ideal-card { background: var(--ideal-surface); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); padding: var(--ideal-space-4); margin-bottom: var(--ideal-space-4); box-shadow: 0 1px 3px rgba(0,0,0,0.05); overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel-head, .dash-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: var(--ideal-space-2); margin-bottom: var(--ideal-space-3); border-bottom: 1px solid var(--ideal-border); padding-bottom: var(--ideal-space-2); }
  .panel-title, .page-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
  .table-wrap, .dash-table-wrap, .table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: var(--ideal-space-4); }
  table { width: 100%; min-width: 800px; border-collapse: collapse; font-size: 0.875rem; }
  th, td { padding: 10px 12px; border-bottom: 1px solid var(--ideal-border); text-align: left; vertical-align: middle; white-space: nowrap; }
  th { background: var(--ideal-bg); font-weight: 600; color: var(--ideal-muted); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
}

/* ---------- 4. COMPONENTS (base) ---------- */
@layer components {
  .btn, .ideal-btn, button[type="submit"] { display: inline-flex; align-items: center; justify-content: center; min-height: var(--ideal-tap); padding: 0 var(--ideal-space-4); border-radius: var(--ideal-radius); font-weight: 600; font-size: 0.875rem; cursor: pointer; border: 1px solid transparent; text-decoration: none; }
  .btn-primary, .ideal-btn { background: var(--ideal-primary); color: #fff; border: none; }
  .btn-primary:hover { background: var(--ideal-primary-dark); color: #fff; }
  .btn-secondary { background: var(--ideal-surface); color: var(--ideal-primary); border: 1px solid var(--ideal-border); }
  .btn-danger { background-color: var(--ideal-danger); color: white; border: none; padding: 0.5rem 1rem; border-radius: var(--ideal-radius); cursor: pointer; }
  .btn-danger:hover { background-color: #b91c1c; }
  .btn-ghost { background: transparent; color: var(--ideal-text); border: 1px solid var(--ideal-border); padding: 0.5rem 1rem; border-radius: var(--ideal-radius); cursor: pointer; }
  .btn-sm { padding: 0.35rem 0.75rem; font-size: 0.875rem; }
  .btn-back { background: rgba(0,0,0,0.05); color: rgba(0,0,0,0.75); }
  .btn-back:hover { background: rgba(0,0,0,0.1); }
  .field { display: flex; flex-direction: column; gap: var(--ideal-space-2); margin-bottom: var(--ideal-space-3); width: 100%; }
  .field-label { font-weight: 600; font-size: 0.875rem; color: var(--ideal-text); }
  .input, input[type="text"], input[type="password"], select { width: 100%; min-height: var(--ideal-tap); padding: 0 var(--ideal-space-3); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); font-family: inherit; font-size: 1rem; background: var(--ideal-surface); color: var(--ideal-text); }
  .seg { display: grid !important; grid-template-columns: repeat(3, 1fr) !important; width: 100% !important; border: 1px solid var(--ideal-border) !important; border-radius: var(--ideal-radius) !important; overflow: hidden !important; background: var(--ideal-surface); }
  .seg label { display: block !important; margin: 0 !important; padding: 0 !important; width: 100% !important; min-width: 0 !important; }
  .seg span { display: flex !important; justify-content: center !important; align-items: center !important; width: 100% !important; padding: 10px 2px !important; font-size: 0.8rem !important; border-right: 1px solid var(--ideal-border) !important; min-height: var(--ideal-tap) !important; cursor: pointer !important; white-space: nowrap !important; }
  .seg label:last-child span { border-right: none !important; }
  .seg input { position: absolute !important; opacity: 0 !important; pointer-events: none !important; }
  .seg-p input:checked + span { background: var(--ideal-primary) !important; color: #fff !important; }
  .seg-a input:checked + span { background: var(--ideal-danger) !important; color: #fff !important; }
  .seg-l input:checked + span { background: var(--ideal-warning) !important; color: #fff !important; }
  .kpi-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ideal-space-4); margin-bottom: var(--ideal-space-4); }
  @media (max-width: 480px) { .kpi-row { grid-template-columns: 1fr; } }
  .kpi-value-lg { font-size: 2rem; font-weight: 700; color: var(--ideal-primary); line-height: 1.2; }
  .kpi-value-md { font-size: 1.5rem; font-weight: 700; color: var(--ideal-success); line-height: 1.2; }
  .kpi-success { color: var(--ideal-success); }
  .kpi-item { display: flex; flex-direction: column; gap: var(--ideal-space-1); }
  .kpi--warn { border-left: 4px solid #f59e0b; }
  .kpi--good { border-left: 4px solid #27ae60; }
  .tag { display: inline-block !important; padding: 0.25rem 0.5rem !important; font-size: 0.75rem !important; font-weight: 600 !important; border-radius: 4px !important; line-height: 1.2 !important; letter-spacing: 0.02em !important; }
  .tag--positive { background-color: #ecfdf5 !important; color: #047857 !important; border: 1px solid #a7f3d0 !important; }
  .tag--negative { background-color: #fef2f2 !important; color: #b91c1c !important; border: 1px solid #fecaca !important; }
  .tag--neutral { background-color: #f3f4f6 !important; color: #4b5563 !important; border: 1px solid #e5e7eb !important; }
  .tag.DONE, .tag.COMPLETED, .tag.ACTIVE { background: rgba(39,174,96,0.15); color: #166534; }
  .tag.WARN, .tag.IN_PROGRESS, .tag.BLOCKED { background: rgba(241,196,15,0.15); color: #92400e; }
  .tag.CRITICAL { background: rgba(192,57,43,0.15); color: #7f1d1d; font-weight: 600; }
  .tag.INFO, .tag.PENDING, .tag.ASSIGNED, .tag.SKIPPED { background: rgba(0,0,0,0.06); color: rgba(0,0,0,0.65); }
  

  
  .coach-summary-panel { background: var(--ideal-bg) !important; border-left: 4px solid var(--ideal-primary) !important; }
  .coach-summary-text { font-size: 1rem !important; line-height: 1.5 !important; color: var(--ideal-muted) !important; }

  .panel--inset { background-color: var(--ideal-bg); border: 1px solid var(--ideal-border); padding: var(--ideal-space-4); border-radius: var(--ideal-radius); }
  .panel--warning { border-left: 4px solid var(--ideal-warning) !important; background-color: var(--ideal-warning-bg); padding: var(--ideal-space-4); border-radius: var(--ideal-radius); }
  .panel--info { padding: 1rem 1.25rem; border-radius: 8px; background: rgba(52,152,219,0.08); border-left: 4px solid rgba(52,152,219,0.6); }
  .panel--positive { padding: 1rem 1.25rem; border-radius: 8px; background: rgba(39,174,96,0.06); border-left: 4px solid #27ae60; }
  .panel--negative { padding: 1rem 1.25rem; border-radius: 8px; background: rgba(192,57,43,0.06); border-left: 4px solid #c0392b; }
}

/* ---------- 4. COMPONENTS (continued: quick-links, funnel, help, tables, forms, threads, toggles, mastery, session) ---------- */
@layer components {
  .quick-links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--ideal-space-4); }
  .qlink { display: flex; flex-direction: column; padding: var(--ideal-space-4); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); text-decoration: none; color: var(--ideal-text); background: var(--ideal-surface); transition: border-color 0.2s; }
  .qlink:hover { border-color: var(--ideal-primary); }
  .qlink-sub { font-size: 0.875rem; color: var(--ideal-muted); margin-top: var(--ideal-space-1); }
  .funnel-card { display: flex; flex-direction: column; padding: var(--ideal-space-4); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); background: var(--ideal-surface); margin-bottom: var(--ideal-space-3); transition: border-color 0.2s; text-align: left !important; align-items: flex-start !important; }
  .funnel-card:hover { border-color: var(--ideal-primary); }
  .funnel-card summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; font-weight: 600; color: var(--ideal-text); width: 100%; }
  .funnel-card summary::-webkit-details-marker { display: none; }
  .funnel-card[open] summary { margin-bottom: var(--ideal-space-3); padding-bottom: var(--ideal-space-3); border-bottom: 1px solid var(--ideal-border); }
  .funnel-summary { display: flex; flex-direction: column; gap: var(--ideal-space-2); cursor: pointer; list-style: none; width: 100%; }
  .funnel-meta { display: flex; align-items: center; gap: var(--ideal-space-2); }
  .funnel-title { font-size: 1rem; font-weight: 600; color: var(--ideal-text); margin-bottom: var(--ideal-space-2); line-height: 1.4; }
  @media (min-width: 600px) { .funnel-summary { flex-direction: row; justify-content: space-between; align-items: center; } }
  .page-header-flex { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--ideal-space-3); }
  .help-btn { background: transparent; border: 1px solid var(--ideal-border); border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ideal-muted); flex-shrink: 0; font-weight: bold; }
  .help-btn:hover { background: var(--ideal-bg); color: var(--ideal-primary); border-color: var(--ideal-primary); }
  .help-drawer-overlay.is-open { display: block !important; }
  .help-drawer.is-open { transform: translateX(0) !important; }
  .help-drawer-header { display: flex; justify-content: space-between; align-items: center; padding: var(--ideal-space-4); border-bottom: 1px solid var(--ideal-border); }
  .help-drawer-body { padding: var(--ideal-space-4); overflow-y: auto; flex: 1; }
  .ideal-table { width: 100%; border-collapse: collapse; text-align: left; }
  .ideal-table th, .ideal-table td { padding: var(--ideal-space-3); border-bottom: 1px solid var(--ideal-border); }
  .ideal-table th { background: var(--ideal-bg); font-weight: 600; color: var(--ideal-text); }
  .ideal-table tr:hover { background: var(--ideal-bg); }
  .ideal-form-group { margin-bottom: var(--ideal-space-4); display: flex; flex-direction: column; gap: var(--ideal-space-1); }
  .ideal-label { font-weight: 600; font-size: 0.875rem; color: var(--ideal-text); }
  .ideal-input, .ideal-select { padding: var(--ideal-space-2) var(--ideal-space-3); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); font-size: 1rem; width: 100%; max-width: 400px; }
  .ideal-input:focus, .ideal-select:focus { outline: 2px solid var(--ideal-primary); border-color: transparent; }
  .ideal-form-group input[type="text"], .ideal-form-group input[type="number"], .ideal-form-group input[type="password"], .ideal-form-group select, .ideal-form-group textarea { padding: var(--ideal-space-2) var(--ideal-space-3); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); font-size: 1rem; width: 100%; max-width: 400px; font-family: inherit; }
  .ideal-form-group input:focus, .ideal-form-group select:focus, .ideal-form-group textarea:focus { outline: 2px solid var(--ideal-primary); border-color: transparent; }
  .ideal-code-block { background: var(--ideal-bg); border: 1px dashed var(--ideal-border); padding: var(--ideal-space-3); font-family: monospace; font-size: 1.1rem; letter-spacing: 1px; border-radius: var(--ideal-radius); word-break: break-all; margin-top: var(--ideal-space-2); }
  .ideal-recovery-list { background: var(--ideal-warning-bg); border: 1px solid var(--ideal-warning); padding: var(--ideal-space-4); border-radius: var(--ideal-radius); list-style-type: none; font-family: monospace; font-size: 1.1rem; display: grid; grid-template-columns: 1fr 1fr; gap: var(--ideal-space-2); }
  .msg-thread { display: flex; flex-direction: column; gap: var(--ideal-space-3); margin-top: var(--ideal-space-4); }
  .msg-card { background: var(--ideal-surface); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); padding: var(--ideal-space-4); }
  .msg-header { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--ideal-muted); margin-bottom: var(--ideal-space-2); border-bottom: 1px solid var(--ideal-border); padding-bottom: var(--ideal-space-2); }
  .msg-body { font-size: 0.95rem; color: var(--ideal-text); line-height: 1.5; white-space: pre-wrap; }
  .msg { padding: 0.75rem 1rem; border-radius: 6px; margin: 0.75rem 0; }
  .msg.error { background: rgba(192,57,43,0.1); color: #7f1d1d; }
  .msg.info { background: rgba(52,152,219,0.1); color: #1e40af; }
  .msg.success { background: rgba(39,174,96,0.1); color: #166534; }
  .msg--highlighted { border-left: 3px solid #fbbf24; background: rgba(251,191,36,0.06); }
  .task-gate-row { display: flex; justify-content: space-between; align-items: center; padding: var(--ideal-space-3) 0; border-bottom: 1px solid var(--ideal-border); }
  .task-gate-list { display: flex; flex-direction: column; border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); overflow: hidden; }
  .task-gate-row:last-child { border-bottom: none; }
  .task-gate-row:hover { background: var(--ideal-bg); }
  .task-meta { font-size: 0.75rem; color: var(--ideal-muted); margin-top: 4px; }
  .toggle-switch { position: relative; display: inline-block; width: 48px; height: 24px; flex-shrink: 0; }
  .toggle-switch input { opacity: 0; width: 0; height: 0; }
  .toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: 0.4s; border-radius: 24px; }
  .toggle-slider::before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: 0.4s; border-radius: 50%; }
  input:checked + .toggle-slider { background-color: var(--ideal-success); }
  input:checked + .toggle-slider::before { transform: translateX(24px); }
  input:focus + .toggle-slider { box-shadow: 0 0 1px var(--ideal-success); }
  .prompt-container { position: relative; margin-top: var(--ideal-space-4); }
  .prompt-box { background: #1e1e1e; color: #d4d4d4; padding: var(--ideal-space-4); border-radius: var(--ideal-radius); font-family: monospace; font-size: 0.85rem; white-space: pre-wrap; line-height: 1.5; max-height: 300px; overflow-y: auto; display: block; }
  .copy-btn { position: absolute; top: -12px; right: 12px; padding: 6px 12px; font-size: 0.75rem; cursor: pointer; background: var(--ideal-primary); color: white; border: none; border-radius: 4px; font-weight: 600; z-index: 10; }
  .batch-toggle { display: flex; gap: var(--ideal-space-2); margin-bottom: var(--ideal-space-4); }
  .batch-btn { flex: 1; padding: var(--ideal-space-3); text-align: center; border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); cursor: pointer; background: var(--ideal-bg); font-weight: 600; color: var(--ideal-text); }
  .batch-btn.active { background: var(--ideal-primary); color: white; border-color: var(--ideal-primary); }
  .font-mono { font-family: monospace; }
  .mastery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--ideal-space-4); margin-top: var(--ideal-space-4); }
  .mastery-card { background: var(--ideal-surface); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); padding: var(--ideal-space-4); }
  .mastery-card.NEW { border-top: 4px solid var(--ideal-muted); }
  .mastery-card.LEARNING { border-top: 4px solid var(--ideal-warning); }
  .mastery-card.REVIEW { border-top: 4px solid var(--ideal-primary); }
  .mastery-card.MASTERED { border-top: 4px solid var(--ideal-success); }
  .session-card { background: var(--ideal-surface); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); padding: var(--ideal-space-4); margin-bottom: var(--ideal-space-3); }
  .session-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--ideal-border); padding-bottom: var(--ideal-space-2); margin-bottom: var(--ideal-space-2); }
  .session-meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ideal-space-2); font-size: 0.85rem; color: var(--ideal-muted); }
  @media (max-width: 600px) { .session-meta { grid-template-columns: 1fr; } }
  .file-input { padding: var(--ideal-space-3); border: 1px dashed var(--ideal-border); border-radius: var(--ideal-radius); width: 100%; background: var(--ideal-bg); cursor: pointer; }
  .status-box { padding: var(--ideal-space-3) var(--ideal-space-4); border-radius: var(--ideal-radius); margin-bottom: var(--ideal-space-4); display: none; font-weight: 500; }
  .status-box.is-visible { display: block; }
  .status-box--error { background: var(--ideal-danger-bg); border-left: 5px solid var(--ideal-danger); color: #991b1b; }
  .status-box--success { background: var(--ideal-success-bg); border-left: 5px solid var(--ideal-success); color: #166534; }
  .status-box--info { background: var(--ideal-primary-bg); border-left: 5px solid var(--ideal-primary); color: #1e3a8a; }
  .kzm-stars { display: inline-flex; gap: 2px; align-items: center; font-size: 1.3rem; }
  .kzm-star-filled { color: #f59e0b; }
  .kzm-star-empty { color: #d1d5db; }
}

/* ---------- 5. MIZAN (UNIFIED) ---------- */
@layer components {
  .mizan-hero { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: var(--ideal-space-4); padding: var(--ideal-space-5); background: var(--ideal-surface); border-radius: var(--ideal-radius); border: 1px solid var(--ideal-border); width: 100%; box-sizing: border-box; }
  @media (max-width: 768px) { .mizan-hero { flex-direction: column; align-items: stretch; } }
  .mizan-ring-wrapper { position: relative; width: 180px; height: 180px; flex-shrink: 0; margin: 0 auto; }
  .mizan-ring { position: relative; width: 100%; height: 100%; border-radius: 50%; background: conic-gradient(var(--ideal-primary) calc(var(--score) * 0.1%), var(--ideal-border) 0); display: flex; align-items: center; justify-content: center; }
  .mizan-ring::before { content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%; background: var(--ideal-surface); }
  .mizan-ring-inner { position: relative; z-index: 2; text-align: center; }
  .mizan-score { font-size: 2.5rem; font-weight: 800; line-height: 1; color: var(--ideal-text); }
  .mizan-label { font-size: 0.85rem; color: var(--ideal-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 1px; margin-top: 4px; }
  .mizan-ring-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--ideal-space-6); background: var(--ideal-surface); border-radius: var(--ideal-radius); border: 1px solid var(--ideal-border); }
  .mizan-ring-container .mizan-ring { position: relative; width: 200px; height: 200px; border-radius: 50%; background: conic-gradient(var(--ideal-primary) calc(var(--score) * 0.1%), var(--ideal-border) 0); display: flex; align-items: center; justify-content: center; }
  .mizan-ring-container .mizan-ring::before { content: ""; position: absolute; width: 160px; height: 160px; border-radius: 50%; background: var(--ideal-surface); }
  .mizan-risk-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin-top: var(--ideal-space-4); width: 100%; }
  .risk-segment { height: 100%; }
  .risk-red { width: 30%; background: #ef4444; }
  .risk-orange { width: 10%; background: #f97316; }
  .risk-yellow { width: 10%; background: #eab308; }
  .risk-green { width: 50%; background: #22c55e; }
  .risk-indicator { position: relative; height: 24px; margin-top: -18px; }
  .risk-pin { position: absolute; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 8px solid var(--ideal-text); transform: translateX(-50%); }
  .mizan-scale-wrapper { width: 100%; margin-top: var(--ideal-space-4); }
  .mizan-scale-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--ideal-border); position: relative; }
  .scale-zone { height: 100%; }
  .scale-red { width: 30%; background: #ef4444; }
  .scale-orange { width: 10%; background: #f97316; }
  .scale-yellow { width: 10%; background: #eab308; }
  .scale-green { width: 50%; background: #22c55e; }
  .mizan-pin { position: absolute; top: -6px; width: 4px; height: 28px; background: var(--ideal-text); border-radius: 2px; transform: translateX(-50%); transition: left 0.3s ease; }
  .mizan-scale-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--ideal-muted); margin-top: var(--ideal-space-2); font-weight: 600; }
  .mizan-consequence { padding: var(--ideal-space-3); border-radius: var(--ideal-radius); font-size: 0.9rem; margin-top: var(--ideal-space-4); border-left: 4px solid var(--ideal-text); }
  .consequence-safe { background: #ecfdf5; border-color: #22c55e; color: #166534; }
  .consequence-warn { background: #fffbeb; border-color: #eab308; color: #854d0e; }
  .consequence-danger { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
}

/* ---------- 6. NAV (UNIFIED — single canonical) ---------- */
@layer components {
  .ent-navbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--ideal-surface); border-bottom: 1px solid var(--ideal-border); position: sticky; top: 0; z-index: 10000; box-shadow: 0 1px 3px rgba(0,0,0,0.05); flex-wrap: nowrap; }
  .ent-brand { font-size: 1.25rem; font-weight: 800; color: var(--ideal-primary); text-decoration: none; display: flex; align-items: center; gap: 4px; }
  .ent-brand-dot { color: var(--ideal-danger, #dc2626); font-weight: 600; }
  .ent-nav-links { display: flex; gap: var(--ideal-space-4); align-items: center; }
  .ent-nav-link { text-decoration: none; color: var(--ideal-text); font-weight: 500; font-size: 0.95rem; min-height: 44px; display: inline-flex; align-items: center; padding: 8px 6px; transition: color 0.2s; }
  .ent-nav-link:hover, .ent-nav-link[aria-current="page"] { color: var(--ideal-primary); font-weight: 600; }
  .ent-nav-form { margin: 0; }
  .ent-nav-logout { padding: 6px 12px; font-size: 0.85rem; font-weight: 500; min-height: 44px; border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); background: transparent; color: var(--ideal-text); cursor: pointer; white-space: nowrap; transition: all 0.15s; }
  .ent-nav-logout:hover { background: var(--ideal-danger-bg); border-color: var(--ideal-danger); color: var(--ideal-danger); }
  .ent-nav-logout-block { width: 100%; text-align: left; background: transparent; border: 0; cursor: pointer; }
  .ent-mobile-menu { display: none; }
  .ent-mobile-menu summary { list-style: none; cursor: pointer; padding: 8px; display: flex; align-items: center; justify-content: center; }
  .ent-mobile-menu summary::-webkit-details-marker { display: none; }
  .ent-mobile-dropdown { position: absolute; right: 0; top: 100%; margin-top: 10px; width: 260px; max-height: 80vh; overflow-y: auto; background: var(--ideal-surface); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); box-shadow: 0 10px 25px rgba(0,0,0,0.2); display: flex; flex-direction: column; padding: var(--ideal-space-2) 0; z-index: 10002; }
  .ent-dropdown-link { padding: var(--ideal-space-2) var(--ideal-space-4); text-decoration: none; color: var(--ideal-text); font-size: 0.9rem; min-height: 48px; display: flex; align-items: center; }
  .ent-dropdown-link:hover { background: var(--ideal-bg); color: var(--ideal-primary); }
  .ent-dropdown-header { font-size: 0.75rem; text-transform: uppercase; color: var(--ideal-muted); font-weight: 700; padding: var(--ideal-space-2) var(--ideal-space-4); margin-top: var(--ideal-space-2); }
  .ent-dropdown-header:first-child { margin-top: 0; }
  .ent-divider { height: 1px; background: var(--ideal-border); margin: var(--ideal-space-2) 0; }
  .ent-dropdown-btn { width: 100%; text-align: left; background: none; border: none; cursor: pointer; }
  .ent-nav-link:focus-visible, .ent-dropdown-link:focus-visible, .ent-nav-logout:focus-visible, .ent-nav-logout-block:focus-visible, .ent-mobile-menu summary:focus-visible, .ent-brand:focus-visible { outline: 2px solid var(--ideal-primary); outline-offset: 2px; border-radius: 2px; }
  @media (max-width: 1024px) {
    .ent-navbar { position: fixed; top: 0; left: 0; width: 100%; z-index: 10000; }
    body { padding-top: 60px; }
    .ent-nav-links { display: none; }
    .ent-nav-form { display: none; }
    .ent-mobile-menu { display: block; position: relative; z-index: 10001; }
    .ent-mobile-dropdown { max-height: calc(100vh - 70px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  }
}

/* ---------- 7. BATTLE / GAME ---------- */
@layer components {
  .battle-wrapper { display: flex; justify-content: center; align-items: center; padding: var(--ideal-space-4) 0; }
  .battle-card { width: 100%; max-width: 600px; background: var(--ideal-surface); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); padding: var(--ideal-space-6); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
  .battle-header { text-align: center; margin-bottom: var(--ideal-space-6); }
  .arena { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--ideal-space-6); }
  .player-sprite, .monster-sprite { font-size: 4rem; text-align: center; }
  .versus { font-size: 1.5rem; font-weight: 800; color: var(--ideal-muted); }
  .hp-track { width: 100%; height: 12px; background: var(--ideal-border); border-radius: 6px; overflow: hidden; margin-top: var(--ideal-space-2); }
  .hp-fill { height: 100%; background: var(--ideal-danger); width: 100%; transition: width 0.3s ease; }
  .hint-box { background: var(--ideal-warning-bg); border: 1px solid var(--ideal-warning); color: #92400e; padding: var(--ideal-space-3); border-radius: var(--ideal-radius); margin-bottom: var(--ideal-space-4); }
  .feedback-box { display: none; background: var(--ideal-success-bg); border: 1px solid var(--ideal-success); color: #166534; padding: var(--ideal-space-3); border-radius: var(--ideal-radius); margin-top: var(--ideal-space-4); }
  .wizard-gates { display: flex; flex-wrap: wrap; gap: var(--ideal-space-2); margin-top: var(--ideal-space-6); border-top: 1px solid var(--ideal-border); padding-top: var(--ideal-space-4); }
  .wizard-gate { padding: var(--ideal-space-2) var(--ideal-space-3); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); text-decoration: none; color: var(--ideal-text); font-size: 0.85rem; font-weight: 500; }
  .wizard-gate:hover { background: var(--ideal-bg); }
  .wizard-gate.active { background: var(--ideal-primary); color: white; border-color: var(--ideal-primary); }
  .pokedex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--ideal-space-4); margin-top: var(--ideal-space-4); }
  .pokedex-card { background: var(--ideal-surface); border: 1px solid var(--ideal-border); border-radius: var(--ideal-radius); padding: var(--ideal-space-4); text-align: center; transition: transform 0.2s, box-shadow 0.2s; text-decoration: none; color: var(--ideal-text); display: block; }
  .pokedex-card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 4px 12px rgba(0,0,0,0.15); border-color: var(--ideal-primary); }
  .pokedex-card.caught { border-top: 4px solid var(--ideal-success); }
  .pokedex-card.uncaught { opacity: 0.6; filter: grayscale(100%); }
  .monster-emoji { font-size: 3rem; display: block; margin-bottom: var(--ideal-space-2); }
  .kc-name { font-weight: 600; font-size: 0.9rem; }
  .kc-subject { font-size: 0.75rem; color: var(--ideal-muted); margin-top: 4px; }
  .options-grid { display: flex; flex-direction: column; gap: var(--ideal-space-2); margin-top: var(--ideal-space-4); }
  .option-btn { padding: var(--ideal-space-3) var(--ideal-space-4); background: var(--ideal-surface); border: 2px solid var(--ideal-border); border-radius: var(--ideal-radius); cursor: pointer; text-align: left; font-size: 1rem; font-family: inherit; transition: all 0.2s ease; width: 100%; }
  .option-btn:hover:not(:disabled) { border-color: var(--ideal-primary); background: var(--ideal-bg); transform: translateX(4px); }
  .option-btn.option-correct { background: var(--ideal-success-bg); border-color: var(--ideal-success); color: #166534; font-weight: 600; }
  .option-btn.option-wrong { background: var(--ideal-danger-bg); border-color: var(--ideal-danger); color: #991b1b; }
  .option-btn:disabled { cursor: default; opacity: 0.85; }
  .monster-sprite { transition: transform 0.3s ease; }
  .battle-question { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
  .battle-option { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; line-height: 1.4; }
  .monster-box { text-align: center; padding: var(--ideal-space-6); }
  .monster-icon { font-size: 5rem; margin-bottom: var(--ideal-space-4); }
  .xp-bar-container { background: var(--ideal-border); border-radius: 10px; height: 20px; width: 100%; overflow: hidden; margin: var(--ideal-space-4) 0; }
  .xp-bar-fill { background: var(--ideal-success); height: 100%; transition: width 0.3s ease; }
  .rank-card { display: flex; flex-direction: column; align-items: center; background: #1e293b; color: white; padding: 20px; border-radius: 12px; margin: 20px auto; width: 100%; max-width: 400px; box-sizing: border-box; border: 2px solid #334155; }
  .rank-icon { font-size: 4rem; line-height: 1; }
  .rank-title { font-size: 1.5rem; font-weight: 800; color: #fbbf24; margin-top: 10px; text-transform: uppercase; letter-spacing: 2px; }
  .rank-sub { font-size: 0.9rem; color: #94a3b8; margin-top: 5px; }
  .daily-goal-box { background: var(--ideal-surface); padding: 20px; border-radius: 12px; border: 1px solid var(--ideal-border); margin: 20px auto; width: 100%; max-width: 400px; box-sizing: border-box; text-align: center; }
  .goal-progress-bg { background: #e5e7eb; height: 12px; border-radius: 6px; overflow: hidden; margin: 15px 0 5px; }
  .goal-progress-fill { background: var(--ideal-primary); height: 100%; transition: width 0.3s; }
}

/* ---------- 8. STICKY / TIMELINE / HISTORY (UNIFIED) ---------- */
@layer components {
  .sticky-bottom-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; background: #ffffff; padding: 1rem; border-top: 2px solid var(--ideal-primary, #2563eb); box-shadow: 0 -4px 12px rgba(0,0,0,0.1); }
  @media (min-width: 768px) { .sticky-bottom-bar { position: sticky; bottom: 1rem; left: auto; right: auto; max-width: 1200px; margin: 0 auto; border: 2px solid var(--ideal-primary, #2563eb); border-radius: 12px; } }
  .compact-sticky-bar { position: fixed; bottom: 0; left: 0; right: 0; background: #ffffff; padding: 0.5rem 1rem; border-top: 1px solid #e2e8f0; box-shadow: 0 -2px 10px rgba(0,0,0,0.05); z-index: 1050; display: flex; justify-content: space-between; align-items: center; }
  @media (min-width: 768px) { .compact-sticky-bar { position: sticky; bottom: 1rem; left: auto; right: auto; max-width: 800px; margin: 2rem auto 0; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); padding: 1rem 1.5rem; } }
  .compact-sticky-bar .save-btn { padding: 0.5rem 1rem; font-size: 0.9rem; white-space: nowrap; display: flex; align-items: center; gap: 0.5rem; height: 42px; }
  .urdu-box { display: none; margin-top: 1rem; padding: 1rem; background: #f0fdf4; border-right: 4px solid #10b981; border-radius: 8px; font-size: 1.1rem; line-height: 2; color: #064e3b; text-align: left; font-family: 'Noto Nastaliq Urdu', serif; }
  .urdu-box.show { display: block; }
  .q-checkbox { width: 20px; height: 20px; cursor: pointer; }
  .back-arrow { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: #f1f5f9; color: #1e293b; text-decoration: none; transition: background 0.2s; }
  .back-arrow:hover { background: #e2e8f0; }
  .global-history-nav { display: flex; gap: 0.5rem; padding: 0.5rem 1rem; max-width: 1200px; margin: 0 auto; }
  .history-nav-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; cursor: pointer; transition: all 0.2s; }
  .history-nav-btn:hover { background: #e2e8f0; color: #0f172a; }
  .timeline { position: relative; padding-left: 0; margin: 1.5rem 0; }
  .timeline-item { display: flex; align-items: flex-start; gap: 1rem; padding: 1rem 0; position: relative; }
  .timeline-marker { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; flex-shrink: 0; background: #e2e8f0; color: #64748b; border: 2px solid #cbd5e1; z-index: 2; position: relative; transition: all 0.3s ease; }
  .timeline-item.is-done .timeline-marker { background: #22c55e; border-color: #22c55e; color: #ffffff; }
  .timeline-item.is-active .timeline-marker { background: #2563eb; border-color: #2563eb; color: #ffffff; box-shadow: 0 0 0 6px rgba(37,99,235,0.15); }
  .timeline-item.is-locked .timeline-marker { background: #f1f5f9; border-color: #e2e8f0; color: #94a3b8; }
  .timeline-line { position: absolute; left: 20px; top: 50px; bottom: 0; width: 2px; background: #e2e8f0; z-index: 1; }
  .timeline-item.is-done + .timeline-item .timeline-line { background: #22c55e; }
  .timeline-item.is-locked .timeline-line { background: #e2e8f0; }
  .timeline-body { flex: 1; min-width: 0; padding-top: 0.4rem; }
  .timeline-title { font-weight: 600; font-size: 1rem; color: #1e293b; margin-bottom: 0.25rem; }
  .timeline-item.is-locked .timeline-title { color: #94a3b8; }
  .timeline-desc { font-size: 0.85rem; color: #64748b; line-height: 1.5; }
  .timeline-cta { margin-top: 0.75rem; }
  .progress-header { position: sticky; top: 0; z-index: 100; background: #ffffff; border-bottom: 1px solid #e2e8f0; padding: 0.75rem 1rem; margin: -1rem -1rem 1rem -1rem; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
  .progress-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
  .progress-bar-track { flex: 1; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; min-width: 80px; }
  .progress-bar-fill { height: 100%; background: #2563eb; border-radius: 3px; transition: width 0.4s ease; }
  .progress-label { font-size: 0.8rem; font-weight: 600; color: #1e293b; white-space: nowrap; }
  .source-text { line-height: 1.6 !important; font-size: 0.95rem; }
}

/* ---------- 9. SESSION TIMEOUT ---------- */
@layer components {
  .session-timeout-modal, #session-timeout, .timeout-popup { position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; background: var(--ideal-surface) !important; padding: 30px !important; border-radius: 12px !important; box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important; z-index: 99999 !important; text-align: center !important; border: 1px solid var(--ideal-border) !important; width: 90% !important; max-width: 400px !important; }
  .session-timeout-overlay { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; background: rgba(0,0,0,0.5) !important; z-index: 99998 !important; }
  .session-timeout-modal button, .timeout-popup button { margin-top: 20px !important; padding: 10px 24px !important; font-size: 1rem !important; border-radius: 8px !important; display: inline-block !important; }
}

/* ---------- 10. PIPELINE UI ---------- */
@layer components {
  .pipe-progress-wrap { margin: 0.75rem 0; }
  .pipe-progress-wrap progress { width: 100%; height: 20px; appearance: none; -webkit-appearance: none; border: none; border-radius: 10px; overflow: hidden; background: rgba(0,0,0,0.08); }
  .pipe-progress-wrap progress::-webkit-progress-bar { background: rgba(0,0,0,0.08); border-radius: 10px; }
  .pipe-progress-wrap progress::-webkit-progress-value { background: #0052CC; border-radius: 10px; transition: width 0.3s ease; }
  .pipe-progress-wrap progress::-moz-progress-bar { background: #0052CC; border-radius: 10px; }
  .pipe-progress-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; font-size: 0.9rem; color: rgba(0,0,0,0.55); margin-top: 0.35rem; }
  .stage-strip { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 1rem 0 0.5rem; }
  .stage-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.35rem 0.65rem; border-radius: 6px; background: rgba(0,0,0,0.06); font-size: 0.85rem; font-weight: 500; min-width: 34px; justify-content: center; }
  .stage-chip.done { background: rgba(39,174,96,0.15); color: #166534; }
  .stage-chip.current { background: rgba(52,152,219,0.2); color: #1e40af; outline: 2px solid rgba(52,152,219,0.6); }
  .stage-chip.teacher { border-left: 3px solid rgba(241,196,15,0.9); }
  .stage-chip .c { font-size: 0.75rem; opacity: 0.7; }
  .stage-vert { list-style: none; padding: 0; margin: 1rem 0; display: none; }
  .stage-vert li { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; margin: 0.35rem 0; border-left: 3px solid rgba(0,0,0,0.15); background: rgba(0,0,0,0.02); border-radius: 0 6px 6px 0; }
  .stage-vert li.done { border-left-color: #27ae60; background: rgba(39,174,96,0.05); }
  .stage-vert li.current { border-left-color: #3498db; background: rgba(52,152,219,0.05); }
  .stage-vert li.teacher { border-left-color: #f1c40f; }
  .stage-vert li .num { font-weight: 700; min-width: 24px; text-align: center; color: rgba(0,0,0,0.55); font-size: 1rem; }
  .stage-vert li.done .num { color: #27ae60; }
  .stage-vert li .lbl { flex: 1; font-weight: 500; }
  .stage-vert li .meta { font-size: 0.8rem; color: rgba(0,0,0,0.5); }
  .stage-vert li .arrow { color: rgba(0,0,0,0.35); }
  @media (max-width: 560px) { .stage-strip { display: none; } .stage-vert { display: block; } }
  .pipe-card { padding: 1rem; margin: 1rem 0; border-radius: 8px; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
  .pipe-card.done { border-left: 4px solid #27ae60; }
  .pipe-card.blocked { border-left: 4px solid #f1c40f; }
  .pipe-card > a.title { display: block; text-decoration: none; color: inherit; }
  .pipe-card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; }
  .pipe-card .paper { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; font-size: 0.95rem; }
  .pipe-card .ttl { color: rgba(0,0,0,0.7); font-size: 0.9rem; margin-top: 0.25rem; }
  .pipe-card .herline { color: rgba(0,0,0,0.5); font-size: 0.85rem; margin-top: 0.25rem; }
  .pipe-card .tag { font-size: 0.8rem; }
  .pipe-card .tag.done { background: rgba(39,174,96,0.15); color: #166534; }
  .pipe-card .tag.block { background: rgba(241,196,15,0.15); color: #92400e; }
  .pipe-card .tag.act { background: rgba(52,152,219,0.15); color: #1e40af; }
  .pipe-nextbox { margin-top: 1rem; padding: 0.75rem 1rem; background: rgba(52,152,219,0.06); border-left: 4px solid #3498db; border-radius: 6px; }
  .pipe-nextbox.done { background: rgba(39,174,96,0.06); border-left-color: #27ae60; }
  .pipe-nextbox.teacher { background: rgba(241,196,15,0.06); border-left-color: #f1c40f; }
  .pipe-nextbox .lbl { font-weight: 600; color: rgba(0,0,0,0.65); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
  .pipe-nextbox .val { margin: 0.35rem 0; font-size: 1rem; }
  .pipe-nextbox .btn { display: inline-block; padding: 0.4rem 0.85rem; background: #0052CC; color: white; border-radius: 6px; text-decoration: none; font-weight: 500; font-size: 0.9rem; }
  .pipe-nextbox .btn:hover { background: #0747A6; }
  .stage-list { list-style: none; padding: 0; margin: 1rem 0; }
  .stage-list li { padding: 1rem; margin: 0.5rem 0; border-radius: 8px; background: rgba(0,0,0,0.02); border-left: 4px solid rgba(0,0,0,0.15); }
  .stage-list li.done { border-left-color: #27ae60; background: rgba(39,174,96,0.04); }
  .stage-list li.current { border-left-color: #3498db; background: rgba(52,152,219,0.04); }
  .stage-list li.waiting { border-left-color: rgba(0,0,0,0.15); }
  .stage-list li.teacher:not(.done) { border-left-color: #f1c40f; }
  .stage-list li > a { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; text-decoration: none; color: inherit; }
  .stage-list .stage-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
  .stage-list .left { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; }
  .stage-list .num { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(0,0,0,0.06); font-weight: 700; font-size: 0.9rem; }
  .stage-list li.done .num { background: rgba(39,174,96,0.2); color: #166534; }
  .stage-list li.current .num { background: rgba(52,152,219,0.2); color: #1e40af; }
  .stage-list .body { flex: 1; min-width: 0; }
  .stage-list .ttl { font-weight: 600; }
  .stage-list .sub { font-size: 0.85rem; color: rgba(0,0,0,0.55); margin-top: 0.15rem; }
  .stage-list .tag { font-size: 0.8rem; padding: 0.25rem 0.65rem; border-radius: 999px; background: rgba(0,0,0,0.06); white-space: nowrap; }
  .stage-list .tag.done { background: rgba(39,174,96,0.15); color: #166534; }
  .stage-list .tag.current { background: rgba(52,152,219,0.15); color: #1e40af; }
  .stage-list .tag.waiting { background: rgba(0,0,0,0.06); }
  .stage-list .tag.teacher { background: rgba(241,196,15,0.15); color: #92400e; }
  .pipe-footer { font-size: 0.85rem; color: rgba(0,0,0,0.55); text-align: center; margin: 2rem 0 1rem; }
  .pipe-exit { text-align: center; padding: 1rem 0; }
  .pipe-exit a { color: #0052CC; text-decoration: none; }
  .pipe-exit a:hover { text-decoration: underline; }
  .pipe-back { display: inline-block; margin-bottom: 0.75rem; color: #0052CC; text-decoration: none; font-weight: 500; }
  .pipe-back:hover { text-decoration: underline; }
}

/* ---------- 11. STEPPER / GEM / FORM PAGES ---------- */
@layer components {
  .ideal-stepper { list-style: none; padding: 0; margin: 1.5rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .ideal-stepper li { flex: 1; min-width: 100px; display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.75rem; border-left: 4px solid rgba(0,0,0,0.15); background: rgba(0,0,0,0.03); border-radius: 6px; font-size: 0.875rem; }
  .ideal-stepper li.s-done { border-left-color: #27ae60; background: rgba(39,174,96,0.06); }
  .ideal-stepper li.s-active { border-left-color: #3498db; background: rgba(52,152,219,0.08); outline: 2px solid rgba(52,152,219,0.4); }
  .ideal-stepper li.s-blocked { border-left-color: #c0392b; background: rgba(192,57,43,0.06); }
  .ideal-stepper li.s-waiting { border-left-color: rgba(0,0,0,0.15); }
  .ideal-stepper li.s-locked { opacity: 0.55; }
  .ideal-stepper .num { min-width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(0,0,0,0.08); font-weight: 700; font-size: 0.85rem; }
  .ideal-stepper li.s-done .num { background: rgba(39,174,96,0.25); color: #166534; }
  .ideal-stepper li.s-active .num { background: rgba(52,152,219,0.25); color: #1e40af; }
  .ideal-stepper .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .ideal-stepper .label { font-weight: 600; font-size: 0.875rem; }
  .ideal-stepper .meta { font-size: 0.75rem; color: rgba(0,0,0,0.55); }
  @media (max-width: 768px) { .ideal-stepper { flex-direction: column; gap: 0.75rem; } .ideal-stepper li { width: 100%; min-width: 100%; } }
  .gem-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
  .gem-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
  .gem-purpose { color: rgba(0,0,0,0.6); margin: 0.35rem 0 0; font-size: 0.95rem; }
  .stage-pill { display: inline-block; padding: 0.35rem 0.8rem; background: rgba(0,82,204,0.1); color: #0052CC; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
  .progress-banner { padding: 1rem 1.25rem; border-radius: 8px; background: rgba(52,152,219,0.08); border-left: 4px solid #3498db; margin: 1rem 0; font-size: 0.95rem; line-height: 1.5; }
  .gem-warning-box { padding: 0.75rem 1rem; margin: 1rem 0; border: 1px solid #fdba74; border-radius: 8px; background: #fff7ed; color: #9a3412; font-size: 0.92rem; }
  .gem-warning-box a { color: #9a3412; font-weight: 700; text-decoration: underline; }
  .gem-warn-text { color: #92400e; }
  .gem-flow { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 1rem 0; margin: 0.5rem 0; }
  .gem-flow .step { display: flex; align-items: center; gap: 0.5rem; padding: 0.65rem 0.9rem; background: rgba(0,0,0,0.03); border-radius: 8px; flex: 1; min-width: 130px; }
  .gem-flow .n { min-width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #0052CC; color: white; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
  .gem-flow .ico { font-size: 1.4rem; flex-shrink: 0; }
  .gem-flow .body { flex: 1; min-width: 0; }
  .gem-flow .title { font-weight: 600; font-size: 0.9rem; }
  .gem-flow .sub { font-size: 0.78rem; color: rgba(0,0,0,0.55); }
  .gem-flow .arrow { color: rgba(0,0,0,0.35); font-size: 1.2rem; flex-shrink: 0; }
  .slots { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; }
  .slot { padding: 1rem; border-radius: 8px; border: 1px solid rgba(0,0,0,0.1); background: white; }
  .slot.saved { border-color: rgba(39,174,96,0.4); background: rgba(39,174,96,0.03); }
  .slot-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; gap: 0.5rem; flex-wrap: wrap; }
  .slot-title { font-weight: 700; font-size: 1rem; }
  .slot-status { font-size: 0.85rem; color: rgba(0,0,0,0.55); }
  .slot.saved .slot-status { color: #166534; font-weight: 600; }
  .gem-saved { padding: 0.75rem; background: rgba(0,0,0,0.03); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin: 0.5rem 0; }
  .gem-paste { width: 100%; padding: 0.75rem; box-sizing: border-box; border: 1px solid rgba(0,0,0,0.15); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; min-height: 150px; resize: vertical; }
  .step-list { list-style: none; padding: 0; margin: 0; }
  .step-list li { display: flex; gap: 0.75rem; padding: 1rem 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
  .step-list li.active { background: rgba(52,152,219,0.04); }
  .panel-slot { margin-top: 1.5rem; padding: 1rem; background: rgba(52,152,219,0.06); border-left: 4px solid #3498db; border-radius: 6px; }
  .form-inline { margin: 0; }
  .pwa-banner { display: none; position: fixed; bottom: 20px; left: 50%; background: #2c3e50; color: #fff; padding: 15px 25px; border-radius: 8px; z-index: 9999; align-items: center; gap: 15px; font-family: sans-serif; transform: translateX(-50%); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
  .pwa-banner-btn { background: #27ae60; color: #fff; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: bold; }
  .brand-dot-warn { color: var(--ideal-warning, #f39c12); }
  .hint-box { padding: 0.75rem; background: rgba(52,152,219,0.08); border-left: 3px solid #3498db; border-radius: 6px; margin-bottom: 0.5rem; }
}

/* ---------- 11b. Master Stepper + Hero card (Mere Kaam / task_hub) ---------- */
.stepper-wrap {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
    position: relative;
    padding: 0 20px;
}
.stepper-line {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--ideal-border);
    z-index: 1;
}
.step-item {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 80px;
}
.step-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    background: var(--ideal-surface);
    border: 3px solid var(--ideal-border);
    /* TODO(color-debt): #9ca3af has no CSS var yet */
    color: #9ca3af;
    transition: all 0.3s;
}
.step-item.active .step-circle {
    /* TODO(color-debt): #3b82f6 / #eff6ff have no CSS vars yet */
    border-color: #3b82f6;
    background: #eff6ff;
    color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}
.step-item.completed .step-circle {
    border-color: var(--ideal-success);
    background: var(--ideal-success);
    color: var(--ideal-surface);
}
.step-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ideal-muted);
    text-align: center;
}
.step-item.active .step-label {
    color: #3b82f6;
}

.hero-card {
    background: var(--ideal-surface);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    /* TODO(color-debt): #f3f4f6 has no CSS var yet */
    border: 1px solid #f3f4f6;
}
.hero-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--ideal-text);
    margin-bottom: 12px;
}
.hero-text {
    font-size: 1.05rem;
    color: var(--ideal-muted);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* ---------- 12. TEACHER PAGES ---------- */
@layer components {
  .banner-warning { padding: 1rem 1.25rem; margin-bottom: 1rem; border: 3px solid #b45309; border-radius: 8px; background: #fffbeb; }
  .banner-warning h2 { margin: 0 0 0.4rem; font-size: 1rem; color: #b45309; font-weight: 700; }
  .banner-warning ul { margin: 0.3rem 0 0.8rem 1.2rem; padding: 0; }
  .banner-warning .banner-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
  .btn-banner { display: inline-block; padding: 0.55rem 0.9rem; min-height: 44px; line-height: 1.2; background: #1e40af; color: #fff; font-weight: 700; text-decoration: none; border-radius: 6px; border: none; cursor: pointer; font-family: inherit; }
  .btn-banner:hover { background: #1e3a8a; }
  .btn-banner-danger { background: #fff; color: #b91c1c; border: 1px solid #b91c1c; }
  .btn-banner-danger:hover { background: rgba(185,28,28,0.06); }
  .students-list label { display: block; padding: 0.35rem 0.5rem; cursor: pointer; border-radius: 4px; }
  .students-list label:hover { background: rgba(0,0,0,0.03); }
  .form-label { display: block; font-weight: 600; margin: 0.5rem 0 0.25rem; }
  .form-submit { margin-top: 1rem; }
  .lead { font-size: 1.05rem; color: rgba(0,0,0,0.65); margin: 0.5rem 0 1rem; }
  .note { font-size: 0.875rem; color: rgba(0,0,0,0.55); margin-top: 0.25rem; }
  .mh { font-size: 0.8rem; color: rgba(0,0,0,0.55); margin-bottom: 0.25rem; }
  .status { font-size: 0.9rem; padding: 0.35rem 0.75rem; border-radius: 999px; }
  .status.off { background: rgba(0,0,0,0.06); color: rgba(0,0,0,0.55); }
  .status.on { background: rgba(39,174,96,0.15); color: #166534; font-weight: 600; }
  @keyframes kpiFlash { 0% { background: rgba(52,152,219,0.25); } 100% { background: rgba(0,0,0,0); } }
  .kpi.flash { animation: kpiFlash 0.9s ease-out 1; }
  .controls { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0; }
  .doc-header { padding-bottom: 1rem; border-bottom: 2px solid rgba(0,0,0,0.1); margin-bottom: 1.5rem; }
  .doc-meta { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; }
  .doc-tag { font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; color: rgba(0,0,0,0.55); font-weight: 600; }
  .doc-lede { font-size: 1rem; line-height: 1.6; color: rgba(0,0,0,0.65); margin-top: 0.5rem; }
  .doc-section { margin: 1.5rem 0; }
  .doc-alert { padding: 0.75rem 1rem; border-radius: 6px; border-left: 4px solid; background: rgba(39,174,96,0.08); border-left-color: #16a34a; color: #166534; margin: 0.75rem 0; }
  .doc-alert--error { padding: 0.75rem 1rem; border-radius: 6px; border-left: 4px solid; background: rgba(192,57,43,0.08); border-left-color: #dc2626; color: #7f1d1d; margin: 0.75rem 0; }
  .doc-body { margin-bottom: 0.5rem; }
  .request-card { border: 1px solid #d0d5dd; border-radius: 8px; padding: 14px; margin: 10px 0; }
  .request-meta { font-size: 0.875rem; color: #6b7280; }
  .request-reason { font-size: 0.875rem; margin: 8px 0; background: #f9fafb; padding: 8px; border-radius: 6px; }
  .request-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
  .request-note-input { flex: 1; min-width: 180px; padding: 8px; border: 1px solid #d0d5dd; border-radius: 6px; font-family: inherit; font-size: 0.9rem; }
  .back-line { margin: 1rem 0; }
  .back-line a { color: #0052CC; text-decoration: none; font-weight: 500; }
  .back-line a:hover { text-decoration: underline; }
  .big-link { display: inline-block; padding: 0.75rem 1.25rem; background: rgba(0,82,204,0.08); color: #0052CC; text-decoration: none; border-radius: 8px; font-weight: 600; margin: 0.5rem 0; }
  .big-link:hover { background: rgba(0,82,204,0.15); }
  .big-link.ext::after { content: " \2197"; }
  .link-row { margin: 1rem 0; }
  .stepper { padding: 1rem; border-radius: 8px; background: rgba(0,0,0,0.02); margin: 1rem 0; }
  .progress-text { font-size: 0.9rem; color: rgba(0,0,0,0.65); margin-top: 0.75rem; text-align: center; }
  .complete-card { text-align: center; padding: 2rem 1.5rem; background: rgba(39,174,96,0.06); border-radius: 12px; margin: 1.5rem 0; }
  .complete-icon { font-size: 3rem; color: #27ae60; font-weight: 700; margin-bottom: 0.75rem; }
  .next-actions { display: flex; gap: 0.75rem; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 1.25rem; }
  .step-card { padding: 1.5rem; border-radius: 8px; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin: 1rem 0; }
  .step-card .block { margin: 1rem 0; }
  .step-card .block h3 { margin: 0 0 0.5rem; font-size: 1rem; font-weight: 600; }
  .step-card .block ol, .step-card .block ul { padding-left: 1.25rem; margin: 0.5rem 0; }
  .step-card .block li { margin: 0.35rem 0; }
  .stuck { padding: 0.75rem 1rem; border-radius: 6px; background: rgba(241,196,15,0.1); border-left: 4px solid #f1c40f; font-size: 0.9rem; }
  .reset-form { margin: 1rem auto; text-align: center; max-width: 400px; }
}

/* ---------- 13. VIOLATIONS / OPS ---------- */
@layer components {
  .violation-form { display: grid; gap: 14px; margin-top: 14px; }
  .violation-label { display: block; }
  .violation-label-text { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
  .violation-strike { color: #b42318; font-weight: 700; }
  .evidence-cell { max-width: 320px; }
  .no-violations { margin-top: 12px; color: #6b7280; }
  .ops-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
  .ops-bar h1 { margin: 0; }
  .ops-bar-meta { font-size: 0.82rem; color: rgba(0,0,0,0.55); margin-top: 0.25rem; }
  .ops-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
  .ops-refresh-btn { background: #ffebe6; color: #b92500; font-weight: 700; padding: 0.5rem 1rem; border: none; border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 0.9rem; }
  .ops-refresh-btn:hover { background: #fdd; }
  .ops-btn-sec { background: rgba(0,0,0,0.06); color: rgba(0,0,0,0.75); padding: 0.5rem 1rem; border: none; border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 0.9rem; font-weight: 500; }
  .ops-btn-sec:hover { background: rgba(0,0,0,0.1); }
  .ops-kpi { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 1rem; background: rgba(0,0,0,0.02); border-radius: 8px; margin-bottom: 1rem; }
  .ops-cell { flex: 1; min-width: 110px; padding: 0.75rem; text-align: center; background: white; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
  .ops-cell b { display: block; font-size: 1.5rem; line-height: 1; }
  .ops-cell span { font-size: 0.75rem; color: rgba(0,0,0,0.55); text-transform: uppercase; letter-spacing: 0.03em; }
  .ops-cell--good { border-left: 4px solid #27ae60; }
  .ops-cell--warn { border-left: 4px solid #f59e0b; }
  .ops-cell--crit { border-left: 4px solid #c0392b; }
  .ops-details { background: white; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
  .ops-summary { cursor: pointer; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; list-style: revert; user-select: none; color: #0052CC; }
  .ops-summary-hint { font-weight: 400; font-size: 0.78rem; text-transform: none; letter-spacing: 0; margin-left: 0.6rem; color: rgba(0,0,0,0.55); }
  .ops-live-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; padding: 0.5rem 0; border-bottom: 1px solid rgba(0,0,0,0.05); }
  .ops-live-row:last-child { border-bottom: none; }
  .ops-live-row b { min-width: 80px; }
  .ops-mins { margin-left: auto; font-size: 0.8rem; color: rgba(0,0,0,0.55); }
  .ops-empty { padding: 1rem; text-align: center; color: rgba(0,0,0,0.5); }
  .ops-filter-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin: 1rem 0 0.8rem; }
  .ops-filter-label { font-size: 0.82rem; color: rgba(0,0,0,0.55); }
  .ops-filter-select { padding: 4px 6px; border-radius: 4px; font-size: 0.85rem; min-width: 160px; border: 2px solid rgba(0,0,0,0.15); font-family: inherit; }
  .ops-filter-count { font-size: 0.82rem; margin-left: auto; color: rgba(0,0,0,0.55); }
  .ops-hint { background: #f0f9ff; border-left: 4px solid #0369a1; padding: 0.85rem 1rem; border-radius: 4px; margin: 1rem 0; font-size: 0.9rem; }
  .ops-table-hidden-init { display: none; }
  .ops-alerts-table { width: 100%; border-collapse: collapse; }
  .ops-alerts-table th, .ops-alerts-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.06); }
  .ops-alerts-table th { font-weight: 600; font-size: 0.85rem; color: rgba(0,0,0,0.65); }
  .ops-sitrep { padding: 1rem; background: rgba(0,0,0,0.03); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; max-height: 400px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
}

/* ---------- 14. OPTION 1 SEMANTIC (breadcrumb, disclosure, portal-state, chw) ---------- */
@layer components {
  .breadcrumb { font-size: 0.875rem; margin: 0.5rem 0; }
  .breadcrumb a { color: #0052CC; text-decoration: none; font-weight: 500; }
  .breadcrumb a:hover { text-decoration: underline; }
  .breadcrumb .separator { color: rgba(0,0,0,0.4); margin: 0 0.35rem; }
  .disclosure { background: white; border-radius: 8px; margin: 0.5rem 0; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
  .disclosure > summary { display: flex; align-items: center; gap: 0.75rem; padding: 1rem; cursor: pointer; list-style: none; font-weight: 600; }
  .disclosure > summary::-webkit-details-marker { display: none; }
  .disclosure > summary::after { content: "\25B8"; margin-left: auto; color: rgba(0,0,0,0.4); font-size: 0.8rem; transition: transform 0.15s; }
  .disclosure[open] > summary::after { transform: rotate(90deg); }
  .disclosure-body { padding: 0 1rem 1rem; line-height: 1.6; }
  .policy-index { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,0.08); font-size: 0.8rem; font-weight: 600; flex-shrink: 0; }
  .grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
  @media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
  .sticky-bar { position: sticky; top: 0; z-index: 10; background: white; padding: 0.75rem 0; border-bottom: 2px solid rgba(0,0,0,0.1); margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
  .kpi-grid-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin: 1rem 0; }
  .empty-state-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(39,174,96,0.12); color: #27ae60; font-size: 1.2rem; margin-bottom: 0.5rem; }
  .empty-state-title { display: block; font-weight: 600; margin-bottom: 0.25rem; color: rgba(0,0,0,0.75); }
  .collapsible-section { border-radius: 8px; margin: 1rem 0; }
  .collapsible-section > summary { cursor: pointer; list-style: none; padding: 0.75rem 1rem; background: rgba(0,0,0,0.03); border-radius: 8px; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-weight: 600; }
  .collapsible-section > summary::-webkit-details-marker { display: none; }
  .collapsible-section > summary::after { content: "\25BC"; font-size: 0.7rem; color: rgba(0,0,0,0.5); }
  .collapsible-section[open] > summary::after { content: "\25B2"; }
  .portal-state { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-radius: 8px; flex-wrap: wrap; }
  .portal-state-on { background: rgba(39,174,96,0.08); border-left: 4px solid #27ae60; }
  .portal-state-off { background: rgba(192,57,43,0.06); border-left: 4px solid #c0392b; }
  .portal-state-icon { font-size: 1.5rem; flex-shrink: 0; }
  .portal-state-text { flex: 1; min-width: 200px; }
  .portal-state-title { display: block; font-weight: 700; }
  .portal-state-sub { display: block; font-size: 0.9rem; color: rgba(0,0,0,0.65); margin-top: 0.25rem; }
  .portal-state-action { flex-shrink: 0; }
  .pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1.5rem 0; flex-wrap: wrap; }
  .pagination-btn { display: inline-block; padding: 0.4rem 0.9rem; border-radius: 6px; background: rgba(0,0,0,0.06); color: rgba(0,0,0,0.75); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
  .pagination-btn:hover { background: rgba(0,0,0,0.1); }
  .pagination-btn.disabled { opacity: 0.4; cursor: not-allowed; }
  .pagination-info { font-size: 0.875rem; color: rgba(0,0,0,0.55); }
  .chw-toolbar { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; flex-wrap: wrap; justify-content: space-between; }
  .chw-table { width: 100%; border-collapse: collapse; }
  .chw-table th, .chw-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid rgba(0,0,0,0.08); vertical-align: middle; }
  .chw-table th { font-weight: 600; font-size: 0.8rem; color: rgba(0,0,0,0.65); text-transform: uppercase; letter-spacing: 0.03em; }
  .chw-cell { text-align: center; width: 60px; }
  .chw-switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
  .chw-switch input { opacity: 0; width: 0; height: 0; }
  .chw-slider { position: absolute; inset: 0; background: rgba(0,0,0,0.2); border-radius: 22px; transition: background 0.2s; }
  .chw-slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: transform 0.2s; }
  .chw-switch input:checked + .chw-slider { background: #27ae60; }
  .chw-switch input:checked + .chw-slider::before { transform: translateX(18px); }
  .chw-saved-pill { display: inline-block; margin-left: 0.5rem; padding: 0.1rem 0.4rem; background: rgba(39,174,96,0.15); color: #166534; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
  .chw-name { color: #0052CC; text-decoration: none; font-weight: 500; }
  .chw-name:hover { text-decoration: underline; }
  .chw-stars { display: inline-flex; gap: 0.15rem; }
  .chw-star { cursor: pointer; font-size: 1.2rem; position: relative; display: inline-block; }
  .chw-star input { opacity: 0; position: absolute; width: 100%; height: 100%; margin: 0; cursor: pointer; }
  .chw-star span { color: rgba(0,0,0,0.2); }
  .chw-star input:checked + span { color: #fbbf24; }
  .chw-pts { font-weight: 600; text-align: center; }
  .chw-diary-toggle > summary { cursor: pointer; font-size: 0.85rem; color: #0052CC; }
}

/* ---------- 15. PIPELINE DETAIL ---------- */
@layer components {
  .glossary-searchbox label { font-weight: 600; margin-bottom: 0.5rem; display: block; }
  .glossary-searchbox input[type="search"] { width: 100%; padding: 0.75rem 1rem; border: 1px solid rgba(0,0,0,0.15); border-radius: 8px; font-size: 1rem; box-sizing: border-box; }
  #glossary-panel { display: none; position: relative; max-height: 400px; overflow-y: auto; margin-top: 0.5rem; }
  #glossary-panel.open { display: block; }
  .hit { padding: 0.5rem 1rem; border-bottom: 1px solid rgba(0,0,0,0.08); cursor: pointer; }
  .hit:hover { background: rgba(0,0,0,0.04); }
  .hit:last-child { border-bottom: none; }
  .hit-term { font-weight: 600; }
  .hit-def { font-size: 0.9rem; color: rgba(0,0,0,0.55); }
  .hit mark { background: rgba(255,193,7,0.4); padding: 0 2px; border-radius: 2px; }
  #glossary-detail { display: none; margin-top: 1rem; }
  #glossary-detail.open { display: block; }
  .glossary-term { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.25rem; }
  .glossary-sub { color: rgba(0,0,0,0.55); font-size: 0.9rem; }
  .glossary-kc { margin-top: 0.75rem; font-size: 0.9rem; color: rgba(0,0,0,0.55); }
  .glossary-kc a { color: #0052CC; }
  #glossary-empty { display: none; padding: 1rem; text-align: center; background: rgba(0,0,0,0.03); border-radius: 8px; margin-top: 1rem; }
  .detail-back { display: inline-block; margin: 1rem 0; color: #0052CC; text-decoration: none; font-weight: 500; }
  .detail-back:hover { text-decoration: underline; }
  .detail-card { padding: 1rem; border-bottom: 1px solid rgba(0,0,0,0.08); }
  .detail-card .detail-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; gap: 0.5rem; flex-wrap: wrap; }
  .detail-card .detail-subject { font-weight: 700; font-size: 1.05rem; }
  .detail-card .detail-score { font-weight: 600; padding: 0.25rem 0.75rem; background: rgba(0,0,0,0.05); border-radius: 6px; }
  .detail-card .detail-band { display: inline-block; margin-left: 0.5rem; padding: 0.2rem 0.6rem; background: rgba(241,196,15,0.15); border-radius: 999px; font-size: 0.85rem; }
  .detail-card .detail-wrong { color: #c0392b; }
  .detail-card .detail-right { color: #27ae60; }
  .detail-card .detail-h { font-weight: 600; margin: 0; }
  .detail-card .detail-icon { margin-right: 0.5rem; }
  .detail-card details { margin-top: 1rem; }
  .detail-card summary { cursor: pointer; font-weight: 600; margin: 0.5rem 0; }
  .detail-card .detail-box { padding: 0.75rem; background: rgba(0,0,0,0.03); border-radius: 6px; margin-top: 0.5rem; }
  .detail-steps { margin-top: 1rem; }
  .detail-step { padding: 0.75rem 1rem; border-left: 4px solid rgba(0,0,0,0.1); background: rgba(0,0,0,0.02); margin: 0.5rem 0; border-radius: 6px; }
  .detail-step.done { border-left-color: #27ae60; background: rgba(39,174,96,0.05); }
  .detail-step.active { border-left-color: #3498db; background: rgba(52,152,219,0.05); }
  .detail-step.locked { opacity: 0.55; }
  .detail-step .detail-hint { font-size: 0.9rem; color: rgba(0,0,0,0.55); margin: 0.25rem 0; }
  .detail-step .detail-progress-line { font-size: 0.85rem; color: rgba(0,0,0,0.55); margin-bottom: 0.5rem; }
  .detail-step .detail-progress-bar { height: 8px; background: rgba(0,0,0,0.08); border-radius: 4px; overflow: hidden; margin-bottom: 1rem; }
  .detail-progress-bar progress { width: 100%; height: 100%; appearance: none; -webkit-appearance: none; border: none; }
  .detail-progress-bar progress::-webkit-progress-bar { background: rgba(0,0,0,0.08); }
  .detail-progress-bar progress::-webkit-progress-value { background: #3498db; }
  .detail-progress-bar progress::-moz-progress-bar { background: #3498db; }
  .detail-step .act { background: #0052CC; color: white; padding: 0.5rem 1rem; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; margin-top: 0.5rem; }
  .detail-step .act:hover { background: #0747A6; }
  .detail-step .act:disabled { opacity: 0.5; cursor: not-allowed; }
  .detail-step .faded { padding: 0.75rem; background: rgba(0,0,0,0.03); border-radius: 6px; margin: 0.5rem 0; line-height: 1.8; }
  .detail-step .faded .blank { display: inline-block; min-width: 80px; padding: 0.25rem 0.5rem; border: 1px solid rgba(0,0,0,0.2); border-radius: 4px; font-family: inherit; font-size: inherit; }
  .detail-step .rewrite { width: 100%; padding: 0.75rem; border: 1px solid rgba(0,0,0,0.15); border-radius: 6px; font-family: inherit; font-size: 1rem; min-height: 100px; resize: vertical; box-sizing: border-box; }
  .detail-steps .msg { padding: 0.5rem 1rem; border-radius: 6px; margin-top: 0.75rem; display: none; }
  .detail-steps .msg.ok { display: block; background: rgba(39,174,96,0.1); color: #166534; }
  .detail-steps .msg.err { display: block; background: rgba(192,57,43,0.1); color: #7f1d1d; }
}

/* ---------- 16. UTILITIES ---------- */
@layer utilities {
  .text-muted { color: var(--ideal-muted) !important; }
  .text-center { text-align: center !important; }
  .text-right { text-align: right !important; }
  .text-left { text-align: left !important; }
  .text-2xl { font-size: 1.5rem; line-height: 1.3; }
  .text-sm { font-size: 0.875rem; }
  .text-xs { font-size: 0.75rem; }
  .text-lg { font-size: 1.125rem; }
  .text-base { font-size: 1rem; }
  .text-md { font-size: 1.1rem; }
  .font-bold { font-weight: 700; }
  .underline { text-decoration: underline; }
  .no-underline { text-decoration: none; }
  .u-color-27ae60 { color: var(--ideal-success) !important; }
  .u-color-dc2626 { color: var(--ideal-danger) !important; }
  .u-text-center { text-align: center !important; }
  .u-width-100 { width: 100% !important; }
  .u-bg-white, .u-background-fff { background: var(--ideal-surface) !important; }
  .u-display-flex, .d-flex { display: flex !important; }
  .u-flex-column { flex-direction: column !important; }
  .u-justify-content-space-between, .justify-between { justify-content: space-between !important; }
  .u-align-items-center, .align-center { align-items: center !important; }
  .align-items-start { align-items: flex-start !important; }
  .d-inline { display: inline !important; }
  .d-inline-block { display: inline-block; }
  .d-block { display: block; }
  .hidden { display: none !important; }
  .is-hidden { display: none; }
  .d-none { display: none !important; }
  .flex-wrap { flex-wrap: wrap; }
  .flex-1 { flex: 1 1 auto; min-width: 0; }
  .flex-shrink-0 { flex-shrink: 0; }
  .border-0 { border: 0; }
  .border-b { border-bottom: 1px solid rgba(0,0,0,0.06); }
  .py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .py-4 { padding-top: 1rem; padding-bottom: 1rem; }
  .p-6 { padding: 1.5rem; }
  .p-0 { padding: 0; }
  .w-100 { width: 100%; }
  .whitespace-pre-wrap { white-space: pre-wrap; }
  .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
  .text-primary { color: #0052CC; }
  .text-danger { color: #b42318; }
  .text-positive { color: #27ae60; font-weight: 600; }
  .list-plain { list-style: none; padding: 0; margin: 0; }
  .input-narrow { max-width: 120px; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .ml-auto { margin-left: auto; }
  .ml-3 { margin-left: 0.6rem; }
  .mt-2 { margin-top: var(--ideal-space-2) !important; }
  .mt-3 { margin-top: 0.75rem; }
  .mt-4 { margin-top: var(--ideal-space-4) !important; }
  .mb-2 { margin-bottom: var(--ideal-space-2) !important; }
  .mb-4 { margin-bottom: 1rem !important; }
  .my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
  .my-4 { margin-top: 1rem; margin-bottom: 1rem; }
  .leading-tight { line-height: 1.35; }
  .gap-2 { gap: var(--ideal-space-2) !important; }
  .gap-4 { gap: 1rem; }
  .pl-20 { padding-left: 20px !important; }
  .icon-xl { font-size: 2rem; }
  .grid-full { grid-column: 1 / -1; }
  .summary-clean { cursor: pointer; list-style: none; }
  .skip { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
  .skip:focus, .skip:active { position: static; width: auto; height: auto; left: auto; overflow: visible; background: #fff; padding: 0.5rem 1rem; border: 2px solid #333; border-radius: 4px; }
  .m-0 { margin: 0 !important; }
  .btn-large { padding: 0.75rem 1.5rem; font-size: 1.05rem; font-weight: 600; }
  .btn-block { width: 100%; display: block; margin: 0.5rem 0; }
  @media (max-width: 768px) {
    .u-display-flex, .d-flex { flex-direction: column !important; gap: var(--ideal-space-2) !important; }
  }
}

/* ---------- 17. SHARE / OUTPUT / TOAST / DEV ---------- */
@layer components {
  .share-url { display: block; padding: 1rem; background: rgba(0,0,0,0.04); border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; text-align: center; color: inherit; }
  .ideal-textarea { width: 100%; padding: 0.75rem 1rem; border: 1px solid rgba(0,0,0,0.15); border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; min-height: 300px; resize: vertical; background: white; color: inherit; box-sizing: border-box; }
  .output-block { display: block; padding: 1rem; background: rgba(0,0,0,0.04); border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; overflow-x: auto; max-height: 400px; overflow-y: auto; margin: 0; }
  progress.progress-native { width: 100%; height: 24px; appearance: none; -webkit-appearance: none; border: none; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,0.08); }
  progress.progress-native::-webkit-progress-bar { background: rgba(0,0,0,0.08); border-radius: 8px; }
  progress.progress-native::-webkit-progress-value { background: rgba(52,152,219,0.85); border-radius: 8px; transition: width 0.3s ease; }
  progress.progress-native::-moz-progress-bar { background: rgba(52,152,219,0.85); border-radius: 8px; }
  .toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 12px 20px; border-radius: 8px; background: #2c3e50; color: white; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease; z-index: 9999; max-width: 90vw; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
  .toast.ok { background: #27ae60; }
  .toast.err { background: #c0392b; }
  .dev-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid rgba(0,0,0,0.08); flex-wrap: wrap; }
  .dev-row:last-child { border-bottom: none; }
  .dev-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dev-fp { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; color: rgba(0,0,0,0.55); flex-shrink: 0; }
  .dev-row .ideal-input { flex: 1; min-width: 100px; max-width: 200px; }
  .qtext { font-size: 1.1rem; line-height: 1.6; margin: 1rem 0; }
  .meta { font-size: 0.875rem; }
  .hint { font-size: 0.85rem; margin-top: 0.5rem; }
  .answer { padding: 1rem; background: rgba(0,0,0,0.03); border-radius: 8px; line-height: 1.6; }
  .btn-good { background: #27ae60; color: white; padding: 0.5rem 1rem; border-radius: 8px; border: none; cursor: pointer; }
  .btn-warn { background: #e67e22; color: white; padding: 0.5rem 1rem; border-radius: 8px; border: none; cursor: pointer; }
  .self-report { padding-top: 1rem; border-top: 1px solid rgba(0,0,0,0.08); }
  .band { padding: 1.5rem; border-radius: 12px; border-left: 6px solid; background: rgba(0,0,0,0.03); margin-top: 1rem; }
  .band--struck-off, .band--action { background: rgba(192,57,43,0.08); border-left-color: #c0392b; }
  .band--critical, .band--at-risk { background: rgba(230,126,34,0.08); border-left-color: #e67e22; }
  .band--watch { background: rgba(241,196,15,0.10); border-left-color: #f1c40f; }
  .band--neutral { background: rgba(149,165,166,0.08); border-left-color: #95a5a6; }
  .band--improving, .band--good { background: rgba(52,152,219,0.08); border-left-color: #3498db; }
  .band--excellent { background: rgba(39,174,96,0.08); border-left-color: #27ae60; }
  .band--default { background: rgba(0,0,0,0.03); border-left-color: #999; }
  .band-head { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
  .band-ic { font-size: 2rem; line-height: 1; }
  .band-ttl { font-weight: 700; font-size: 1.15rem; }
  .band-chip { padding: 0.25rem 0.75rem; background: rgba(0,0,0,0.08); border-radius: 999px; font-size: 0.875rem; font-weight: 600; }
  .band-score { font-size: 3rem; font-weight: 800; line-height: 1; margin: 0.5rem 0; }
  .band-denom { font-size: 1.25rem; font-weight: 500; color: rgba(0,0,0,0.5); }
  .band-label { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
  .band-line { line-height: 1.6; margin: 0.5rem 0; }
  .band-damage { padding: 0.75rem; background: rgba(0,0,0,0.05); border-radius: 8px; font-size: 0.9rem; margin: 0.75rem 0; }
  .band-progress { width: 100%; height: 16px; appearance: none; -webkit-appearance: none; border: none; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,0.08); margin: 1rem 0; }
  .band-progress::-webkit-progress-bar { background: rgba(0,0,0,0.08); border-radius: 8px; }
  .band-progress::-webkit-progress-value { background: #3498db; border-radius: 8px; }
  .band-progress::-moz-progress-bar { background: #3498db; border-radius: 8px; }
  .band-btn { display: inline-block; padding: 0.5rem 1rem; background: rgba(0,0,0,0.8); color: white; border-radius: 8px; text-decoration: none; font-weight: 600; margin-top: 0.75rem; }
  .band-btn:hover { background: rgba(0,0,0,0.9); }
  .metrics { gap: 1rem; }
  .metric { min-width: 100px; }
  .badge-chip { display: inline-block; padding: 0.35rem 0.75rem; background: rgba(255,193,7,0.15); color: #8a6d3b; border-radius: 999px; font-size: 0.85rem; margin: 0.25rem; }
  .flags { padding: 1rem; background: rgba(231,76,60,0.08); border-radius: 8px; }
  .pos { color: #27ae60; font-weight: 600; }
  .neg { color: #c0392b; font-weight: 600; }
  .empty { padding: 1.5rem; text-align: center; background: rgba(0,0,0,0.03); border-radius: 8px; }
  .footer { font-size: 0.85rem; text-align: center; margin-top: 2rem; }
  .doc-version { font-size: 0.85rem; }
  .subhead { border-bottom: 1px solid rgba(0,0,0,0.1); padding-bottom: 0.5rem; }
  .story { padding: 1rem; }
  .q { margin: 0.5rem 0; font-style: italic; }
  .text { line-height: 1.6; margin: 0.75rem 0; }
  .analogy { margin: 0.5rem 0; font-size: 0.9rem; }
  .comprehension { padding: 0.75rem; }
  .done { padding: 0.75rem; background: rgba(39,174,96,0.08); border-radius: 8px; }
  .rt { margin-top: 0.5rem; font-style: italic; }
  .err { padding: 0.75rem; background: rgba(231,76,60,0.08); border-radius: 8px; }
}

/* ---------- 18. URDU FONT (single canonical) ---------- */
@font-face {
  font-family: 'Jameel Noori Nastaleeq';
  src: url('fonts/JameelNooriNastaleeq.woff') format('woff');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
body, .question-text, .model-answer, .source-text, .urdu-text, .urdu-translation, [dir="rtl"] {
  font-family: 'Jameel Noori Nastaleeq', system-ui, -apple-system, sans-serif !important;
}
.urdu-text, .urdu-translation, [dir="rtl"] {
  line-height: 2.2 !important;
}

/* Floating Help Button (Added for UX Audit) */
.floating-help-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ideal-primary, #0052CC);
    color: white;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}
.floating-help-btn:hover {
    transform: scale(1.05);
    background: var(--ideal-primary-dark, #0747A6);
}

/* 1-Minute Summary Accordion */
.urgent-summary { background: #fffbeb; border: 2px solid #f59e0b; border-radius: 8px; margin-bottom: 1.5rem; padding: 0.5rem; }
.urgent-summary summary { font-weight: 800; font-size: 1.1rem; color: #b45309; cursor: pointer; padding: 0.5rem; }
.urgent-summary .summary-content { padding: 1rem; background: white; border-radius: 6px; margin-top: 0.5rem; font-size: 1rem; line-height: 1.6; }
.guide-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
.guide-table th, .guide-table td { border: 1px solid #e2e8f0; padding: 0.5rem; text-align: left; }
.guide-table th { background: #f8fafc; font-weight: 600; }

/* Trophy Count Visibility Fix */
.trophy-count-large {
    font-size: 3.5rem !important;
    font-weight: 900 !important;
    color: var(--ideal-primary, #0052CC) !important;
    line-height: 1 !important;
    margin: 1rem 0 !important;
    text-align: center !important;
}

/* Trophy Cabinet UI (2026-10-22) */
.trophy-icon {
    font-size: 2rem !important;
    line-height: 1 !important;
}


/* =========================================
   SUB-NAVIGATION TABS (Unified 2026-10-22)
   Standard: W3C ARIA navigation pattern, GOV.UK sub-nav
   ========================================= */
.ideal-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--ideal-border, #dfe1e6);
    margin: 1rem 0 1.5rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}
.ideal-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    min-height: 44px;
    color: var(--ideal-muted, #6b7280);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.ideal-tab:hover {
    color: var(--ideal-primary, #0052CC);
    background: var(--ideal-bg, #f5f5f5);
}
.ideal-tab[aria-current="page"] {
    color: var(--ideal-primary, #0052CC);
    border-bottom-color: var(--ideal-primary, #0052CC);
}
@media (max-width: 480px) {
    .ideal-tab {
        padding: 0.6rem 0.75rem;
        font-size: 0.875rem;
    }
}


/* =========================================
   GLOBAL GUIDE DRAWER (Urdu, RTL)
   ========================================= */
.global-guide-section {
    margin-bottom: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--ideal-border, #dfe1e6);
}
.global-guide-section:last-child { border-bottom: none; padding-bottom: 0; }
.global-guide-section summary {
    list-style: none;
    cursor: pointer;
    padding: 0.75rem 0;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ideal-primary, #0052CC);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
}
.global-guide-section summary::-webkit-details-marker { display: none; }
.global-guide-section summary::before {
    content: "◂";
    display: inline-block;
    font-size: 0.75rem;
    color: var(--ideal-primary, #0052CC);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.global-guide-section[open] summary::before { transform: rotate(-90deg); }
.global-guide-section p { margin: 0.5rem 0; line-height: 2; }
.global-guide-section ul { padding-left: 1.5rem; margin: 0.5rem 0; }
.global-guide-section li { margin: 0.35rem 0; line-height: 1.9; }
.global-guide-section strong { color: var(--ideal-text, #111); }
#global-help {
    font-family: inherit;
    direction: ltr;
    text-align: left;
}
#global-help h2, #global-help h3 { font-family: inherit; }
#global-help .help-drawer-body { font-size: 1.05rem; line-height: 2.2; }


/* =========================================
   GLOBAL HELP DRAWER & FAB (Industry Standard)
   ========================================= */
.help-fab {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 1050;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--ideal-primary, #0d6efd);
    color: #ffffff;
    border: 3px solid #ffffff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
    padding: 0;
}

.help-fab:hover {
    transform: scale(1.08);
    background-color: #0b5ed7;
}

.help-fab svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

.help-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1055;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.help-overlay.is-open {
    display: block;
    opacity: 1;
}

.help-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 420px;
    height: 100vh;
    background: #ffffff;
    z-index: 1060;
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    direction: ltr;
}

.help-drawer.is-open {
    right: 0;
}

.help-drawer-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.help-drawer-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-family: inherit;
    text-align: left;
    line-height: 2;
}

.help-drawer-body details {
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.help-drawer-body summary {
    font-weight: bold;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--ideal-primary, #0d6efd);
}

.help-drawer-body p {
    margin-top: 10px;
    color: #555;
    font-size: 1.05rem;
}


/* === Phase E.2: inline-style replacement utilities === */
.day-counter-wrapper { display: none; text-align: center; padding: 30px 20px; margin-top: 40px; border-top: 1px solid #eee; background: #f8f9fa; width: 100%; }
.day-counter-wrapper.is-visible,
.day-counter-wrapper.show-widget { display: block !important; }
.day-counter-title { font-weight: 800; color: #0d6efd; margin-bottom: 10px; }
.day-counter-actions { display: flex; justify-content: center; gap: 10px; margin-top: 15px; }


.help-drawer-title { font-size: 1.2rem; font-weight: bold; }


/* Per-page guides use .help-btn for close button - override to look like close button */
.help-drawer-header .help-btn {
    position: static !important;
    width: auto !important;
    height: auto !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: #0f172a !important;
    box-shadow: none !important;
    z-index: auto !important;
    font-size: 1.5rem !important;
    border: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
}

.help-drawer-header .help-btn:hover {
    background: #e2e8f0 !important;
    color: #dc2626 !important;
}
.help-drawer-intro { font-size: 1.05rem; color: var(--ideal-muted); margin-bottom: 1rem; }
.guide-section-item { margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.guide-section-summary { font-weight: bold; cursor: pointer; color: var(--ideal-primary); font-size: 1.1rem; }
.guide-section-body { margin-top: 10px; color: #555; }


/* === Phase E.5: final inline-style replacements === */
.dm-btn-locked  { background:#f3f4f6; color:#9ca3af; border:1px solid #e5e7eb; cursor:not-allowed; padding:4px 12px; }
.dm-btn-change  { border:1px solid #cbd5e1; background:#fff; color:#1e293b; padding:4px 12px; }
.dm-btn-lock    { border:1px solid #fca5a5; background:#fef2f2; color:#b91c1c; padding:4px 12px; }
.dm-btn-label   { font-size:0.85em; }
.dm-lock-form   { display:inline-block; margin:0; }
.pacing-jump-box{ background:#f8fafc; border-radius:8px; }


/* === Phase G: Teacher Daily Codes page === */
.daily-codes-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.daily-codes-filter  { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.daily-codes-table   { width: 100%; border-collapse: collapse; }
.daily-codes-table th,
.daily-codes-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--ideal-border); text-align: left; }
.daily-codes-table th { background: #f8fafc; font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
.code-cell { font-size: 1.4rem; font-weight: 600; color: #0d6efd; text-align: center; }
.test-code-badge { display: inline-block; padding: 4px 12px; background: #eef2ff; border-radius: 8px; font-weight: 600; }

/* === Phase H: Duty Cards === */
.duty-card { background: #f8fafc; padding: 1rem; border-radius: 8px; border-left: 5px solid #0d6efd; }
.duty-list { display: flex; flex-direction: column; gap: 0.75rem; }
.duty-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem; background: white; border: 1px solid #e2e8f0; border-radius: 6px; }

/* === Page Navigation & Pagination === */
.page-nav {
    display: inline-flex;
    margin: 0.5rem 0 0.25rem 0;
    vertical-align: middle;
}
.page-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.page-nav-btn:first-child {
    border-radius: 6px 0 0 6px;
    border-right: none;
}
.page-nav-btn:last-child {
    border-radius: 0 6px 6px 0;
}
.page-nav-btn:hover {
    background: #f8fafc;
    color: #0f172a;
}
.page-nav-btn:active {
    background: #e2e8f0;
}
.page-nav-btn:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 1rem;
}
.pagination-info {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}
.pagination-controls {
    display: flex;
    gap: 0.5rem;
}
.pagination-link {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.pagination-link:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}
.pagination-link:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 1px;
}
.pagination-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
/* === END NAV PAGINATION === */


/* === Two-Shift Test Codes === */
.test-code-badge--morning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.test-code-badge--evening { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.shift-morning { background: #fffbeb; }
.shift-evening { background: #eff6ff; }

.ms-2 { margin-left: 0.5rem; }


/* === Trophy + Badge Cabinet (Mizan only) === */
.badge-count-large {
    font-size: 2.5rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1;
    margin-top: 0.5rem;
}
.trophy-cabinet-card {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
}
.badge-cabinet-card {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #93c5fd;
}


/* === Handwriting Card (Mizan & Discipline) === */
.handwriting-card {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}
.handwriting-title {
    color: #b45309;
}
.handwriting-badge {
    background: #f59e0b;
    color: white;
}
.handwriting-desc {
    color: #92400e;
}


/* === Daily Mission Enterprise Action Buttons === */
.action-btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}
.enterprise-btn {
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}
.dm-lock-form {
    margin: 0;
    padding: 0;
    width: 100%;
    display: flex;
}
.dm-lock-form .btn {
    width: 100%;
}
@media (min-width: 577px) {
    .action-btn-group {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .enterprise-btn {
        width: auto;
        min-width: 110px;
        padding: 0 20px;
    }
    .dm-lock-form {
        width: auto;
    }
    .dm-lock-form .btn {
        width: auto;
    }
}



.ql-bubble .ql-editor {
    min-height: 120px;
    padding: 12px;
}
.ql-bubble .ql-editor.ql-blank::before {
    color: #94a3b8;
    font-style: normal;
}
.d-none { display: none !important; }




/* === Clean Textarea Styling === */
.ideal-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    resize: vertical;
}
.ideal-textarea:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}


/* A9. Direction & Typography for Latin Script (Roman Urdu) */
.guide-text-ltr {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    font-weight: 400 !important;
    line-height: 1.6 !important;
    text-align: left !important;
    color: #333 !important;
}
.guide-text-ltr h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #111 !important;
}
.guide-text-ltr p {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

/* AI Rewrite Tier — Copy Toast */
.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 9999;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.3s ease;
  max-width: 90vw;
  text-align: center;
}
.copy-toast.show { opacity: 1; }
.copy-toast--error { background: #b91c1c; }

.visually-hidden {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Modal for manual copy fallback */
.copy-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.copy-modal {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.copy-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: #111;
}
.copy-modal-hint {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 12px 0;
}
.copy-modal-textarea {
  width: 100%;
  height: 240px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  resize: vertical;
  margin-bottom: 12px;
  background: #fafafa;
  color: #111;
}
.copy-modal-btns {
  display: flex;
  gap: 10px;
}

/* Roman Urdu toggle */
.tier-lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.tier-lang-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #2563eb;
}
.tier-lang-label { font-weight: 600; color: #111; }
.tier-lang-state { color: #6b7280; font-size: 12px; }


/* === Archive Days (Past Days, Phase 4) === */
.archive-day-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.archive-day-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    background: #f8fafc;
    font-weight: 600;
    list-style: none;
    user-select: none;
}
.archive-day-summary::-webkit-details-marker { display: none; }
.archive-day-summary::before {
    content: "▶";
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s;
    font-size: 0.7rem;
    color: #64748b;
}
.archive-day-panel[open] .archive-day-summary::before {
    transform: rotate(90deg);
}
.archive-day-title { color: #0f172a; flex: 1; }
.archive-day-meta { font-size: 0.85rem; color: #64748b; font-weight: 500; }
.archive-day-body {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
}
.archive-subject-group { margin-bottom: 0.75rem; }
.archive-subject-group:last-child { margin-bottom: 0; }
.archive-subject-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.4rem;
}
.archive-questions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.archive-question-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid;
    transition: transform 0.15s, box-shadow 0.15s;
    min-height: 36px;
}
.archive-question-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.archive-q-graded {
    background: #ecfdf5;
    border-color: #86efac;
    color: #166534;
}
.archive-q-drafted {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}
.archive-q-not_started {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}
.archive-status-icon { font-size: 0.85rem; }

@media (max-width: 576px) {
    .archive-day-summary { padding: 0.65rem 0.85rem; }
    .archive-day-body { padding: 0.65rem 0.85rem; }
    .archive-question-chip { font-size: 0.85rem; padding: 0.35rem 0.65rem; min-height: 34px; }
}

/* === BULLETPROOF HELP DRAWER CLOSE BUTTON (Phase 13) === */
.help-drawer .help-drawer-close-btn,
.help-drawer .help-drawer-header .help-drawer-close-btn {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border: 2px solid #cbd5e1 !important;
    border-radius: 8px !important;
    font-size: 24px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 99999 !important;
    font-family: Arial, sans-serif !important;
    text-decoration: none !important;
    box-shadow: none !important;
    outline: none !important;
    transform: none !important;
}

.help-drawer .help-drawer-close-btn:hover {
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
}

/* Per-page guides use .help-btn — override for close purpose */
.help-drawer-header .help-btn {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border: 2px solid #cbd5e1 !important;
    border-radius: 8px !important;
    font-size: 24px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    z-index: 99999 !important;
    transform: none !important;
    box-shadow: none !important;
}

.help-drawer-header .help-btn:hover {
    background: #dc2626 !important;
    color: #ffffff !important;
}

/* === Phase 15: Definitive Help Drawer Fix (Z-Index & Size) === */
.help-drawer {
    z-index: 999999 !important;
    top: 0 !important;
    height: 100vh !important;
}

/* Ensure the header isn't covered and has enough padding */
.help-drawer-header {
    padding: 12px 20px !important;
    min-height: 56px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: #f8f9fa !important;
    border-bottom: 1px solid #e9ecef !important;
}

/* The close button - smaller size, perfectly centered */
.help-drawer .help-drawer-header .help-drawer-close-btn,
.help-drawer .help-drawer-header .help-btn {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border: 2px solid #cbd5e1 !important;
    border-radius: 6px !important;
    font-size: 18px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 999999 !important;
    font-family: Arial, sans-serif !important;
    text-decoration: none !important;
    box-shadow: none !important;
    outline: none !important;
    transform: none !important;
}

.help-drawer .help-drawer-header .help-drawer-close-btn:hover,
.help-drawer .help-drawer-header .help-btn:hover {
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
}


/* ============================================================
   Handwriting Points — Prominent Display (v4.0)
   Added: 2026-10-25
   ============================================================ */
.handwriting-points-huge {
    font-size: 4rem;
    font-weight: 800;
    color: #d97706;
    line-height: 1;
    text-align: center;
    margin: 0.5rem 0;
}

.handwriting-points-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #6b7280;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-align: center;
    margin-top: 0.25rem;
}

/* ============================================================
   Result Page — Side-by-Side Score Cards
   ============================================================ */
.result-stats-grid {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.result-stat-block {
    text-align: center;
    min-width: 140px;
}

.result-stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
}

.result-stat-value--academic {
    color: #1e293b;
}

.result-stat-value--likhai {
    color: #16a34a;
}


/* ---------- 11d. Task Hub: Choice Grid & Semantic Hero Cards ---------- */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}
.selection-card {
    background: var(--ideal-surface);
    border: 1px solid var(--ideal-border);
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}
.selection-card:hover {
    border-color: var(--ideal-primary);
    box-shadow: 0 8px 16px rgba(13,110,253,0.08);
    transform: translateY(-2px);
}
.card-icon { font-size: 3rem; margin-bottom: 16px; }
.card-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; color: var(--ideal-text); }
.card-desc { color: var(--ideal-muted); margin-bottom: 24px; flex-grow: 1; font-size: 0.95rem; }
.btn-outline-primary {
    background: transparent;
    color: var(--ideal-primary);
    border: 2px solid var(--ideal-primary);
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
    padding: 12px;
}
.btn-outline-primary:hover {
    background: var(--ideal-primary);
    color: white;
}

/* Semantic Hero Cards */
.hero-card {
    background: var(--ideal-surface);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid var(--ideal-border);
    border-left-width: 6px;
}
.hero-card--info { border-left-color: #3b82f6; }
.hero-card--warning { border-left-color: #f59e0b; background: #fffbeb; }
.hero-card--success { border-left-color: #10b981; }
.hero-card--danger { border-left-color: #ef4444; background: #fef2f2; }
.hero-card--primary { border-left-color: #8b5cf6; background: #f5f3ff; }
.hero-title { font-size: 1.8rem; font-weight: 800; color: var(--ideal-text); margin-bottom: 12px; }
.hero-text { font-size: 1.05rem; color: var(--ideal-muted); margin-bottom: 32px; line-height: 1.6; }

/* ═══════════════════════════════════════════════════════════
   Phase A additions — Mission stepper page (task_hub_v2)
   Appended $(date +%Y-%m-%d) — no existing rules modified.
   ═══════════════════════════════════════════════════════════ */

.mission-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
}
.mission-page__topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.wallet-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-weight: 700;
    font-size: 0.95rem;
}
.mission-heading {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ideal-text);
    margin-bottom: 20px;
    text-align: center;
}
.mission-cards {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}
.mission-gap-card {
    margin-top: 16px;
}
.mission-footer {
    margin-top: 32px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--ideal-muted);
}
@media (min-width: 768px) {
    .mission-cards { grid-template-columns: 1fr 1fr; }
}

/* ── Mobile tuning for existing stepper (tighten on small screens) ── */
@media (max-width: 480px) {
    .stepper-wrap { padding: 0 8px; margin-bottom: 20px; }
    .step-item    { width: 56px; gap: 4px; }
    .step-circle  { width: 36px; height: 36px; font-size: 1rem; }
    .step-label   { font-size: 0.6rem; }
}

/* V3 Self-Healing Edit Form */
.edit-form-container {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-top: 16px;
}
.edit-textarea {
    width: 100%;
    min-height: 120px;
    padding: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1.05rem;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
    background: #ffffff;
    color: #1e293b;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.edit-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}
.edit-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 8px;
}

/* Fix for squished textareas in Edit Form */
.edit-form-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
}
.edit-textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
    min-height: 150px !important; /* Taller for professional look */
    padding: 16px !important;
    font-size: 1.05rem !important;
    line-height: 1.6 !important;
    border-radius: 8px !important;
    border: 1px solid #cbd5e1 !important;
    resize: vertical !important;
}

/* V3 Edit Form - Flat Layout, No Flexbox Dependencies */
.v3-edit-form {
    width: 100% !important;
    box-sizing: border-box;
    padding: 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 16px;
}
.v3-edit-form textarea {
    width: 100% !important;
    box-sizing: border-box;
    min-height: 140px;
    padding: 14px;
    font-size: 1rem;
    line-height: 1.6;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    resize: vertical;
    font-family: inherit;
    background: #ffffff;
    color: #1e293b;
    display: block;
}
.v3-edit-form textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}
.v3-edit-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 8px;
}

/* Quota Lock - Physical lock on the card */
.card-locked {
    opacity: 0.35 !important;
    pointer-events: none !important;
    filter: grayscale(100%) !important;
    user-select: none !important;
}
#submit-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    background-color: #e2e8f0 !important;
    color: #94a3b8 !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
}
#submit-btn:not(:disabled) {
    background-color: #10b981 !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
}

/* V3 Pipeline - Self-Healing Components */
.pipeline-question-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}
.pipeline-story-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
    margin-bottom: 16px;
}
.pipeline-heal-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 20px;
    margin-top: 16px;
    margin-bottom: 16px;
}
.pipeline-heal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #b45309;
    margin-bottom: 8px;
}
.pipeline-heal-desc {
    font-size: 0.95rem;
    color: #92400e;
    margin-bottom: 16px;
    line-height: 1.6;
}
.pipeline-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
    background: #ffffff;
    margin-bottom: 12px;
    box-sizing: border-box;
}
.pipeline-textarea:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}
.q-text-display {
    word-break: break-word;
    white-space: pre-wrap;
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 1rem;
    line-height: 1.6;
}



/* ═══════════════════════════════════════════════════════════
   CALENDAR COMPONENT v2 — ITCSS + design-token aligned
   Added 2026-10-29, refined 2026-10-29
   Used by: portal_mission_calendar.html, completion_calendar.html
   Standards: W3C HTML5 <table>, WAI-ARIA Grid Pattern, WCAG 2.2 AA
   Overrides global table/th/td rules (base layer) — unlayered wins.
   ═══════════════════════════════════════════════════════════ */
.calendar-grid {
  width: 100%;
  min-width: 0;                  /* CRITICAL: overrides global table { min-width: 800px } */
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  text-align: center;
  margin: 0;
  font-size: inherit;            /* overrides global table { font-size: 0.875rem } */
}
.calendar-grid thead th {
  text-align: center;            /* overrides global th { text-align: left } */
  vertical-align: middle;
  padding: var(--ideal-space-1) 2px;
  border: none;                  /* overrides global th { border-bottom } */
  background: transparent;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ideal-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: normal;           /* overrides global th { white-space: nowrap } */
}
.calendar-grid tbody td {
  text-align: center;            /* overrides global td { text-align: left } */
  vertical-align: top;
  padding: 2px;
  border: none;                  /* overrides global td { border-bottom } */
  white-space: normal;           /* overrides global td { white-space: nowrap } */
}

.calendar-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-height: 58px;
  padding: var(--ideal-space-1) 2px;
  line-height: 1.1;
  border-radius: var(--ideal-radius);
  font-family: inherit;
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--ideal-bg);
  color: inherit;
  transition: box-shadow 0.12s;
}
.calendar-cell:hover         { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.calendar-cell:focus-visible { outline: 2px solid var(--ideal-primary); outline-offset: 2px; }

.calendar-cell .cell-day    { font-size: 0.65rem; font-weight: 700; opacity: 0.85; }
.calendar-cell .cell-date   { font-size: 1rem;     font-weight: 700; }
.calendar-cell .cell-actual { font-size: 0.65rem; font-weight: 600; opacity: 0.9; }

/* Status variants — all colors sourced from :root tokens */
.calendar-cell.is-upcoming {
  background: var(--ideal-bg);
  color: var(--ideal-muted);
  border-color: var(--ideal-border);
}
.calendar-cell.is-not-started {
  background: var(--ideal-warning-bg);
  color: var(--ideal-warning);
  border-color: var(--ideal-warning);
}
.calendar-cell.is-missed {
  background: var(--ideal-danger-bg);
  color: var(--ideal-danger);
  border-color: var(--ideal-danger);
}
.calendar-cell.is-completed {
  background: var(--ideal-success-bg);
  color: var(--ideal-success);
  border-color: var(--ideal-success);
}
.calendar-cell.is-today {
  background: var(--ideal-primary-bg);
  color: var(--ideal-primary);
  border-color: var(--ideal-primary);
  font-weight: 700;
}
.calendar-cell.is-viewing {
  box-shadow: 0 0 0 2px var(--ideal-text) inset;
}


/* ═══════════════════════════════════════════════════════════
   TEACHER COMPLETION MATRIX — added 2026-10-29
   Used by: teacher_completion_matrix.html
   Standards: W3C HTML5 <table>, sticky column/row, WCAG 2.2 AA
   ═══════════════════════════════════════════════════════════ */
.matrix-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--ideal-border);
  border-radius: var(--ideal-radius);
  background: var(--ideal-surface);
  -webkit-overflow-scrolling: touch;
  /* Removed max-height to allow natural page scrolling */
}
.matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.75rem;
  width: max-content;
  /* Force minimum width to guarantee the scroll bar appears on mobile */
  min-width: 1000px; 
}
.matrix-table th,
.matrix-table td {
  border: none;
  border-bottom: 1px solid var(--ideal-border);
  padding: 4px 4px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}
.matrix-table thead th {
  background: var(--ideal-bg);
  color: var(--ideal-muted);
  font-weight: 600;
  font-size: 0.7rem;
  position: sticky;
  top: 0;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.matrix-table .col-student {
  position: sticky;
  left: 0;
  background: var(--ideal-surface);
  z-index: 2;
  text-align: left;
  min-width: 140px;
  max-width: 180px;
  font-weight: 600;
  padding: 6px 10px;
  font-size: 0.85rem;
  color: var(--ideal-text);
  border-right: 1px solid var(--ideal-border);
}
.matrix-table thead th.col-student {
  z-index: 3;
  background: var(--ideal-bg);
}
.matrix-table tbody tr:hover td.col-student { background: var(--ideal-bg); }
.matrix-table .col-summary {
  font-weight: 600;
  padding: 6px 10px;
  color: var(--ideal-text);
}

.matrix-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.matrix-cell.is-done   { background: var(--ideal-success-bg); color: var(--ideal-success); border-color: var(--ideal-success); }
.matrix-cell.is-missed { background: var(--ideal-danger-bg);  color: var(--ideal-danger);  border-color: var(--ideal-danger); }
.matrix-cell.is-future { background: var(--ideal-bg);         color: var(--ideal-muted); }
.matrix-cell.is-na     { background: transparent;             color: var(--ideal-muted); opacity: 0.4; }

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ideal-space-3);
  align-items: center;
  margin-top: var(--ideal-space-3);
  font-size: 0.85rem;
  color: var(--ideal-muted);
}

/* Dropdown Component */
.ideal-dropdown { display: inline-block; position: relative; }
.ideal-dropdown summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; }
.ideal-dropdown summary::-webkit-details-marker { display: none; }
.ideal-dropdown-content { position: absolute; top: 100%; left: 0; min-width: 250px; z-index: 50; box-shadow: 0 4px 12px rgba(0,0,0,0.1); border: 1px solid var(--ideal-border); background: var(--ideal-surface); border-radius: var(--ideal-radius); }
.star-select { padding: 4px; border: 1px solid var(--ideal-border); border-radius: 4px; background: var(--ideal-surface); font-size: 0.85rem; width: 50px; text-align: center; }

/* Floating God Control Room Button */
.fab-control-room {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, background 0.2s;
}
.fab-control-room:hover {
    background: #059669;
    color: white;
    transform: scale(1.05);
    text-decoration: none;
}
/* Fix mobile overflow issues in grids and flex layouts */
.kpi-row > *, .d-flex > * { min-width: 0; }
.kpi-row .ideal-select, .kpi-row .ideal-input,
.d-flex .ideal-select, .d-flex .ideal-input { min-width: 0; width: 100%; }
html, body { overflow-x: hidden; }

/* Fix mobile overflow issues in grids and flex layouts */
.kpi-row > *, .d-flex > * { min-width: 0; }
.kpi-row .ideal-select, .kpi-row .ideal-input,
.d-flex .ideal-select, .d-flex .ideal-input { min-width: 0; width: 100%; }
html, body { overflow-x: hidden; }
