:root {
    --primary: #0066ff;
    --primary-dark: #0052cc;
    --primary-light: #e6f0ff;
    --secondary: #6c757d;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --border: #dee2e6;
    --border-light: #f1f3f4;
    
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-xl: 0 8px 24px rgba(0,0,0,0.2);
    
    --radius: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    box-shadow: var(--shadow-sm);
    z-index: 100;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 18px;
    color: var(--primary);
}

.logo i {
    font-size: 20px;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.doc-title {
    font-size: 16px;
    font-weight: 500;
    padding: 6px 12px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    transition: var(--transition);
    min-width: 200px;
    text-align: center;
}

.doc-title:hover {
    background: var(--bg-secondary);
}

.doc-title:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.user-avatar:hover {
    background: var(--primary-dark);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: thin;
    flex-shrink: 0;
}

.toolbar::-webkit-scrollbar {
    height: 4px;
}

.toolbar::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.toolbar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 4px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

.icon-btn, .tool-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    color: var(--text-primary);
    position: relative;
}

.icon-btn:hover, .tool-btn:hover {
    background: var(--bg-secondary);
}

.icon-btn:active, .tool-btn:active {
    transform: scale(0.95);
}

.tool-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.tool-btn.format-painter-active {
    background: var(--warning);
    color: white;
}

.font-select, .size-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    min-width: 120px;
}

.size-select {
    min-width: 80px;
}

.font-select:hover, .size-select:hover {
    border-color: var(--primary);
}

.font-select:focus, .size-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.color-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.sidebar {
    width: 280px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: var(--transition);
    flex-shrink: 0;
    height: 100%;
}

.sidebar.active {
    transform: translateX(0);
}

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

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.outline-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.outline-item {
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    color: var(--text-secondary);
}

.outline-item:hover {
    background: var(--bg-secondary);
}

.doc-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.version-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.version-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    font-size: 13px;
}

.version-time {
    color: var(--text-secondary);
}

.version-desc {
    color: var(--text-primary);
}

.editor-area {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-secondary);
    position: relative;
    padding: 20px;
}

.editor-area::-webkit-scrollbar {
    width: 12px;
}

.editor-area::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.editor-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 6px;
    border: 2px solid var(--bg-secondary);
}

.editor-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.editor-wrapper {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    min-height: 100%;
}

.page {
    padding: 60px;
    outline: none;
    font-size: 16px;
    line-height: 1.8;
    transition: var(--transition);
    min-height: calc(100vh - 250px);
    height: auto;
    padding-bottom: 100px;
}

.page h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 24px 0 16px;
    color: var(--text-primary);
}

.page h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 20px 0 12px;
    color: var(--text-primary);
}

.page h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 16px 0 10px;
    color: var(--text-primary);
}

.page p {
    margin: 12px 0;
    color: var(--text-primary);
}

.page ul, .page ol {
    margin: 12px 0;
    padding-left: 24px;
}

.page li {
    margin: 6px 0;
}

.page blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.page code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    font-size: 0.9em;
}

.page pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
}

.page pre code {
    background: none;
    padding: 0;
}

.page table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.page th, .page td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.page th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.page a {
    color: var(--primary);
    text-decoration: none;
}

.page a:hover {
    text-decoration: underline;
}

.page img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 16px 0;
    cursor: pointer;
    transition: var(--transition);
}

.page img.image-shadow {
    box-shadow: var(--shadow-lg);
}

.page img.image-border {
    border: 2px solid var(--border);
}

.page img.image-rounded {
    border-radius: var(--radius-lg);
}

.page video {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 16px 0;
}

.page iframe {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 16px 0;
}

.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 32px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: 0 16px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-center {
    flex: 1;
    text-align: center;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

.modal-lg {
    max-width: 700px;
}

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

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

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

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border);
}

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

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group input[type="file"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.style-options {
    display: flex;
    gap: 16px;
}

.style-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.image-preview, .video-preview {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    text-align: center;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img, .video-preview iframe {
    max-width: 100%;
    max-height: 300px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.table-size-selector {
    text-align: center;
}

.size-grid {
    display: inline-grid;
    grid-template-columns: repeat(10, 30px);
    grid-template-rows: repeat(10, 30px);
    gap: 2px;
    margin-bottom: 16px;
}

.grid-cell {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 2px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.grid-cell:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.grid-cell.selected {
    background: var(--primary);
    border-color: var(--primary);
}

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

.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.export-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.export-option i {
    font-size: 24px;
    color: var(--primary);
}

.option-info h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.option-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.footer {
    padding: 12px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .toolbar {
        padding: 8px;
    }
    
    .toolbar-group {
        padding: 0 2px;
    }
    
    .page {
        padding: 30px 20px;
    }
    
    .sidebar {
        position: absolute;
        z-index: 200;
        height: 100%;
        box-shadow: var(--shadow-lg);
    }
    
    .export-options {
        grid-template-columns: 1fr;
    }
    
    .modal-dialog {
        width: 95%;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
