  .tool-content {
  flex: 1;
  position: relative;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  min-height: 0;
}

    .tool-content>div {
      width: 100%;
      height: 100%;
    }

    .toggle-view-btn {
    background: transparent !important;
    border: none;
    color: #A0A0B0;
    padding: 7px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.3s ease-in-out;
    border-radius: 16px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.toggle-view-btn:hover:not(.active) {
    color: #FFFFFF;
}

/* Whiteboard theme overrides */
#whiteboardTool[data-whiteboard-theme='light'] .excalidraw {
    /* Force Excalidraw background to be light */
    --canvas-background: #ffffff !important;
}
#whiteboardTool[data-whiteboard-theme='dark'] .excalidraw {
    /* Force Excalidraw background to be dark */
    --canvas-background: #202124 !important;
}

.excalidraw .App-menu__left.Island {
      left: auto !important;
      right: 16px !important;
    }

    .excalidraw .help-icon,
    .excalidraw button[aria-label="Help"] {
      display: none !important;
    }

    .excalidraw .sidebar-trigger {
      display: none !important;
    }

    .excalidraw [data-testid="search-menu-button"],
    .excalidraw [data-testid="clear-canvas-button"],
    .excalidraw [data-testid="toggle-dark-mode"] {
      display: flex !important;
    }

        .excalidraw [data-testid="dropdown-menu"] [data-testid="toolbar-frame"],
    .excalidraw [data-testid="dropdown-menu"] [data-testid="toolbar-embeddable"],

    .excalidraw [data-testid="dropdown-menu"] [data-testid="toolbar-laser"]+div {
      display: none !important;
    }

    .excalidraw [data-testid="image-export-button"],
    .excalidraw [data-testid="help-menu-item"],
    .excalidraw [data-testid="search-menu-button"],
    .excalidraw a[aria-label="GitHub"],
    .excalidraw a[aria-label="X"],
    .excalidraw a[aria-label="Discord"],
    .excalidraw [data-testid="dropdown-menu"] p.dropdown-menu-group,
    .excalidraw [data-testid="dropdown-menu"] div[style*="height: 1px"],
    .excalidraw [data-testid="dropdown-menu"] .dropdown-menu-group-title {
      display: none !important;
    }

    #demoToolContainer {
      width: 100%;
      height: 100%;
      position: relative;
      background-color: #1e1e1e;
      border-radius: 12px;
      overflow: hidden;
    }

    #demoToolContainer iframe.demo-code-frame {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: none;
    }

        /* --- START: Desmos 2D/3D Toggle Button --- */
#desmos-mode-toggle {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#desmos-mode-toggle:hover {
    background-color: #e0e0e0;
    border-color: #bbb;
}

#desmos-mode-toggle i {
    font-size: 24px;
    color: #555;
    pointer-events: none; /* Clicks should be handled by the button */
}

  .desmos-graph,
.desmos-3d-graph {
  display: block;
  margin: 10px 0 20px 0; /* Ensures left alignment */
  width: 500px;         /* NEW: Set width */
  height: 400px;        /* NEW: Set height */
  max-width: 100%;      /* Ensures it shrinks on small screens */
  border-radius: 12px;
  overflow: hidden;
  background-color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  position: relative;
}

    .desmos-graph iframe,
    .desmos-3d-graph iframe {
      display: block;
      width: 100%;
      height: 100%;
      border: none;
    }

    .desmos-3d-graph-label {
      text-align: center;
      font-size: 14px;
      margin-top: 4px;
      color: #ccc;
      margin-left: 0;
    }

    #ti84Tool iframe {
      scrollbar-width: none;
    }

    #ti84Tool iframe::-webkit-scrollbar {
      display: none;
    }

    .toggle-button-checkWork {
      font-weight: 500;
    }

    .toggle-button-checkWork.active {
      font-weight: 600;
    }

    .toggle-button-demo {
      flex: 1;
      text-align: center;
      cursor: pointer;
      user-select: none;
      z-index: 1;
      color: #f0f0f0;
      transition: color 0.2s ease-in-out;
      padding: 8px 0;
      font-weight: 500;
    }

    .toggle-button-demo.active {
      color: #fff;
      font-weight: 600;
    }

    .toggle-button-flashcards {
      font-weight: 500;
    }

    .toggle-button-flashcards.active {
      font-weight: 600;
    }

     .toggle-button-pdfViewer {
      font-weight: 500;
    }

    .toggle-button-pdfViewer.active {
      font-weight: 600;
    }

    /* Chips & Placeholders */
 .screenshot-chip {
        position: relative;
        display: inline-flex; /* Use inline-flex for proper sizing */
        align-items: center;
        justify-content: center;
        padding: 4px; /* Padding to create the 'frame' effect */
        
        /* New styling to match the input area */
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 14px; /* Softer, more modern radius */
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.05);
        
        cursor: pointer;
        transition: all 0.2s ease;
        
        /* Remove fixed width/height from the container */
        width: auto;
        height: auto;
    }

    .screenshot-chip .chip-image-preview {
        width: 50px;
        height: 50px;
        aspect-ratio: 1 / 1; /* Ensures a square aspect ratio */
        object-fit: cover;   /* Scales the image to fill the square, cropping excess */
        border-radius: 11px; /* Slightly smaller radius to fit inside the padded chip */
        display: block;      /* Ensures no extra space below the image */
    }


     .screenshot-chip:hover {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.25);
        /*transform: translateY(-2px);*/
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.07);
    }

    .screenshot-chip:hover .chip-actions {
      display: flex;
    }

    .screenshot-chip:hover .remove-chip {
      display: flex;
    }

    .screenshot-chip[data-type="whiteboard"],
    .screenshot-chip[data-type="desmos"] {
      height: 30px;
      width: auto;
      min-width: 120px;
      padding: 0 12px;
      display: flex;
      align-items: center;
      gap: 8px;

      background: linear-gradient(145deg, #2c2c3e, #353548);
      border: 1px solid #4a4a5e;
      border-radius: 8px;

      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), inset 0 1px 0px rgba(255, 255, 255, 0.04);
      transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    }

    .screenshot-chip[data-type="whiteboard"] img,
    .screenshot-chip[data-type="desmos"] img {
      display: none !important;
    }

    .screenshot-chip[data-type="whiteboard"] .chip-main-icon,
    .screenshot-chip[data-type="desmos"] .chip-main-icon {
      font-size: 18px;
      color: #b5a7d8;
      line-height: 1;
    }

    .screenshot-chip[data-type="whiteboard"] span,
    .screenshot-chip[data-type="desmos"] span {
      font-size: 13px;
      font-weight: 500;
      color: #d0c8e8;
      line-height: 1;
    }

    .screenshot-chip[data-type="whiteboard"]:hover,
    .screenshot-chip[data-type="desmos"]:hover {
      background: linear-gradient(145deg, #353548, #3e3e52);
      border-color: #5f5f76;
      transform: translateY(-1px);
      box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0px rgba(255, 255, 255, 0.05);
    }

    .screenshot-chip[data-type="whiteboard"].blue-pulse,
    .screenshot-chip[data-type="desmos"].blue-pulse {
      animation: none;
    }

    .screenshot-chip[data-type="whiteboard"] .chip-actions,
    .screenshot-chip[data-type="desmos"] .chip-actions {
      top: 50%;
      transform: translateY(-50%);
      right: 6px;
    }

    .screenshot-updates-area {
      display: flex;
      gap: 10px;
      margin-bottom: 12px;
      align-items: center;
      flex-wrap: wrap;
    }

    .chat-attachment-placeholder {
      display: flex;
      align-items: center;
      width: 100%;
      padding: 12px 18px;
      margin: 10px 0;
      border-radius: 12px;
      cursor: pointer;
      transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
      box-sizing: border-box;

      background-color: #2c2e3a;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2),
        inset 0 1px 0px rgba(255, 255, 255, 0.03);
    }

    .chat-attachment-placeholder i {
      font-size: 22px;
      margin-right: 12px;
      transition: color 0.2s ease, transform 0.2s ease;
    }

    .chat-attachment-placeholder span {
      font-size: 15px;
      font-weight: 500;
      color: #E0E0E5;
      transition: color 0.2s ease;
    }

    .chat-attachment-placeholder.desmos {
      border: 1.5px solid #2E8B57;
    }

    
    .chat-attachment-placeholder.desmos i {
      color: #3CB371;
    }

    .chat-attachment-placeholder.desmos:hover {
      border-color: #3CB371;
    }

    .chat-attachment-placeholder.desmos:hover i {
      color: #50C878;
      transform: scale(1.05);
    }

    .chat-attachment-placeholder.desmos:hover span {
      color: #F0F0F5;
    }

    .chat-attachment-placeholder.whiteboard {
      border: 1.5px solid #8A63D2;
    }

    .chat-attachment-placeholder.whiteboard i {
      color: #A07BE0;
    }

    .chat-attachment-placeholder.whiteboard:hover {
      border-color: #A07BE0;
    }

     .chat-attachment-placeholder.whiteboard:hover i {
      color: #C4A8FF;
      transform: scale(1.05);
    }

    .chat-attachment-placeholder.whiteboard:hover span {
      color: #F0F0F5;
    }

    .chat-attachment-placeholder:hover {
      background-color: #353745;
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.05);
    }

    .blue-pulse {
      animation: purpleSparkle 1.2s ease-out;
    }

    .chip-actions {
      position: absolute;
      top: 2px;
      right: 4px;
      display: none;
      align-items: center;
      gap: 3px;
      background: rgba(50, 50, 50, 0.7);
      border-radius: 10px;
      padding: 1px 3px;
    }


    .chip-icon-btn {
      background: none;
      border: none;
      color: #e0e0e0;
      font-size: 18px;
      cursor: pointer;
      padding: 2px;
      line-height: 1;
      transition: color 0.2s ease, transform 0.1s ease;
    }

    .chip-icon-btn.expand-retract>i {
      font-size: 16px;
      vertical-align: middle;
      display: inline-block;
    }


    .chip-icon-btn.remove {
      color: #ff6b6b;
    }

    .chip-icon-btn.remove:hover {
      color: #ff4d4d;
    }


    .chip-icon-btn.remove>i {
      vertical-align: middle;
      display: inline-block;
    }

    .chip-icon-btn:hover {
      color: #ffffff;
      transform: scale(1.1);
    }

     .remove-chip {
      position: absolute;
      top: 2px;
      right: 4px;
      background: #333;
      color: #ff3b30;
      border: none;
      border-radius: 50%;
      width: 30px;
      height: 30px;
      font-size: 20px;
      display: none;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      line-height: 30px;
    }

    /* The button itself. Positioned absolutely within the parent. */
