: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-btn.active {
    background: var(--accent);
    color: #ffffff;
    font-weight: 600;
    border-color: var(--accent);
    box-shadow: 0 4px 14px rgba(91, 141, 239, 0.35);
}

.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: 32px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

.panel {
    width: 100%;
    max-width: 780px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: fadeSlideIn 0.35s ease-out;
    border: 1px solid var(--border);
}

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

.panel-header {
    padding: 24px 28px 18px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}

.panel-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.title-icon {
    font-size: 1.4rem;
}

.panel-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.panel-body {
    padding: 24px 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    flex-wrap: wrap;
}

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

.code-area {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.7;
    resize: vertical;
    transition: all var(--transition);
    background: #fafbfc;
    color: var(--text-primary);
    min-height: 160px;
}

.code-area:focus {
    outline: none;
    border-color: var(--border-focus);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.08);
}

.code-area::placeholder {
    color: #b0b8c4;
}

.output-area {
    background: #f9fafb;
    border-style: dashed;
    cursor: default;
    min-height: 120px;
}

.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.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-primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
    background: #3b7de0;
    border-color: #3b7de0;
    box-shadow: 0 4px 16px rgba(91, 141, 239, 0.35);
    transform: translateY(-1px);
}

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

.btn-outline:hover {
    background: #f9fafb;
    border-color: #c0c7d0;
    color: var(--text-primary);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border-color: var(--border);
    width: 100%;
    justify-content: center;
    padding: 10px 20px;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #c0c7d0;
    box-shadow: var(--shadow-sm);
}

.output-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.output-actions {
    display: flex;
    gap: 8px;
}

.validate-output {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.issue {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.issue-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.issue-warn {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.issue-ok {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.issue-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.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-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: 24px 16px;
        padding-top: 70px;
    }

    .panel-header {
        padding: 18px 16px 14px;
    }

    .panel-body {
        padding: 16px;
        gap: 14px;
    }

    .panel-title {
        font-size: 1.15rem;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

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

    .panel {
        border-radius: var(--radius);
    }

    .panel-body {
        padding: 12px;
        gap: 10px;
    }

    .panel-header {
        padding: 14px 12px 10px;
    }

    .action-row {
        flex-direction: column;
        gap: 8px;
    }

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

    .code-area {
        font-size: 0.85rem;
        padding: 10px 12px;
        min-height: 100px;
    }
}
