* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 200px;
    background: #2c3e50;
    color: #fff;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
}

.nav-item.active {
    background: #3498db;
}

.main-content {
    flex: 1;
    margin-left: 200px;
    padding: 20px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.page-header h2 {
    font-size: 24px;
    color: #2c3e50;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-primary {
    background: #3498db;
    color: #fff;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: #fff;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
}

.student-count {
    font-size: 14px;
    font-weight: normal;
    color: #666;
    margin-left: 10px;
}

.question-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.question-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 200px;
    display: flex;
    flex-direction: column;
}

.question-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.question-card-header {
    display: flex;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.question-date {
    font-size: 36px;
    font-weight: bold;
    color: #3498db;
    line-height: 1;
    margin-right: 10px;
    float: left;
}

.printed-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: normal;
    color: #fff;
    background: #27ae60;
    padding: 4px 10px;
    border-radius: 4px;
    margin-right: auto;
}

.question-preview {
    flex: 1;
    overflow: hidden;
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.question-card-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.question-card-footer span {
    margin-right: 8px;
}

.question-card-footer .more-students {
    color: #3498db;
}

.question-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-shrink: 0;
}

.question-card-actions .btn {
    padding: 4px 10px;
    font-size: 12px;
}

.edit-container {
    display: flex;
    gap: 20px;
}

.edit-main {
    flex: 1;
}

.edit-sidebar {
    width: 350px;
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.edit-sidebar h3 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #2c3e50;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-input:focus {
    outline: none;
    border-color: #3498db;
}

.form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
}

.a5-paper-wrapper {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
}

.a5-paper {
    width: 148mm;
    min-height: 210mm;
    padding: 15mm;
    margin: 0 auto;
    border: 2px dashed #ccc;
    background: #fff;
}

.ql-container {
    min-height: 400px;
    font-size: 16px;
}

.ql-editor {
    min-height: 400px;
    line-height: 1.5;
}

.student-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.student-item {
    padding: 10px 12px;
    text-align: center;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    background: #f8f9fa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

.student-item:hover {
    border-color: #3498db;
    background: #e8f4fc;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.student-item.selected {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.student-item .delete-btn {
    display: none;
    margin-left: 5px;
    color: #e74c3c;
    cursor: pointer;
}

.student-item:hover .delete-btn {
    display: inline;
}

.detail-container {
    display: flex;
    gap: 20px;
}

.detail-main {
    flex: 1;
}

.detail-sidebar {
    width: 280px;
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.detail-sidebar h3 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #2c3e50;
}

.student-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.student-list .student-tag {
    padding: 6px 12px;
    background: #ecf0f1;
    border-radius: 4px;
    font-size: 13px;
}

.detail-paper {
    padding: 15mm;
}

.detail-paper #detail-content {
    line-height: 1.8;
    white-space: pre-wrap;
    font-size: 16pt;
}

.detail-paper #detail-content img {
    max-width: 100%;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.fraction-input-group {
    margin-bottom: 10px;
}

.fraction-input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #666;
}

.fraction-divider {
    height: 2px;
    background: #333;
    margin: 15px 0;
}

.fraction-wrapper {
    display: inline-block;
    vertical-align: middle;
}

.fraction-blot {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 2px;
    font-family: 'Times New Roman', serif;
    line-height: 1.2;
}

.fraction-blot .numerator {
    border-bottom: 1px solid currentColor;
    padding: 0 4px 2px;
    min-width: 20px;
    text-align: center;
}

.fraction-blot .denominator {
    padding: 2px 4px 0;
    min-width: 20px;
    text-align: center;
}

.ql-editor img {
    max-width: 100%;
    cursor: nwse-resize;
}

.ql-editor img:hover {
    outline: 2px solid #3498db;
}

.print-page {
    background: #fff;
}

.print-actions {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 10px;
}

.print-page .print-item {
    width: 148mm;
    min-height: 210mm;
    padding: 15mm;
    margin: 0 auto 20px;
    background: #fff;
    page-break-after: always;
}

.print-page .print-item:last-child {
    page-break-after: auto;
}

.print-page .print-item .student-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.print-page .print-item .question-content {
    line-height: 1.8;
    white-space: pre-wrap;
    font-size: 16pt;
}

.print-page .print-item .question-content img {
    max-width: 100%;
}

@media print {
    .no-print {
        display: none !important;
    }
    
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        padding: 0;
    }
    
    .print-page .print-item {
        border: none;
        margin: 0;
        padding: 10mm;
        width: 148mm;
        min-height: 210mm;
        page-break-after: always;
    }
    
    .print-page .print-item:last-child {
        page-break-after: auto;
    }
    
    .print-page .print-item .student-name {
        font-size: 18px;
        font-weight: bold;
        margin-bottom: 15px;
        padding-bottom: 10px;
        border-bottom: 1px solid #333;
    }
    
    .print-page .print-item .question-content {
        line-height: 1.8;
        white-space: pre-wrap;
        font-size: 16pt;
    }
    
    .print-page .print-item .question-content img {
        max-width: 100%;
    }
    
    @page {
        size: A5 portrait;
        margin: 0;
    }
    
    body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.ql-toolbar.ql-snow {
    border: 1px solid #ccc;
    border-radius: 4px 4px 0 0;
}

.ql-container.ql-snow {
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

.ql-editor.ql-blank::before {
    font-style: normal;
    color: #aaa;
}

.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
    content: attr(data-value);
}

.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="12pt"]::before { content: '12pt'; }
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="14pt"]::before { content: '14pt'; }
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="16pt"]::before { content: '16pt'; }
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="18pt"]::before { content: '18pt'; }
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="20pt"]::before { content: '20pt'; }

.ql-snow .ql-picker.ql-lineheight .ql-picker-label::before,
.ql-snow .ql-picker.ql-lineheight .ql-picker-item::before {
    content: attr(data-value);
}

.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value="1"]::before { content: '1.0'; }
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value="1.5"]::before { content: '1.5'; }
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value="2"]::before { content: '2.0'; }

.ql-editor p {
    margin-bottom: 0.5em;
}

.ql-editor .ql-size-12pt { font-size: 12pt; }
.ql-editor .ql-size-14pt { font-size: 14pt; }
.ql-editor .ql-size-16pt { font-size: 16pt; }
.ql-editor .ql-size-18pt { font-size: 18pt; }
.ql-editor .ql-size-20pt { font-size: 20pt; }

.ql-editor span[data-lineheight="1.0"] { line-height: 1.0; }
.ql-editor span[data-lineheight="1.5"] { line-height: 1.5; }
.ql-editor span[data-lineheight="2.0"] { line-height: 2.0; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    margin-bottom: 20px;
}

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 400px;
    max-width: 90%;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
    font-size: 28px;
}

.login-tip {
    text-align: center;
    margin-top: 15px;
    font-size: 13px;
    color: #95a5a6;
}

.btn-block {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

.teacher-info {
    padding: 10px 20px;
    font-size: 13px;
    color: #bdc3c7;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 10px;
}

.btn-logout {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
}

.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.class-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.class-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
}

.class-name {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 8px;
}

.class-subject {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 15px;
}

.class-actions {
    display: flex;
    gap: 10px;
}
