:root {
    --bg: #282a36;
    --bg-darker: #1e1f29;
    --bg-sidebar: #21222c;
    --bg-actbar: #191a21;
    --current-line: #44475a;
    --selection: #44475a;
    --fg: #f8f8f2;
    --comment: #6272a4;
    --cyan: #8be9fd;
    --green: #50fa7b;
    --orange: #ffb86c;
    --pink: #ff79c6;
    --purple: #bd93f9;
    --red: #ff5555;
    --yellow: #f1fa8c;

    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

    --sidebar-w: 240px;
    --actbar-w: 48px;
    --statusbar-h: 24px;
    --tabs-h: 36px;
    --transition: .18s ease;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--fg);
    background: var(--bg);
}

body {
    display: grid;
    grid-template-columns: var(--actbar-w) var(--sidebar-w) 1fr;
    grid-template-rows: 1fr var(--statusbar-h);
    grid-template-areas:
        "actbar sidebar editor"
        "status status  status";
}

body.sidebar-closed {
    grid-template-columns: var(--actbar-w) 0px 1fr;
}

body.sidebar-closed #sidebar {
    width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 9999;
    background: var(--purple);
    color: #fff;
    padding: 8px 16px;
    font-size: 14px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    position: fixed;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    overflow: visible;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .18);
}

#activity-bar {
    grid-area: actbar;
    background: var(--bg-actbar);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
    gap: 4px;
    border-right: 1px solid rgba(255, 255, 255, .04);
    z-index: 10;
}

.activity-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--comment);
    cursor: pointer;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
    position: relative;
}

.activity-icon:hover {
    color: var(--fg);
    background: rgba(255, 255, 255, .05);
}

.activity-icon.active {
    color: var(--fg);
}

.activity-icon.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--fg);
    border-radius: 0 2px 2px 0;
}

#sidebar {
    grid-area: sidebar;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, .04);
    transition: width var(--transition), opacity var(--transition);
    overflow: hidden;
    width: var(--sidebar-w);
    user-select: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 6px;
    min-height: 38px;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--comment);
}

.sidebar-header button {
    background: none;
    border: none;
    color: var(--comment);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
}

.sidebar-header button:hover {
    color: var(--fg);
    background: rgba(255, 255, 255, .07);
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .5px;
    color: var(--fg);
    cursor: default;
}

.chevron {
    transition: transform var(--transition);
}

.chevron.open {
    transform: rotate(90deg);
}

#notes-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding-bottom: 12px;
}

#notes-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px 4px 28px;
    cursor: pointer;
    font-size: 13px;
    color: var(--fg);
    transition: background var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

#notes-list li .note-icon {
    flex-shrink: 0;
    color: var(--purple);
    display: flex;
    align-items: center;
}

#notes-list li .note-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

#notes-list li:hover {
    background: rgba(255, 255, 255, .04);
}

#notes-list li.active {
    background: var(--selection);
}

#notes-list li .delete-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--comment);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
    border-radius: 3px;
}

#notes-list li:hover .delete-btn {
    opacity: 1;
}

#notes-list li .delete-btn:hover {
    color: var(--red);
    background: rgba(255, 85, 85, .12);
}

#editor-area {
    grid-area: editor;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

#split-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

.editor-pane+.editor-pane {
    border-left: 2px solid rgba(255, 255, 255, .06);
}

.editor-pane.active-pane>.pane-tabs-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: transparent;
}

.pane-tabs-bar {
    display: flex;
    align-items: stretch;
    height: var(--tabs-h);
    background: var(--bg-darker);
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    position: relative;
}

.pane-tabs-bar:empty {
    display: none;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    font-size: 12px;
    color: var(--comment);
    cursor: pointer;
    border-right: 1px solid rgba(255, 255, 255, .04);
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
    position: relative;
    min-width: 0;
    flex-shrink: 0;
}

.tab:hover {
    color: var(--fg);
}

.tab .tab-name {
    cursor: text;
}

.tab.active {
    background: var(--bg);
    color: var(--fg);
}

.tab.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--purple);
}

