:root {
    --sidebar-width: 280px;
    --sidebar-bg: #1a1d27;
    --sidebar-bg-hover: #242836;
    --sidebar-text: #b0b8c8;
    --sidebar-text-active: #ffffff;
    --accent: #5b8def;
    --accent-light: #e8f0fe;
    --accent-glow: rgba(91, 141, 239, 0.25);
    --danger: #e85d75;
    --danger-light: #fde8ec;
    --success: #4caf84;
    --success-light: #e8f7ef;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-focus: #5b8def;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', 'Monaco', 'Menlo', 'Courier New', monospace;
    --grid-color: rgba(0, 0, 0, 0.04);
    --grid-size: 22px;
}


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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    background-color: #f8f9fb;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    background-position: -1px -1px;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
}

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


.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-top {
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.logo-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.65rem;
    font-weight: 700;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    letter-spacing: 0;
    transition: transform var(--transition);
}

.logo-l {
    background: #e8f0fe;
    color: #3b7de0;
}

.logo-i {
    background: #fde8ec;
    color: #d94862;
}

.logo-pipe {
    background: #e5e7eb;
    color: #6b7280;
    font-size: 1.4rem;
}

.logo-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    margin-left: 6px;
    letter-spacing: 0.5px;
}

.logo-subtitle {
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 2px;
    letter-spacing: 0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    font-family: inherit;
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
}

.nav-btn:hover {
    background: var(--sidebar-bg-hover);
    color: #d1d5db;
    border-color: rgba(255, 255, 255, 0.06);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-label {
    font-weight: 500;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 16px 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: #8b92a3;
    font-size: 0.72rem;
    transition: all var(--transition);
    line-height: 1.4;
}

.footer-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #c0c7d4;
}

.footer-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.studio-link:hover {
    color: #a0b8f0;
}

.beian-link {
    font-size: 0.68rem;
}

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    transition: all var(--transition);
}

.mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition);
}

.mobile-menu-toggle:hover {
    box-shadow: var(--shadow-lg);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 28px 28px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
    gap: 16px;
    animation: fadeIn 0.5s ease-out;
}

.mode-tabs {
    display: flex;
    gap: 4px;
    background: var(--card-bg);
    padding: 4px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    align-self: flex-start;
}

.mode-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}

.mode-tab:hover {
    color: var(--text-primary);
    background: #f3f4f6;
}

.mode-tab.active {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.mode-tab:active {
    transform: scale(0.95);
}

.tab-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.richtext-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.richtext-toolbar.hidden {
    display: none;
}

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

.toolbar-group + .toolbar-group {
    border-left: 1px solid var(--border);
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.toolbar-btn:hover {
    background: #f3f4f6;
    color: var(--text-primary);
    border-color: var(--border);
    transform: scale(1.08);
}

.toolbar-btn:active {
    background: #e5e7eb;
    transform: scale(0.93);
}

.editor-preview-container {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 0;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: opacity 0.25s ease-out, box-shadow 0.3s ease;
}

.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.char-count {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #f3f4f6;
    padding: 2px 10px;
    border-radius: 20px;
}

.richtext-editor {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
    outline: none;
    min-height: 300px;
    transition: opacity 0.2s ease;
}

.richtext-editor.hidden {
    display: none;
}

.richtext-editor h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 16px 0 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    color: var(--text-primary);
}

.richtext-editor h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 14px 0 8px;
    color: var(--text-primary);
}

.richtext-editor h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 12px 0 6px;
    color: var(--text-primary);
}

.richtext-editor p {
    margin: 6px 0;
}

.richtext-editor ul,
.richtext-editor ol {
    margin: 8px 0;
    padding-left: 24px;
}

.richtext-editor li {
    margin: 4px 0;
}

.richtext-editor a {
    color: var(--accent);
    text-decoration: underline;
}

.richtext-editor blockquote {
    margin: 10px 0;
    padding: 8px 16px;
    border-left: 4px solid var(--accent);
    background: var(--accent-light);
    color: var(--text-secondary);
}

.richtext-editor code {
    font-family: var(--font-mono);
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
}

.richtext-editor pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 10px 0;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.6;
}

.richtext-editor pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.md-editor {
    flex: 1;
    padding: 20px 24px;
    border: none;
    outline: none;
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-primary);
    resize: none;
    background: #fcfdfe;
    min-height: 300px;
    transition: opacity 0.2s ease, background 0.3s ease;
}

.md-editor.hidden {
    display: none;
}

.md-editor::placeholder {
    color: #b0b8c4;
}

.divider-bar {
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background var(--transition);
    position: relative;
}

.divider-bar:hover,
.divider-bar.active {
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.preview-content {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
    background: #ffffff;
}

.preview-content.preview-md {
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.6;
    padding: 16px 20px;
}

.preview-content h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 16px 0 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

.preview-content h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 14px 0 8px;
}

.preview-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 12px 0 6px;
}

.preview-content p {
    margin: 6px 0;
}

.preview-content ul,
.preview-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.preview-content li {
    margin: 4px 0;
}

.preview-content a {
    color: var(--accent);
}

.preview-content blockquote {
    margin: 10px 0;
    padding: 8px 16px;
    border-left: 4px solid var(--accent);
    background: var(--accent-light);
    color: var(--text-secondary);
}

.preview-content code {
    font-family: var(--font-mono);
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
}

.preview-content pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 10px 0;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.6;
}

.preview-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.preview-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

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

.preview-content th {
    background: #f9fafb;
    font-weight: 600;
}

.preview-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.preview-content hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 16px 0;
}

.export-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    justify-content: center;
    animation: fadeSlideUp 0.4s ease-out;
    transition: box-shadow 0.3s ease;
}

.export-bar:hover {
    box-shadow: var(--shadow-lg);
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.02); }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 20px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-export {
    background: #ffffff;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-export:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: translateY(-1px);
    animation: pulse 0.8s ease-in-out;
}

.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: #1f2937;
    color: #ffffff;
    padding: 12px 22px;
    border-radius: 30px;
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    white-space: nowrap;
}

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

.toast-success-icon {
    width: 18px;
    height: 18px;
    color: #4caf84;
    flex-shrink: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 260px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-overlay.visible {
        display: block;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 16px 12px;
        padding-top: 64px;
    }

    .editor-preview-container {
        flex-direction: column;
    }

    .divider-bar {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }

    .richtext-editor,
    .md-editor {
        min-height: 200px;
    }

    .preview-content {
        min-height: 200px;
    }

    .mode-tabs {
        align-self: stretch;
    }

    .mode-tab {
        flex: 1;
        justify-content: center;
        font-size: 0.82rem;
        padding: 8px 12px;
    }

    .richtext-toolbar {
        justify-content: center;
    }

    .export-bar {
        flex-direction: column;
    }

    .btn-export {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 12px 8px;
        padding-top: 56px;
    }

    .editor-preview-container {
        border-radius: var(--radius);
    }

    .richtext-editor,
    .md-editor,
    .preview-content {
        padding: 14px 16px;
        font-size: 0.88rem;
    }

    .toolbar-btn {
        width: 28px;
        height: 28px;
    }
}
