:root {
    --bg: #1e1e1e;
    --panel: #252526;
    --panel-2: #2d2d30;
    --panel-3: #1f1f1f;
    --panel-hover: #2a2d2e;

    --line: rgba(255,255,255,.09);
    --line-strong: rgba(255,255,255,.16);

    --text: #cccccc;
    --text-strong: #ffffff;
    --muted: #9da3aa;
    --muted-2: #6f7680;

    --accent: #0078d4;
    --accent-hover: #1f8fff;
    --accent-light: #4da3ff;
    --accent-soft: rgba(0,120,212,.16);
    --accent-mid: rgba(0,120,212,.34);
    --accent-strong: rgba(0,120,212,.52);

    --red: #f87171;
    --green: #4ade80;
    --blue: #4da3ff;

    --shadow: 0 18px 55px rgba(0,0,0,.38);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #2d2d30;
    color: var(--text);
    min-height: 34px;
    padding: 7px 11px;
    font-size: 12px;
    cursor: pointer;
    box-shadow: none;
}

button:hover {
    border-color: var(--accent-strong);
    background: #3a3d41;
}

button:disabled {
    opacity: .45;
    cursor: not-allowed;
    border-color: var(--line);
    background: #2d2d30;
}

button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

button.primary:hover {
    border-color: var(--accent-light);
    background: var(--accent-hover);
}

button.danger-soft {
    background: rgba(248,113,113,.12);
    border-color: rgba(248,113,113,.25);
    color: #fecaca;
}

.ide-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width, 310px) 5px minmax(0, 1fr);
}

