/* Cheecore Education - Grade, Annotation & File Styles */
/* Grade page: three-zone layout, toolbar, canvas, rubric, annotation, upload, print, toast */

/* ===== TOP BAR ===== */
.gr-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.gr-topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.gr-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}
.gr-back-btn:hover { background: var(--gray-50); color: var(--gray-800); border-color: var(--gray-300); }
.gr-topbar-info { min-width: 0; }
.gr-topbar-student {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gr-topbar-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-500);
    flex-wrap: wrap;
    margin-top: 1px;
}
.gr-topbar-assign { color: var(--gray-700); font-weight: 500; }
.gr-topbar-dot { color: var(--gray-300); }
.gr-topbar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== V3 TWO-ZONE LAYOUT ===== */
.gr-layout-new {
    display: flex;
    gap: 20px;
    align-items: start;
}
.gr-left {
    flex: 1 1 55%;
    min-width: 0;
}
.gr-right {
    flex: 0 0 420px;
    width: 420px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: sticky;
    top: 74px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}
.gr-right .gr-card { margin-bottom: 0; }

/* ===== FILE LIST IN RIGHT PANEL ===== */
.gr-file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.gr-file-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--gray-50);
    border: 1.5px solid var(--gray-100);
    border-radius: 8px;
    gap: 10px;
    transition: all 0.15s;
}
.gr-file-card:hover {
    background: #fff;
    border-color: var(--gray-300);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.gr-file-card-image.gr-file-card-active {
    background: #EEF2FF;
    border-color: var(--primary);
    border-left: 3px solid var(--primary);
}
.gr-file-card-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}
.gr-file-card-icon { font-size: 20px; flex-shrink: 0; width: 28px; text-align: center; }
.gr-file-card-info { min-width: 0; }
.gr-file-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}
.gr-file-card-size { font-size: 11px; color: var(--gray-500); }
.gr-file-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.gr-file-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 5px;
    border: 1.5px solid var(--gray-200);
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    color: var(--gray-700);
    transition: all 0.15s;
    display: inline-block;
}
.gr-file-btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.gr-file-btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.gr-file-btn-primary:hover { background: var(--primary-dark, #2563eb); color: #fff; }
.gr-file-btn-outline { color: var(--gray-600); }

/* ===== INFO BANNER ===== */
.gr-info-banner {
    padding: 10px 14px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 8px;
    font-size: 12px;
    color: #92400E;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.gr-info-banner-blue {
    background: #EFF6FF;
    border-color: #BFDBFE;
    color: #1E40AF;
}
.gr-banner-content { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.gr-banner-content strong { font-size: 13px; }
.gr-banner-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}
.gr-banner-close:hover { opacity: 1; }

/* ===== CURRENT FILE INDICATOR ===== */
.gr-current-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--gray-600);
    background: #fff;
    border-left: 1.5px solid var(--gray-200);
    border-right: 1.5px solid var(--gray-200);
    border-bottom: 1.5px solid var(--gray-200);
    border-radius: 0 0 var(--radius) var(--radius);
}
.gr-current-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

/* ===== CANVAS EMPTY STATE ===== */
.gr-canvas-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}
.gr-empty-state { text-align: center; padding: 48px 24px; }
.gr-empty-icon { font-size: 48px; margin-bottom: 12px; }
.gr-empty-title { font-weight: 600; color: var(--gray-700); margin: 0 0 6px 0; }
.gr-empty-hint { font-size: 12px; color: var(--gray-500); max-width: 360px; margin: 0 auto; line-height: 1.6; }

/* ===== KEEP OLD GR-LAYOUT (grade_done etc) ===== */
.gr-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 20px;
    align-items: start;
}
.gr-viewer { min-width: 0; }
.gr-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 74px;
}

