/**
 * 字帖临摹工具前台样式 - 左右布局 / 分页打印版
 */

/* 主容器 - 左右布局 */
.calligraphy-container {
    display: flex;
    flex-direction: row;
    gap: 20px;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    align-items: flex-start;
}

/* 左侧工具设置区 */
.right-panel {
    width: 380px;
    min-width: 320px;
    max-width: 450px;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    flex-shrink: 0;
}

/* 工具栏Tab选项卡布局 */
.toolbar-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    background: #e8e8e8;
    border-radius: 6px;
    padding: 4px;
    width: fit-content;
    max-width: 100%;
    flex-wrap: wrap;
}

.toolbar-tab {
    flex: 0 0 auto;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
}

.toolbar-tab:hover {
    background: rgba(255,255,255,0.6);
}

.toolbar-tab.active {
    background: #fff;
    color: #007bff;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.toolbar-panel {
    display: none;
}

.toolbar-panel.active {
    display: block;
}

.toolbar-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: flex-end;
}

.toolbar-grid .form-group {
    margin-bottom: 0;
    flex: 0 0 auto;
    min-width: 180px;
}

.toolbar-grid .form-group:has(textarea),
.toolbar-grid .form-group:has(#custom-text) {
    width: 100%;
    min-width: 100%;
}

/* 字体选择Tab区域 */
.toolbar-grid .form-group:has(.font-tabs) {
    width: 100%;
    min-width: 100%;
}

/* 紧凑的滑块组 */
.toolbar-grid .form-group:has(input[type="range"]) {
    min-width: 200px;
    max-width: 280px;
}

/* 单选组横向排列 */
.toolbar-grid .form-group:has(.radio-group) {
    min-width: 300px;
    flex: 1 1 auto;
}

.toolbar-form-actions {
    width: 100%;
    justify-content: flex-start;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 10px;
    display: flex;
}

.toolbar-form-actions .btn {
    flex: 0 0 auto;
    min-width: 100px;
}

/* 右侧预览区 */
.left-panel {
    flex: 1;
    background: #fff;
    min-width: 0;
}

.left-panel .placeholder {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
    border: 2px dashed #ddd;
    border-radius: 8px;
}

.right-panel h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 18px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

.right-panel h4 {
    margin: 20px 0 10px;
    font-size: 14px;
    color: #555;
}

/* 表单组 */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group select,
.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 单选组 */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 15px;
}

.radio-group label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: normal;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.radio-group input[type="radio"] {
    margin: 0;
}

/* 复选框标签 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}

/* 按钮 */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    text-align: center;
}

.btn-primary {
    background: #007bff;
    color: #fff;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-small {
    padding: 5px 12px;
    font-size: 12px;
}

/* 表单操作区 */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions .btn {
    flex: 1;
}

/* 禁用状态 */
.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.disabled-text {
    color: #999;
    font-style: italic;
    font-size: 13px;
}

/* ===== Tab 选项卡 ===== */
.font-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    padding: 3px;
    width: fit-content;
    max-width: 100%;
}

.font-tab {
    flex: 0 0 auto;
    padding: 5px 12px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 13px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
}

.font-tab:hover {
    background: rgba(255,255,255,0.5);
}

.font-tab.active {
    background: #fff;
    color: #007bff;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.font-tab-panel {
    display: none;
}

.font-tab-panel.active {
    display: block;
}

/* 保存内容行 */
.save-content-row {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.save-content-row .input-small {
    flex: 1;
    min-width: 120px;
}

/* 页码指示器 */
.page-indicator {
    margin-top: 15px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

/* 维护信息 */
.calligraphy-maintenance {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
    background: #f5f5f5;
    border-radius: 8px;
}

/* ========== 滑块样式 ========== */
input[type="range"]#font-size-slider,
input[type="range"]#font-color-slider {
    width: 100%;
    margin: 8px 0 4px;
}

.slider-hint {
    font-size: 12px;
    color: #999;
    margin-top: 2px;
}

/* ========== 颜色选择器 ========== */
.color-preview {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid #ccc;
    vertical-align: middle;
    margin: 0 4px;
}

.color-quick-btns {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.color-quick-btns .btn-small {
    flex: 0 0 auto;
    min-width: 60px;
    padding: 4px 10px;
    font-size: 11px;
}

/* ========== 拼音行（每行汉字上方单独显示） ========== */
.pinyin-line {
    display: grid;
    gap: 8px;
    margin-bottom: 2px;
    justify-items: center;
    align-items: end;
    min-height: 1.2em;
}

.pinyin-char {
    font-size: 0.75rem;
    color: #555;
    text-align: center;
    line-height: 1.2;
    min-height: 1.2em;
}

/* ========== 字帖网格 ========== */

.calligraphy-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
    justify-items: center;
    align-items: center;
}

/* 横线格使用块级布局 */
.calligraphy-grid.blank {
    display: block;
}

.grid-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid #e0e0e0;
    background: transparent;
    overflow: hidden;
    container-type: inline-size;
}

