* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
    background: #f0f2f5;
    color: #2c3e50;
    line-height: 1.6;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    color: #fff;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 22px 20px 18px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.header h1 { font-size: 22px; }
.home-link {
    position: absolute;
    top: 18px; left: 20px;
    color: rgba(255,255,255,0.92);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 14px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 16px;
    transition: background 0.15s;
}
.home-link:hover { background: rgba(255,255,255,0.18); border-color: #fff; }
.history-link {
    position: absolute;
    top: 18px; right: 20px;
    color: rgba(255,255,255,0.92);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 14px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 16px;
    transition: background 0.15s;
}
.history-link:hover { background: rgba(255,255,255,0.18); border-color: #fff; }

.main-container { max-width: 1100px; margin: 0 auto; padding: 20px; }

.panel {
    background: #fff;
    border-radius: 12px;
    padding: 24px 28px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.panel h2 {
    font-size: 17px;
    color: #1e40af;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0f2fe;
}

.control-row {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.control-group label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}
.control-group input,
.control-group select,
.control-group textarea {
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.control-group input:focus,
.control-group select:focus,
.control-group textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.control-group select { background: #fff; cursor: pointer; }

.title-input { width: 260px; }
.date-input { width: 160px; }

.weekday-row {
    display: flex;
    gap: 4px;
    align-items: center;
}
.weekday-chip {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px 8px;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    transition: all 0.15s;
}
.weekday-chip:hover { border-color: #3b82f6; }
.weekday-chip.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}
.weekday-chip input { display: none; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #475569;
    margin-top: 4px;
}
.checkbox-row input[type=checkbox] {
    width: 16px; height: 16px;
    accent-color: #3b82f6;
    cursor: pointer;
}

.word-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    font-size: 14px;
    line-height: 1.8;
}

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
    padding: 9px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2563eb; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover:not(:disabled) { background: #d97706; }
.btn-outline { background: #fff; color: #3b82f6; border: 1.5px solid #3b82f6; }
.btn-outline:hover:not(:disabled) { background: #eff6ff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-info { background: #0ea5e9; color: #fff; }
.btn-info:hover:not(:disabled) { background: #0284c7; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.def-check {
    width: 22px;
    height: 22px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    margin: auto 0;
}
.def-check:hover:not(:disabled) { border-color: #3b82f6; color: #3b82f6; }
.def-check.checked {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

.word-list-editor { display: none; }
.word-list-editor.show { display: block; }

.word-edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.word-edit-table th {
    background: #f0f9ff;
    color: #0369a1;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #bae6fd;
}
.word-edit-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}
.word-edit-table tr:hover td { background: #f8fafc; }
.word-edit-table .row-not-found { background: #fef2f2; }
.word-edit-table .row-not-found:hover td { background: #fee2e2; }
.word-edit-table .row-def-mismatch { background: #fff8e1; }
.word-edit-table .row-def-mismatch:hover td { background: #ffecb3; }
.word-edit-table input.editable {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.word-edit-table input.editable:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.word-edit-table input.readonly-def {
    background: #f5f5f5;
    color: #555;
    border-style: dashed;
    cursor: default;
}
.word-edit-table select.editable {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s;
}
.word-edit-table select.editable:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.word-edit-table td select.select-pos {
    width: auto;
    min-width: 90px;
    margin-bottom: 4px;
}
.word-edit-table td select.select-def {
    width: 100%;
}
.word-edit-table td select + select {
    margin-top: 4px;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-found { background: #d1fae5; color: #065f46; }
.badge-missing { background: #fee2e2; color: #991b1b; }

.stats-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 12px 0;
    font-size: 13px;
    align-items: center;
}
.stats-bar .stat {
    padding: 6px 14px;
    border-radius: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
}
.stats-bar .stat:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.stats-bar .stat.active {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
.stat-total { background: #e0f2fe; color: #0369a1; }
.stat-found { background: #d1fae5; color: #065f46; }
.stat-missing { background: #fee2e2; color: #991b1b; }
.stat-mismatch { background: #fff3cd; color: #856404; }
.filter-hint {
    font-size: 12px;
    color: #64748b;
    margin-left: 8px;
}
.difficulty-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}

.schedule-preview {
    margin-top: 10px;
    padding: 12px 16px;
    background: #f0f9ff;
    border-radius: 8px;
    font-size: 13px;
    color: #0369a1;
    display: none;
    line-height: 1.8;
}
.schedule-preview.show { display: block; }
.schedule-preview .grp-label {
    font-weight: 700;
    color: #1e40af;
    margin-right: 8px;
}
.schedule-preview .date-item {
    display: inline-block;
    padding: 2px 8px;
    margin: 0 2px;
    background: #dbeafe;
    border-radius: 4px;
}

.import-popup {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.import-popup.show { display: flex; }
.import-popup .popup-inner {
    background: #fff;
    border-radius: 14px;
    width: 620px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.popup-header {
    padding: 18px 22px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.popup-header h3 { font-size: 16px; color: #1e293b; }
.popup-close {
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: #94a3b8; padding: 4px; line-height: 1;
}
.popup-close:hover { color: #334155; }
.popup-body { padding: 16px 22px; overflow-y: auto; flex: 1; }
.popup-body .search-row { display: flex; gap: 8px; margin-bottom: 14px; }
.popup-body .search-row input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}
.popup-body .search-row input:focus { border-color: #3b82f6; }
.popup-word-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.popup-word-list .item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
}
.popup-word-list .item:hover { background: #f0f9ff; }
.popup-word-list .item.selected { background: #dbeafe; }
.popup-word-list .item input[type=checkbox] {
    width: 17px; height: 17px;
    accent-color: #3b82f6;
    cursor: pointer;
}
.popup-word-list .item .eng {
    font-weight: 600;
    color: #1e293b;
    min-width: 120px;
}
.popup-word-list .item .chn {
    color: #64748b;
    font-size: 13px;
    flex: 1;
}
.popup-footer {
    padding: 14px 22px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ===== 手机端响应式适配 ===== */
@media (max-width: 768px) {
    html, body { font-size: 16px !important; -webkit-text-size-adjust: 100%; }
    .main-container { max-width: 100% !important; width: 100% !important; padding: 8px !important; box-sizing: border-box; margin: 0 !important; }
    .panel { padding: 12px 10px !important; border-radius: 8px; margin-bottom: 10px; }
    .panel h2 { font-size: 17px !important; margin-bottom: 10px; }
    
    /* 统计按钮 */
    .stats-bar { gap: 6px; flex-wrap: wrap; }
    .stat { padding: 8px 12px; font-size: 14px !important; }
    
    /* 单词编辑表格 */
    .word-edit-table { width: 100% !important; table-layout: fixed; min-width: unset !important; }
    .word-edit-table th, .word-edit-table td { padding: 8px 3px !important; font-size: 15px !important; }
    .word-edit-table th:first-child,
    .word-edit-table td:first-child { width: 24px !important; font-size: 15px !important; }
    .word-edit-table th:last-child,
    .word-edit-table td:last-child { width: 54px !important; }
    
    /* 输入区虚线框 */
    td > div[style*="dashed"] { padding: 5px !important; margin-bottom: 5px !important; border-radius: 5px !important; }
    
    /* "您输入："/"库匹配："标签 - 手机端隐藏以扩大输入框宽度 */
    .input-label,
    span[style*="font-size:11px;color:#64748b"] { display: none !important; }
    
    /* 输入框 - 关键：字号16px防止iOS自动缩放 */
    .word-input-en, .word-input-def,
    .db-word-select, .db-def-select,
    .editable { font-size: 16px !important; padding: 8px 8px !important; border-radius: 5px !important; }
    
    /* 按钮 */
    .btn-reparse { font-size: 13px !important; padding: 6px 0 !important; }
    .btn-sm { padding: 5px 6px !important; font-size: 12px !important; }
    
    /* 右侧按钮槽位 */
    .right-slot, div[style*="width:56px"] { width: 48px !important; gap: 3px !important; }
    
    /* 确认复选框 */
    .def-check { width: 26px !important; height: 26px !important; font-size: 14px !important; border-width: 2px !important; }
    
    /* 释义单选按钮 */
    .radio-btn { width: 26px !important; height: 26px !important; font-size: 11px !important; }
    
    /* 难度标签 */
    .difficulty-badge { font-size: 12px !important; padding: 2px 7px !important; border-radius: 10px !important; }
    
    /* 字数统计 */
    td span[style*="color:#94a3b8"] { font-size: 12px !important; margin-top: 3px !important; }
    
    /* 删除按钮 */
    .btn-danger { padding: 4px 8px !important; font-size: 13px !important; margin-top: 6px !important; border-radius: 6px !important; }
    
    /* 控制按钮行 */
    .btn-row { gap: 8px !important; margin-top: 12px !important; }
    .btn-row .btn { padding: 12px 16px !important; font-size: 15px !important; border-radius: 8px !important; }
    
    /* 顶部表单输入框 - 16px防止缩放 */
    textarea { font-size: 16px !important; padding: 10px !important; border-radius: 6px !important; }
    input[type="text"], input[type="number"], select { font-size: 16px !important; padding: 10px !important; border-radius: 6px !important; }
    
    /* 头部 */
    .header h1 { font-size: 18px; }
    .header-inner { padding: 10px 8px !important; }
    .home-link, .history-link { font-size: 13px !important; padding: 6px 10px !important; top: 10px !important; }
    
    /* 表头竖排文字 */
    .word-edit-table th[style*="writing-mode"] { padding: 6px 2px !important; font-size: 13px !important; letter-spacing: 2px !important; }
    
    /* "库匹配："标签 */
    span[style*="visibility:hidden"] + input,
    span[style*="white-space:nowrap"] { font-size: 13px !important; }
    
    /* flex行gap */
    div[style*="display:flex"][style*="gap:4px"] { gap: 3px !important; margin-bottom: 3px !important; }
    
    /* 词性前缀（n. v. adj.等）在select中 */
    select { font-size: 15px !important; }
    
    /* 库匹配区 */
    td div[style*="background:#fff"][style*="dashed"] { padding: 5px !important; border-radius: 5px !important; }
    
    /* 词性和变形的select样式 */
    .db-word-select, .db-def-select { font-size: 15px !important; }
    
    /* 确保整个页面在手机上不横向溢出 */
    body { overflow-x: hidden; }
}

@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
    .print-area { display: block !important; }
    body.showing-answer .print-area { display: none !important; }
    body.showing-answer .answer-area { display: block !important; }
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
}
.history-item:hover { background: #f0f9ff; }
.history-item .hi-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
}
.history-item .hi-meta {
    font-size: 12px;
    color: #94a3b8;
}
.history-item .hi-actions {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}
.print-area {
    display: none;
    font-family: "Microsoft YaHei", "SimHei", "KaiTi", serif;
}
.print-table-wrap { width: 100%; }
.print-page-title {
    text-align: left;
    font-size: 14px;
    font-weight: bold;
    color: #000;
    margin-bottom: 1mm;
    padding-left: 2px;
}
.print-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.print-table th, .print-table td {
    border: 0.5pt solid #333;
    padding: 1px 3px;
    text-align: center;
    vertical-align: middle;
    font-size: 11px;
    color: #000;
}
.print-table th {
    font-weight: bold;
    height: 9mm;
    line-height: 1.2;
}
.print-table th .review-oneline {
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
}
.print-table th .review-oneline .cir-num {
    font-size: 18px;
    margin-right: 3px;
    vertical-align: middle;
}

tr.subrow-a td.col-write,
tr.subrow-b td.col-write,
tr.subrow-c td.col-write {
    height: 3.5mm;
    padding-top: 0;
    padding-bottom: 0;
}

tr.subrow-a td.col-write {
    border-bottom: 0.5pt solid #90c695;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
tr.subrow-b td.col-write {
    border-top: none;
    border-bottom: 0.5pt solid #e57373;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
tr.subrow-c td.col-write {
    border-top: none;
}

.col-no { width: 4%; font-size: 12px; }
.col-def {
    width: 14%;
    overflow: hidden;
    white-space: normal;
    line-height: 1.15;
    word-break: break-all;
    vertical-align: middle;
    font-size: 11px;
}
.col-len { width: 5%; font-size: 11px; }
.col-write { width: 15.4%; }

.print-page-footer {
    text-align: center;
    font-size: 11px;
    color: #000;
}

@media print {
    .print-page-footer {
        position: fixed;
        bottom: 2mm;
        left: 0;
        right: 0;
    }
    .print-table th { height: 8mm; }
    tr.subrow-a td.col-write,
    tr.subrow-b td.col-write,
    tr.subrow-c td.col-write {
        height: 3.4mm;
    }
    tr.subrow-a td.col-write {
        border-bottom-color: #90c695;
    }
    tr.subrow-b td.col-write {
        border-bottom-color: #e57373;
    }
    .print-page { page-break-after: always; }
    .print-page:last-child { page-break-after: avoid; }
}

/* ============ 答案纸样式 ============ */
.answer-area { display: none; }
.showing-answer .answer-area { display: block; }
.showing-answer .print-area { display: none; }

.answer-page-title {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 6px;
    color: #1e293b;
    letter-spacing: 2px;
}

.answer-header-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #64748b;
    margin-bottom: 8px;
    padding: 0 2px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
}

/* answer-grid v6-4cols-rowflow-20260718 - 横向排序自动流动 */
.answer-sheet {
    padding: 10mm;
    background: #fff;
}

.answer-grid-row {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px 12px;
    font-size: 12px;
    line-height: 1.4;
    grid-auto-flow: row;
}

.answer-item {
    padding: 2px 0;
    border-bottom: 1px dotted #cbd5e1;
    word-break: break-word;
    overflow-wrap: break-word;
    break-inside: avoid;
}

.answer-item .ans-line1 {
    margin-bottom: 2px;
}

.answer-item .ans-no {
    display: inline-block;
    min-width: 24px;
    color: #0f172a;
    font-weight: 600;
}

.answer-item .ans-def {
    color: #334155;
}

.answer-item .ans-line2 {
    padding-left: 24px;
}

.answer-item .ans-en {
    color: #2563eb;
    font-weight: 500;
}

@media print {
    .answer-area {
        display: block !important;
    }
    .answer-sheet {
        padding: 8mm;
        box-shadow: none;
    }
    .answer-item {
        break-inside: avoid;
    }
}
