    :root {
      --primary: #1a73e8;
      --danger:  #d93025;
      --success: #188038;
      --warn:    #f9ab00;
      --bg:      #f8f9fa;
      --card:    #ffffff;
      --border:  #dadce0;
      --text:    #202124;
      --muted:   #5f6368;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Google Sans', 'Segoe UI', system-ui, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
    }
    header {
      background: var(--primary);
      color: #fff;
      padding: 16px 32px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      box-shadow: 0 2px 6px rgba(0,0,0,.2);
    }
    .header-left { display: flex; align-items: center; gap: 12px; }
    header h1 { font-size: 1.3rem; font-weight: 600; }
    header span { font-size: .85rem; opacity: .85; }
    .status-pill {
      font-size: .78rem;
      padding: 5px 12px;
      border-radius: 20px;
      background: rgba(255,255,255,.18);
      color: #fff;
      white-space: nowrap;
    }
    main {
      max-width: 920px;
      margin: 28px auto;
      padding: 0 16px 48px;
      display: grid;
      gap: 22px;
    }
    .card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 24px;
    }
    .card h2 {
      font-size: .95rem;
      color: var(--muted);
      margin-bottom: 16px;
      font-weight: 600;
      letter-spacing: .3px;
      text-transform: uppercase;
    }
    label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 6px; }
    input, select, textarea {
      width: 100%;
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 10px 12px;
      font-size: .9rem;
      outline: none;
      transition: border-color .2s;
      background: var(--bg);
      color: var(--text);
    }
    input[type="checkbox"], input[type="radio"] {
      width: auto;
    }
    input:focus, select:focus, textarea:focus { border-color: var(--primary); background: #fff; }
    textarea { resize: vertical; min-height: 76px; font-family: 'Fira Code', Consolas, monospace; }
    .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    .preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
    .preset-chip {
      font-size: .8rem;
      padding: 5px 11px;
      border-radius: 16px;
      border: 1px solid var(--border);
      background: #fff;
      cursor: pointer;
      color: var(--primary);
      transition: background .15s;
    }
    .preset-chip:hover { background: #e8f0fe; border-color: var(--primary); }
    .drop-zone {
      border: 2px dashed var(--border);
      border-radius: 12px;
      padding: 28px 20px;
      text-align: center;
      cursor: pointer;
      transition: background .2s, border-color .2s, padding .2s;
      position: relative;
    }
    .drop-zone.compact {
      padding: 12px 16px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
    }
    .drop-zone.compact svg { width: 22px; height: 22px; flex-shrink: 0; }
    .drop-zone.compact p { margin-top: 0; font-size: .85rem; }
    .drop-zone.dragover { background: #e8f0fe; border-color: var(--primary); }
    .drop-zone input[type=file] { opacity: 0; position: absolute; inset: 0; cursor: pointer; }
    .drop-zone p { color: var(--muted); font-size: .9rem; margin-top: 8px; }
    #preview-img {
      display: none;
      max-width: 100%;
      max-height: 360px;
      object-fit: contain;
      margin: 0 auto;
      border-radius: 8px;
    }
    #crop-workspace {
      display: none;
      margin-top: 14px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: #fafafa;
      padding: 12px;
    }
    .crop-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 10px;
    }
    .crop-toolbar-group {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }
    .crop-hint {
      font-size: .8rem;
      color: var(--muted);
      margin-bottom: 8px;
      line-height: 1.45;
    }
    .canvas-stage {
      width: 100%;
      overflow: auto;
      background: #eceff1;
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 8px;
      text-align: center;
    }
    #crop-canvas {
      display: inline-block;
      max-width: 100%;
      height: auto;
      border-radius: 4px;
      box-shadow: 0 2px 8px rgba(0,0,0,.12);
      background: #fff;
      cursor: crosshair;
      user-select: none;
      touch-action: none;
    }
    .filter-pill {
      border: 1px solid var(--border);
      background: #fff;
      color: #475569;
      border-radius: 12px;
      padding: 3px 10px;
      font-size: .78rem;
      font-weight: 600;
      cursor: pointer;
      transition: all .15s ease;
      white-space: nowrap;
    }
    .filter-pill:hover {
      background: #f1f5f9;
      border-color: #94a3b8;
    }
    .filter-pill.active {
      background: var(--primary) !important;
      color: #fff !important;
      border-color: var(--primary) !important;
      box-shadow: 0 1px 3px rgba(26,115,232,0.25);
    }
    .box-count-pill {
      font-size: .78rem;
      font-weight: 600;
      padding: 4px 10px;
      border-radius: 14px;
      background: #e8f0fe;
      color: var(--primary);
    }
    .btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: var(--primary);
      color: #fff;
      border: none;
      border-radius: 8px;
      padding: 10px 20px;
      font-size: .9rem;
      font-weight: 500;
      cursor: pointer;
      transition: opacity .2s;
    }
    .btn:hover { opacity: .9; }
    .btn:disabled { opacity: .45; cursor: not-allowed; }
    .btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
    .btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
    .btn-success { background: var(--success); }
    .btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 6px; }
    .btn-icon {
      border: 1px solid var(--border);
      background: #fff;
      color: var(--danger);
      border-radius: 6px;
      padding: 5px 9px;
      cursor: pointer;
      font-size: .78rem;
      white-space: nowrap;
    }
    .btn-icon:hover { background: #fce8e6; }
    .btn-step-insert {
      border: 1px solid var(--border);
      background: #fff;
      color: var(--primary);
      border-radius: 6px;
      padding: 5px 9px;
      cursor: pointer;
      font-size: .78rem;
      white-space: nowrap;
    }
    .btn-step-insert:hover { background: #e8f0fe; border-color: var(--primary); }

    /* Kết quả OCR có thể chỉnh sửa + kéo thả */
    #ocr-result { display: none; }
    .step-list { list-style: none; display: grid; gap: 12px; }
    .step-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 12px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: #fff;
      transition: border-color .15s, background .15s, opacity .15s;
    }
    .step-item.error-highlight {
      border-color: var(--danger);
      background: #fff5f5;
    }
    .step-item.problem-row {
      border-color: #f9ab00;
      background: #fffbf0;
    }
    .step-item.problem-row.mismatch-highlight {
      border-color: var(--danger);
      background: #fff4f4;
    }
    .step-num.problem-line {
      background: #b06000;
      min-width: 110px;
    }
    .step-num.problem-line.error { background: var(--danger); }
    .btn-toggle-role {
      border: 1px solid #f9ab00;
      background: #fff8e1;
      color: #7a4f01;
      border-radius: 6px;
      padding: 5px 9px;
      cursor: pointer;
      font-size: .78rem;
      font-weight: 500;
      white-space: nowrap;
    }
    .btn-toggle-role:hover { background: #fef0c7; }
    .btn-toggle-role.is-problem {
      border-color: var(--primary);
      background: #e8f0fe;
      color: var(--primary);
    }
    .btn-toggle-role.is-problem:hover { background: #d2e3fc; }
    .btn-toggle-step-type {
      border: 1px solid #94a3b8;
      background: #f1f5f9;
      color: #334155;
      border-radius: 6px;
      padding: 5px 9px;
      cursor: pointer;
      font-size: .78rem;
      font-weight: 600;
      white-space: nowrap;
      transition: all .15s ease;
    }
    .btn-toggle-step-type:hover { background: #e2e8f0; }
    .btn-toggle-step-type.is-narrative {
      border-color: #3b82f6;
      background: #eff6ff;
      color: #1d4ed8;
      box-shadow: 0 1px 2px rgba(59, 130, 246, 0.15);
    }
    .btn-toggle-step-type.is-narrative:hover { background: #dbeafe; }
    .step-item.is-narrative-step {
      border-left: 4px solid #3b82f6;
      background: #fbfdff;
    }
    .problem-lock-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 8px;
    }
    .lock-toggle {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: .84rem;
      font-weight: 500;
      color: var(--text);
      cursor: pointer;
      margin: 0;
    }
    .lock-toggle input[type=checkbox] { width: auto; cursor: pointer; }
    .auto-problem-pill {
      display: none;
      font-size: .78rem;
      font-weight: 600;
      color: #137333;
      background: #e6f4ea;
      border: 1px solid #ceead6;
      border-radius: 14px;
      padding: 3px 10px;
    }
    .copied-warn-banner {
      background: #fce8e6;
      border-left: 4px solid var(--danger);
      color: #a50e0e;
      border-radius: 0 8px 8px 0;
      padding: 12px 16px;
      font-size: .9rem;
      font-weight: 600;
      margin-bottom: 14px;
      line-height: 1.5;
    }
    .step-item.dragging { opacity: .45; border-style: dashed; }
    .step-item.drag-over-above { border-top: 3px solid var(--primary); }
    .step-item.drag-over-below { border-bottom: 3px solid var(--primary); }
    .drag-handle {
      flex-shrink: 0;
      user-select: none;
      cursor: grab;
      color: var(--muted);
      font-size: 1.1rem;
      line-height: 28px;
      padding: 2px 4px;
      border-radius: 6px;
      margin-top: 2px;
      letter-spacing: -2px;
    }
    .drag-handle:hover { background: var(--bg); color: var(--text); }
    .drag-handle:active { cursor: grabbing; }
    .step-num {
      flex-shrink: 0;
      min-width: 62px; height: 28px;
      padding: 0 8px;
      background: var(--primary);
      color: #fff;
      border-radius: 14px;
      display: flex; align-items: center; justify-content: center;
      font-size: .78rem; font-weight: 600;
      margin-top: 4px;
      white-space: nowrap;
    }
    .step-num.error { background: var(--danger); }
    .step-body { flex: 1; min-width: 0; display: grid; gap: 8px; }
    .step-body.has-crop {
      grid-template-columns: minmax(170px, 260px) 1fr;
      align-items: start;
      gap: 12px;
    }
    @media (max-width: 720px) {
      .step-body.has-crop { grid-template-columns: 1fr; }
    }
    .step-crop-box {
      border: 1px solid var(--border);
      border-radius: 8px;
      background: #fff;
      padding: 6px;
      display: grid;
      gap: 4px;
      max-width: 100%;
      overflow: hidden;
    }
    .step-crop-label {
      font-size: .72rem;
      font-weight: 600;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: .2px;
    }
    .step-crop-img,
    .modal-line-crop-img,
    .admin-crop-img,
    .ap-steps-box img {
      max-width: 100% !important;
      max-height: 90px !important;
      width: auto !important;
      height: auto !important;
      object-fit: contain !important;
      display: block;
      background: #fff;
      border-radius: 4px;
    }
    .step-editor-col { min-width: 0; display: grid; gap: 6px; }
    .step-input { font-family: 'Fira Code', Consolas, monospace; font-size: .88rem; }
    .step-preview { font-size: .92rem; color: var(--text); padding: 4px 6px; background: var(--bg); border-radius: 6px; min-height: 28px; }
    .step-actions {
      display: flex;
      flex-direction: column;
      gap: 4px;
      flex-shrink: 0;
    }

    /* KaTeX overflow & formula scroll */
    .katex-display,
    .katex,
    .katex-html,
    .step-preview,
    #problem_preview,
    .modal-line-preview,
    #ocr-part-problem-preview,
    .hint-box,
    .theory-box,
    .verdict-text,
    #hw-part-stem-box {
      overflow-x: auto !important;
      overflow-y: hidden !important;
      max-width: 100% !important;
      -webkit-overflow-scrolling: touch !important;
    }

    /* Quick Math Toolbar */
    .quick-math-toolbar {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px 12px;
      background: #f8fafc;
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      margin-bottom: 12px;
      overflow-x: auto;
      white-space: nowrap;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: thin;
    }
    .quick-math-title {
      font-size: .82rem;
      font-weight: 700;
      color: #334155;
      margin-right: 4px;
      flex-shrink: 0;
      white-space: nowrap;
    }
    .btn-math-token {
      min-height: 36px !important;
      min-width: 36px !important;
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      flex-shrink: 0 !important;
      padding: 6px 10px !important;
      font-size: .88rem !important;
      font-weight: 700 !important;
      border-radius: 6px !important;
      background: #ffffff !important;
      border: 1px solid #94a3b8 !important;
      color: #0f172a !important;
      cursor: pointer;
      touch-action: manipulation;
      user-select: none;
      transition: all .12s ease;
      margin-top: 0 !important;
    }
    .btn-math-token:active {
      background: #e2e8f0 !important;
      transform: scale(0.96);
    }

    .modal-math-toolbar {
      display: flex;
      align-items: center;
      gap: 4px;
      margin-top: 6px;
      overflow-x: auto;
      white-space: nowrap;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: thin;
      padding-bottom: 4px;
    }
    .modal-math-title {
      font-size: .75rem;
      color: #64748b;
      font-weight: 600;
      margin-right: 2px;
      flex-shrink: 0;
      white-space: nowrap;
    }
    .btn-math-modal {
      min-height: 36px !important;
      min-width: 36px !important;
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      flex-shrink: 0 !important;
      padding: 6px 10px !important;
      font-size: .88rem !important;
      font-weight: 700 !important;
      background: #ffffff !important;
      border: 1px solid #cbd5e1 !important;
      border-radius: 6px !important;
      color: #0f172a !important;
      cursor: pointer;
      touch-action: manipulation;
      user-select: none;
      transition: all .12s ease;
    }
    .btn-math-modal:hover {
      background: #e2e8f0 !important;
      border-color: #94a3b8 !important;
    }
    .btn-math-modal:active {
      background: #cbd5e1 !important;
      transform: scale(0.96);
    }

    /* Kết quả chấm bài */
    #grade-result { display: none; }
    .verdict {
      display: flex; align-items: center; gap: 12px;
      padding: 16px; border-radius: 10px; margin-bottom: 16px;
    }
    .verdict.correct { background: #e6f4ea; }
    .verdict.wrong   { background: #fce8e6; }
    .verdict-icon { font-size: 2rem; }
    .verdict-text h3 { font-size: 1.08rem; }
    .verdict-text p  { font-size: .875rem; color: var(--muted); margin-top: 2px; }
    .info-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; font-size: .875rem; margin-bottom: 16px; }
    .info-label { color: var(--muted); font-weight: 500; }
    .hint-box {
      background: #fff8e1;
      border-left: 4px solid var(--warn);
      border-radius: 0 8px 8px 0;
      padding: 14px 16px;
      font-size: .92rem;
      line-height: 1.65;
      margin-bottom: 16px;
    }
    .theory-box {
      background: #e8f0fe;
      border-left: 4px solid var(--primary);
      border-radius: 0 8px 8px 0;
      padding: 12px 16px;
      font-size: .88rem;
      line-height: 1.6;
      margin-bottom: 16px;
    }
    .remedial-list { list-style: none; display: grid; gap: 10px; }
    .remedial-list li {
      padding: 12px 14px;
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: .88rem;
      line-height: 1.6;
    }
    .remedial-list details { margin-top: 6px; color: var(--muted); }
    .remedial-list summary { cursor: pointer; color: var(--primary); font-size: .82rem; font-weight: 500; }
    .badge {
      display: inline-block;
      padding: 3px 10px;
      border-radius: 20px;
      font-size: .78rem;
      font-weight: 600;
    }
    .badge-warn  { background: #fef3cd; color: #856404; }
    .badge-error { background: #fce8e6; color: var(--danger); }
    .badge-ok    { background: #e6f4ea; color: var(--success); }
    .spinner {
      width: 18px; height: 18px;
      border: 3px solid rgba(255,255,255,.4);
      border-top-color: #fff;
      border-radius: 50%;
      animation: spin .7s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .error-msg { color: var(--danger); font-size: .875rem; margin-top: 10px; }
    .success-msg { color: var(--success); font-size: .88rem; margin-top: 10px; font-weight: 500; }
    .header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
    .role-btn {
      border: 1px solid rgba(255,255,255,.5);
      background: rgba(255,255,255,.14);
      color: #fff;
      padding: 6px 14px;
      border-radius: 20px;
      font-size: .8rem;
      font-weight: 600;
      cursor: pointer;
      transition: background .15s;
    }
    .role-btn:hover { background: rgba(255,255,255,.26); }
    .role-btn.admin-active { background: #fef3cd; color: #7a4f01; border-color: #f9ab00; }
    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(32,33,36,.48);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 999;
      padding: 16px;
    }
    .modal-backdrop.open { display: flex; }
    .modal-card {
      background: #fff;
      border-radius: 12px;
      padding: 24px;
      width: 100%;
      max-width: 400px;
      box-shadow: 0 12px 32px rgba(0,0,0,.22);
    }
    .modal-card h3 { font-size: 1.05rem; margin-bottom: 8px; }
    .modal-card p { font-size: .86rem; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }

    @media print {
      body * { visibility: hidden !important; }
      #modal-review-slip, #modal-review-slip * { visibility: visible !important; }
      #modal-review-slip {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #ffffff !important;
        box-shadow: none !important;
      }
      .no-print { display: none !important; }
      #printable-review-slip { padding: 10px !important; width: 100% !important; }
    }
    #teacher-review-card {
      display: none;
      border: 2px solid var(--warn);
      background: #fffdf5;
    }
    .teacher-badge {
      display: inline-block;
      background: #fef3cd;
      color: #7a4f01;
      padding: 2px 10px;
      border-radius: 12px;
      font-size: .75rem;
      font-weight: 600;
      margin-left: 8px;
    }
    .check-row {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-top: 14px;
      font-size: .9rem;
    }
    .check-row input[type=checkbox] { width: auto; transform: scale(1.15); cursor: pointer; }

    /* Workspace Navigation Tabs & Platform UI */
    .workspace-nav {
      background: #fff;
      border-bottom: 1px solid var(--border);
      padding: 0 24px;
      display: flex;
      gap: 6px;
      overflow-x: auto;
      box-shadow: 0 1px 3px rgba(0,0,0,.04);
    }
    .nav-tab {
      border: none;
      background: transparent;
      color: var(--muted);
      font-size: .88rem;
      font-weight: 600;
      padding: 12px 16px;
      cursor: pointer;
      border-bottom: 3px solid transparent;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: color .15s, border-color .15s, background .15s;
    }
    .nav-tab:hover { color: var(--primary); background: #f8fafe; }
    .nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
    .nav-badge {
      background: var(--danger);
      color: #fff;
      font-size: .72rem;
      font-weight: 700;
      padding: 1px 7px;
      border-radius: 12px;
    }
    .workspace-panel { display: none; gap: 22px; }
    .workspace-panel.active { display: grid; }
    .user-chip {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: rgba(255,255,255,.22);
      padding: 5px 12px;
      border-radius: 20px;
      font-size: .8rem;
      font-weight: 600;
      color: #fff;
    }
    .join-code-pill {
      display: inline-block;
      font-family: 'Fira Code', Consolas, monospace;
      font-weight: 700;
      letter-spacing: 1px;
      background: #e8f0fe;
      color: var(--primary);
      padding: 3px 10px;
      border-radius: 6px;
      border: 1px dashed var(--primary);
      font-size: .85rem;
    }
    .sub-card {
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 16px;
      background: #fff;
      display: grid;
      gap: 10px;
    }
    .sub-card.unread-highlight {
      border: 2px solid #f9ab00;
      background: #fffdf5;
    }
    .sub-card-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      gap: 8px;
    }
    .feedback-box {
      background: #e8f0fe;
      border-left: 4px solid var(--primary);
      border-radius: 0 8px 8px 0;
      padding: 10px 14px;
      font-size: .88rem;
      line-height: 1.55;
    }
    .feedback-box.new-fb {
      background: #fff8e1;
      border-left-color: var(--warn);
    }
    .stat-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
      gap: 12px;
      margin: 14px 0;
    }
    .stat-box {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 14px;
      text-align: center;
    }
    .stat-val { font-size: 1.55rem; font-weight: 700; color: var(--primary); }
    .stat-lbl { font-size: .78rem; color: var(--muted); margin-top: 4px; }
    .ai-report-box {
      background: linear-gradient(135deg, #f0f6ff 0%, #f8f9fa 100%);
      border: 1px solid #c6dafc;
      border-left: 5px solid var(--primary);
      border-radius: 10px;
      padding: 16px 18px;
      line-height: 1.7;
      font-size: .93rem;
      margin: 14px 0;
    }
    .data-table {
      width: 100%;
      border-collapse: collapse;
      font-size: .86rem;
      margin-top: 8px;
    }
    .data-table th, .data-table td {
      border-bottom: 1px solid var(--border);
      padding: 9px 10px;
      text-align: left;
      vertical-align: top;
    }
    .data-table th { color: var(--muted); font-weight: 600; background: var(--bg); }
    .auth-tabs {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-bottom: 14px;
    }
    .auth-tab-btn {
      padding: 8px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--bg);
      font-weight: 600;
      cursor: pointer;
    }
    .auth-tab-btn.active {
      background: var(--primary);
      color: #fff;
      border-color: var(--primary);
    }
    .demo-fills {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin: 10px 0 4px;
    }

    /* ==========================================================================
       MOBILE RESPONSIVE TWEAKS (@media max-width: 768px)
       Tối ưu hiển thị đẹp & cảm ứng mượt mà trên iPhone/Android (390x844...)
       ========================================================================== */
    @media (max-width: 768px) {
      body {
        font-size: 15px;
      }

      /* Header thu gọn, không tràn mép */
      header {
        padding: 10px 12px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
      }
      .header-left {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
      }
      .header-left svg {
        width: 28px;
        height: 28px;
        flex-shrink: 0;
      }
      header h1 {
        font-size: 1.02rem !important;
        line-height: 1.3 !important;
      }
      header span {
        font-size: .74rem !important;
        display: block;
        opacity: .9;
      }
      .header-right {
        display: flex !important;
        align-items: center !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding-bottom: 2px !important;
        gap: 6px !important;
        width: 100% !important;
      }
      .header-right::-webkit-scrollbar {
        display: none;
      }
      .role-btn, .status-pill, .user-chip {
        flex-shrink: 0 !important;
        font-size: .75rem !important;
        padding: 5px 10px !important;
      }

      /* Top Tab Workspace Nav cuộn ngang mượt */
      .workspace-nav {
        padding: 0 8px !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        display: flex !important;
        gap: 4px !important;
      }
      .workspace-nav::-webkit-scrollbar {
        display: none;
      }
      .nav-tab {
        flex-shrink: 0 !important;
        padding: 10px 12px !important;
        font-size: .84rem !important;
        white-space: nowrap !important;
      }

      /* Main container & cards */
      main {
        max-width: 100% !important;
        margin: 10px auto !important;
        padding: 0 10px 32px !important;
        gap: 14px !important;
      }
      .card {
        padding: 14px 12px !important;
        border-radius: 10px !important;
      }
      .card h2 {
        font-size: .88rem !important;
        margin-bottom: 12px !important;
      }

      /* Form nhập thông tin xếp dọc 100% */
      .form-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
      }
      input, select, textarea {
        font-size: 16px !important; /* Ngăn iOS Safari tự zoom */
        padding: 9px 11px !important;
      }
      .problem-lock-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
      }

      /* BTVN active banner trên mobile */
      #homework-active-banner {
        padding: 10px 12px !important;
      }
      #hw-part-pills {
        gap: 6px !important;
      }

      /* Section ② Khoanh vùng cắt ảnh */
      .crop-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
      }
      .crop-toolbar-group {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
        width: 100% !important;
      }
      .crop-toolbar-group .btn {
        justify-content: center !important;
        min-height: 36px !important;
        font-size: .78rem !important;
        padding: 6px 8px !important;
      }
      #crop-workspace {
        padding: 8px !important;
      }
      .canvas-stage {
        padding: 4px !important;
      }
      #crop-canvas, #recrop-canvas {
        touch-action: none !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        max-width: 100% !important;
      }

      /* Section ③ Thẻ bước giải & nút thao tác */
      .step-item {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 10px !important;
      }
      .drag-handle {
        align-self: flex-start !important;
      }
      .step-num {
        min-width: unset !important;
        width: fit-content !important;
        padding: 2px 10px !important;
        margin-top: 0 !important;
      }
      .step-body {
        width: 100% !important;
        min-width: 0 !important;
      }
      .step-body.has-crop {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
      }
      .step-crop-box {
        width: 100% !important;
      }
      .step-crop-img,
      .modal-line-crop-img,
      .admin-crop-img,
      .ap-steps-box img {
        max-width: 100% !important;
        max-height: 90px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
      }
      .step-editor-col {
        width: 100% !important;
      }
      .step-actions {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 6px !important;
        border-top: 1px dashed var(--border) !important;
        padding-top: 8px !important;
        margin-top: 4px !important;
      }
      .step-actions button {
        flex: 1 1 auto !important;
        min-height: 36px !important;
        padding: 6px 8px !important;
        font-size: .8rem !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
      }

      /* Quick Math Toolbar trên mobile */
      .quick-math-toolbar, .modal-math-toolbar {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding: 6px 8px !important;
        gap: 6px !important;
      }
      .quick-math-toolbar::-webkit-scrollbar, .modal-math-toolbar::-webkit-scrollbar {
        display: none;
      }
      .btn-math-token, .btn-math-modal {
        min-height: 36px !important;
        min-width: 36px !important;
        flex-shrink: 0 !important;
        font-size: .88rem !important;
      }

      /* Nút chức năng chân form */
      .btn-row {
        gap: 8px !important;
      }
      .btn-row .btn {
        flex: 1 1 100% !important;
        justify-content: center !important;
        min-height: 42px !important;
      }

      /* Section ④ Kết quả chấm */
      .verdict {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        padding: 12px !important;
      }
      .info-grid {
        grid-template-columns: 1fr !important;
        gap: 4px !important;
      }

      /* Modals (Kiểm tra sửa từng dòng & Khoanh lại 1 dòng) */
      .modal-backdrop {
        padding: 8px !important;
      }
      #modal-ocr-correction .modal-card,
      #modal-line-recrop .modal-card {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 96vh !important;
        border-radius: 10px !important;
        margin: 0 !important;
      }
      #modal-ocr-correction .modal-card > div:first-child,
      #modal-line-recrop .modal-card > div:first-child {
        padding: 12px 14px !important;
      }
      #modal-ocr-correction .modal-card > div:last-child,
      #modal-line-recrop .modal-card > div:last-child {
        padding: 12px 14px !important;
      }
      #ocr-correction-modal-body {
        padding: 10px 8px !important;
        gap: 12px !important;
      }
      .ocr-modal-part-card {
        padding: 10px !important;
        gap: 10px !important;
      }
      .ocr-modal-line-item {
        padding: 10px 8px !important;
      }
      .modal-line-crop-img {
        max-height: 70px !important;
      }
      #modal-ocr-correction .btn,
      #modal-line-recrop .btn {
        min-height: 38px !important;
        font-size: .84rem !important;
      }
      #modal-ocr-correction .modal-card > div:last-child > div {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
      }
      #btn-confirm-ocr-correction {
        width: 100% !important;
        justify-content: center !important;
      }
    }

    /* Sub-tabs Quản lý Lớp & BTVN */
    .teacher-subtab-btn {
      background: none;
      border: 1px solid transparent;
      padding: 8px 16px;
      font-size: .92rem;
      font-weight: 600;
      color: #64748b;
      cursor: pointer;
      border-radius: 8px;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all .2s;
    }
    .teacher-subtab-btn:hover {
      background: #f1f5f9;
      color: #1e293b;
    }
    .teacher-subtab-btn.active {
      background: #eff6ff;
      color: #1d4ed8;
      border: 1px solid #bfdbfe;
      font-weight: 700;
      box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    }
    .teacher-subs-table th, .teacher-subs-table td {
      padding: 10px 12px;
      vertical-align: middle;
    }
    .teacher-subs-table tr:hover {
      background: #f8fafc;
    }

    /* --- Nút Hỗ trợ Zalo nổi ở góc dưới bên phải --- */
    #zalo-support-widget {
      position: fixed;
      bottom: 18px;
      right: 18px;
      z-index: 900;
      display: flex;
      align-items: center;
      pointer-events: auto;
      user-select: none;
    }

    #btn-zalo-pill {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: linear-gradient(135deg, #0068FF 0%, #0052cc 100%);
      color: #ffffff;
      border: 1.5px solid rgba(255, 255, 255, 0.4);
      border-radius: 999px;
      padding: 8px 16px;
      font-size: .86rem;
      font-weight: 700;
      cursor: pointer;
      box-shadow: 0 4px 14px rgba(0, 104, 255, 0.35);
      opacity: 0.92;
      transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
      margin: 0;
      white-space: nowrap;
    }

    #btn-zalo-pill:hover {
      opacity: 1;
      transform: translateY(-2px) scale(1.03);
      box-shadow: 0 6px 20px rgba(0, 104, 255, 0.5);
    }

    .zalo-icon-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: rgba(255, 255, 255, 0.22);
      width: 22px;
      height: 22px;
      border-radius: 50%;
    }

    @keyframes zaloModalZoomIn {
      from {
        opacity: 0;
        transform: scale(0.92) translateY(12px);
      }
      to {
        opacity: 1;
        transform: scale(1) translateY(0);
      }
    }

    @media print {
      #zalo-support-widget,
      #modal-zalo-qr {
        display: none !important;
      }
    }
  
    /* --- AI Processing UI Lock & Floating Indicator --- */
    body.ai-processing-locked {
      user-select: none;
      cursor: wait !important;
    }
    body.ai-processing-locked button,
    body.ai-processing-locked .btn,
    body.ai-processing-locked .nav-tab,
    body.ai-processing-locked .tab-btn,
    body.ai-processing-locked input,
    body.ai-processing-locked select,
    body.ai-processing-locked textarea,
    body.ai-processing-locked .drop-zone {
      pointer-events: none !important;
      opacity: 0.62 !important;
      cursor: wait !important;
    }
    #global-ai-processing-bar {
      position: fixed;
      top: 18px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 100000;
      background: rgba(15, 23, 42, 0.94);
      color: #ffffff;
      padding: 10px 24px;
      border-radius: 999px;
      box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 0 0 1.5px rgba(56, 189, 248, 0.5);
      font-weight: 600;
      font-size: 0.92rem;
      display: none;
      align-items: center;
      gap: 12px;
      backdrop-filter: blur(8px);
      pointer-events: auto !important;
      opacity: 1 !important;
      animation: fadeInDown 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }
    .processing-spinner {
      width: 16px;
      height: 16px;
      border: 2px solid #38bdf8;
      border-top-color: transparent;
      border-radius: 50%;
      animation: spin 0.75s linear infinite;
      display: inline-block;
    }
    @keyframes spin {
      to { transform: rotate(360deg); }
    }
    @keyframes fadeInDown {
      from { opacity: 0; transform: translate(-50%, -10px); }
      to { opacity: 1; transform: translate(-50%, 0); }
    }

