/* Base Styles */
      * { margin: 0; padding: 0; box-sizing: border-box; }
      html, body {
        height: 100%;
        overflow: hidden;
      }
      body {
        font-family: Arial, sans-serif;
        background: #f5f5f5;
        font-size: 14px;
        line-height: 1.5;
        display: flex;
        flex-direction: column;
      }

      /* Header Bar - Compact single line */
      .header {
        background: white;
        color: #3B82F6;
        padding: 8px 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
        border-bottom: 10px solid #3B82F6;
      }
      .header-left {
        display: flex;
        align-items: center;
        gap: 12px;
      }
      .aistellor-logo {
        height: 22px;
      }
      .header-logo {
        height: 50px;
        width: auto;
        margin-top: 8px;
      }
      .header-right {
        display: flex;
        align-items: center;
        gap: 10px;
      }
      .header h1 {
        margin: 0;
        margin-top: 4px;
        font-size: 33px;
        font-style: normal;
        color: #B91C1C;
      }
      .header h1 em {
        font-style: italic;
      }
      .header h2 {
        margin: 0;
        margin-top: 4px;
        font-size: 19px;
        font-weight: normal;
        color: #3B82F6;
        opacity: 0.9;
      }
      .header-divider {
        opacity: 0.5;
        font-size: 30px;
        color: #3B82F6;
        margin-top: 4px;
      }

      /* Exit Demo Button */
      .exit-demo-button {
        width: 32px;
        height: 32px;
        background: transparent;
        border: 2px solid #3B82F6;
        color: #3B82F6;
        font-size: 18px;
        cursor: pointer;
        border-radius: 4px;
        transition: all 0.3s;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 10px;
      }
      .exit-demo-button:hover {
        background: rgba(44, 90, 160, 0.1);
      }
      .exit-demo-button:active {
        transform: scale(0.95);
      }

      /* Status Indicators in Header */
      .cache-indicator {
        background: rgba(59, 130, 246, 0.1);
        border: 1px solid rgba(59, 130, 246, 0.3);
        border-radius: 6px;
        padding: 6px 15px;
        font-size: 16px;
        font-weight: bold;
        display: flex;
        align-items: center;
        gap: 8px;
        color: #3B82F6;
      }

      .cache-indicator .status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #ccc;
      }

      .cache-indicator.off .status-dot {
        background: #999;
      }

      .cache-indicator.establishing .status-dot {
        background: #ff9800;
        animation: pulse 1.5s infinite;
      }

      .cache-indicator.active .status-dot {
        background: #4caf50;
      }

      .cache-indicator.refreshing .status-dot {
        background: #2196f3;
        animation: pulse 1s infinite;
      }

      .cache-indicator.error .status-dot {
        background: #f44336;
      }

      @keyframes pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.5; }
      }

      .cache-indicator .status-text {
        flex: 1;
      }

      .cache-indicator .token-count {
        color: rgba(59, 130, 246, 0.7);
        font-size: 10px;
        margin-left: 4px;
      }

      /* Model Identity Display */
      .model-identity {
        background: rgba(59, 130, 246, 0.1);
        border: 1px solid rgba(59, 130, 246, 0.3);
        border-radius: 6px;
        padding: 6px 15px;
        font-size: 16px;
        color: #3B82F6;
        max-width: 200px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .model-identity .label {
        font-weight: bold;
        margin-right: 4px;
      }

      /* Main Two-Column Layout */
      .main-layout {
        flex: 1;
        display: flex;
        overflow: hidden;
        padding: 10px;
        gap: 10px;
      }

      /* Left Panel - Clinical Notes (50% width) */
      .left-panel {
        flex: 0 0 50%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }

      /* Right Panel - Controls (50% width) */
      .right-panel {
        flex: 0 0 50%;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        gap: 10px;
      }

      /* Card Components */
      .card {
        background: white;
        border-radius: 8px;
        padding: 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        display: flex;
        flex-direction: column;
      }

      /* Clinical card fills left panel */
      .clinical-card {
        flex: 1;
        min-height: 0;
        margin: 0;
      }

      /* Control label */
      .control-label {
        display: block;
        margin-bottom: 8px;
        font-weight: bold;
        color: #1e3d6f;
        font-size: 21px;
      }

      /* Input Section */
      .input-section {
        position: relative;
        display: flex;
        flex-direction: column;
        height: 100%;
      }
      .clinical-notes-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
      }
      .clinical-notes-header label {
        font-weight: bold;
        color: #1e3d6f;
        font-size: 18px;
        margin: 0;
      }
      .edit-toggle-btn {
        padding: 4px 10px;
        font-size: 13px;
        background: #f0f4f8;
        border: 1px solid #ccd;
        border-radius: 4px;
        cursor: pointer;
        color: #1e3d6f;
        transition: background 0.2s;
      }
      .edit-toggle-btn:hover {
        background: #e0e8f0;
      }
      .edit-toggle-btn.editing {
        background: #3B82F6;
        color: white;
        border-color: #3B82F6;
      }

      /* Case Metadata Panel */
      .case-metadata-panel {
        background: #f8f9fa;
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 12px;
        margin-top: 12px;
      }
      .metadata-row {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
      }
      .metadata-row label {
        min-width: 70px;
        font-weight: bold;
        color: #1e3d6f;
        font-size: 13px;
      }
      .metadata-row input[type="text"] {
        flex: 1;
        padding: 6px 10px;
        border: 1px solid #ccc;
        border-radius: 4px;
        font-size: 13px;
      }
      .metadata-row textarea {
        flex: 1;
        padding: 6px 10px;
        border: 1px solid #ccc;
        border-radius: 4px;
        font-size: 13px;
        font-family: Arial, sans-serif;
        resize: vertical;
      }
      .metadata-row select {
        padding: 6px 10px;
        border: 1px solid #ccc;
        border-radius: 4px;
        font-size: 13px;
        background: white;
      }
      .metadata-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid #ddd;
      }
      .metadata-btn {
        padding: 6px 14px;
        font-size: 13px;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        transition: background 0.2s;
      }
      .metadata-btn.save-btn {
        background: #3B82F6;
        color: white;
      }
      .metadata-btn.save-btn:hover {
        background: #1e4080;
      }
      .metadata-btn.add-btn {
        background: #28a745;
        color: white;
      }
      .metadata-btn.add-btn:hover {
        background: #218838;
      }
      .metadata-btn.delete-btn {
        background: #dc3545;
        color: white;
      }
      .metadata-btn.delete-btn:hover {
        background: #c82333;
      }

      .input-section label {
        display: block;
        margin-bottom: 8px;
        font-weight: bold;
        color: #1e3d6f;
        font-size: 18px;
      }
      .input-section textarea {
        width: 100%;
        flex: 1;
        padding: 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        resize: none;
        font-family: Arial, sans-serif;
        font-size: 17px;
        transition: border-color 0.3s, box-shadow 0.3s;
      }
      .input-section textarea:focus {
        outline: none;
        border-color: #3B82F6;
        box-shadow: 0 0 0 2px rgba(44, 90, 160, 0.1);
      }

      /* Clinical notes markdown display */
      .clinical-notes-display {
        width: 100%;
        flex: 1;
        padding: 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-family: Arial, sans-serif;
        font-size: 15px;
        background: #fff;
        color: #333;
        overflow-y: auto;
        line-height: 1.5;
      }
      .clinical-notes-display h1,
      .clinical-notes-display h2,
      .clinical-notes-display h3,
      .clinical-notes-display h4 {
        margin-top: 12px;
        margin-bottom: 8px;
        color: #1e3d6f;
      }
      .clinical-notes-display h1 { font-size: 1.4em; }
      .clinical-notes-display h2 { font-size: 1.25em; }
      .clinical-notes-display h3 { font-size: 1.1em; }
      .clinical-notes-display h4 { font-size: 1em; }
      .clinical-notes-display p {
        margin-bottom: 8px;
      }
      .clinical-notes-display ul,
      .clinical-notes-display ol {
        margin-left: 20px;
        margin-bottom: 8px;
      }
      .clinical-notes-display li {
        margin-bottom: 4px;
      }
      .clinical-notes-display strong {
        font-weight: bold;
      }
      .clinical-notes-display em {
        font-style: italic;
      }

      /* Select in right panel */
      .right-panel select {
        width: 100%;
        padding: 10px;
        border: 1px solid #ddd;
        border-radius: 4px;
        background: white;
        cursor: pointer;
      }
      .right-panel select:focus {
        outline: none;
        border-color: #3B82F6;
      }

      /* Case filter row */
      .case-filter-row {
        display: flex;
        gap: 10px;
        align-items: center;
      }
      .case-filter {
        flex: 0 0 130px;
      }
      .case-select {
        flex: 1;
        font-size: 17px;
      }
      .copy-case-btn {
        flex: 0 0 32px;
        height: 32px;
        padding: 0;
        font-size: 16px;
        background: #f0f0f0;
        border: 1px solid #ccc;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.2s;
      }
      .copy-case-btn:hover {
        background: #e0e0e0;
      }
      .copy-case-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
      }
      .copy-case-btn.copied {
        background: #4caf50;
        color: white;
        border-color: #4caf50;
      }
      .case-footnote {
        margin-top: 8px;
        font-size: 13px;
        color: #666;
        font-style: italic;
      }

      /* Batch Buttons */
      .batch-buttons {
        display: flex;
        gap: 8px;
        margin-top: 10px;
        align-items: center;
      }
      .batch-btn {
        padding: 6px 12px;
        font-size: 12px;
        background: #5c6bc0;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        transition: background 0.2s;
      }
      .batch-btn:hover {
        background: #3f51b5;
      }
      .batch-btn:disabled {
        background: #9e9e9e;
        cursor: not-allowed;
      }
      .batch-progress {
        font-size: 12px;
        color: #666;
        margin-left: 8px;
      }

      /* Summary card and content */
      .summary-card {
        min-height: 100px;
      }
      .summary-content {
        width: 100%;
        min-height: 60px;
        max-height: 300px;
        overflow-y: auto;
        padding: 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-family: Arial, sans-serif;
        font-size: 15px;
        background: #f8f9fa;
        color: #333;
        line-height: 1.5;
      }
      .summary-content .placeholder-text {
        color: #999;
        font-style: italic;
        margin: 0;
      }

      /* Markdown body styles */
      .markdown-body h1, .markdown-body h2, .markdown-body h3 {
        margin-top: 12px;
        margin-bottom: 8px;
        font-weight: bold;
        color: #1e3d6f;
      }
      .markdown-body h1 { font-size: 1.4em; }
      .markdown-body h2 { font-size: 1.2em; }
      .markdown-body h3 { font-size: 1.1em; }
      .markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body h3:first-child {
        margin-top: 0;
      }
      .markdown-body p {
        margin: 8px 0;
      }
      .markdown-body ul, .markdown-body ol {
        margin: 8px 0;
        padding-left: 24px;
      }
      .markdown-body li {
        margin: 4px 0;
      }
      .markdown-body strong {
        font-weight: bold;
      }
      .markdown-body em {
        font-style: italic;
      }
      .markdown-body hr {
        border: none;
        border-top: 1px solid #ddd;
        margin: 12px 0;
      }
      .markdown-body code {
        background: #e9ecef;
        padding: 2px 4px;
        border-radius: 3px;
        font-family: monospace;
        font-size: 0.9em;
      }
      .markdown-body pre {
        background: #e9ecef;
        padding: 10px;
        border-radius: 4px;
        overflow-x: auto;
      }
      .markdown-body pre code {
        background: none;
        padding: 0;
      }
      .markdown-body blockquote {
        border-left: 3px solid #3B82F6;
        margin: 8px 0;
        padding-left: 12px;
        color: #555;
      }
      
      /* SENT Indicator */
      .sent-indicator {
        position: absolute;
        bottom: 10px;
        right: 20px;
        padding: 5px 10px;
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid #d32f2f;
        color: #d32f2f;
        border-radius: 4px;
        font-weight: bold;
        animation: fadeIn 0.3s ease-out;
      }
      @keyframes fadeIn {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
      }
      
      /* AI Settings Row */
      .ai-settings-row {
        display: flex;
        align-items: center;
        gap: 15px;
        flex-wrap: wrap;
      }
      .ai-settings-row .ai-config-button {
        flex-shrink: 0;
      }
      .system-lane-label {
        display: flex;
        align-items: center;
        gap: 6px;
        cursor: pointer;
        font-weight: bold;
        color: #333;
        margin: 0;
        white-space: nowrap;
      }
      .system-lane-label input[type="checkbox"] {
        margin: 0;
        transform: scale(1.2);
      }
      .clear-alerts-btn {
        padding: 2px 8px;
        font-size: 12px;
        margin-left: 8px;
        background: white;
        color: black;
        border: 1px solid #ccc;
        cursor: pointer;
        border-radius: 3px;
      }
      .clear-alerts-btn:hover {
        background: #f0f0f0;
      }
      .clear-alerts-btn:active {
        background: #d0d0d0;
        transform: translateY(1px);
        box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
      }
      .reasoning-inline {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 10px;
        background: #e3f2fd;
        border-radius: 4px;
        border: 1px solid #90caf9;
      }
      .reasoning-inline.hidden {
        display: none;
      }
      .reasoning-inline label {
        font-weight: bold;
        color: #333;
        margin: 0;
        white-space: nowrap;
      }
      .reasoning-inline select {
        padding: 4px 8px;
        border: 1px solid #90caf9;
        border-radius: 4px;
        background: white;
        cursor: pointer;
        font-size: 14px;
      }
      .reasoning-inline select:focus {
        outline: none;
        border-color: #2196f3;
      }
      
      /* Button Caption */
      .button-caption {
        font-size: 13px;
        color: #666;
        margin: 0 0 12px 0;
        font-style: italic;
      }

      /* Button Row */
      .button-row {
        display: flex;
        gap: 15px;
        margin-top: 20px;
        flex-wrap: wrap;
      }
      
      /* Event Buttons */
      .event-button {
        flex: 1;
        min-width: 140px;
        padding: 15px 30px;
        background: #3B82F6;
        color: white;
        border: none;
        border-radius: 4px;
        font-size: 16px;
        cursor: pointer;
        transition: background 0.3s;
      }
      .event-button:hover:not(:disabled) {
        background: #2563EB;
      }
      .event-button.info-only {
        background: #60A5FA;
      }
      .event-button.info-only:hover:not(:disabled) {
        background: #3B82F6;
      }
      .event-button:disabled {
        background: #ccc;
        cursor: not-allowed;
        opacity: 0.6;
      }
      
      /* AI Config Button */
      .ai-config-button {
        padding: 15px 30px;
        background: #3B82F6;
        color: white;
        border: none;
        border-radius: 4px;
        font-size: 16px;
        cursor: pointer;
        transition: background 0.3s;
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 150px;  /* Ensure enough width for "Choose AI" without wrapping */
        white-space: nowrap;  /* Prevent text wrapping */
        justify-content: center;
      }
      .ai-config-button:hover {
        background: #1565c0;
      }
      .gear-icon {
        font-size: 18px;
      }
      
      /* Alert Indicator Button - Square button with fixed width */
      .event-button.alert-indicator {
        flex: 0 0 60px !important;  /* Fixed width for square button */
        min-width: 60px !important;
        max-width: 60px !important;
        padding: 15px 0 !important;  /* Same vertical padding, no horizontal */
        background: white !important;
        color: black !important;
        border: 2px solid transparent !important;
        box-shadow: none !important;
        font-weight: normal !important;
        text-align: center !important;
      }

      /* Alert Indicator default state - grey when no alert active */
      .event-button.alert-indicator.alert-default {
        background: #666666 !important;  /* Grey when no alert active */
        color: white !important;
        border: 2px solid #666666 !important;
        box-shadow: none !important;
        pointer-events: auto !important;
        cursor: default !important;  /* Remove pointer cursor */
      }

      /* Only show design when button is empty (no text content) */
      .event-button.alert-indicator.alert-default:empty::before {
        content: "◯";  /* Circle design - only appears when button has no text */
        font-size: 20px;
        color: white;
      }

      /* Prevent hover effects on alert indicator */
      .event-button.alert-indicator.alert-default:hover {
        background: #666666 !important;
        border: 2px solid #666666 !important;
      }

      /* Disable active/click effect for default state */
      .event-button.alert-indicator.alert-default:active {
        background: #666666 !important;  /* Keep same color on click */
        transform: none !important;  /* Prevent any click animation */
        box-shadow: none !important;  /* Prevent any shadow changes */
      }

      /* Alert Indicator when alert is pending - turns red */
      .event-button.alert-indicator.alert-pending {
        background: #ff0000 !important;
        color: white !important;
        border: 2px solid #ff0000 !important;
        font-weight: bold !important;
        box-shadow: 0 2px 8px rgba(255,0,0,0.3) !important;
        animation: alertPulse 1s infinite;
      }
      
      /* Alert Indicator for medium severity - turns orange */
      .event-button.alert-indicator.alert-medium {
        background: #f57c00 !important;
        color: white !important;
        border: 2px solid #f57c00 !important;
        font-weight: bold !important;
        box-shadow: 0 2px 8px rgba(245,124,0,0.3) !important;
        animation: alertPulse 1s infinite;
      }
      
      /* Alert Indicator for low severity - turns blue */
      .event-button.alert-indicator.alert-low {
        background: #0066cc !important;
        color: white !important;
        border: 2px solid #0066cc !important;
        font-weight: bold !important;
        box-shadow: 0 2px 8px rgba(0,102,204,0.3) !important;
        animation: alertPulse 1s infinite;
      }

      /* Alert Indicator for error/timeout - turns gray */
      .event-button.alert-indicator.alert-error {
        background: #666666 !important;
        color: white !important;
        border: 2px solid #666666 !important;
        font-weight: bold !important;
        box-shadow: 0 2px 8px rgba(102,102,102,0.3) !important;
      }

      @keyframes alertPulse {
        0% { opacity: 1; }
        50% { opacity: 0.7; }
        100% { opacity: 1; }
      }
      
      /* Dialog Overlay */
      .dialog-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1000;
      }
      
      /* Dialog Base */
      .dialog {
        background: white;
        border-radius: 8px;
        max-width: 750px;
        width: 90%;
        max-height: 90vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
      }
      
      /* Analyzing Dialog Specific */
      .analyzing-dialog {
        padding: 40px;
        text-align: center;
      }
      .spinner {
        width: 50px;
        height: 50px;
        margin: 0 auto 20px;
        border: 3px solid #f3f3f3;
        border-top: 3px solid #3B82F6;
        border-radius: 50%;
        animation: spin 1s linear infinite;
      }
      @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
      }
      #timer {
        font-size: 24px;
        color: #3B82F6;
        margin-top: 10px;
      }
      
      /* Alert Dialog */
      .dialog-header {
        padding: 20px;
        color: white;
        font-size: 18px;
        font-weight: bold;
        position: relative;
      }
      .dialog-header.concern {
        background: #d32f2f;
      }
      .dialog-header.protocol {
        background: #1976d2;
      }
      .dialog-header.no-concern {
        background: #4caf50;
      }
      
      /* Retry indicator in header */
      .retry-indicator {
        position: absolute;
        top: 20px;
        right: 20px;
        background: rgba(255, 255, 255, 0.2);
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 13px;
        font-weight: normal;
      }
      
      .dialog-body {
        padding: 20px;
        overflow-y: auto;
        flex: 1;
      }
      
      .concern-text {
        background: #fff9c4;
        padding: 15px;
        border-radius: 4px;
        margin-bottom: 15px;
        font-size: 16px;
      }
      
      .discussion-text {
        background: #e3f2fd;
        padding: 15px;
        border-left: 4px solid #1976d2;
        margin-bottom: 15px;
      }
      
      /* Consider documenting label */
      .consider-label {
        font-size: 16px;
        font-weight: bold;
        color: #333;
      }
      
      /* Standalone consider label */
      .consider-label-standalone {
        margin-top: 25px;
        margin-bottom: 10px;
        font-size: 16px;
        font-weight: bold;
        color: #333;
      }
      
      /* Info buttons container */
      .info-buttons-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
        gap: 15px;
      }
      
      /* Wrapper for buttons */
      .buttons-wrapper {
        display: flex;
        gap: 10px;
        margin-left: auto;
      }
      
      .info-button {
        padding: 8px 16px;
        background: #4caf50;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.3s;
        font-size: 14px;
        font-weight: normal;
      }
      
      .info-button:hover:not(:disabled) {
        background: #45a049;
      }
      
      .info-button:disabled {
        background: #9e9e9e;
        cursor: not-allowed;
        opacity: 0.6;
      }
      
      .info-button:active:not(:disabled) {
        transform: scale(0.95);
      }
      
      /* Info content sections */
      .rules-content {
        background: #f9f9f9;
        padding: 15px;
        border-radius: 4px;
        margin-bottom: 15px;
        border: 1px solid #e0e0e0;
      }
      
      .notes-content {
        background: #fffef0;
        padding: 15px;
        border-radius: 4px;
        margin-bottom: 15px;
        border: 1px solid #e8e6d0;
        position: relative;
      }
      
      .copy-button {
        position: absolute;
        bottom: 10px;
        right: 10px;
        padding: 4px 8px;
        background: #4caf50;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 12px;
        transition: all 0.3s;
      }
      
      .copy-button:hover {
        background: #45a049;
      }
      
      .copy-button:active {
        transform: scale(0.95);
      }
      
      /* Two Column Layout for Items */
      .items-two-column-container {
        display: flex;
        gap: 20px;
      }
      
      .items-left-column {
        flex: 0 0 52%;
        min-width: 0;
      }
      
      .items-right-column {
        flex: 1;
        min-width: 0;
      }
      
      .section-title {
        font-weight: 700;
        font-size: 15px;
        margin-top: 20px;
        margin-bottom: 10px;
        color: #1e3d6f;
      }
      
      .section-title:first-child {
        margin-top: 0;
      }
      
      /* Section divider */
      .section-divider {
        border: 0;
        height: 1px;
        background: #e0e0e0;
        margin: 15px 0;
      }
      
      .item-row {
        display: flex;
        align-items: center;
        padding: 6px 0;
        gap: 10px;
      }
      
      /* Test items with buttons underneath */
      .test-item-row {
        margin-bottom: 12px;
        padding: 6px 0;
      }

      .test-item-text {
        margin-bottom: 6px;
        font-weight: normal;
        max-width: 35ch;
        width: 35ch;  /* Add explicit width to enforce the limit */
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        line-height: 1.4;
      }

      .test-answer-buttons {
        display: flex;
        gap: 2px;
        margin-left: 10px;  /* Smaller indent under the text */
        flex-wrap: wrap;  /* Allow wrapping if needed */
      }
      
      .test-answer-buttons .answer-button {
        padding: 4px 8px;
        font-size: 11px;
      }

      .item-text {
        flex: 0 1 auto;
        max-width: 20ch;  /* Reduced for narrower columns */
        word-wrap: break-word;  /* Allow wrapping between words */
        overflow-wrap: break-word;  /* Modern version of word-wrap */
        white-space: normal;  /* Allow text to wrap to multiple lines */
        line-height: 1.4;  /* Add some line spacing for wrapped text */
       }
      
      .answer-buttons {
        display: flex;
        gap: 5px;
      }
      
      .answer-button {
        padding: 5px 12px;
        border: 1px solid #ddd;
        background: white;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.3s;
        font-size: 13px;
      }
      .answer-button:hover {
        background: #f0f7ff;
      }
      .answer-button.selected {
        background: #3B82F6;
        color: white;
        border-color: #3B82F6;
      }
      
      .dialog-footer {
        padding: 20px;
        border-top: 1px solid #eee;
        display: flex;
        justify-content: flex-end;
        gap: 10px;
      }
      
      .dialog-footer button {
        padding: 10px 20px;
        border-radius: 4px;
        border: none;
        cursor: pointer;
        font-size: 14px;
        transition: opacity 0.3s;
      }
      .dialog-footer button.secondary {
        background: #757575;
        color: white;
      }
      .dialog-footer button.primary {
        background: #3B82F6;
        color: white;
      }
      .dialog-footer button:hover {
        opacity: 0.9;
      }
      
      /* Info Dialog Styling */
      .info-dialog {
        max-width: 500px;
        border-radius: 12px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.15);
        overflow: hidden;
      }
      .info-dialog .info-header {
        background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
        padding: 20px 24px;
        display: flex;
        align-items: center;
        gap: 12px;
      }
      .info-dialog .info-icon {
        font-size: 24px;
      }
      .info-dialog .info-body {
        padding: 24px;
        background: #fafafa;
      }
      .info-dialog .info-body p {
        margin: 0;
        font-size: 15px;
        line-height: 1.6;
        color: #333;
      }
      .info-dialog .info-body p + p {
        margin-top: 12px;
      }
      .info-dialog .info-body code {
        background: #e3f2fd;
        padding: 2px 6px;
        border-radius: 4px;
        font-family: 'Consolas', 'Monaco', monospace;
        font-size: 13px;
        color: #1565c0;
      }
      .info-dialog .dialog-footer {
        background: #fff;
        border-top: 1px solid #e0e0e0;
        padding: 16px 24px;
        justify-content: center;
      }
      .info-dialog .dialog-footer button.primary {
        min-width: 100px;
        padding: 10px 24px;
        font-size: 15px;
        font-weight: 500;
        border-radius: 6px;
      }

      /* AI Config Dialog */
      .config-dialog {
        max-width: 600px;
      }
      .config-dialog .dialog-header {
        background: #1976d2;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .ai-config-row {
        display: flex;
        gap: 15px;
        align-items: flex-end;
        margin-bottom: 12px;
      }
      .ai-config-row .form-group {
        margin-bottom: 0;
      }
      .close-button {
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        cursor: pointer;
        padding: 0;
        width: 30px;
        height: 30px;
      }
      .form-group {
        margin-bottom: 15px;
      }
      .form-group label {
        display: block;
        margin-bottom: 5px;
        font-weight: bold;
      }
      .form-group select,
      .form-group input {
        width: 100%;
        padding: 8px;
        border: 1px solid #ddd;
        border-radius: 4px;
      }

      /* ── Utility classes (CSP-safe replacements for inline styles) ── */
      .hidden { display: none !important; }
      .d-flex { display: flex !important; }
      .d-block { display: block !important; }
      .d-inline-block { display: inline-block !important; }

      .btn-disabled { opacity: 0.5; cursor: not-allowed; }
      .text-muted { color: #666; }
      .status-available { color: #4caf50; }
      .status-unavailable { color: #f44336; }
      .status-muted { color: #757575; }

      /* ── Modal overlay (shared by batch summary + iframe dialog) ── */
      .modal-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 10000;
      }
      .modal-dialog {
        background: white;
        padding: 30px;
        border-radius: 8px;
        text-align: center;
        min-width: 300px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
      }

      /* ── Iframe dialog (alert viewer) ── */
      .iframe-dialog-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 10000;
        pointer-events: none;
      }
      .iframe-dialog-container {
        background: white;
        width: 700px;
        height: 90vh;
        min-height: 400px;
        max-height: 90vh;
        border-radius: 4px;
        overflow: hidden;
        box-shadow: 0 10px 40px rgba(0,0,0,0.3);
        pointer-events: auto;
        position: relative;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
        border: 1px solid #d0d0d0;
        display: flex;
        flex-direction: column;
      }
      .iframe-dialog-frame {
        width: 100%;
        height: 100%;
        flex: 1;
        border: none;
        margin: 0;
        padding: 0;
        display: block;
      }

      /* ── Flash messages ── */
      .flash-message {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: #4caf50;
        color: white;
        padding: 20px 40px;
        border-radius: 8px;
        font-size: 16px;
        font-weight: bold;
        box-shadow: 0 4px 6px rgba(0,0,0,0.2);
        z-index: 10000;
        animation: flashFade 1s ease-out;
      }
      .flash-loading {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: #1976d2;
        color: white;
        padding: 8px 16px;
        border-radius: 4px;
        font-size: 13px;
        z-index: 10001;
      }

      /* ── Batch summary dialog (innerHTML) ── */
      .batch-summary-title {
        margin: 0 0 20px 0;
        color: #1e3d6f;
      }
      .batch-summary-stats {
        font-size: 18px;
        margin-bottom: 15px;
      }
      .batch-summary-detail {
        margin-bottom: 10px;
      }
      .batch-summary-separator {
        margin-bottom: 10px;
        padding-top: 10px;
        border-top: 1px solid #ddd;
      }
      .batch-summary-info { color: #2196f3; margin-bottom: 5px; }
      .batch-summary-warning { color: #ff9800; margin-bottom: 5px; }
      .batch-summary-error { color: #d32f2f; }
      /* ── HTML template overrides (replaces inline styles) ── */
      .header-logo-sized { height: 48px; }
      .alert-indicator-default {
        background-color: white;
        box-shadow: none;
        font-weight: normal;
      }
      .button-row-spaced { margin-top: 8px; }
      .analyzing-dialog-compact { width: 150px; height: auto; padding: 0; }
      .analyzing-content-centered { padding: 15px; text-align: center; }
      .timer-display { font-size: 20px; font-weight: bold; color: #007bff; }
      .flex-2 { flex: 2; }
      .flex-1 { flex: 1; }
      .mt-12 { margin-top: 12px; }
      .grid-span-2 { grid-column: span 2; }

      .batch-summary-ok-btn {
        margin-top: 15px;
        padding: 10px 30px;
        background: #2c5aa0;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 16px;
      }