/* ===== FILE TABS ===== */
.gr-file-tabs {
    display: flex;
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-x: auto;
}
.gr-file-tab {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
}
.gr-file-tab:last-child { border-right: none; }
.gr-file-tab:hover { background: #fff; color: var(--primary); }
.gr-file-tab.active {
    background: #fff;
    border-bottom-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}
.gr-tab-icon { font-size: 16px; flex-shrink: 0; }
.gr-tab-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.gr-tag-pdf {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #FEE2E2;
    color: #991B1B;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ===== TOOLBAR ===== */
.gr-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #fff;
    border-left: 1.5px solid var(--gray-200);
    border-right: 1.5px solid var(--gray-200);
    border-bottom: 1.5px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 8px;
}
.gr-tools-left {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
}
.gr-tool-btn {
    padding: 6px 8px;
    border: 1.5px solid var(--gray-300);
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    transition: all var(--transition);
}
.gr-tool-btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.gr-tool-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.gr-tool-sep {
    width: 1px;
    height: 20px;
    background: var(--gray-300);
    margin: 0 3px;
}
.gr-color-pick {
    width: 26px;
    height: 26px;
    border: 1.5px solid var(--gray-300);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}
.gr-size-sel {
    padding: 4px 6px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-family: inherit;
    background: #fff;
}
.gr-icon-btn {
    padding: 4px 8px;
    border: 1.5px solid var(--gray-300);
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--gray-700);
    line-height: 1;
}
.gr-icon-btn:hover { background: var(--gray-50); }
.gr-icon-btn-danger { border-color: var(--danger); color: var(--danger); }
.gr-icon-btn-danger:hover { background: var(--danger-light); }
.gr-tools-hint {
    font-size: var(--text-xs);
    color: var(--gray-500);
    white-space: nowrap;
}

/* ===== PDF PAGE NAV ===== */
.gr-pdf-nav {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 12px;
    background: #fff;
    border-left: 1.5px solid var(--gray-200);
    border-right: 1.5px solid var(--gray-200);
    border-bottom: 1.5px solid var(--gray-200);
    font-size: 13px;
    color: var(--gray-700);
}
.gr-pdf-page { font-weight: 500; }

/* ===== CANVAS AREA ===== */
.gr-canvas-wrap {
    position: relative;
    min-height: 300px;
    background: #e5e5e5;
    border-left: 1.5px solid var(--gray-200);
    border-right: 1.5px solid var(--gray-200);
    border-bottom: 1.5px solid var(--gray-200);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}
.gr-annot-img {
    display: block;
    width: 100%;
    max-width: 100%;
}
.gr-annot-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
    z-index: 2;
}
.gr-pdf-canvas {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* ===== NO FILES STATE ===== */
.gr-no-files {
    text-align: center;
    padding: 48px 24px;
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
}
.gr-no-files-icon { font-size: 40px; margin-bottom: 8px; }

/* ===== STUDENT TEXT BLOCK ===== */
.gr-text-block {
    margin-top: 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}
.gr-text-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
}
.gr-text-body {
    padding: 14px;
    max-height: 350px;
    overflow-y: auto;
    background: #fff;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    cursor: text;
    user-select: text;
}

/* ===== OTHER FILES ===== */
.gr-other-files {
    margin-top: 16px;
    padding: 14px;
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
}

/* ===== PANEL CARDS ===== */
.gr-card {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.gr-card-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* ===== QUICK SCORE CHIPS ===== */
.gr-quick-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.gr-qs-btn {
    padding: 6px 12px;
    border: 1.5px solid var(--gray-200);
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    font-family: inherit;
    transition: all 0.15s;
}
.gr-qs-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #EEF2FF;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(79,70,229,0.12);
}
.gr-qs-btn:active { transform: translateY(0); }

/* ===== RUBRIC WITH SLIDERS ===== */
.gr-rubric { display: flex; flex-direction: column; gap: 8px; }
.gr-rubric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.gr-rubric-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    flex: 0 0 auto;
    min-width: 90px;
    max-width: 120px;
}
.gr-rubric-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.gr-rubric-slider {
    flex: 1;
    min-width: 40px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--gray-200);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    accent-color: var(--primary);
}
.gr-rubric-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.gr-rubric-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.gr-rubric-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: var(--gray-200);
    border: none;
}
.gr-rubric-num {
    width: 48px;
    padding: 5px 2px;
    border: 1.5px solid var(--gray-300);
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    flex-shrink: 0;
    transition: border-color 0.15s;
    -moz-appearance: textfield;
}
.gr-rubric-num::-webkit-inner-spin-button,
.gr-rubric-num::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.gr-rubric-num:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}
.gr-rubric-max {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 500;
    flex-shrink: 0;
}
.gr-rubric-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0 4px;
    border-top: 1px solid var(--gray-100);
}
.gr-rubric-total-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    flex-shrink: 0;
}
.gr-rubric-total-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}
.gr-rubric-bar {
    position: relative;
    height: 26px;
    background: var(--gray-100);
    border-radius: 13px;
    overflow: hidden;
    margin-top: 2px;
}
.gr-rubric-bar-fill {
    height: 100%;
    border-radius: 13px;
    background: var(--success);
    transition: width 0.3s ease, background 0.3s ease;
}
.gr-rubric-bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-700);
    z-index: 1;
    pointer-events: none;
    text-shadow: 0 0 4px rgba(255,255,255,0.7);
}