.add-to-whiteboard-btn {
    position: absolute;
    bottom: 8px; /* Padding from the bottom */
    right: 8px;  /* THE FIX: Positioned on the right */
    
    /* Appearance */
    background-color: rgba(30, 30, 35, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    
    /* Icon Centering */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    padding: 0;
    
    /* Interactivity & Animation */
    cursor: pointer;
    opacity: 1; /* THE FIX: Always visible */
    transform: translateY(0);
    transition: transform 0.2s ease-out, background-color 0.2s ease;
}

/* Hover effect for the button itself */
.add-to-whiteboard-btn:hover {
    background-color: rgba(50, 50, 55, 0.8);
    transform: scale(1.05); /* Slight zoom on hover */
}

.generated-image-container {
    position: relative;
    display: inline-block; /* Ensures the container fits the image size */
    line-height: 1; /* Prevents extra space below the image */
    margin-bottom: 10px; /* Space below the image container */
}

/* Make sure the image inside fills the container properly */
.generated-image-container img {
    display: block;
    border-radius: 12px;
    max-width: 100%;
}

  .image-stack {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      margin-bottom: 5px;
      margin-top: 5px;
    }

    .message-image {
      max-width: 100%;
      max-height: 300px;
      display: block;
      margin: 5px 0;
      border-radius: 8px;
      margin-top: 10px;
    }

    /* File Upload & QR */
    #fileUploadModalTitle {}

    /* File Card Styling */
.file-card {
    position: relative;
    width: 100px;
    height: 100px;
    background-color: rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    cursor: default;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.file-card .file-icon {
    font-size: 40px;
    color: #EC7063; /* Reddish for PDF */
    margin-bottom: 8px;
}

.file-card .file-name {
    font-size: 0.75rem;
    color: #C0C0C8;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-card .remove-file-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background-color: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.file-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}


.file-card:hover .remove-file-btn {
    opacity: 1;
}

.file-upload-browse-btn {
      background: #4a4a65;
      color: #eee;
      border: none;
      padding: 10px 20px;
      border-radius: 20px;
      font-size: 0.95em;
      font-weight: 500;
      cursor: pointer;
      transition: background-color 0.2s ease, transform 0.1s ease;
    }

    .file-upload-browse-btn:hover {
      background: #5f5f82;
      transform: scale(1.03);
    }

    .file-upload-drop-zone {
      border: 2px dashed #504a70;
      border-radius: 12px;
      padding: 30px 20px;
      text-align: center;
      background-color: rgba(255, 255, 255, 0.03);
      transition: background-color 0.2s ease, border-color 0.2s ease;
      margin-top: 15px;
      margin-bottom: 20px;
      cursor: pointer;
    }

    .file-upload-drop-zone.dragover {
      background-color: rgba(161, 140, 209, 0.15);
      border-color: #a18cd1;
    }

    .file-upload-instructions {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
    }

    .file-upload-instructions i {
      font-size: 3.0em;
      color: #a18cd1;
      margin-bottom: 10px;
    }

    .file-upload-instructions p {
      font-size: 1.1em;
      color: #d0c8e8;
      font-weight: 500;
      margin: 0;
    }

    .file-upload-instructions span {
      display: block;
      font-size: 0.9em;
      color: #8a81a8;
      margin: 5px 0;
    }


    .file-upload-modal-content {
      max-width: 500px;
      width: 90%;
      background: linear-gradient(155deg, #28253d 0%, #1c1a2b 100%);
      border-radius: 16px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), 0 0 0 1.5px rgba(255, 255, 255, 0.07) inset;
      padding: 25px 30px;
      display: flex;
      flex-direction: column;

      transform: scale(0.92) translateY(15px);
      opacity: 0;
      transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.05), opacity 0.35s ease-out;
    }

      .file-upload-status {
      font-size: 0.9em;
      color: #aaa;
      min-height: 1.2em;
      text-align: center;
      margin-top: 5px;
    }

    .file-upload-status.error {
      color: #ff8a80;
    }

     .file-upload-status.success {
      color: #81c784;
    }

        #uploadChoicePopover {}


         .upload-choice-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      background: #3a3a52;
      border: 1px solid #555;
      color: #eee;
      padding: 10px 15px;
      border-radius: 8px;
      cursor: pointer;
      width: 100%;
      font-size: 15px;
      margin-bottom: 10px;
      transition: background-color 0.2s ease;
    }


    .upload-choice-btn i {
      font-size: 20px;
    }

    .upload-choice-btn:hover {
      background-color: #4a4a65;
    }

    .upload-choice-btn:last-child {
      margin-bottom: 0;
    }

    #qrCodeContainer {
      background: white;
      padding: 15px;
      border-radius: 10px;
      display: block;
      margin-left: auto;
      margin-right: auto;
      margin-bottom: 25px;
      width: fit-content;
      box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    }

    #qrCodeContainer img {
      display: block;
      width: 200px;
      height: 200px;
      margin: 0 auto;
    }


    #qrCodeModal .close-preview-button {
      /* Positioning */
      top: 20px;
      right: 25px;
      
      /* Make the button invisible */
      background: none !important;
      border: none !important;
      box-shadow: none !important;
      
      /* Sizing */
      width: auto;
      height: auto;
      padding: 5px; /* Add a small invisible clickable area around the icon */
      
      /* Icon Styling */
      color: #909296; /* A more subtle grey for the icon */
      font-size: 28px;
      opacity: 0.7;
      
      /* Transitions */
      transition: color 0.2s ease, opacity 0.2s ease;
      
      /* Reset other potential styles from the generic class */
      line-height: 1;
      border-radius: 0;
      display: inline-block;
    }

    #qrCodeModal .close-preview-button:hover {
      opacity: 1;
      color: #e9ecef; /* Barely noticeable brightening effect */
      background: none !important; /* Ensure no background appears on hover */
      transform: none;
    }

    #qrStatus {
      font-size: 14px;
      font-weight: 500;
      color: #ddd;
      margin-top: 0;
      margin-bottom: 10px;
      min-height: 1.2em;
    }

    #qrSpinner {
      margin-top: 10px;
    }


     #qrStatus.success {
      color: #81c784;
    }

    #qrStatus.error {
      color: #e57373;
    }


    .qr-modal-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 35px 25px;
    }

    

    .qr-modal-content h3 {
      margin-top: 0;
      margin-bottom: 10px;
      font-weight: 600;
      font-size: 1.2em;
      color: #eee;
    }

    .qr-modal-content p {
      font-size: 14px;
      color: #ccc;
      line-height: 1.5;
      margin-bottom: 25px;
      max-width: 90%;
    }