.tab .tab-close {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity var(--transition), background var(--transition);
}

.tab:hover .tab-close,
.tab.active .tab-close {
    opacity: 1;
}

.tab .tab-close:hover {
    background: rgba(255, 255, 255, .1);
    color: var(--fg);
}

.pane-editor-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.pane-welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--comment);
    animation: fadeIn .4s ease;
}

.welcome-title {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 600;
    color: var(--purple);
    letter-spacing: -0.5px;
}

.welcome-sub {
    font-size: 14px;
    color: var(--comment);
}

.pane-welcome-screen kbd {
    margin-top: 8px;
    background: var(--current-line);
    padding: 6px 14px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--comment);
    border: 1px solid rgba(255, 255, 255, .06);
}

.pane-welcome-screen kbd strong {
    color: var(--green);
}

.pane-editor-container {
    display: flex;
    height: 100%;
}

.pane-editor-container.hidden {
    display: none;
}

.pane-line-numbers {
    min-width: 50px;
    padding: 16px 12px 16px 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
    color: var(--comment);
    user-select: none;
    overflow: hidden;
    background: var(--bg);
    opacity: .5;
    white-space: pre;
}

.pane-editor {
    flex: 1;
    padding: 16px 20px;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
    caret-color: var(--purple);
    tab-size: 4;
    overflow-y: auto;
}

.pane-editor::placeholder {
    color: var(--comment);
    opacity: .4;
}

#status-bar {
    grid-area: status;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--purple);
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    z-index: 20;
}

.status-left,
.status-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-credit {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    text-decoration: none;
    font-size: 11px;
    transition: opacity var(--transition);
}

.status-credit:hover {
    opacity: .8;
}

.status-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
}

.status-credit strong {
    font-weight: 600;
}

.status-sep {
    opacity: .4;
    font-size: 10px;
}

#context-menu {
    position: fixed;
    background: var(--bg-darker);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 6px;
    padding: 4px 0;
    min-width: 180px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
    z-index: 1000;
    animation: ctxIn .12s ease;
}

#context-menu.hidden {
    display: none;
}

@keyframes ctxIn {
    from {
        opacity: 0;
        transform: scale(.96) translateY(-4px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    cursor: pointer;
    color: var(--fg);
    font-size: 12px;
    transition: background var(--transition);
    border-radius: 0;
}

.ctx-item:hover {
    background: var(--selection);
}

.ctx-item.danger {
    color: var(--red);
}

.ctx-item.danger:hover {
    background: rgba(255, 85, 85, .12);
}

.ctx-separator {
    height: 1px;
    background: rgba(255, 255, 255, .06);
    margin: 4px 0;
}

#rename-overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1100;
    pointer-events: none;
}

#rename-overlay.hidden {
    display: none;
}

#rename-input {
    background: var(--bg-darker);
    border: 1px solid var(--purple);
    color: var(--fg);
    font-family: var(--font-ui);
    font-size: 13px;
    padding: 3px 8px;
    border-radius: 3px;
    outline: none;
    width: 180px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
    pointer-events: auto;
}

@media (max-width: 768px) {
    body {
        grid-template-columns: var(--actbar-w) 0px 1fr;
    }

    body:not(.sidebar-closed) {
        grid-template-columns: var(--actbar-w) var(--sidebar-w) 1fr;
    }

    #sidebar {
        position: fixed;
        left: var(--actbar-w);
        top: 0;
        bottom: var(--statusbar-h);
        z-index: 50;
        box-shadow: 10px 0 30px rgba(0, 0, 0, .5);
        transform: translateX(-100%);
        opacity: 0;
        transition: transform var(--transition), opacity var(--transition);
    }

    body:not(.sidebar-closed) #sidebar {
        transform: translateX(0);
        opacity: 1;
        width: var(--sidebar-w);
    }

    .editor-pane {
        flex: 1 0 100%;
    }

    #split-container {
        flex-direction: column;
    }

    .editor-pane+.editor-pane {
        border-left: none;
        border-top: 2px solid rgba(255, 255, 255, .06);
    }

    .welcome-title {
        font-size: 20px;
    }
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}