/* ===== QUICK FEEDBACK TEMPLATES ===== */
.gr-quick-fb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.gr-fb-chip {
    padding: 5px 12px;
    border: 1.5px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    color: var(--gray-600);
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}
.gr-fb-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #EEF2FF;
}

/* ===== FEEDBACK TEXTAREA ===== */
.gr-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.gr-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}

/* ===== TEXT ANNOTATIONS ===== */
.gr-ann-row {
    position: relative;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-left: 4px solid var(--gray-300);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}
.gr-ann-row[data-ann-type="praise"]    { border-left-color: #10B981; }
.gr-ann-row[data-ann-type="suggestion"] { border-left-color: #3B82F6; }
.gr-ann-row[data-ann-type="correction"] { border-left-color: #EF4444; }
.gr-ann-hd {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.gr-ann-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    -webkit-appearance: none;
    appearance: none;
    background-color: #10B981;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0h8L4 5z' fill='rgba(255,255,255,0.7)'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 20px;
}
.gr-ann-badge option {
    background: #fff;
    color: #333;
    font-size: 12px;
}
.gr-ann-row[data-ann-type="praise"]    .gr-ann-badge { background-color: #10B981; }
.gr-ann-row[data-ann-type="suggestion"] .gr-ann-badge { background-color: #3B82F6; }
.gr-ann-row[data-ann-type="correction"] .gr-ann-badge { background-color: #EF4444; }
.gr-ann-quote-txt {
    font-size: 12px;
    color: var(--gray-500);
    font-style: italic;
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 2px 4px;
    outline: none;
    font-family: inherit;
}
.gr-ann-quote-txt:focus {
    color: var(--gray-700);
    font-style: normal;
    background: var(--gray-50);
    border-radius: 3px;
}
.gr-ann-quote-txt::placeholder {
    color: var(--gray-400);
    font-style: italic;
}
.gr-ann-del {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--gray-400);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    margin-left: auto;
}
.gr-ann-del:hover {
    background: #FEE2E2;
    color: #DC2626;
}
.gr-ann-body-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.gr-ann-comment {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 36px;
    line-height: 1.5;
    transition: border-color 0.15s;
}
.gr-ann-comment:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}

/* ===== CORRECTED FILES ===== */
.gr-corr-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    gap: 8px;
}
.gr-corr-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.gr-corr-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-800);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}
.gr-corr-size { font-size: 11px; color: var(--gray-500); }
.gr-corr-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.gr-corr-view, .gr-corr-down {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}
.gr-corr-view { background: #DBEAFE; color: #1E40AF; }
.gr-corr-view:hover { background: #BFDBFE; }
.gr-corr-down { background: #ECFDF5; color: #065F46; }
.gr-corr-down:hover { background: #D1FAE5; }
.gr-corr-del {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.gr-corr-del:hover { background: var(--danger-light); }
.gr-upload-row { display: flex; align-items: center; gap: 10px; }

/* ===== BOTTOM BAR ===== */
.gr-bottombar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    margin-top: 20px;
    position: sticky;
    bottom: 12px;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    gap: 16px;
    flex-wrap: wrap;
}
.gr-bb-left { flex-shrink: 0; }
.gr-bb-status {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
}
.gr-bb-center {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
    min-width: 0;
}
.gr-bb-score-num {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
    transition: color 0.2s;
}
.gr-bb-score-div {
    font-size: 16px;
    color: var(--gray-400);
    margin: 0 2px;
}
.gr-bb-score-max {
    font-size: 16px;
    color: var(--gray-400);
    font-weight: 500;
}
.gr-bb-bar {
    width: 120px;
    height: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
    margin-left: 8px;
}
.gr-bb-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--success);
    transition: width 0.25s ease, background 0.25s ease;
}
.gr-bb-right { flex-shrink: 0; }

/* ===== PREVIEW MODE ===== */
.gr-preview-mode .gr-panel {
    opacity: 0.6;
    pointer-events: none;
}
.gr-preview-mode .gr-bottombar { opacity: 0.5; pointer-events: none; }
.gr-preview-mode .gr-toolbar { opacity: 0.5; pointer-events: none; }
.gr-preview-mode .gr-file-tabs { pointer-events: none; }
.gr-preview-mode .gr-canvas-wrap { pointer-events: none; }
.gr-preview-mode .gr-ann-del { display: none; }
.gr-preview-mode .gr-corr-del { display: none; }
.gr-preview-mode .gr-upload-row { display: none; }
.gr-preview-mode .gr-quick-fb { display: none; }
.gr-preview-mode .gr-topbar-actions .btn-success { pointer-events: none; opacity: 0.5; }
.gr-preview-mode .gr-file-card-actions .gr-annotate-btn { display: none; }

/* ===== ANIMATIONS ===== */
.file-uploading .gr-corr-name { font-style: italic; }
.drop-zone-active {
    position: relative;
}
.drop-zone-active::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    background: rgba(59,130,246,0.06);
    z-index: 5;
    pointer-events: none;
    animation: drop-pulse 1.5s ease-in-out infinite;
}
@keyframes drop-pulse {
    0%, 100% { border-color: var(--primary); background: rgba(59,130,246,0.04); }
    50% { border-color: var(--primary-dark, #2563eb); background: rgba(59,130,246,0.1); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .gr-layout-new { flex-direction: column; }
    .gr-right { flex: 1 1 auto; width: 100%; position: static; max-height: none; overflow-y: visible; }
    .gr-layout { grid-template-columns: 1fr; }
    .gr-panel { position: static; top: auto; }
    .gr-topbar { padding: 8px 12px; }
    .gr-topbar-student { font-size: 14px; }
    .gr-bb-score-num { font-size: 24px; }
    .gr-bb-bar { width: 80px; }
    .gr-rubric-name { min-width: 90px; font-size: 12px; }
    .gr-corr-name { max-width: 120px; }
    .gr-file-card-name { max-width: 120px; }
}
@media (max-width: 640px) {
    .gr-topbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .gr-topbar-actions { justify-content: flex-end; }
    .gr-topbar-meta { flex-wrap: wrap; }
    .gr-bottombar { flex-direction: column; gap: 10px; padding: 10px 14px; }
    .gr-bb-center { width: 100%; }
    .gr-bb-bar { width: 100%; flex: 1; }
    .gr-toolbar { padding: 6px 8px; }
    .gr-tools-left { gap: 2px; }
    .gr-tool-btn { padding: 5px 6px; }
    .gr-ann-row { padding: 6px 8px; }
    .gr-ann-hd { flex-wrap: wrap; }
    .gr-rubric-row { flex-wrap: wrap; }
    .gr-rubric-name { min-width: 100%; }
    .gr-rubric-ctrl { width: 100%; }
}

/* ===== SHARED: Annotation Cards (used by grade_done, ta/submission_detail, student/submission) ===== */
.annotation-card {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    border-left: 3px solid var(--gray-400);
    white-space: pre-line;
    word-break: break-word;
}
.annotation-card:last-child { margin-bottom: 0; }
.annotation-card.annotation-praise { background: #ECFDF5; border-left-color: #059669; }
.annotation-card.annotation-suggestion { background: #EEF2FF; border-left-color: #4F46E5; }
.annotation-card.annotation-correction { background: #FEF2F2; border-left-color: #DC2626; }

/* ===== SHARED: Annotation Container (used by other pages) ===== */
.annotation-container {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fafafa;
}
.file-tabs {
    display: flex;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    overflow-x: auto;
}
.file-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border: none;
    background: var(--gray-50);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    transition: all var(--transition);
}
.file-tab.active { background: #fff; border-bottom-color: var(--primary); color: var(--primary); }
.file-tab:hover { color: var(--primary); }

.annotation-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    align-items: center;
}
.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--gray-300);
    margin: 0 4px;
}
.toolbar-hint {
    font-size: var(--text-xs);
    color: var(--gray-500);
    margin-left: auto;
}
.color-picker { width: 28px; height: 28px; border: none; cursor: pointer; padding: 0; border-radius: 4px; }
.size-select { padding: 4px 6px; border: 1px solid var(--gray-300); border-radius: 4px; font-size: var(--text-sm); }
.tool-btn {
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--text-sm);
    font-family: inherit;
}
.tool-btn:hover { background: var(--gray-50); }
.tool-btn-danger { border-color: var(--danger); color: var(--danger); }
.tool-btn-danger:hover { background: var(--danger-light); }

.pdf-nav {
    display: none;
    padding: 6px 12px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.canvas-wrapper {
    position: relative;
    min-height: 300px;
    background: #e5e5e5;
    cursor: crosshair;
}
.annot-image { display: block; max-width: 100%; width: 100%; }
.annot-canvas { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 2; }
.pdf-render-canvas { display: none; position: absolute; top: 0; left: 0; z-index: 1; }

.ann-tool {
    padding: 6px 8px;
    border: 1.5px solid var(--gray-300);
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    transition: all var(--transition);
}
.ann-tool:hover { background: var(--gray-50); border-color: var(--gray-400); }
.ann-tool.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== SHARED: File Items (used by grade_done, ta/submission_detail, student/submission) ===== */
/* Base .file-item styles in components.css */

.file-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: background var(--transition);
}
.file-item-row:hover { background: #fff; }
.file-item-icon { font-size: 16px; flex-shrink: 0; width: 24px; text-align: center; }
.file-item-name {
    flex: 1;
    font-weight: 500;
    color: var(--gray-800);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-item-size { font-size: 11px; color: var(--gray-500); flex-shrink: 0; }

/* ===== SHARED: File Badges ===== */
.file-badge {
    font-size: var(--text-xs);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}
.file-badge-image { background: #DBEAFE; color: #1E40AF; }
.file-badge-pdf { background: #FEE2E2; color: #991B1B; }
.file-badge-txt { background: var(--gray-100); color: var(--gray-600); }
.file-badge-corrected { background: #ECFDF5; color: #065F46; }

/* ===== SHARED: Unified File Section (used by ta/submission_detail, grade_done) ===== */
.unified-file-section {
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: var(--space-4);
}
.file-subsection { padding: 14px 18px; }
.file-subsection + .file-subsection { border-top: 1.5px solid var(--gray-200); }
.file-subsection-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.file-subsection-upload {
    background: #F0FDF4;
    border-left: 3px solid var(--success);
}
.file-item-list { display: flex; flex-direction: column; gap: 4px; }
.file-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.file-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== SHARED: Print Styles ===== */
@media print {
    .sidebar, .mobile-menu-btn { display: none !important; }
    .main-content { margin-left: 0; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ===== Lightbox: DOCX & TXT preview ===== */
.fv-docx-preview {
    background: #fff;
    color: #333;
    padding: 24px 32px;
    border-radius: 6px;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.8;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.fv-docx-preview h1, .fv-docx-preview h2, .fv-docx-preview h3 { margin-top: 1em; margin-bottom: 0.5em; }
.fv-docx-preview p { margin-bottom: 0.8em; }
.fv-docx-preview table { border-collapse: collapse; width: 100%; margin-bottom: 1em; }
.fv-docx-preview td, .fv-docx-preview th { border: 1px solid #ddd; padding: 6px 10px; }
.fv-docx-warnings {
    margin-top: 12px;
    padding: 8px 14px;
    background: #FFFBEB;
    color: #92400E;
    border-radius: 4px;
    font-size: 12px;
}
.fv-txt-preview {
    background: #fff;
    color: #333;
    padding: 21px 24px;
    border-radius: 6px;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.fv-txt-preview pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.7;
    margin: 0;
    font-family: inherit;
}

/* ===== SHARED: Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}
.toast {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}
.toast-success { background: #059669; }
.toast-error { background: #DC2626; }
.toast-info { background: #2563EB; }
.toast-warning { background: #D97706; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }
@keyframes gaSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.ga-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: gaSpin 0.7s linear infinite;
}

/* ===== SHARED: File Viewer Lightbox ===== */
.fv-lightbox { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10000; }
.fv-lightbox.fv-open { display: block; }
.fv-lightbox-backdrop { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); }
.fv-lightbox-content { position: relative; z-index: 1; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.fv-lightbox-body { max-width: 92vw; max-height: 92vh; display: flex; align-items: center; justify-content: center; }
.fv-lightbox-image { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 4px; box-shadow: 0 8px 40px rgba(0,0,0,0.5); }
.fv-pdf-wrapper { width: 90vw; height: 90vh; }
.fv-pdf-iframe { width: 100%; height: 100%; border: none; border-radius: 4px; background: #fff; }
.fv-lightbox-close { position: fixed; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 36px; cursor: pointer; z-index: 2; opacity: 0.7; transition: opacity 0.2s; line-height: 1; }
.fv-lightbox-close:hover { opacity: 1; }
.fv-lightbox-prev, .fv-lightbox-next { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.12); border: none; color: #fff; font-size: 28px; cursor: pointer; z-index: 2; padding: 16px 10px; border-radius: 4px; opacity: 0.5; transition: opacity 0.2s; }
.fv-lightbox-prev:hover, .fv-lightbox-next:hover { opacity: 1; background: rgba(255,255,255,0.2); }
.fv-lightbox-prev { left: 10px; }
.fv-lightbox-next { right: 10px; }
.fv-lightbox-counter { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; z-index: 2; opacity: 0.7; background: rgba(0,0,0,0.5); padding: 4px 14px; border-radius: 20px; }

/* ===== SHARED: Download All Button ===== */
.file-download-all {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 12px;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all var(--transition);
}
.file-download-all:hover { background: var(--primary); color: #fff; }