/* PDF Viewer & Preview */
#pdfViewerTool {
      display: none;
      width: 100%;
      height: 100%;
      background-color: #333;
      border-radius: 12px;
      overflow: hidden;
    }

    #pdfViewerTool embed {
      width: 100%;
      height: 100%;
      border: none;
    }

    .pdf-canvas-container {
      flex-grow: 1;
      position: relative;
      overflow: auto;
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: #333842;
    }


    .pdf-controls {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 8px;
      background-color: #1e2127;
      border-top: 1px solid #3a3f4b;
      gap: 10px;
      flex-shrink: 0;
    }

    .pdf-controls .page-info {
      color: #c8cdd4;
      font-size: 14px;
      margin: 0 10px;
    }

    .pdf-controls button,
    .pdf-controls select,
    .pdf-controls input[type="color"] {
      background-color: #3a3f4b;
      color: #c8cdd4;
      border: 1px solid #525863;
      padding: 6px 10px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 14px;
    }

    .pdf-controls button.active-tool {
      background-color: #528bff;
      color: white;
      border-color: #528bff;
    }

    .pdf-controls button:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .pdf-controls button:hover,
    .pdf-controls select:hover {
      background-color: #4c525e;
    }

    .pdf-controls input[type="color"] {
      padding: 2px;
      min-width: 30px;
      height: 30px;
    }

    .pdf-link {
      display: inline-flex;
      align-items: center;
      background-color: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 8px;
      padding: 5px 12px;
      margin-top: 8px;
      margin-bottom: 5px;
      text-decoration: none;
      color: #d1c4e9;
      font-size: 0.9em;
      font-weight: 500;
      cursor: pointer;
      transition: background-color 0.2s ease, transform 0.1s ease;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }


    .pdf-link i {
      font-size: 1.4em;
      margin-right: 8px;
      color: #ef5350;
      flex-shrink: 0;
    }


    .pdf-link span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .pdf-link:hover {
      background-color: rgba(255, 255, 255, 0.15);
      transform: translateY(-1px);
    }

    .pdf-thumbnail {
      max-width: 100%;
      height: auto;
      border-radius: 8px;
      margin-bottom: 5px;
      cursor: pointer;
      display: block;
    }

    .pdf-viewer-ui-container {
      display: flex;
      flex-direction: column;
      width: 100%;
      height: 100%;
      position: relative;
    }

    #pdfPageCanvas,
    #pdfAnnotationCanvas {
      position: absolute;
      top: 0;
      left: 0;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    }


    #pdfPreviewEmbed {
      width: 100%;
      height: 100%;
      display: block;
      border: none;
    }


    #pdfPreviewModal .preview-content {
      position: relative;
      background: #333;
      border-radius: 15px;
      overflow: hidden;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
      display: flex;
      align-items: stretch;
      justify-content: stretch;

      width: 85vw;
      height: 90vh;
    }

     #fullscreenPreview img,
    #pdfPreviewModal .preview-content embed,
    #pdfPreviewModal .preview-content img {
      max-width: 90vw;
      max-height: 90vh;
      object-fit: contain;
      width: auto;
      height: auto;
    }


    .preview-content {
      position: relative;
      background: #fff;
      border: 1px solid #fff;
      border-radius: 25px;
      max-width: 90vw;
      max-height: 90vh;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
    }


    .preview-content.pdf-mode {
      width: 80vw;
      height: 90vh;
      max-width: none;
      max-height: none;
    }



    .preview-image {
      display: block;
      max-width: 100%;
      max-height: 100%;
      width: auto;
      height: auto;
      object-fit: contain;
    }


    .close-preview-button {
      position: absolute;
      top: 15px;
      right: 20px;
      background: transparent;
      border: none;
      color: #a0a0a0;
      cursor: pointer;
      font-size: 28px;
      opacity: 0.7;
      transition: opacity 0.2s ease, color 0.2s ease;
      padding: 5px;
      line-height: 1;
    }

    .close-preview-button:hover {
      opacity: 1;
      color: #ffffff;
      transform: none;
    }

     .fullscreen-preview-modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: rgba(0, 0, 0, 0.9);
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 1000;
    }

    .fullscreen-preview-modal.hide {
      display: none;
    }


    #annotationCanvasPreview {
      position: absolute;
      cursor: crosshair;
      touch-action: none;
    }

    #annotationToolbarPreview {
      position: absolute;
      top: 15px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(40, 40, 45, 0.92);
      padding: 8px 12px;
      border-radius: 25px;
      box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
      display: flex;
      gap: 10px;
      align-items: center;
      z-index: 1001;
      transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    }

     #annotationToolbarPreview .active-annotation-tool {
      background-color: #8a63d2;
      color: white;
      border-color: #a18cd1;
      box-shadow: 0 0 8px rgba(138, 99, 210, 0.5);
    }

    #annotationToolbarPreview .active-annotation-tool:hover {
      background-color: #9f7ce6;
    }


    #annotationToolbarPreview button,
    #annotationToolbarPreview input[type="color"] {
      background-color: rgba(255, 255, 255, 0.12);
      color: #e0e0e0;
      border: 1px solid rgba(255, 255, 255, 0.25);
      padding: 7px 10px;
      border-radius: 20px;
      cursor: pointer;
      font-size: 14px;
      transition: background-color 0.2s, color 0.2s, transform 0.1s;
      display: inline-flex;
      align-items: center;
      gap: 5px;
    }

    #annotationToolbarPreview button i {
      font-size: 18px;
    }


    #annotationToolbarPreview button:hover {
      background-color: rgba(255, 255, 255, 0.22);
      color: #fff;
      transform: scale(1.05);
    }

    #annotationToolbarPreview input[type="color"] {
      padding: 0;
      width: 30px;
      height: 30px;
      border-radius: 50%;
      overflow: hidden;
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
      background-color: transparent;
      border: 2px solid rgba(255, 255, 255, 0.3);
    }

    #annotationToolbarPreview input[type="color"]::-webkit-color-swatch {
      border: none;
      border-radius: 50%;
    }

    #annotationToolbarPreview input[type="color"]::-webkit-color-swatch-wrapper {
      padding: 0;
    }

    #annotationToolbarPreview.hidden-toolbar {
      opacity: 0;
      transform: translateX(-50%) translateY(-10px);
      pointer-events: none;
    }


    /* Flashcards */