/* 标点符号单元格 */
.grid-cell.punctuation {
    background: transparent;
}

/* 标点符号颜色 - 不强制继承，让内联样式生效 */
.grid-cell.punctuation .hanzi {
    /* color 由 JS 内联样式设置 */
}

/* 空单元格填充 */
.grid-cell.empty-cell {
    background: transparent;
    border-style: dashed;
    opacity: 0.5;
}

/* 横线格的空行占位 */
.calligraphy-grid.blank .grid-cell.empty-cell {
    background: transparent;
    border-bottom: 1px solid #ccc;
    opacity: 0.3;
    min-height: 32px;
    height: 32px;
}

/* 方格模式：确保只有外框，无内部辅助线 */
.calligraphy-grid.fang .grid-cell {
    border: 1px solid #333;
}
.calligraphy-grid.fang .grid-bg {
    display: none !important;
}

/* 方格打印样式 */
@media print {
    .calligraphy-grid.fang .grid-cell {
        border: 0.5px solid #333;
    }
    .calligraphy-grid.fang .grid-bg {
        display: none !important;
    }
}

.hanzi {
    line-height: 1;
    z-index: 2;
    user-select: none;
    /* 字体大小由容器查询或JS动态计算 */
    font-size: var(--cell-font-size, 80%);
    /* 确保文字不换行，防止重叠 */
    white-space: nowrap;
    overflow: hidden;
}

.stroke-num {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.6rem;
    color: #aaa;
    z-index: 2;
}

/* 描红底字 - 已废弃，不再使用 */
.trace-char {
    display: none !important;
}

/* ===== 辅助线元素（使用DOM元素而非CSS背景，确保打印可见） ===== */
.grid-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

/* 确保字体在辅助线上方 */
.hanzi {
    position: relative;
    z-index: 1;
}

/* 回宫格内宫线 */
.grid-bg .inner-rect {
    position: absolute;
    top: 15%;
    left: 15%;
    width: 70%;
    height: 70%;
    border: 1px solid #ccc;
    pointer-events: none;
}

/* 米字格横中线 */
.grid-bg .line-h {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 0;
    border-top: 0.3px solid #ddd;
    pointer-events: none;
}

/* 米字格竖中线 */
.grid-bg .line-v {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 0.3px solid #ddd;
    pointer-events: none;
}

/* 米字格对角线1（左上→右下） */
.grid-bg .line-d1 {
    position: absolute;
    top: 0;
    left: 0;
    width: 141.42%;
    height: 0;
    border-top: 0.3px solid #ddd;
    transform-origin: 0 0;
    transform: rotate(45deg);
    pointer-events: none;
}

/* 米字格对角线2（右上→左下） */
.grid-bg .line-d2 {
    position: absolute;
    top: 0;
    right: 0;
    width: 141.42%;
    height: 0;
    border-top: 0.3px solid #ddd;
    transform-origin: 100% 0;
    transform: rotate(-45deg);
    pointer-events: none;
}

/* 田字格横中线 */
.calligraphy-grid.tian .grid-bg .line-h {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 0;
    border-top: 0.3px solid #ddd;
    pointer-events: none;
}

/* 田字格竖中线 */
.calligraphy-grid.tian .grid-bg .line-v {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 0.3px solid #ddd;
    pointer-events: none;
}

/* 回宫格（外宫大方框 + 内宫小方框，内宫占70%） */
.calligraphy-grid.huigong .grid-bg {
    background: none;
}

/* 回宫格外宫边框 */
.calligraphy-grid.huigong .grid-cell {
    border: 1px solid #333;
}

/* 回宫格打印样式 */
@media print {
    .calligraphy-grid.huigong .grid-cell {
        border: 0.5px solid #333;
    }
    .calligraphy-grid.huigong .grid-bg .inner-rect {
        border-color: #5a6b7a;
    }
}

