:root {
    --bg:         #1E1E1E;
    --sidebar-bg: #252526;
    --tab-bg:     #2D2D2D;
    --tab-active: #1E1E1E;
    --border:     #3C3C3C;
    --text:       #D4D4D4;
    --muted:      #6A9955;
    --accent:     #4EC9B0;
    --accent2:    #569CD6;
    --accent3:    #CE9178;
    --accent4:    #DCDCAA;
    --green:      #4EC9B0;
    --yellow:     #DCDCAA;
    --orange:     #CE9178;
    --blue:       #569CD6;
    --pink:       #C586C0;
    --red:        #F44747;
    --line-num:   #858585;
    --statusbar:  #007ACC;
    --mono:       'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

*, *:hover, a, a:hover, .tab, .sidebar-item, .project-header {
    cursor: grab !important;
}
*:active {
    cursor: grabbing !important;
}

/* ── TITLE BAR ── */
.titlebar {
    background: #3C3C3C;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #CCCCCC;
    flex-shrink: 0;
    position: relative;
    user-select: none;
}

.titlebar-dots {
    position: absolute;
    left: 12px;
    display: flex;
    gap: 6px;
}

.titlebar-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-red   { background: #FF5F57; }
.dot-yellow{ background: #FFBD2E; }
.dot-green { background: #28C840; }

.titlebar-available {
    position: absolute;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #4EC9B0;
}

.titlebar-available::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4EC9B0;
}

/* ── TABS ── */
.tabs {
    background: var(--tab-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 35px;
    font-size: 12px;
    color: #969696;
    border-right: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.1s;
}

.tab.active {
    background: var(--tab-active);
    color: var(--text);
    border-top: 1px solid var(--statusbar);
}

.tab:hover:not(.active) { background: #2A2A2A; color: var(--text); }

.tab-icon { font-size: 11px; }
.tab-icon.md  { color: #519aba; }
.tab-icon.ts  { color: #3178c6; }
.tab-icon.sh  { color: #4EC9B0; }
.tab-icon.json{ color: #DCDCAA; }
.tab-icon.log { color: #CE9178; }

/* ── MAIN AREA ── */
.editor-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
}

.sidebar-section {
    padding: 4px 0;
}

.sidebar-title {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #BBBBBB;
    padding: 8px 12px 4px;
    user-select: none;
}

.sidebar-group-label {
    font-size: 12px;
    color: #CCCCCC;
    padding: 3px 8px 3px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.sidebar-group-label::before {
    content: '▾';
    font-size: 10px;
    color: var(--line-num);
}

.sidebar-item {
    font-size: 12px;
    color: #CCCCCC;
    padding: 2px 8px 2px 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: background 0.1s;
}

.sidebar-item:hover { background: #2A2D2E; }

.sidebar-item.active {
    background: #37373D;
    color: white;
}

.sidebar-item .file-icon { font-size: 11px; }

/* ── PROFILE CARD ── */
.profile-card {
    margin: 12px;
    padding: 10px;
    background: #2A2D2E;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: linear-gradient(135deg, #569CD6, #4EC9B0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    color: white;
    margin-bottom: 6px;
}

.profile-name {
    font-size: 12px;
    color: white;
    font-weight: 500;
}

.profile-role {
    font-size: 10px;
    color: var(--line-num);
    margin-top: 2px;
}

/* ── EDITOR ── */
.editor {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
    display: flex;
}

.line-numbers {
    padding: 16px 0;
    text-align: right;
    color: var(--line-num);
    font-size: 13px;
    user-select: none;
    flex-shrink: 0;
    min-width: 48px;
    padding-right: 12px;
    padding-left: 8px;
    line-height: 22px;
}

.code-content {
    flex: 1;
    padding: 16px 24px 16px 0;
    line-height: 22px;
    font-size: 13px;
}

/* ── CODE SYNTAX ── */
.c  { color: #6A9955; } /* comment */
.kw { color: #569CD6; } /* keyword */
.fn { color: #DCDCAA; } /* function */
.st { color: #CE9178; } /* string */
.nu { color: #B5CEA8; } /* number */
.ty { color: #4EC9B0; } /* type */
.pr { color: #9CDCFE; } /* property */
.op { color: #D4D4D4; } /* operator */
.cm { color: #C586C0; } /* comment special */

.line { display: block; white-space: pre-wrap; min-height: 22px; }
.line:hover { background: rgba(255,255,255,0.03); }

/* Sections hidden by default */
.file-section { display: none; }
.file-section.active { display: block; }

/* ── EXPANDABLE PROJECT ── */
.project-row {
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.project-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    cursor: pointer;
    user-select: none;
}

.project-num { color: var(--line-num); width: 20px; }
.project-name { color: var(--accent4); font-weight: 500; }
.project-type { color: var(--line-num); margin-left: auto; font-size: 11px; }
.project-toggle { color: var(--line-num); font-size: 10px; transition: transform 0.2s; }
.project-toggle.open { transform: rotate(90deg); }
.project-desc-short { color: var(--line-num); font-size: 12px; }

.project-body { display: none; padding: 4px 0 8px 32px; }
.project-body.open { display: block; }

.project-body .line { color: var(--text); }

/* ── STATUS BAR ── */
.statusbar {
    background: var(--statusbar);
    height: 22px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 16px;
    flex-shrink: 0;
    font-size: 11px;
    color: white;
    user-select: none;
}

.statusbar-right {
    margin-left: auto;
    display: flex;
    gap: 16px;
}

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
    .sidebar { display: none; }
    .line-numbers { min-width: 36px; padding-right: 8px; }
}

/* ── LIGHT THEME ── */
body.light {
    --bg:         #FFFFFF;
    --sidebar-bg: #F3F3F3;
    --tab-bg:     #ECECEC;
    --tab-active: #FFFFFF;
    --border:     #E0E0E0;
    --text:       #1E1E1E;
    --muted:      #008000;
    --accent:     #007ACC;
    --accent2:    #0000FF;
    --accent3:    #A31515;
    --accent4:    #795E26;
    --line-num:   #999999;
    --statusbar:  #007ACC;
}

body.light .titlebar { background: #DDDDDD; color: #333; }
body.light .tab { color: #555; }
body.light .tab.active { color: #1E1E1E; }
body.light .tab:hover:not(.active) { background: #E5E5E5; }
body.light .sidebar-item { color: #555; }
body.light .sidebar-item:hover { background: #E8E8E8; }
body.light .sidebar-item.active { background: #DCDCDC; color: #000; }
body.light .sidebar-group-label { color: #555; }
body.light .profile-card { background: #EBEBEB; }
body.light .profile-name { color: #1E1E1E; }
body.light .c  { color: #008000; }
body.light .kw { color: #0000FF; }
body.light .fn { color: #795E26; }
body.light .st { color: #A31515; }
body.light .ty { color: #267F99; }
body.light .pr { color: #001080; }


/* ── SCROLL PROGRESS BAR ── */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(to right, #007ACC, #4EC9B0);
    z-index: 9999;
    transition: width 0.1s;
    pointer-events: none;
}

/* ── SMOOTH TAB ANIMATIONS ── */
.file-section {
    animation: none;
}

.file-section.fade-in {
    animation: fadeIn 0.2s ease;
}

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

/* ── SHAKE ANIMATION ── */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

.shake {
    animation: shake 0.4s ease;
}

/* ── LIVE SIGNAL ── */
.live-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4EC9B0;
    margin-right: 6px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* ── TYPEWRITER MODE ── */
.typewriter-mode .code-content .line {
    opacity: 0;
    animation: revealLine 0.05s ease forwards;
}

@keyframes revealLine {
    to { opacity: 1; }
}

/* ── TYPEWRITER MODE ── */
.file-section.active .code-content .line {
    opacity: 0;
    animation: revealLine 0.08s ease forwards;
}

@keyframes revealLine {
    to { opacity: 1; }
}

/* ── 3D CARD EFFECT ── */
.profile-card {
    transform-style: preserve-3d;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    will-change: transform;
}

.profile-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ── AMBIENT MODE ── */
#ambient-overlay {
    position: fixed;
    inset: 0;
    background: #080D1A;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
}

#ambient-overlay.active {
    opacity: 1;
    pointer-events: all;
}

#ambient-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.ambient-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(78, 201, 176, 0.4);
    animation: fadeInOut 3s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* ── FOCUS MODE ── */
body.focus-mode .sidebar { display: none; }
body.focus-mode .tabs { display: none; }
body.focus-mode .titlebar { display: none; }
body.focus-mode .statusbar { display: none; }
body.focus-mode .minimap { display: none; }
body.focus-mode .editor {
    padding: 2rem 4rem;
}