#flashcardsTool {
      display: none;
      width: 100%;
      height: 100%;
      padding: 20px;
      box-sizing: border-box;
      background-color: #1c1a2b;
      border-radius: 12px;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      position: relative;
    }

    #flashcardsTool h2.flashcard-viewer-title {
      color: #e8e4f5;
      font-size: 1.8em;
      margin-bottom: 20px;
      text-align: center;
      font-weight: 600;
      width: 100%;
      flex-shrink: 0;
    }


    .flashcard-back {
      display: block;
      padding: 25px 20px;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: rgba(161, 140, 209, 0.4) rgba(255, 255, 255, 0.05);
    }

    /* Make paragraphs flow like text on the back face */
    .flashcard-back p {
      display: inline;
      margin: 0;
      padding: 0;
    }


    .flashcard-back::-webkit-scrollbar { width: 5px; }


        .flashcard-back::-webkit-scrollbar-thumb { background-color: rgba(161, 140, 209, 0.4); border-radius: 2.5px; }


            .flashcard-back::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 2.5px; }

.flashcard-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 10px 20px;
      margin-top: 15px;
      margin-bottom: 5px;
      font-size: 15px;
      font-weight: 600;
      color: #1B2631;
      background: linear-gradient(145deg, #58D68D, #ABEBC6);
      border: 1px solid #A9DFBF;
      border-radius: 25px;
      cursor: pointer;
      transition: all 0.3s ease;
      box-shadow: 0 3px 8px rgba(46, 204, 113, 0.3);
      gap: 8px;
      min-width: 200px;
      text-align: center;
    }

    .flashcard-button i {
      font-size: 1.2em;
    }