/* 米字格（横中线+竖中线+两条对角线） */
.calligraphy-grid.mi .grid-bg {
    background: none;
}

/* 田字格（横中线+竖中线，四分格定位） */
.calligraphy-grid.tian .grid-bg {
    background: none;
}

/* 方格（仅外框，无内部辅助线） */
.calligraphy-grid.fang .grid-bg {
    display: none !important;
}
.calligraphy-grid.fang .grid-cell {
    border: 1px solid #333;
}

/* 无辅助线模式（空白格） */
.calligraphy-grid.none .grid-bg {
    display: none !important;
}
.calligraphy-grid.none .grid-cell {
    border: none !important;
}

/* 横线格（底部横线，模拟作业本） */
.calligraphy-grid.blank {
    display: block;
}
.calligraphy-grid.blank .grid-cell {
    border: none;
    border-bottom: 1px solid #ccc;
    aspect-ratio: auto;
    width: 100%;
    min-height: 32px;
    height: 32px;
    justify-content: flex-start;
    align-items: center;
    padding-left: 5px;
    margin: 6px 0;
    display: flex;
    flex-direction: row;
}
.calligraphy-grid.blank .grid-cell .hanzi {
    font-size: var(--cell-font-size, 20px);
    line-height: 32px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* 不设置 color: inherit，让内联样式或父级继承自然生效 */
}
.calligraphy-grid.blank .grid-cell.empty-cell {
    background: transparent;
    border-bottom: 1px solid #ccc;
    opacity: 0.3;
    min-height: 32px;
    height: 32px;
}

/* 打印分页 */
.print-page {
    margin-bottom: 30px;
    border: 1px dashed #ddd;
    padding: 15px;
    background: transparent;
    page-break-after: always;
    break-inside: avoid;
    container-type: inline-size;
}

.print-page:last-child {
    page-break-after: auto;
}

/* ========== 打印样式 ========== */