.ide-sidebar {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.ide-resizer {
    cursor: col-resize;
    background: #1e1e1e;
    border-right: 1px solid rgba(255,255,255,.05);
}

.ide-resizer:hover,
body.resizing .ide-resizer {
    background: var(--accent-strong);
}

.ide-brand {
    height: 70px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 15px;
    border-bottom: 1px solid rgba(0,120,212,.20);
    background: var(--panel);
}

.ide-logo {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(0,120,212,.28);
    background: rgba(0,120,212,.10);
    flex-shrink: 0;
}

.ide-brand-text {
    min-width: 0;
}

.ide-brand-text strong {
    display: block;
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 750;
}

.ide-brand-text span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ide-toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.ide-toolbar button {
    padding-inline: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ide-toolbar button:hover,
.topbar-actions button:hover {
    border-color: var(--accent-strong);
}

.ide-section-title {
    padding: 11px 14px 6px;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.tree {
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 4px 8px 44px;
    font-size: 13px;
}

.tree ul {
    list-style: none;
    margin: 0 0 0 6px;
    padding-left: 14px;
    border-left: 1px solid rgba(255,255,255,.10);
}

.tree > ul {
    padding-left: 0;
    border-left: 0;
    margin-left: 0;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 29px;
    padding: 0 8px;
    border-radius: 5px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    font-weight: 500;
}

.tree-item:hover {
    background: #2a2d2e;
    color: var(--text-strong);
}

.tree-item.open,
.tree-item.active-parent {
    color: var(--text-strong);
    font-weight: 700;
}

.tree-item.active {
    background: #37373d;
    color: #fff;
    outline: 1px solid rgba(255,255,255,.10);
    box-shadow: inset 3px 0 0 var(--accent);
}

.tree-item.active-parent::before {
    content: "";
    width: 2px;
    height: 16px;
    border-radius: 999px;
    background: var(--accent);
    margin-right: 4px;
}

.tree-toggle {
    width: 12px;
    flex: 0 0 12px;
    text-align: center;
    font-size: 11px;
    color: var(--muted-2);
    transition: .15s;
}

.tree-item.open > .tree-toggle {
    color: var(--accent-light);
    font-weight: 900;
}

.tree-icon {
    width: 18px;
    flex: 0 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #b7bec8;
}

.tree-item.open > .tree-icon,
.tree-item.active-parent > .tree-icon {
    color: #cde6ff;
}

.tree-icon svg,
.tab-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-muted {
    opacity: .45;
}

.code-badge {
    min-width: 22px;
    display: inline-grid;
    place-items: center;
    padding: 1px 3px;
    border-radius: 4px;
    color: #cde6ff;
    background: rgba(0,120,212,.14);
    border: 1px solid rgba(0,120,212,.26);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: -.02em;
}

.ide-main {
    min-width: 0;
    min-height: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #1e1e1e;
}

.ide-topbar {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 0 14px;
    border-bottom: 1px solid rgba(0,120,212,.18);
    background: #252526;
}

.file-meta {
    min-width: 0;
}

.current-file {
    font-size: 13px;
    font-weight: 750;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 44vw;
}

.status-text {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.theme-select {
    height: 34px;
    min-width: 132px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #2d2d30;
    color: var(--text);
    padding: 0 10px;
    font-size: 12px;
    font-weight: 650;
    outline: none;
}

.theme-select:focus {
    border-color: rgba(0,120,212,.75);
}

.ide-tabs {
    height: 39px;
    display: flex;
    align-items: end;
    gap: 1px;
    padding: 0 8px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    background: #252526;
}

.ide-tab {
    position: relative;
    height: 38px;
    min-width: 128px;
    max-width: 260px;
    padding: 0 8px 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #aeb8c5;
    background: #2d2d30;
    border: 1px solid transparent;
    border-bottom: 0;
    cursor: pointer;
    user-select: none;
}

.ide-tab:hover {
    background: #333337;
    color: #fff;
}

.ide-tab.active {
    color: #fff;
    background: #1e1e1e;
    border-color: var(--line);
}

.ide-tab.active::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: var(--accent);
}

.ide-tab.dirty .ide-tab-title::after {
    content: " •";
    color: var(--accent-light);
}

.tab-icon {
    width: 16px;
    flex: 0 0 16px;
    display: inline-flex;
}

.ide-tab-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
}

.ide-tab-close {
    margin-left: auto;
    width: 20px;
    height: 20px;
    min-height: 20px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: inherit;
    opacity: .65;
    box-shadow: none;
}

.ide-tab-close:hover {
    opacity: 1;
    background: rgba(255,255,255,.08);
}

.editor {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    width: 100%;
    overflow: hidden;
    background: var(--ace-bg, #1e1e1e);
    padding-bottom: 40px;
}

body.editor-theme-light .editor,
body.editor-theme-light .ace_editor {
    --ace-bg: #ffffff;
    background: #ffffff !important;
}

body.editor-theme-dark .editor {
    --ace-bg: #1e1e1e;
    background: #1e1e1e;
}

.ace_editor {
    font-family: "JetBrains Mono", "Fira Code", Consolas, monospace !important;
}

.ace_marker-layer .ace_bracket {
    border: 2px solid var(--accent) !important;
    border-radius: 3px;
    background: rgba(0,120,212,.18) !important;
}

.ace_marker-layer .ide-match-bracket {
    position: absolute;
    border: 2px solid var(--accent) !important;
    background: rgba(0,120,212,.20) !important;
    border-radius: 3px;
    z-index: 20;
}

.ace_marker-layer .ide-match-line {
    position: absolute;
    background: rgba(0,120,212,.08) !important;
    border-left: 3px solid var(--accent);
    z-index: 5;
}

.ide-statusbar {
    height: 27px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 12px;
    color: #fff;
    background: var(--accent);
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
}

.status-help {
    overflow: hidden;
    text-overflow: ellipsis;
}

.save-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 170px;
    font-weight: 750;
}

.save-idle,
.save-saving,
.save-success,
.save-error,
.save-warn {
    color: #fff;
}

.ide-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.66);
    backdrop-filter: blur(7px);
}