.flashcard-button.error {
      background: linear-gradient(145deg, #EC7063, #F5B7B1);
      border-color: #FADBD8;
      color: #78281F;
      box-shadow: 0 3px 8px rgba(203, 67, 53, 0.4);
    }


     .flashcard-button.error:hover:not(:disabled) {
      background: linear-gradient(145deg, #F1948A, #FADBD8);
      box-shadow: 0 5px 15px rgba(203, 67, 53, 0.6);
    }

    .flashcard-button.loading {
      background: linear-gradient(145deg, #27AE60, #58D68D);
    }

    .flashcard-button.loading .bx-loader-alt {
      display: inline-block;
      animation: spin 1s linear infinite;
    }

    .flashcard-button.ready {
      background: linear-gradient(145deg, #5DADE2, #AED6F1);
      border-color: #AED6F1;
      color: #1A5276;
      box-shadow: 0 3px 8px rgba(41, 128, 185, 0.4);
    }

    .flashcard-button.ready:hover:not(:disabled) {
      background: linear-gradient(145deg, #85C1E9, #D6EAF8);
      box-shadow: 0 5px 15px rgba(41, 128, 185, 0.6);
    }

    .flashcard-button:disabled {
      cursor: not-allowed;
      opacity: 0.7;
      box-shadow: none;
      transform: none;
    }

    .flashcard-button:hover:not(:disabled) {
      background: linear-gradient(145deg, #82E0AA, #D5F5E3);
      box-shadow: 0 5px 15px rgba(46, 204, 113, 0.5);
      transform: translateY(-2px) scale(1.02);
      color: #17202A;
      border-color: #E8F8F5;
    }


    .flashcard-button:not(.loading) .bx-loader-alt {
      display: none;
    }


    .flashcard-card {
      width: 100%;
      height: 100%;
      position: relative;
      transform-style: preserve-3d;
      transition: transform 0.7s cubic-bezier(0.4, 0.0, 0.2, 1);
      cursor: pointer;
      border-radius: 18px;
      box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35),
        0 0 0 1.5px rgba(255, 255, 255, 0.07) inset;
    }

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

    .flashcard-content-wrapper {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      width: 100%;
      max-width: 700px;
      margin-bottom: 20px;
    }

    .flashcard-dot {
      width: 9px;
      height: 9px;
      border-radius: 50%;
      background-color: rgba(255, 255, 255, 0.2);
      margin: 0 6px;
      cursor: pointer;
      transition: background-color 0.2s ease, transform 0.2s ease;
    }

    .flashcard-dot:hover {
      background-color: rgba(255, 255, 255, 0.4);
      transform: scale(1.25);
    }

    .flashcard-dot.active {
      background-color: #b39ddb;
      transform: scale(1.4);
      box-shadow: 0 0 8px rgba(179, 157, 219, 0.5);
    }

     .flashcard-expanded-message {
      color: #aaa;
      font-style: italic;
      padding: 15px;
      border: 1px dashed #444;
      border-radius: 8px;
      margin-top: 10px;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
    }

     .flashcard-face {
      position: absolute;
      width: 100%;
      height: 100%;
      backface-visibility: hidden;
      border-radius: 18px;
      box-sizing: border-box;
      font-size: 1.15em;
      line-height: 1.8;
      text-align: center; /* Center text for both faces by default */
    }


    /* FIX: Center standalone math blocks on BOTH faces correctly */
    .flashcard-face .block-math-wrapper,
    .flashcard-face .ML__display-math {
        display: inline-block !important; /* Treat the block as a single, large inline item */
        width: auto;
        max-width: 100%;
        margin: 0.8em 0 !important; /* Vertical margin only */
    }




     .flashcard-face .inline-math math-field[read-only] .ML__container,
    .flashcard-face .block-math-wrapper math-field[read-only] .ML__container {
      padding: 0 !important;
    }

    .flashcard-face .inline-math math-field[read-only] .ML__content,
    .flashcard-face .block-math-wrapper math-field[read-only] .ML__content {
      padding: 0 1px !important;
    }

    .flashcard-face math-field {
      display: inline-block;
      margin: 5px 0;
      font-size: 1em !important;
      background-color: transparent !important;
      border: none !important;
      color: inherit !important;
      max-width: 100%;
      overflow-x: auto;
      padding: 2px 5px;
      border-radius: 4px;
      text-align: left;
    }

    /* UNIFIED MATH STYLING for both faces */
    .flashcard-face math-field[read-only] {
      display: inline-block;
      vertical-align: -0.3em;
      margin: 0 0.1em;
      padding: 0;
      line-height: inherit;
      font-size: inherit;
      color: inherit !important;
      background-color: transparent !important;
      border: none !important;
      overflow: visible;
      max-width: none;
    }

    .flashcard-face math-field[read-only] .ML__container,
    .flashcard-face math-field[read-only] .ML__content {
        padding: 0 !important;
    }

    .flashcard-front {
      background: linear-gradient(145deg, #36324e, #26233a);
      color: #e8e4f5;
    }


    .flashcard-nav-arrow {
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.15);
      color: #b0a8c9;
      border-radius: 50%;
      width: 44px;
      height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 30px;
      cursor: pointer;
      transition: all 0.25s ease;
      box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
      z-index: 10;
      flex-shrink: 0;
    }


    .flashcard-nav-arrow.disabled {
      opacity: 0.3;
      cursor: not-allowed;
      transform: scale(1);
      background: rgba(255, 255, 255, 0.03);
      box-shadow: none;
    }

    .flashcard-nav-arrow:hover {
      background: rgba(255, 255, 255, 0.15);
      color: #fff;
      transform: scale(1.08);
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    }

    .flashcard-pagination-dots {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      flex-shrink: 0;
    }

     .flashcard-prompt-container {
      text-align: center;
      margin-top: 10px;
    }

    .flashcard-retract-chat-btn {
      background: rgba(255, 255, 255, 0.1);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: #ccc;
      padding: 6px 12px;
      font-size: 0.9em;
      border-radius: 15px;
      cursor: pointer;
      transition: all 0.2s ease;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      margin-top: 8px;
    }


    .flashcard-retract-chat-btn:hover {
      background: rgba(255, 255, 255, 0.15);
      color: #fff;
    }


    .flashcard-scene {
      width: 100%;
      max-width: 450px;
      height: 300px;
      perspective: 1000px;
      margin: 0 20px;
      flex-grow: 1;
      flex-shrink: 1;
      min-width: 280px;
    }


/* Grading / Check Work */
#checkWorkTool {
      display: none;
      width: 100%;
      height: 100%;
      position: relative;
      overflow: auto;
      background-color: #202124;
      border-radius: 12px;
      padding: 15px;
      box-sizing: border-box;
      display: flex;
      justify-content: center;
      align-items: flex-start;
    }

 #checkWorkTool .grading-tool-close-btn {
      position: absolute;
      top: 10px;
      right: 10px;
      background: rgba(50, 50, 50, 0.6);
      border: 1px solid rgba(255, 255, 255, 0.15);
      color: #e0e0e0;
      border-radius: 50%;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 22px;
      cursor: pointer;
      transition: background-color 0.2s, transform 0.2s, color 0.2s;
      z-index: 10;
      line-height: 1;
    }

    #checkWorkTool .grading-tool-close-btn:hover {
      background-color: rgba(70, 70, 70, 0.8);
      color: #ffffff;
      transform: scale(1.1);
    }

    #checkWorkTool .grading-tool-close-btn i {
      pointer-events: none;
    }

    #checkWorkTool canvas {
      position: absolute;
      left: 0;
      top: 0;
      pointer-events: auto;
    }

    #checkWorkTool img {
      display: block;
      max-width: 100%;
      max-height: calc(100vh - 160px);
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }


    #checkWorkTool.zoomed-view {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding: 20px;
    }

    #checkWorkTool.zoomed-view .crop-canvas-zoomed {
      display: block;
      max-width: 90%;
      max-height: calc(100% - 120px);
      object-fit: contain;
      border: 2px solid #504a70;
      border-radius: 8px;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
      margin-bottom: 20px;
    }


    .checkwork-tooltip {
      position: absolute;
      background: rgba(40, 40, 45, 0.95);
      color: #e0e0e0;
      padding: 10px 14px;
      border-radius: 8px;
      font-size: 14px;
      line-height: 1.5;
      max-width: 280px;
      pointer-events: none;
      z-index: 10010;
      border: 1px solid rgba(255, 255, 255, 0.15);
      box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
      display: none;
      white-space: normal;
    }

    .checkwork-tooltip code {
      background-color: rgba(255, 255, 255, 0.1);
      padding: 1px 4px;
      border-radius: 4px;
      font-family: 'SF Mono', Menlo, Monaco, Consolas, "Courier New", monospace;
      font-size: 0.9em;
    }

    .checkwork-tooltip p {
      margin: 0 0 5px 0;
      color: #d1c4e9;
    }

    .checkwork-tooltip p:last-child {
      margin-bottom: 0;
    }

    .grading-loader-animation {
      width: 100px;
      height: 6px;
      background-color: rgba(255, 255, 255, 0.1);
      border-radius: 3px;
      overflow: hidden;
      position: relative;
    }

    .grading-loader-bar {
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 40%;
      border-radius: 3px;
      background: linear-gradient(90deg,
          rgba(161, 140, 209, 0.3) 0%,
          rgba(161, 140, 209, 0.9) 50%,
          rgba(161, 140, 209, 0.3) 100%);
      animation: gradingProgressAnimation 1.8s infinite ease-in-out;
    }


    .grading-loader-container {
      background-color: rgba(45, 45, 60, 0.7);
      border: 1px solid rgba(80, 80, 100, 0.5);
      border-radius: 8px;
      padding: 10px 15px;
      margin-top: 12px;
      max-width: 250px;
      width: fit-content;
      display: flex;
      align-items: center;
      gap: 10px;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
      overflow: hidden;
      position: relative;
      animation: fadeInGradingLoader 0.3s ease-out;
    }

    .grading-loader-text {
      font-size: 13px;
      color: #b0a8c9;
      font-weight: 500;
    }

    .grading-view-active-message {
      background-color: rgba(70, 70, 90, 0.6);
      border: 1px solid rgba(100, 100, 120, 0.4);
      border-radius: 8px;
      padding: 12px 18px;
      margin-top: 12px;
      max-width: 300px;
      width: fit-content;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 8px;
      color: #c0b8d8;
      font-size: 13px;
      animation: fadeInGradingLoader 0.3s ease-out;
    }

    .grading-view-active-message .retract-grading-btn {
      background: rgba(255, 255, 255, 0.1);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: #ccc;
      padding: 6px 12px;
      font-size: 0.9em;
      border-radius: 15px;
      cursor: pointer;
      transition: all 0.2s ease;
      display: inline-flex;
      align-items: center;
      gap: 5px;
    }

    .grading-view-active-message .retract-grading-btn:hover {
      background: rgba(255, 255, 255, 0.15);
      color: #fff;
    }


    .open-grading-view-btn {
      background: rgba(255, 255, 255, 0.15);
      border: 1px solid rgba(255, 255, 255, 0.25);
      color: #e0d8f0;
      padding: 8px 15px;
      font-size: 0.95em;
      font-weight: 500;
      border-radius: 20px;
      cursor: pointer;
      transition: all 0.2s ease;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .open-grading-view-btn:hover {
      background: rgba(255, 255, 255, 0.25);
      color: #fff;
    }


    /* MCQ Quiz */
#mcqQuizCompletionScreen {
      width: 100%;
      max-width: 750px;
      text-align: center;
      padding: 30px 20px;
    }

    #mcqQuizCompletionScreen h2 {
      font-size: 2em;
      color: #e0e0e5;
      margin-bottom: 25px;
    }


    #mcqQuizModal {
      background-color: #1c1a2b;
      width: 90%;
      height: auto;
      max-width: 800px;
      max-height: 90vh;
      border-radius: 16px;
      box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
      padding: 0;
      display: flex;
      flex-direction: column;
      transform: scale(0.95) translateY(-20px);
      opacity: 0;
      transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease-out;
      overflow: hidden;
    }


    #mcqQuizModalBackdrop {
      position: fixed;
      inset: 0;
      background-color: rgba(15, 15, 25, 0.6);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 6000;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.3s ease-out, visibility 0s linear 0.3s;
    }

    #mcqQuizModalBackdrop:not(.hidden) {
      opacity: 1;
      visibility: visible;
      transition: opacity 0.3s ease-out, visibility 0s linear 0s;
    }

    #mcqQuizModalBackdrop:not(.hidden) #mcqQuizModal {
      transform: scale(1) translateY(0);
      opacity: 1;
    }


    #mcqQuizTool {
      display: none;
      width: 100%;
      height: 100%;
      background-color: #1c1a2b;
      border-radius: 12px;
      overflow: hidden;
      padding: 0;
      display: flex;
      flex-direction: column;
      box-sizing: border-box;
    }

    #mcqQuizTool .mcq-quiz-header {
      flex-shrink: 0;
    }

    #mcqQuizTool .mcq-quiz-content-area {
      flex-grow: 1;
      overflow-y: auto;
    }

    #mcqQuizTool .mcq-quiz-footer {
      flex-shrink: 0;
    }

    .mcq-quiz-action-btn {
      background: none;
      border: 1px solid #4a4a65;
      color: #b0a8c9;
      border-radius: 8px;
      padding: 8px 10px;
      font-size: 1em;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      gap: 6px;
    }


    .mcq-quiz-action-btn i {
      font-size: 20px;
    }

    .mcq-quiz-action-btn.create-btn {
      background-color: #3a5cad;
      border-color: #5c7bc9;
      color: #fff;
    }

    .mcq-quiz-action-btn.create-btn:hover {
      background-color: #4e6dbd;
      border-color: #7a9ae0;
    }

    .mcq-quiz-action-btn:hover {
      background-color: #35324e;
      border-color: #6a6788;
      color: #fff;
    }

    .mcq-quiz-card-header {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 10px;
    }

    .mcq-quiz-card-header i {
      font-size: 24px;
      color: #b5a7d8;
    }

    .mcq-quiz-card-header h3 {
      font-size: 1.15em;
      font-weight: 600;
      color: #e0e0e5;
      margin: 0;
      line-height: 1.3;
    }

    .mcq-quiz-card-meta {
      font-size: 0.85em;
      color: #908aab;
      margin-bottom: 15px;
    }

    .mcq-quiz-completion-actions .mcq-quiz-done-btn {
      padding: 14px 40px;
      font-size: 1.1em;
    }

    .mcq-quiz-content-area {
      flex-grow: 1;
      padding: 25px 30px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      scrollbar-width: thin;
      scrollbar-color: rgba(161, 140, 209, 0.4) rgba(22, 20, 33, 0.5);
    }

    .mcq-quiz-content-area::-webkit-scrollbar {
      width: 6px;
    }

    .mcq-quiz-content-area::-webkit-scrollbar-track {
      background: rgba(22, 20, 33, 0.5);
      border-radius: 3px;
    }

    .mcq-quiz-content-area::-webkit-scrollbar-thumb {
      background-color: rgba(161, 140, 209, 0.4);
      border-radius: 3px;
    }

    .mcq-quiz-explanation-area {
      margin-top: 15px;
      padding: 15px;
      background-color: rgba(76, 175, 80, 0.05);
      border: 1px solid rgba(76, 175, 80, 0.2);
      border-radius: 8px;
      font-size: 0.95em;
      color: #c8e6c9;
      line-height: 1.6;
      display: none;
    }

    .mcq-quiz-explanation-area.visible {
      display: block;
    }

    .mcq-quiz-explanation-area strong {
      color: #a5d6a7;
    }

    .mcq-quiz-feedback-icon {
      margin-left: 15px;
      font-size: 22px;
      flex-shrink: 0;
    }

    .mcq-quiz-feedback-icon.correct {
      color: #4CAF50;
    }

    .mcq-quiz-feedback-icon.incorrect {
      color: #F44336;
    }

    .mcq-quiz-footer {
      padding: 18px 25px;
      background-color: #1e1c2b;
      border-top: 1px solid #2c2a3f;
      text-align: right;
      flex-shrink: 0;
    }

    .mcq-quiz-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 18px 25px;
      background-color: #1e1c2b;
      border-bottom: 1px solid #2c2a3f;
      flex-shrink: 0;

    }

    .mcq-quiz-header-actions {
      display: flex;
      align-items: center;
      gap: 15px;
    }


    .mcq-quiz-header-title {
      font-size: 1.25em;
      font-weight: 600;
      color: #e0e0e5;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }


    .mcq-quiz-highlights {
      text-align: left;
      margin-bottom: 30px;
      background-color: rgba(255, 255, 255, 0.03);
      padding: 20px;
      border-radius: 10px;
      border: 1px solid #302e45;
    }

    .mcq-quiz-highlights h3 {
      font-size: 1.5em;
      color: #c5bddd;
      margin-bottom: 18px;
      padding-bottom: 10px;
      border-bottom: 1px solid #3a3852;
    }

    .mcq-quiz-highlights li {
      font-size: 1.05em;
      color: #b0aac0;
      margin-bottom: 14px;
      line-height: 1.65;
      padding-left: 28px;
      position: relative;
    }

    .mcq-quiz-highlights li::before {
      content: '•';
      color: #a18cd1;
      font-size: 1.6em;
      position: absolute;
      left: 0;
      top: 0px;
    }

    .mcq-quiz-highlights li math-field {
      display: inline-block;
    }

    .mcq-quiz-highlights ul {
      list-style: none;
      padding-left: 0;
    }

     .mcq-quiz-hint-area {
      margin-top: 20px;
      font-size: 0.95em;
    }

    .mcq-quiz-hint-text {
      margin-top: 8px;
      padding: 10px 12px;
      background-color: rgba(255, 255, 255, 0.04);
      border-left: 3px solid #a18cd1;
      border-radius: 0 6px 6px 0;
      color: #b0a8c9;
      line-height: 1.5;
      display: none;
    }

    .mcq-quiz-hint-text.visible {
      display: block;
    }

    .mcq-quiz-next-btn {
      padding: 12px 30px;
      font-size: 1.05em;
      font-weight: 600;
      background-color: #3a5cad;
      border: 1px solid #5c7bc9;
      color: #fff;
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.2s ease;
    }


    .mcq-quiz-next-btn:disabled {
      background-color: #33394a;
      border-color: #45495a;
      color: #787c8f;
      cursor: not-allowed;
    }

    .mcq-quiz-next-btn:hover:not(:disabled) {
      background-color: #4e6dbd;
      border-color: #7a9ae0;
      transform: translateY(-1px);
    }


    .mcq-quiz-open-btn {
      display: block;
      width: 100%;
      padding: 12px;
      font-size: 1.0em;
      font-weight: 600;
      color: #FFFFFF;
      background: linear-gradient(135deg, #6a5acd, #836fff);
      border: none;
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.25s ease;
      box-shadow: 0 3px 10px rgba(106, 90, 205, 0.3);
    }

    .mcq-quiz-open-btn.generating {
      background: linear-gradient(135deg, #4a4380, #5a4ea2);
      cursor: wait;
    }

    .mcq-quiz-open-btn:not(.generating):hover {
      background: linear-gradient(135deg, #7b68ee, #937eff);
      transform: translateY(-2px);
      box-shadow: 0 5px 15px rgba(106, 90, 205, 0.4);
    }

    .mcq-quiz-option {
      background-color: #25233a;
      border: 1.5px solid #3a3852;
      border-radius: 10px;
      padding: 15px 18px;
      cursor: pointer;
      transition: all 0.2s ease-out;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      color: #d0c8e8;
      font-size: 1.05em;
      position: relative;
    }


     .mcq-quiz-option-feedback {
      font-size: 0.9em;
      line-height: 1.5;
      padding: 10px 0 5px 40px;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      margin-top: 10px;
      width: calc(100% - 40px);
      opacity: 0;
      max-height: 0;
      overflow: hidden;
      transition: opacity 0.3s ease-out, max-height 0.35s ease-out, padding-top 0.3s ease-out, margin-top 0.3s ease-out;
    }

    .mcq-quiz-option-letter {
      font-weight: 600;
      margin-right: 12px;
      color: #9e98b3;
      border: 1px solid #555270;
      border-radius: 6px;
      width: 28px;
      height: 28px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .mcq-quiz-option-main-content {
      display: flex;
      align-items: center;
      width: 100%;
    }

    .mcq-quiz-option-text {
      flex-grow: 1;
      line-height: 1.5;
    }

    .mcq-quiz-option-text p {
      margin: 0;
    }

    .mcq-quiz-option-text math-field {
      display: inline-block;
    }


    .mcq-quiz-option.correct {
      border-color: #4CAF50;
      background-color: rgba(76, 175, 80, 0.1);
      color: #a5d6a7;
    }

     .mcq-quiz-option.correct .katex {
    /* A brighter, more vibrant green for the math to stand out */
    color: #c8e6c9 !important; 
}

.mcq-quiz-option.correct .mcq-quiz-option-letter {
      color: #4CAF50;
      border-color: #4CAF50;
    }

    
    .mcq-quiz-option.correct.expanded .mcq-quiz-option-feedback {
      color: #a5d6a7;
      border-top-color: rgba(76, 175, 80, 0.2);
    }

    .mcq-quiz-option.disabled {
      opacity: 0.7;
      cursor: default;
    }

    .mcq-quiz-option.expanded .mcq-quiz-feedback-icon {
      display: none;
    }

    .mcq-quiz-option.expanded .mcq-quiz-option-feedback {
      opacity: 1;
      max-height: 250px;
      padding-top: 10px;
      margin-top: 10px;
    }

    .mcq-quiz-option.incorrect {
      border-color: #F44336;
      background-color: rgba(244, 67, 54, 0.1);
      color: #ef9a9a;
    }


    /* When an option is marked incorrect, target the KaTeX math inside */
.mcq-quiz-option.incorrect .katex {
    /* A brighter, more vibrant red/pink for the math to stand out */
    color: #ffcdd2 !important; 
}

.mcq-quiz-option.incorrect.expanded .mcq-quiz-option-feedback {
      color: #ef9a9a;
      border-top-color: rgba(244, 67, 54, 0.2);
    }

    .mcq-quiz-option.incorrect.selected .mcq-quiz-option-letter {
      color: #F44336;
      border-color: #F44336;
    }


.mcq-quiz-option.selected {
      border-color: #8a63d2;
      background-color: #3a305a;
    }

    .mcq-quiz-option:hover:not(.disabled):not(.selected):not(.correct):not(.incorrect) {
      background-color: #302e45;
      border-color: #555270;
      transform: translateX(3px);
    }

     .mcq-quiz-options {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .mcq-quiz-prompt-container {
      background-color: #2c2c3e;
      border: 1px solid #4a4a5e;
      border-radius: 12px;
      padding: 18px 20px;
      margin-top: 15px;
      max-width: 400px;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
      text-align: left;
    }

    .mcq-quiz-question-counter {
      font-size: 0.9em;
      color: #8a81a8;
      margin-bottom: 8px;
      font-weight: 500;
    }

    .mcq-quiz-question-text {
      font-size: 1.2em;
      color: #e0e0e5;
      line-height: 1.6;
      margin-bottom: 25px;
    }

    .mcq-quiz-question-text .inline-math math-field {
      display: inline-block;
    }

    .mcq-quiz-question-wrapper {
      width: 100%;
      max-width: 700px;
      margin-bottom: 30px;
    }

    

    .mcq-quiz-question-text p {
      margin: 0 0 10px 0;
    }

    .mcq-quiz-question-text math-field {
      margin: 5px 0;
      display: block;
    }

     .mcq-quiz-score-summary {
      display: flex;
      justify-content: space-around;
      align-items: stretch;
      gap: 20px;
      margin-bottom: 35px;
      flex-wrap: wrap;
    }


 .mcq-quiz-show-hint-btn {
      color: #a18cd1;
      cursor: pointer;
      text-decoration: none;
      font-weight: 500;
      display: inline-flex;
      align-items: center;
      gap: 5px;
    }

    .mcq-quiz-show-hint-btn i {
      transition: transform 0.2s ease;
    }

    .mcq-quiz-show-hint-btn.open i {
      transform: rotate(90deg);
    }


    .mcq-quiz-summary-card {
      background-color: #25233a;
      border: 1px solid #3a3852;
      border-radius: 12px;
      padding: 20px 25px;
      flex-basis: 220px;
      flex-grow: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      min-height: 130px;
    }

    .mcq-quiz-summary-card .label {
      font-size: 1em;
      color: #908aab;
      margin-bottom: 10px;
    }

    .mcq-quiz-summary-card .value {
      font-size: 2.5em;
      font-weight: 700;
      color: #e0e0e5;
    }

    .mcq-quiz-summary-card .sub-value {
      font-size: 0.85em;
      color: #7a7593;
      margin-top: 8px;
    }



/* Notebook / Demo / Misc Tools */
.notebook-error {
      color: red;
      border: 1px dashed red;
      padding: 5px;
      margin: 5px 0;
      font-family: sans-serif;
      font-size: 0.8em;
      line-height: 1.4;
      background-color: #ffeeee;
    }


    .notebook-explanation {
  /* Let the explanation take up the remaining flexible space */
  flex-basis: 45%;
  flex-grow: 1;

  padding-left: 15px;
  box-sizing: border-box;
  word-wrap: break-word;
  padding-top: 0.1em;
  line-height: 1.3;
}

/* Explanation Area (.notebook-explanation) */
.notebook-explanation .katex {
    /* Request 2: Make inline math smaller to match text */
    font-size: 0.9em; /* Slightly smaller than the surrounding text for better integration */
    vertical-align: -0.1em; /* Fine-tune vertical alignment */
}


/* This targets the math text itself, ensuring it uses the correct color */
.notebook-explanation math-field[read-only] {
    color: #2a52be;
    vertical-align: -0.1em; /* Keep the vertical alignment tweak */
}



/* In voice.html, inside the main <style> tag */
.notebook-loader .inline-loader-text {
    font-style: italic;
}


.notebook-math {
  /* REMOVED flex properties */
  padding-right: 15px;
  box-sizing: border-box;
  border-right: 1px dashed #d0d0d0;
  min-height: 1.5em;
  display: flex; /* Kept flex here to align the step number and math */
  align-items: flex-start;
  gap: 8px;
  overflow-x: auto; /* A failsafe for EXTREMELY long equations */
  
  /* --- NEW & CRUCIAL --- */
  /* This column is now the container we will query */
  container-type: inline-size;
  container-name: math-col;
}

/* Main Math Area (.notebook-math) */
.notebook-math .katex-display {
    /* FIX: Significantly reduce font size for better balance */
    font-size: 0.75em; 
    margin: 0;
    padding: 0.2em 0;
}

.notebook-math .katex {
    /* Request 1: Change color to graphite */
    color: #4a4a4a; /* A nice, dark graphite gray */
}



 .notebook-math .step-number {
      font-weight: bold;
      color: #555;
      font-size: 0.85em;
      min-width: 20px;
      text-align: right;
      padding-top: 0.1em;
      line-height: 1.1;
      flex-shrink: 0;
    }



  .notebook-math math-field[read-only] {
  background-color: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  vertical-align: top;
  /* Prevent shrinking and allow it to grow to its content's width */
  flex-grow: 0;
  flex-shrink: 0;
  width: max-content;

  font-size: 1em;
  color: #666666;

  font-family: initial;
  line-height: initial;
}

.notebook-math::-webkit-scrollbar {
    height: 8px;
}

.notebook-math::-webkit-scrollbar-thumb {
    background-color: #d6d6d6;
    border-radius: 4px;
    border: 2px solid #f1f1f1;
    background-clip: content-box;
}

.notebook-math::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8;
}

.notebook-math::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.notebook-paper {
      background-color: #fdfdfd;
      border: 1px solid #e0e0e0;
      border-radius: 5px;
      padding: 15px 15px 15px 45px;
      margin: 15px 0;
      position: relative;
      box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
      max-width: 100%;
      width: auto;
      box-sizing: border-box;

      background-image: linear-gradient(#cee7f8 1px, transparent 1px);
      background-size: 100% 1.8em;
      line-height: 1.8em;

      font-family: 'Caveat', cursive;
      font-size: 1.25em;
      color: #2a52be;
    }

    .notebook-paper::before {
      content: '';
      position: absolute;
      top: 0;
      left: 35px;
      bottom: 0;
      width: 1px;
      background-color: #ffaaaa;
    }

    .notebook-row {
  /* SWITCHING to a more stable CSS Grid layout for the columns */
  display: grid;
  grid-template-columns: 55% 1fr; /* 55% for math, the rest for explanation */
  align-items: start; /* Align items to the top */
  
  padding-bottom: 0.4em;
  margin-bottom: 0.4em;
  min-height: 1.8em;
  position: relative;
  /* We are REMOVING the container properties from the row */
}

.demo-code {
      border: 1px solid #444;
      border-radius: 8px;
      padding: 0;
      margin-top: 10px;
      margin-bottom: 20px;
      position: relative;
      width: 400px;
      height: 400px;
      display: flex;
      justify-content: center;
      align-items: center;
      tabindex: 0;
      overflow: hidden;
      background-color: #1e1e1e;
    }

    .demo-code iframe.demo-code-frame {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: none;
    }

    .demo-expand-icon,
    .demo-retract-icon {
      position: absolute;
      top: 8px;
      right: 8px;
      font-size: 22px;
      color: #aaa;
      background-color: rgba(30, 30, 30, 0.7);
      border-radius: 4px;
      padding: 3px;
      cursor: pointer;
      transition: color 0.2s ease;
      z-index: 10;
    }

    .demo-expand-icon:hover,
    .demo-retract-icon:hover {
      color: #eee;
    }


    .demo-expanded-message {
      border: 1px dashed #444;
      border-radius: 8px;
      padding: 15px;
      margin-top: 10px;
      margin-left: 20px;
      width: 400px;
      height: 400px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      text-align: center;
      color: #888;
      font-style: italic;
      position: relative;
      box-sizing: border-box;
    }

    .demo-expanded-message .demo-retract-icon {
      top: 8px;
      right: 8px;
    }


    .demo-experimental-text {
      font-size: 11px;
      color: #888;
      text-align: center;
      margin-top: 5px;
      margin-left: 20px;
      width: 400px;
    }

    .demo-progress-bar {
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, #a18cd1 0%, #fbc2eb 100%);
      border-radius: 4px;
    }

    .demo-progress-container {
      width: 90%;
      max-width: 400px;
      margin: 20px auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
    }

    .demo-progress-text {
      font-size: 14px;
      color: #b5a7d8;
      font-weight: 500;
      margin-bottom: 5px;
      min-height: 1.2em;
    }


      .demo-progress-track {
      width: 100%;
      height: 8px;
      background-color: rgba(255, 255, 255, 0.15);
      border-radius: 4px;
      overflow: hidden;
    }

    .demo-prompt-btn {
      height: 30px;
      width: 80px;
      border: 1px solid #666;
      background-color: #333;
      color: #eee;
      border-radius: 5px;
      cursor: pointer;
      font-size: 14px;
      transition: background-color 0.2s ease, transform 0.1s ease;
    }

    .demo-prompt-btn:hover {
      background-color: #444;
      transform: scale(1.03);
    }

    .demo-prompt-btn.yes:hover {
      background-color: #4CAF50;
      border-color: #4CAF50;
    }

    .demo-prompt-btn.no:hover {
      background-color: #f44336;
      border-color: #f44336;
    }

    .demo-prompt-buttons {
      display: flex;
      justify-content: center;
      gap: 15px;
    }

    .demo-prompt-container {
      border: 1px solid #444;
      border-radius: 8px;
      padding: 15px;
      margin-top: 10px;
      margin-bottom: 20px;
      background: rgba(255, 255, 255, 0.05);
      width: calc(100%);
      max-width: 400px;
      box-sizing: border-box;
    }

    .demo-prompt-text {
      color: #ccc;
      margin-bottom: 12px;
      text-align: center;
    }


      .styled-action-container {
  background-color: #2c2c3e;
  border: 1px solid #4a4a5e;
  border-radius: 8px;
  padding: 20px;
  margin-top: 15px;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}

 .practice-test-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 10px 20px;
      margin-top: 15px;
      margin-bottom: 5px;
      font-size: 15px;
      font-weight: 600;
      color: #e0e0e0;
      background: linear-gradient(145deg, #6a0dad, #a18cd1);
      border: 1px solid #c3aed9;
      border-radius: 25px;
      cursor: pointer;
      transition: all 0.3s ease;
      box-shadow: 0 3px 8px rgba(106, 13, 173, 0.3);
      gap: 8px;
      min-width: 200px;
      text-align: center;
    }


    .practice-test-button i {
      font-size: 1.2em;
    }


     .practice-test-button.error {
      background: linear-gradient(145deg, #ef5350, #e57373);
      border-color: #ffcdd2;
      color: #ffffff;
      box-shadow: 0 3px 8px rgba(239, 83, 80, 0.4);
    }



        .practice-test-button.error i.bx-error-circle {}


        .practice-test-button.error:hover:not(:disabled) {
      background: linear-gradient(145deg, #ff8a80, #ffab91);
      box-shadow: 0 5px 15px rgba(239, 83, 80, 0.6);
      border-color: #ffcdd2;
    }

    .practice-test-button.loading {
      background: linear-gradient(145deg, #5a0b9d, #8a6db1);
    }

    .practice-test-button.loading .bx-loader-alt {
      display: inline-block;
      animation: spin 1s linear infinite;
    }

        .practice-test-button.loading span {}


 .practice-test-button.ready {
      background: linear-gradient(145deg, #80cbc4, #4db6ac);
      border-color: #a7ffeb;
      color: #004d40;
      box-shadow: 0 3px 8px rgba(77, 182, 172, 0.4);
    }

        .practice-test-button.ready i.bxs-flask {}


    .practice-test-button.ready:hover:not(:disabled) {
      background: linear-gradient(145deg, #a7ffeb, #64ffda);
      box-shadow: 0 5px 15px rgba(77, 182, 172, 0.6);
      color: #004d40;
      border-color: #b2fef7;
    }
    
     .practice-test-button:disabled {
      cursor: not-allowed;
      opacity: 0.7;
      box-shadow: none;
      transform: none;
    }


    .practice-test-button:hover:not(:disabled) {
      background: linear-gradient(145deg, #7e1cc7, #b39ddb);
      box-shadow: 0 5px 15px rgba(106, 13, 173, 0.5);
      transform: translateY(-2px) scale(1.02);
      color: #ffffff;
      border-color: #d8b4fe;
    }

    .practice-test-button:not(.loading) .bx-loader-alt {
      display: none;
    }


    .practice-test-prompt .demo-prompt-text {
      color: #e0e0e0;
      margin-bottom: 0;
    }

    .practice-test-prompt .practice-test-button {
      margin-top: 0;
    }

    .practice-test-prompt.demo-prompt-container {
      background: rgba(106, 13, 173, 0.08);
      border-color: rgba(161, 140, 209, 0.3);
      padding: 15px;
    }

    .youtube-embed {
      margin: 10px 0 10px 0;
      position: relative;
      width: 100%;
      max-width: 500px;
      border-radius: 8px;
      overflow: hidden;
      background-color: #000;
    }

    .youtube-embed iframe {
      display: block;
      width: 100%;
      aspect-ratio: 16 / 9;
      border: none;
    }

    











































































































































































    
















































