@media print {
    .right-panel,
    .page-indicator,
    .btn,
    .placeholder,
    .toolbar-tabs,
    .toolbar-form-actions {
        display: none !important;
    }

    .calligraphy-container {
        padding: 0;
        gap: 0;
    }

    .left-panel {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .print-page {
        page-break-after: always;
        break-inside: avoid;
        margin: 0;
        border: none;
        padding: 10mm 10mm 20mm 10mm;
        position: relative;
        height: auto;
        background: transparent !important;
        box-sizing: border-box;
    }

    .print-page:last-child {
        page-break-after: auto;
    }

    /* 打印页眉 */
    .print-page::before {
        content: attr(data-page-header);
        display: block;
        text-align: center;
        font-size: 12px;
        color: #999;
        margin-bottom: 8px;
        border-bottom: 0.5px solid #ddd;
        padding-bottom: 4px;
    }

    /* 打印页脚 - 已移除 ::after，页脚由 JS 动态创建 */
    .grid-cell {
        border: 0.5px solid #ccc;
        break-inside: avoid;
        background: transparent !important;
    }

    .grid-cell.empty-cell {
        background: transparent;
        border-style: dashed;
        opacity: 0.3;
    }
    .calligraphy-grid.blank .grid-cell.empty-cell {
        background: transparent;
        border-bottom: 0.5px solid #ccc;
        min-height: 25px;
        height: 25px;
    }

    .grid-cell.punctuation {
        background: transparent;
    }

    .hanzi {
        /* 不强制颜色，让用户选择的颜色生效 */
        font-size: var(--cell-font-size, 80%) !important;
    }

    .grid-bg {
        opacity: 0.7;
        z-index: 0;
    }

    .hanzi {
        z-index: 1 !important;
    }

    /* 打印时辅助线颜色 */
    .grid-bg .inner-rect {
        border-color: #ccc !important;
    }
    .grid-bg .line-h,
    .grid-bg .line-v,
    .grid-bg .line-d1,
    .grid-bg .line-d2 {
        border-color: #ddd !important;
    }

    .calligraphy-grid.none .grid-cell {
        border: none !important;
    }
    .calligraphy-grid.none .grid-bg {
        display: none !important;
    }

    .calligraphy-grid.blank {
        display: block;
    }
    .calligraphy-grid.blank .grid-cell {
        border: none;
        border-bottom: 0.5px solid #ccc;
        aspect-ratio: auto;
        width: 100%;
        min-height: 25px;
        height: 25px;
        justify-content: flex-start;
        align-items: center;
        padding-left: 5px;
        margin: 4px 0;
        display: flex;
        flex-direction: row;
    }
    .calligraphy-grid.blank .grid-cell .hanzi {
        font-size: 16px;
        line-height: 25px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .calligraphy-grid.blank .grid-cell.empty-cell {
        background: transparent;
        border-bottom: 0.5px solid #ccc;
        min-height: 25px;
        height: 25px;
    }

    .calligraphy-grid {
        gap: 4px;
    }

    .pinyin-line {
        gap: 4px;
        margin-bottom: 2px;
    }

    .pinyin-char {
        /* 不强制颜色，使用屏幕样式 */
        font-size: 0.7rem;
    }

    /* .pinyin-row 和 .pinyin-cell 未使用，实际使用 .pinyin-char */

    .stroke-num {
        /* 不强制颜色，使用屏幕样式 */
    }

    .trace-char {
        /* 描红功能已废弃 */
        display: none !important;
    }
}

/* ========== 响应式 ========== */

/* 平板和手机端：切换为上下布局 */
@media (max-width: 900px) {
    .calligraphy-container {
        flex-direction: column;
        padding: 10px;
        gap: 15px;
    }

    .right-panel {
        width: 100%;
        min-width: auto;
        max-width: none;
        padding: 15px;
    }

    .left-panel {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .hanzi {
        font-size: var(--cell-font-size, 1.8rem);
    }

    .toolbar-tabs {
        width: 100%;
        flex-wrap: wrap;
    }

    .toolbar-tab {
        flex: 1 1 auto;
        font-size: 13px;
        padding: 6px 10px;
        min-width: 70px;
    }

    .toolbar-grid .form-group {
        min-width: 100%;
        max-width: none;
    }

    .form-actions {
        flex-direction: column;
    }
}

/* ========== 几行几列自定义样式 ========== */
.rows-cols-group {
    min-width: 250px;
}

.rows-cols-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rows-cols-inputs span {
    font-weight: bold;
    color: #666;
}

/* ========== 自定义纸张尺寸 ========== */
.custom-paper-size .custom-size-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

.custom-size-inputs input {
    width: 80px;
}

/* ========== 打印边距输入 ========== */
.margin-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.margin-inputs input {
    width: 60px;
}

.margin-row {
    margin-top: 5px;
}

/* ========== 打印页面页脚区域 ========== */
.print-page {
    position: relative;
}

.page-content {
    padding-bottom: 0;
}

.page-footer-area {
    display: none; /* 预览时不显示页脚 */
}

.page-number {
    margin-left: 20px;
    font-weight: bold;
}

/* ========== 管理Tab样式 ========== */
.saved-contents-list {
    max-height: 500px;
    overflow-y: auto;
}

/* Card-based layout for saved contents */
.saved-contents-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.saved-content-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
}

.saved-content-card:hover {
    border-color: #007bff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card-title {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.card-date {
    color: #999;
    font-size: 12px;
}

.card-preview {
    color: #666;
    font-size: 13px;
    margin-bottom: 10px;
    line-height: 1.4;
    word-break: break-all;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.card-actions .btn {
    flex: 0 0 auto;
}

.btn-danger {
    color: #dc3545 !important;
    border-color: #dc3545 !important;
}

.btn-danger:hover {
    background: #dc3545 !important;
    color: #fff !important;
}

.no-contents {
    color: #999;
    text-align: center;
    padding: 20px;
}

/* ========== 编辑对话框样式 ========== */
.content-edit-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.dialog-content {
    position: relative;
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    min-width: 400px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.dialog-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

.dialog-content .form-group {
    margin-bottom: 15px;
}

.dialog-content .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.dialog-content .form-group input,
.dialog-content .form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ========== 打印页脚固定样式 ========== */
.print-footer-fixed {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 5mm 0;
    font-size: 11px;
    color: #999;
    background: #fff;
}

.footer-text {
    display: inline;
}

.footer-page-num {
    display: inline;
    margin-left: 20px;
}

/* ========== 打印样式更新 ========== */
@media print {
    .right-panel,
    .page-indicator,
    .btn,
    .placeholder,
    .toolbar-tabs,
    .toolbar-form-actions {
        display: none !important;
    }

    .calligraphy-container {
        padding: 0;
        gap: 0;
    }

    .left-panel {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .print-page {
        page-break-after: always;
        break-inside: avoid;
        margin: 0;
        border: none;
        padding: 10mm 10mm 25mm 10mm;
        position: relative;
        min-height: 100vh;
        background: transparent !important;
    }

    .print-page:last-child {
        page-break-after: auto;
    }

    .page-content {
        padding-bottom: 15mm;
    }

    .page-footer-area {
        position: absolute;
        bottom: 5mm;
        left: 0;
        right: 0;
        font-size: 10px;
    }

    .page-number {
        font-size: 10px;
    }

    .grid-cell {
        border: 0.5px solid #ccc;
        break-inside: avoid;
        background: transparent !important;
    }

    .grid-cell.empty-cell {
        background: transparent;
        border-style: dashed;
        opacity: 0.3;
    }
    .calligraphy-grid.blank .grid-cell.empty-cell {
        background: transparent;
        border-bottom: 0.5px solid #ccc;
        min-height: 25px;
        height: 25px;
    }

    .grid-cell.punctuation {
        background: transparent;
    }

    .hanzi {
        font-size: var(--cell-font-size, 80%) !important;
        z-index: 1 !important;
    }

    .grid-bg {
        opacity: 0.7;
        z-index: 0;
    }

    .grid-bg .inner-rect {
        border-color: #ccc !important;
    }
    .grid-bg .line-h,
    .grid-bg .line-v,
    .grid-bg .line-d1,
    .grid-bg .line-d2 {
        border-color: #ddd !important;
    }

    .calligraphy-grid.none .grid-cell {
        border: none !important;
    }
    .calligraphy-grid.none .grid-bg {
        display: none !important;
    }

    .calligraphy-grid.blank {
        display: block;
    }
    .calligraphy-grid.blank .grid-cell {
        border: none;
        border-bottom: 0.5px solid #ccc;
        aspect-ratio: auto;
        width: 100%;
        min-height: 25px;
        height: 25px;
        justify-content: flex-start;
        align-items: center;
        padding-left: 5px;
        margin: 4px 0;
        display: flex;
        flex-direction: row;
    }
    .calligraphy-grid.blank .grid-cell .hanzi {
        font-size: 16px;
        line-height: 25px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .calligraphy-grid.blank .grid-cell.empty-cell {
        background: transparent;
        border-bottom: 0.5px solid #ccc;
        min-height: 25px;
        height: 25px;
    }

    .calligraphy-grid {
        gap: 4px;
    }

    .pinyin-line {
        gap: 4px;
        margin-bottom: 2px;
    }

    .pinyin-char {
        font-size: 0.7rem;
    }

    .stroke-num {
    }

    .trace-char {
        display: none !important;
    }

    .saved-contents-table,
    .content-edit-dialog {
        display: none !important;
    }
}

/* ========== 弹窗样式 ========== */
.modal-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: 10000;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 420px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.modal-small {
    max-width: 360px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 15px 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Modal tabs */
.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-tab {
    padding: 8px 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.modal-tab:hover {
    color: #007bff;
}

.modal-tab.active {
    color: #007bff;
    border-bottom-color: #007bff;
    font-weight: 500;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* Content list select */
.content-list-select {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    font-size: 14px;
    min-height: 150px;
}

.content-list-select option {
    padding: 6px 8px;
    cursor: pointer;
}

.content-list-select option:hover {
    background: #f0f0f0;
}

/* Content items in modal */
.content-list-container {
    max-height: 250px;
    overflow-y: auto;
}

.content-item {
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.content-item:hover {
    border-color: #007bff;
    background: #f0f7ff;
}

.content-item.selected {
    border-color: #007bff;
    background: #e6f0ff;
}

.content-item-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.content-item-preview {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.content-item-date {
    font-size: 11px;
    color: #999;
}

.no-contents {
    color: #999;
    text-align: center;
    padding: 30px;
    font-size: 14px;
}

.loading-text {
    color: #999;
    text-align: center;
    padding: 20px;
}

/* Content source button */
.content-source-group {
    width: 100%;
}

.content-source-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 14px;
    border: 2px dashed #ccc;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.content-source-btn:hover {
    border-color: #007bff;
    background: #f0f7ff;
}

.btn-icon {
    font-size: 16px;
}

.btn-save {
    display: flex;
    align-items: center;
    gap: 6px;
}
