: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;
    --prop:       #9CDCFE;
    --line-num:   #858585;
    --statusbar:  #007ACC;
    --mono:       'JetBrains Mono', 'Fira Code', monospace;

    /* Contribution graph cells */
    --contrib-0:  #161b22;
    --contrib-1:  #0e4429;
    --contrib-2:  #006d32;
    --contrib-3:  #26a641;
    --contrib-4:  #39d353;
}

*, *::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; cursor: pointer; }

/* Interactive elements get a pointer; everything else keeps the default cursor */
.tab,
.sidebar-item,
.sidebar-group-label,
.project-header,
button,
[role="button"] {
    cursor: pointer;
}

/* Visible keyboard focus */
.tab:focus-visible,
.sidebar-item:focus-visible,
.project-header:focus-visible,
a:focus-visible,
button:focus-visible {
    outline: 1px solid var(--statusbar);
    outline-offset: -1px;
}

/* ── 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);
    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: var(--accent); }
.tab-icon.json{ color: var(--accent4); }
.tab-icon.log { color: var(--accent3); }

/* ── 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;
    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;
    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);
    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);
}

.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: var(--muted); }   /* comment */
.kw { color: var(--accent2); } /* keyword */
.fn { color: var(--accent4); } /* function */
.st { color: var(--accent3); } /* string */
.nu { color: #B5CEA8; }        /* number */
.ty { color: var(--accent); }  /* type */
.pr { color: var(--prop); }    /* property */
.op { color: var(--text); }    /* operator */
.cm { color: var(--pink); }    /* 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;
    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;
}

/* ── CONSENT BANNER ── */
.consent-banner {
    position: fixed;
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, calc(100% - 2rem));
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    border-radius: 4px;
    padding: 0.9rem 1.1rem;
    font-size: 12px;
    line-height: 1.7;
    z-index: 9996;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.consent-banner .c { display: block; }

.consent-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0.7rem;
}

.consent-btn {
    font-family: var(--mono);
    font-size: 11px;
    padding: 0.35rem 0.9rem;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    transition: border-color 0.2s, background 0.2s;
}

.consent-btn.primary {
    border-color: var(--accent);
    color: var(--accent);
}

.consent-btn:hover { background: rgba(78,201,176,0.08); border-color: var(--accent); }

.consent-link {
    margin-left: auto;
    font-size: 11px;
    color: var(--line-num);
    text-decoration: underline;
}

/* ── 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;
    --pink:       #AF00DB;
    --red:        #CD3131;
    --prop:       #001080;
    --line-num:   #999999;
    --statusbar:  #007ACC;

    --contrib-0:  #EBEDF0;
    --contrib-1:  #9BE9A8;
    --contrib-2:  #40C463;
    --contrib-3:  #30A14E;
    --contrib-4:  #216E39;
}

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 .sidebar-title { color: #666; }
body.light .profile-card { background: #EBEBEB; }
body.light .profile-name { color: #1E1E1E; }
body.light .line:hover { background: rgba(0,0,0,0.04); }
body.light .ty { color: #267F99; }
body.light .consent-banner { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }

/* ── 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;
}

/* ── TAB FADE-IN ── */
.file-section.fade-in {
    animation: fadeIn 0.2s ease;
}

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

/* ── TYPEWRITER REVEAL (first open of each tab only) ── */
.file-section.active.reveal .code-content .line {
    opacity: 0;
    animation: revealLine 0.08s ease forwards;
}

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

/* ── 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); }
}

/* ── 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 .editor {
    padding: 2rem 4rem;
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
    .file-section.active.reveal .code-content .line,
    .file-section.fade-in,
    .live-dot,
    .ambient-hint {
        animation: none !important;
        opacity: 1 !important;
    }
    .profile-card { transition: none; }
}

/* ── COLLAPSIBLE SIDEBAR ── */
.sidebar-group-items {
    overflow: hidden;
    transition: max-height 0.2s ease;
    max-height: 500px;
}

.sidebar-group-items.collapsed {
    max-height: 0;
}

.sidebar-group-label::before {
    transition: transform 0.2s;
    display: inline-block;
}

.sidebar-group-label.collapsed::before {
    transform: rotate(-90deg);
}

/* ── TERMINAL AUTOCOMPLETE ── */
.autocomplete-item:hover {
    background: #2A2D2E !important;
}