.ide-modal {
    width: min(780px, calc(100vw - 34px));
    max-height: 84vh;
    overflow: auto;
    padding: 16px;
    color: var(--text);
    background: #252526;
    border: 1px solid rgba(0,120,212,.26);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.ide-modal.wide {
    width: min(1220px, calc(100vw - 34px));
}

.ide-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.ide-modal-head strong {
    font-size: 15px;
}

.ide-input,
.ide-textarea {
    width: 100%;
    margin-bottom: 12px;
    padding: 10px 13px;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    outline: none;
    color: #fff;
    background: #1e1e1e;
}

.ide-input {
    height: 42px;
}

.ide-textarea {
    min-height: 140px;
    font-family: "JetBrains Mono", Consolas, monospace;
    resize: vertical;
}

.ide-input:focus,
.ide-textarea:focus {
    border-color: rgba(0,120,212,.75);
    box-shadow: 0 0 0 2px rgba(0,120,212,.22);
}

.ide-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 46px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255,255,255,.035);
}

.ide-list-row.clickable {
    cursor: pointer;
}

.ide-list-row.clickable:hover {
    background: rgba(0,120,212,.12);
    border-color: rgba(0,120,212,.30);
}

.ide-list-row span {
    min-width: 0;
    color: #dbe4ee;
    font-size: 13px;
}

.ide-list-row b {
    display: block;
    color: #fff;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ide-list-row small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ide-search-summary {
    color: #cde6ff;
    font-weight: 750;
    margin-bottom: 10px;
    font-size: 12px;
}

.ide-search-file {
    margin: 12px 0 14px;
}

.ide-search-file-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #aeb8c5;
    margin: 10px 0 6px;
}

.search-hit {
    color: #fff;
    background: rgba(0,120,212,.38);
    border-radius: 3px;
    padding: 0 2px;
}

.diff-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.diff-pane {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #1e1e1e;
}

.diff-pane-title {
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 750;
    color: #cbd5e1;
    background: rgba(0,120,212,.08);
    border-bottom: 1px solid var(--line);
}

.diff-line {
    display: grid;
    grid-template-columns: 62px 1fr;
    min-height: 25px;
    border-bottom: 1px solid rgba(255,255,255,.045);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 12.5px;
}

.diff-line:last-child {
    border-bottom: 0;
}

.diff-line code {
    padding: 5px 10px;
    white-space: pre-wrap;
    color: #cbd5e1;
}

.diff-nr {
    padding: 5px 9px;
    color: var(--muted-2);
    background: rgba(255,255,255,.025);
    border-right: 1px solid rgba(255,255,255,.045);
    text-align: right;
}

.diff-line.added {
    background: rgba(74,222,128,.10);
}

.diff-line.added code {
    color: #bbf7d0;
}

.diff-line.removed {
    background: rgba(248,113,113,.10);
}

.diff-line.removed code {
    color: #fecaca;
}

.diff-line.same {
    opacity: .72;
}

.preview-wrap {
    display: grid;
    place-items: center;
    min-height: 360px;
    padding: 18px;
    background: #1e1e1e;
    border-radius: 10px;
    border: 1px solid var(--line);
}

.preview-wrap img {
    max-width: 100%;
    max-height: 68vh;
    border-radius: 8px;
    box-shadow: 0 16px 60px rgba(0,0,0,.45);
}

.tree::-webkit-scrollbar,
.ide-tabs::-webkit-scrollbar,
.ide-modal::-webkit-scrollbar {
    width: 11px;
    height: 11px;
}

.tree::-webkit-scrollbar-track,
.ide-tabs::-webkit-scrollbar-track,
.ide-modal::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.tree::-webkit-scrollbar-thumb,
.ide-tabs::-webkit-scrollbar-thumb,
.ide-modal::-webkit-scrollbar-thumb {
    background: #3a3d41;
    border: 3px solid #1e1e1e;
    border-radius: 999px;
}

.tree::-webkit-scrollbar-thumb:hover,
.ide-tabs::-webkit-scrollbar-thumb:hover,
.ide-modal::-webkit-scrollbar-thumb:hover {
    background: rgba(0,120,212,.55);
}

