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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f1f5f9;
    --bg-white: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --sidebar-active: #2563eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #fff;
}

.sidebar-header p {
    font-size: 13px;
    color: var(--text-muted);
}

.step-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.step-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.step-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.step-item.active {
    background: rgba(37, 99, 235, 0.15);
    border-left-color: var(--sidebar-active);
}

.step-item.completed .step-num {
    background: var(--success);
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    margin-right: 12px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.step-item.active .step-num {
    background: var(--sidebar-active);
}

.step-label {
    font-size: 14px;
    font-weight: 500;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-preview {
    width: 100%;
    justify-content: center;
    background: var(--sidebar-active);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-preview:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-reset {
    width: 100%;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.btn-reset:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-text);
    border-color: rgba(255, 255, 255, 0.3);
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
    max-width: 900px;
}

.form-panel {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.form-header {
    padding: 28px 32px 20px;
    border-bottom: 1px solid var(--border);
}

.form-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.form-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.form-body {
    padding: 28px 32px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-group .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="text"]::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.input-with-unit {
    position: relative;
}

.input-with-unit input {
    padding-right: 50px;
}

.input-with-unit .unit {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.checkbox-item:hover,
.radio-item:hover {
    background: var(--primary-light);
}

.checkbox-item input,
.radio-item input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.form-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}

.step-indicator {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn {
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.preview-panel {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.preview-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.preview-header h2 {
    font-size: 20px;
    font-weight: 700;
}

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

.preview-body {
    padding: 40px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    line-height: 2;
}

.preview-body .doc-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 4px;
}

.preview-body .doc-subtitle {
    text-align: center;
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--text);
}

.preview-body .chapter {
    margin-bottom: 24px;
}

.preview-body .chapter-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.preview-body .chapter-content {
    font-size: 14px;
    text-indent: 2em;
    color: #334155;
}

.preview-body .chapter-content p {
    margin-bottom: 8px;
    text-indent: 2em;
}

.preview-body .chapter-content .no-indent {
    text-indent: 0;
}

.preview-body .chapter-content .sub-title {
    font-weight: 600;
    text-indent: 0;
    margin-top: 12px;
    margin-bottom: 6px;
}

.hidden {
    display: none !important;
}

.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: #fff;
    padding: 12px 28px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.section-divider {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border);
}

.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: 1000;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 520px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

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

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--border);
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #fafbfc;
    border-radius: 0 0 12px 12px;
}

.sheet-size-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.sheet-size-item {
    cursor: pointer;
}

.sheet-size-item input {
    display: none;
}

.sheet-size-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
    transition: all 0.2s;
    background: var(--bg-white);
}

.sheet-size-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.sheet-size-item input:checked + .sheet-size-card {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.sheet-size-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.sheet-size-item input:checked + .sheet-size-card .sheet-size-name {
    color: var(--primary);
}

.sheet-size-dim {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.modal-hint {
    margin-top: 16px;
    padding: 12px 16px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius);
    font-size: 13px;
    color: #0369a1;
    line-height: 1.8;
}

.modal-hint p {
    margin: 0;
}

.modal-hint code {
    background: #e0f2fe;
    padding: 1px 6px;
    border-radius: 3px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    color: #0369a1;
}

.format-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.format-item {
    cursor: pointer;
}

.format-item input {
    display: none;
}

.format-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s;
    background: var(--bg-white);
    position: relative;
}

.format-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.format-item input:checked + .format-card {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.format-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.format-item input:checked + .format-card .format-name {
    color: var(--primary);
}

.format-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.format-tag {
    position: absolute;
    top: -8px;
    right: 12px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        overflow: hidden;
    }

    .sidebar-header h1,
    .sidebar-header p,
    .step-label {
        display: none;
    }

    .sidebar-header {
        padding: 16px;
        text-align: center;
    }

    .step-item {
        justify-content: center;
        padding: 12px 0;
    }

    .step-num {
        margin-right: 0;
    }

    .main-content {
        margin-left: 60px;
        padding: 16px;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .form-body {
        padding: 20px;
    }

    .form-header {
        padding: 20px;
    }

    .form-footer {
        padding: 16px 20px;
    }

    .preview-body {
        padding: 20px;
    }

    .sheet-size-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .modal {
        width: 95vw;
    }
}
