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

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
    background: #eef2f7;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.nav-primary {
    width: 80px;
    background: #f7f7f7;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    gap: 8px;
    flex-shrink: 0;
    z-index: 20;
}

.nav-item {
    width: 62px;
    height: 62px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    color: #94a3b8;
    font-size: 11px;
}

.nav-item:hover { background: #8200db; color: #cbd5e1; }
.nav-item.active { background: #8200db; color: white; }
.nav-icon i { font-size: 18px; }
.nav-label { font-size: 15px; }

.settings-panel {
    width: 360px;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #e2e8f0;
    flex-shrink: 0;
    z-index: 15;
}

.panel-header {
    padding: 18px 20px 12px;
    border-bottom: 1px solid #eef2f8;
    flex-shrink: 0;
}

.panel-header h2 { font-size: 18px; font-weight: 700; color: #1e293b; }
.panel-header p { font-size: 12px; color: #64748b; margin-top: 4px; }

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.setting-page { display: none; }
.setting-page.active { display: block; }

.param-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.param-group label { font-size: 12px; font-weight: 600; color: #475569; }

.sub-tabs {
    display: flex;
    gap: 8px;
    background: #f1f5f9;
    padding: 8px;
    border-radius: 40px;
    margin-bottom: 20px;
}
.sub-tab {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    transition: 0.2s;
}
.sub-tab.active {
    background: #8200db;
    color: white;
    box-shadow: 0 2px 6px rgba(59,130,246,0.3);
}
.sub-content { display: none; }
.sub-content.active { display: block; }

textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    padding: 12px;
    font-size: 13px;
    font-family: 'Consolas', monospace;
    resize: vertical;
    outline: none;
}
textarea:focus { border-color: #8200db; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.main-textarea { min-height: 580px; }

.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 28px 16px;
    text-align: center;
    background: #fafcff;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 16px;
}
.upload-area:hover { border-color: #3b82f6; background: #f0f6ff; }
.file-info { font-size: 11px; color: #3b82f6; margin-top: 8px; }

.paper-cards {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.paper-card {
    flex: 1;
    min-width: 90px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.paper-card:hover { border-color: #94a3b8; background: #f1f5f9; }
.paper-card.active {
    border-color: #8200db;
    background: #eff6ff;
    box-shadow: 0 4px 10px rgba(59,130,246,0.15);
}
.paper-icon { font-size: 28px; margin-bottom: 6px; }
.paper-icon i{font-size: 39px;}
.paper-name { font-size: 12px; font-weight: 600; color: #1e293b; }
.paper-desc { font-size: 10px; color: #64748b; margin-top: 4px; }

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}
.slider-container input {
    flex: 1;
    height: 4px;
    border-radius: 4px;
    -webkit-appearance: none;
    background: #e2e8f0;
}
.slider-container input::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    -webkit-appearance: none;
}
.value-badge {
    background: #eef2ff;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    color: #1e40af;
    min-width: 52px;
    text-align: center;
}
select {
    padding: 9px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: white;
    font-size: 13px;
}
.align-group {
    display: flex;
    gap: 10px;
}
.align-btn {
    flex: 1;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 40px;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.align-btn.active {
    background: #8200db;
    border-color: #8200db;
    color: white;
}
.char-count {
    font-size: 11px;
    color: #64748b;
    text-align: right;
    margin-top: 6px;
}

.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #e2e8f0;
    overflow: hidden;
    position: relative;
}
.preview-toolbar {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid rgba(203,213,225,0.5);
    z-index: 5;
    flex-shrink: 0;
}
.action-group { display: flex; gap: 12px; }
.btn-primary, .btn-secondary, .btn-pdf {
    border: none;
    padding: 8px 20px;
    border-radius: 40px;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
    color: white;
}
.btn-primary { background: #3b82f6; }
.btn-secondary { background: #10b981; }
.btn-pdf { background: #ef4444; }

/* 滚动容器：内容超出时自动出现滚动条 */
.canvas-wrapper {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #d1d9e8;
    cursor: default;
}

.drag-container {
    position: relative;
    display: inline-block;
    transform-origin: 0 0;
}

.preview-img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;  /* 让图片不干扰鼠标事件，由 drag-container 统一处理拖动 */
}

.drag-container.dragging-active {
    cursor: grab;
}
.drag-container.dragging-active:active {
    cursor: grabbing;
}

.preview-footer {
    background: rgb(255 255 255 / 92%);
    backdrop-filter: blur(12px);
    padding: 8px 20px;
    border-radius: 60px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid rgba(203,213,225,0.5);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    z-index: 10;
    flex-shrink: 0;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}
.preview-footer .toolbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    color: #475569;
    font-size: 18px;
}
.preview-footer .toolbar-btn i{font-size: 18px}
.preview-footer .toolbar-btn:hover { background: #e2e8f0; }
.preview-footer .toolbar-btn.active { background: #8200db; color: white; }
.preview-footer .page-info { font-size: 13px; font-weight: 600; color: #475569; padding: 0 8px; }
.preview-footer .page-nav { display: flex; align-items: center; gap: 8px; }
.preview-footer .page-nav button {
    background: white;
    border: 1px solid #cbd5e1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    color: #475569;
}
.preview-footer .page-nav button:hover { background: #f1f5f9; }
.preview-footer .divider { width: 1px; height: 24px; background: #e2e8f0; }
.explain {
    font-size: 14px;
    padding: 6px 15px;
    border-radius: 3px;
    background-color: #fdf7fe;
    color: #8200db;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}
.explain .icon-tishi{color: #8200db;margin-right: 8px;}

.loading-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 24px;
    padding: 32px 48px;
    text-align: center;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(130, 0, 219, 0.3);
    animation: fadeInScale 0.3s ease-out;
}
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px auto;
    border: 3px solid rgba(130, 0, 219, 0.2);
    border-top: 3px solid #8200db;
    border-right: 3px solid #a855f7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loading-text { color: white; font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.loading-subtext { color: #94a3b8; font-size: 12px; }

.app-container:fullscreen,
.app-container:-webkit-full-screen {
    overflow: auto;
    background: #eef2f7;
}
.paper-card[data-paper="line"] .paper-icon i {
    color: #e74c3c;
}
.paper-card[data-paper="line-black"] .paper-icon i {
    color: #333333;
}
.paper-card[data-paper="line-blue"] .paper-icon i {
    color: #4682b4;
}
@media (max-width: 900px) {
    .settings-panel { width: 300px; }
}
.canvas-wrapper::-webkit-scrollbar { width: 10px; height: 10px; }
.canvas-wrapper::-webkit-scrollbar-track { background: #cbd5e1; border-radius: 6px; }
.canvas-wrapper::-webkit-scrollbar-thumb { background: #64748b; border-radius: 6px; }
.canvas-wrapper::-webkit-scrollbar-thumb:hover { background: #475569; }