.auth-body {
    min-height: 100vh;
    overflow: auto;
    display: grid;
    place-items: center;
    padding: 28px;
    background: #1e1e1e;
}

.auth-shell,
.project-shell {
    width: min(1120px, 100%);
}

.auth-card {
    width: min(440px, 100%);
    margin: 0 auto;
    padding: 24px;
    border: 1px solid rgba(0,120,212,.24);
    border-radius: 10px;
    background: #252526;
    box-shadow: var(--shadow);
}

.auth-brand,
.project-head {
    display: flex;
    align-items: center;
    gap: 13px;
}

.auth-brand {
    margin-bottom: 22px;
}

.auth-logo {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(0,120,212,.28);
    background: rgba(0,120,212,.10);
    flex-shrink: 0;
}

.auth-brand strong {
    display: block;
    color: #fff;
    font-weight: 750;
    font-size: 16px;
}

.auth-brand span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12.5px;
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 25px;
    line-height: 1.08;
    letter-spacing: -.03em;
    color: #fff;
}

.auth-copy {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.auth-form label {
    display: block;
    margin: 0 0 6px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 750;
}

.auth-submit {
    width: 100%;
    min-height: 42px;
    margin-top: 3px;
    font-size: 13px;
    font-weight: 750;
}

.auth-code {
    text-align: center;
    font-size: 22px;
    letter-spacing: .22em;
    font-weight: 850;
}

.auth-link,
.topbar-link {
    color: #cde6ff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 750;
}

.auth-link:hover,
.topbar-link:hover {
    color: #fff;
}

.auth-link {
    display: inline-block;
    margin-top: 14px;
}

.auth-alert {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.42;
}

.auth-alert.error {
    color: #fecaca;
    background: rgba(248,113,113,.12);
    border: 1px solid rgba(248,113,113,.25);
}

.auth-alert.notice {
    color: #bbf7d0;
    background: rgba(74,222,128,.10);
    border: 1px solid rgba(74,222,128,.22);
}

.project-shell {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.project-head {
    justify-content: space-between;
    padding: 4px 2px;
}

.project-brand-top {
    margin-bottom: 0;
}

.project-error {
    max-width: 680px;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.project-card {
    margin: 0;
}

.project-card button {
    width: 100%;
    min-height: 184px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    text-align: left;
    border-radius: 10px;
    background: #252526;
    border-color: var(--line-strong);
    box-shadow: var(--shadow);
}

.project-card button:hover {
    transform: translateY(-1px);
    border-color: rgba(0,120,212,.46);
    background: #2a2d2e;
}

.project-card.is-disabled button {
    opacity: .42;
    cursor: not-allowed;
}

.project-logo-wrap {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(0,120,212,.10);
    border: 1px solid rgba(0,120,212,.24);
    overflow: hidden;
}

.project-logo-wrap img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
}

.project-card-text strong,
.project-card-text small,
.project-card-text em {
    display: block;
}

.project-card-text strong {
    color: #fff;
    font-size: 18px;
    font-weight: 750;
}

.project-card-text small {
    min-height: 34px;
    margin-top: 7px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.project-card-text em {
    margin-top: 10px;
    color: #cde6ff;
    font-style: normal;
    font-size: 12px;
    font-weight: 750;
}

.topbar-link {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    white-space: nowrap;
}

.topbar-link.muted {
    color: var(--muted);
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .ide-shell {
        height: auto;
        min-height: 100vh;
        grid-template-columns: 1fr;
    }

    .ide-resizer {
        display: none;
    }

    .ide-sidebar {
        height: 42vh;
        min-height: 320px;
    }

    .ide-main {
        height: 58vh;
        min-height: 430px;
    }

    .current-file {
        max-width: 48vw;
    }

    .topbar-actions {
        gap: 5px;
        overflow-x: auto;
    }

    .topbar-actions button {
        padding-inline: 8px;
    }

    .ide-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .diff-side {
        grid-template-columns: 1fr;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .project-head {
        align-items: flex-start;
        gap: 16px;
    }
}