
    /* 全域設定 */
    :root {
      --primary-color: #4A90E2;
      --secondary-color: #6c757d;
      --success-color: #28a745;
      --danger-color: #dc3545;
      --warning-color: #ffc107;
      --background-color: #f4f7f9;
      --panel-background: #ffffff;
      --border-color: #dfe7ed;
    }

    html, body {
      height: 100%;
      margin: 0;
      font-family: 'Noto Sans TC', sans-serif;
      background-color: var(--background-color);
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    /* 頂部 Header */
    .main-header {
      height: 60px;
      background-color: var(--panel-background);
      border-bottom: 1px solid var(--border-color);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 20px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
      z-index: 10;
    }

    .logo {
      font-size: 1.2rem;
      font-weight: 700;
      color: var(--primary-color);
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .action-buttons {
      display: flex;
      gap: 8px;
    }

    /* 按鈕樣式 */
    .btn {
      padding: 8px 14px;
      border-radius: 4px;
      border: 1px solid transparent;
      cursor: pointer;
      font-size: 0.9rem;
      font-weight: 500;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      color: white;
      transition: 0.2s;
    }
    .btn-secondary { background: #fff; border: 1px solid #ccc; color: #333; }
    .btn-secondary:hover { background: #f0f0f0; }
    .btn-success { background: var(--success-color); }
    .btn-success:hover { background: #218838; }
    .btn-primary { background: var(--primary-color); }
    .btn-primary:hover { background: #357abd; }
    .btn-danger { background: var(--danger-color); }
    .btn-danger:hover { background: #c82333; }
    .btn-warning { background: var(--warning-color); color: #333; }

    .file-upload-wrapper { position: relative; display: inline-block; overflow: hidden; }
    .file-upload-wrapper input[type=file] { position: absolute; left: 0; top: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

    /* 主區域佈局 */
    .workspace-container {
      flex: 1;
      display: flex;
      overflow: hidden;
    }

    #blocklyDiv {
      flex: 1;
    }

    /* 拖拉分隔條 */
    .panel-resizer {
      width: 5px;
      background: #dde4ea;
      cursor: col-resize;
      flex-shrink: 0;
      position: relative;
      transition: background .15s;
    }
    .panel-resizer:hover, .panel-resizer.dragging {
      background: var(--primary-color, #4C97FF);
    }
    .panel-resizer::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 2px;
      height: 32px;
      background: rgba(0,0,0,.15);
      border-radius: 2px;
    }

    /* 右側面板 */
    .side-panel {
      width: 420px;
      min-width: 260px;
      max-width: 700px;
      background: var(--panel-background);
      display: flex;
      flex-direction: column;
      box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
    }

    /* 分頁籤 */
    .panel-tabs {
      display: flex;
      border-bottom: 1px solid var(--border-color);
      background: #f8f9fa;
    }
    .tab-button {
      flex: 1;
      padding: 12px;
      border: none;
      background: none;
      cursor: pointer;
      color: #666;
      font-weight: 500;
      border-bottom: 3px solid transparent;
    }
    .tab-button.active {
      color: var(--primary-color);
      border-bottom-color: var(--primary-color);
      background: white;
      font-weight: 700;
    }

    /* 內容區 */
    .panel-content {
      flex: 1;
      overflow-y: auto;
      padding: 20px;
      position: relative;
    }
    .panel-content > div { display: none; }
    .panel-content > div.active { display: block; }

    /* 單題練習區 */
    .execution-controls {
      text-align: center;
      margin-bottom: 20px;
      padding: 15px;
      background: #f8f9fa;
      border-radius: 8px;
      border: 1px solid #eee;
    }
    #green-flag-icon {
      font-size: 30px;
      color: #28a745;
      cursor: pointer;
      transition: transform 0.2s;
    }
    #green-flag-icon:hover { transform: scale(1.1); }

    /* ★★★ 修正：題目顯示區 (支援空格與換行) ★★★ */
    #questionTitle_single, #quizQuestionTitle { 
      margin-top: 0; color: var(--primary-color); border-bottom: 2px solid #eee; padding-bottom: 10px; 
    }
    #questionContent_single, #quizQuestionContent {
      background: #fafafa;
      padding: 15px;
      border-radius: 6px;
      border: 1px solid #eee;
      
      /* 關鍵 CSS：保留空白與換行，且使用等寬字體 */
      white-space: pre-wrap; 
      font-family: Consolas, "Courier New", monospace; 
      
      line-height: 1.6;
      min-height: 150px;     
      max-height: 400px;     
      overflow-y: auto;      
      margin-bottom: 15px;
    }

    /* 題組測驗工具列 */
    .quiz-toolbar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: #f8f9fa;
      padding: 10px 15px;
      border-radius: 8px;
      border: 1px solid #eee;
      margin-bottom: 15px;
    }
    .quiz-controls-left {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .quiz-info-right {
      text-align: right;
      font-size: 0.9rem;
      line-height: 1.4;
    }
    #green-flag-icon-quiz {
      font-size: 32px;
      color: #28a745;
      cursor: pointer;
      transition: transform 0.2s;
    }
    #green-flag-icon-quiz:hover { transform: scale(1.1); }

    #questionNav {
      display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin-bottom: 15px;
    }
    #questionNav button {
      font-size: 0.85rem;
      padding: 5px 10px;
    }

    /* 教師表格 */
    .form-group { margin-bottom: 15px; }
    .form-control { width: 95%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
    textarea.form-control { resize: vertical; white-space: pre-wrap; font-family: monospace; }
    .teacher-test-case {
      background: #f8f9fa; border: 1px solid #eee; padding: 10px; margin-bottom: 10px; border-radius: 4px; position: relative;
    }
    .remove-case-btn {
      position: absolute; top: 5px; right: 5px; background: none; border: none; color: #dc3545; cursor: pointer; font-size: 1.2rem;
    }

    /* 評分結果 */
    .result-pass { color: var(--success-color); font-weight: bold; }
    .result-fail { color: var(--danger-color); font-weight: bold; }
    .stats-container { display: flex; gap: 10px; margin-bottom: 20px; }
    .stat-card { flex: 1; background: #f8f9fa; padding: 10px; border-radius: 8px; text-align: center; border: 1px solid #dee2e6; }
    .stat-value { font-size: 1.5rem; font-weight: bold; color: var(--primary-color); }
    .stat-label { font-size: 0.8rem; color: #666; }

    /* Modals */
    .modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
    .modal-content { background: white; padding: 20px; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; position: relative; }
    .modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 15px; }
    .modal-close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; }

    /* 變數輸入 Modal */
    .var-modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.4); }
    .modal-var-content { background-color: #fefefe; margin: 15% auto; padding: 20px; border: 1px solid #888; width: 300px; border-radius: 8px; }
    .model-input { width: 100%; padding: 8px; margin-top: 10px; box-sizing: border-box; }
    .model-button { padding: 8px 16px; margin-right: 10px; cursor: pointer; border-radius: 4px; border: none; }
    .model-sure-btn { background-color: var(--success-color); color: white; }
    
    /* 評分記錄列表 */
    .score-record { border: 1px solid #eee; border-radius: 8px; padding: 15px; margin-bottom: 10px; background: white; }
    .record-header { display: flex; justify-content: space-between; margin-bottom: 5px; }
    .record-score { font-weight: bold; color: var(--primary-color); }
    .record-time { font-size: 0.85rem; color: #999; }
    
    /* 聯絡資訊 */
    .contact-info {
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid #eee;
        font-size: 0.95rem;
        color: #555;
    }
    .contact-info strong { color: var(--primary-color); }
