:root {
    --bg: #f7f5ed;
    --grid: #dfded5;
    --text: #181818;
    --muted: #8b8a84;
    --line: #c9c7bc;
    --pink: #ff1675;
    --cyan: #19ddeb;
    --green: #35ef35;
    --blue: #1238ef;
    --orange: #ff5430;
    --paper: #fbfaf4;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    letter-spacing: .035em;
    font-family: "Courier Prime", monospace;
    cursor: none;
}

.terminal-stage {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 48px 48px;
}

.top-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(247,245,237,.94);
    backdrop-filter: blur(3px);
    z-index: 1000;
}

.left-title {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .12em;
}

.right-status {
    font-size: 11px;
    letter-spacing: .16em;
}

.status-dot {
    color: var(--green);
    margin-right: 6px;
    animation: statusBlink 1s infinite;
}

@keyframes statusBlink {
    50% { opacity: .25; }
}

.homebar {
    position: absolute;
    top: 68px;
    left: 50%;
    width: min(760px, calc(100vw - 40px));
    height: 42px;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1.5px solid #171717;
    background: var(--paper);
    box-shadow: 6px 6px 0 rgba(0,0,0,.12);
    z-index: 980;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--text);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    border-right: 1px solid #171717;
    transition: color .16s ease, background .16s ease;
}

.nav-item:nth-child(3) { border-right: 0; }
.nav-item:hover { background: #dfff16; }
.nav-item.active { color: #fff; background: var(--blue); }
.nav-num { font-size: 8px; opacity: .62; }

.nav-marker {
    position: absolute;
    left: calc(50% - 5px);
    bottom: -8px;
    width: 10px;
    height: 10px;
    background: var(--pink);
    border: 1px solid #171717;
    transform: rotate(45deg);
}

.bar {
    height: 5px;
    background: #d8d7cf;
}

.fill {
    height: 100%;
    background: var(--pink);
}

.side-item .bar { width: 100%; }
.accent-pink { color: var(--pink); }
.loading { animation: statusBlink .8s infinite; }

.link-btn {
    border: none;
    background: transparent;
    color: var(--blue);
    font-family: inherit;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    padding: 4px 0;
}

.link-btn::after { content: " ↗"; }

.category-system { position: absolute; top: 126px; left: 22px; z-index: 900; }
.category-toggle {
    width: 154px; height: 42px; padding: 0 13px; display: flex; align-items: center; gap: 12px;
    border: 1.5px solid #171717; background: var(--paper); color: #111;
    box-shadow: 4px 4px 0 rgba(0,0,0,.12); font-family: inherit;
    font-size: 10px; font-weight: 700; letter-spacing: .08em;
}
.burger-lines { width: 18px; display: flex; flex-direction: column; gap: 4px; }
.burger-lines i { width: 100%; height: 1.5px; display: block; background: #111; transition: transform .18s ease, opacity .18s ease; }
.category-system.open .burger-lines i:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.category-system.open .burger-lines i:nth-child(2) { opacity: 0; }
.category-system.open .burger-lines i:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }
.category-dock {
    width: 220px; margin-top: 9px; padding: 9px; display: flex; flex-direction: column; gap: 6px;
    border: 1.5px solid #171717; background: rgba(247,245,237,.96);
    box-shadow: 6px 6px 0 rgba(0,0,0,.11); opacity: 0; visibility: hidden;
    transform: translateX(-12px); transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.category-system.open .category-dock { opacity: 1; visibility: visible; transform: translateX(0); }
.category-window {
    position: relative; width: 100%; min-height: 39px; padding: 8px 10px 8px 38px;
    border: 1px solid #171717; background: #fff; box-shadow: none; color: #202020;
    font-family: inherit; text-align: left; overflow: hidden;
    transition: transform .14s ease, background .14s ease;
}
.window-top {
    position: absolute; top: 50%; left: 11px; width: 17px; height: 17px; padding: 0;
    display: block; border: 1px solid #171717; background: var(--category-color, #dfff16);
    transform: translateY(-50%);
}
.category-window:nth-child(1) { --category-color: #dfff16; }
.category-window:nth-child(2) { --category-color: #ff1675; }
.category-window:nth-child(3) { --category-color: #19ddeb; }
.category-window:nth-child(4) { --category-color: #ffb000; }
.category-window:nth-child(5) { --category-color: #35ef35; }
.category-window:nth-child(6) { --category-color: #8c7cff; }
.category-window:nth-child(7) { --category-color: #ff5430; }
.window-top span { display: none; }
.window-name { font-size: 11px; line-height: 1.05; font-weight: bold; letter-spacing: .035em; }
.category-window:hover { transform: translateX(3px); background: #f0eee6; }
.category-window.active { background: var(--category-color); color: #111; transform: translateX(3px); }
.category-window.active .window-top { background: #111; }

.custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 50000;
    will-change: transform;
    transition: opacity .12s ease;
}

.custom-cursor.visible { opacity: 1; }
.cursor-crosshair { position: absolute; width: 28px; height: 28px; transform: translate(-50%, -50%); }
.cursor-line { position: absolute; background: #111; }
.cursor-line-x { left: -5px; top: 13px; width: 38px; height: 1px; }
.cursor-line-y { left: 13px; top: -5px; width: 1px; height: 38px; }
.cursor-dot { position: absolute; left: 11px; top: 11px; width: 5px; height: 5px; border: 1px solid #111; background: var(--pink); }
.cursor-corner { position: absolute; width: 7px; height: 7px; border-color: #111; border-style: solid; }
.cursor-corner-tl { left: 0; top: 0; border-width: 1px 0 0 1px; }
.cursor-corner-tr { right: 0; top: 0; border-width: 1px 1px 0 0; }
.cursor-corner-bl { left: 0; bottom: 0; border-width: 0 0 1px 1px; }
.cursor-corner-br { right: 0; bottom: 0; border-width: 0 1px 1px 0; }
.cursor-readout { position: absolute; left: 19px; top: 17px; padding: 3px 5px; background: rgba(247,245,237,.88); color: #111; font-size: 7px; line-height: 1.2; white-space: nowrap; }
.custom-cursor.is-active .cursor-crosshair { transform: translate(-50%, -50%) scale(1.35) rotate(45deg); }
.custom-cursor.is-active .cursor-dot { background: #dfff16; }

a, button, .project-card, .folder-front { cursor: none !important; }

.ambient-label {
    position: absolute;
    z-index: 35;
    padding: 6px 10px;
    border: 1px solid #c8c6bc;
    background: rgba(247,245,237,.92);
    font-size: 9px;
    letter-spacing: .06em;
    pointer-events: none;
}

.ambient-a { left: 18%; top: 30%; color: #23a92d; transform: rotate(-1deg); }
.ambient-b { left: 63%; top: 19%; color: var(--blue); transform: rotate(1.5deg); }
.ambient-c { right: 20%; bottom: 23%; color: var(--orange); transform: rotate(-1.5deg); }
.ambient-d { left: 31%; bottom: 18%; color: var(--pink); transform: rotate(1deg); }

.playground {
    position: absolute;
    top: 50px;
    bottom: 45px;
    left: 0;
    right: 0;
    overflow: hidden;
}

.folder-back {
    position: absolute;
    left: 50%;
    top: 54%;
    width: 460px;
    height: 295px;
    transform: translate(-50%,-50%);
    z-index: 80;
    pointer-events: none;
}

.folder-tab {
    position: absolute;
    top: -48px;
    left: 14px;
    width: 200px;
    height: 48px;
    padding-left: 16px;
    display: flex;
    align-items: center;
    background: var(--pink);
    color: #fff;
    border: 1px solid #151515;
    border-bottom: none;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: .12em;
    transform: rotate(-.6deg);
    clip-path: polygon(
        0 8px, 4px 8px, 4px 4px, 8px 4px, 8px 0,
        calc(100% - 8px) 0, calc(100% - 8px) 4px,
        calc(100% - 4px) 4px, calc(100% - 4px) 8px,
        100% 8px, 100% 100%, 0 100%
    );
}

.folder-back-body {
    position: absolute;
    inset: 0;
    background: var(--pink);
    border: 1px solid #171717;
    box-shadow: 11px 11px 0 rgba(22,22,22,.10);
    clip-path: polygon(
        0 12px, 6px 12px, 6px 6px, 12px 6px, 12px 0,
        calc(100% - 12px) 0, calc(100% - 12px) 6px,
        calc(100% - 6px) 6px, calc(100% - 6px) 12px,
        100% 12px, 100% calc(100% - 12px),
        calc(100% - 6px) calc(100% - 12px),
        calc(100% - 6px) calc(100% - 6px),
        calc(100% - 12px) calc(100% - 6px),
        calc(100% - 12px) 100%, 12px 100%,
        12px calc(100% - 6px), 6px calc(100% - 6px),
        6px calc(100% - 12px), 0 calc(100% - 12px)
    );
}

.folder-back-body::before {
    content: "WORK_ARCHIVE / 2024—26";
    position: absolute;
    left: 20px;
    top: 20px;
    padding: 5px 9px;
    background: var(--paper);
    color: #111;
    border: 1px solid #111;
    font-size: 9px;
    letter-spacing: .08em;
    transform: rotate(-1deg);
}

.folder-back-body::after {
    content: "////////////////////////////////";
    position: absolute;
    right: 22px;
    top: 22px;
    color: #111;
    font-size: 10px;
    letter-spacing: -.08em;
    opacity: .75;
}

.project-layer {
    position: absolute;
    inset: 0;
    z-index: 100;
    pointer-events: none;
}

/* Kích thước project */
.project-card {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 220px;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    touch-action: none;
    will-change: transform;
}

.project-card.dragging {
    cursor: grabbing;
    z-index: 10000 !important;
}

.project-thumb {
    position: relative;
    width: 220px;
    height: 160px;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    transition: transform .18s ease, filter .25s ease, opacity .25s ease;
}

.project-card:hover .project-thumb {
    transform: translateY(-6px) scale(1.02);
    box-shadow: none;
}

.project-card.dragging .project-thumb {
    transform: scale(1.04);
    box-shadow: none;
}

.thumb-image {
    position: absolute;
    inset: 0;
    color: #111;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
}

.thumb-image > img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border: 0;
    background: transparent;
}

.thumb-mark {
    position: absolute;
    right: -18px;
    top: 24px;
    padding: 7px 14px;
    background: var(--accent);
    border: 1.5px solid #111;
    transform: rotate(-8deg);
    box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-label {
    color: #111;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: .03em;
}

.project-meta {
    display: none;
}

.project-card.muted .project-thumb {
    filter: grayscale(1) contrast(.88);
    opacity: .16;
}

.project-card.matched .project-thumb {
    opacity: 1;
    filter: none;
}

.project-card.stored {
    opacity: 0;
    pointer-events: none;
}

.folder-front {
    position: absolute;
    left: 50%;
    top: calc(54% + 78px);
    width: 460px;
    height: 220px;
    transform: translate(-50%,-50%);
    z-index: 150;
    background: var(--pink);
    border: 1px solid #151515;
    box-shadow: 10px 10px 0 rgba(22,22,22,.11);
    padding: 20px 20px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: opacity .2s ease;
    clip-path: polygon(
        0 12px, 6px 12px, 6px 6px, 12px 6px, 12px 0,
        calc(100% - 12px) 0, calc(100% - 12px) 6px,
        calc(100% - 6px) 6px, calc(100% - 6px) 12px,
        100% 12px, 100% calc(100% - 12px),
        calc(100% - 6px) calc(100% - 12px),
        calc(100% - 6px) calc(100% - 6px),
        calc(100% - 12px) calc(100% - 6px),
        calc(100% - 12px) 100%, 12px 100%,
        12px calc(100% - 6px), 6px calc(100% - 6px),
        6px calc(100% - 12px), 0 calc(100% - 12px)
    );
}

.folder-front::before {
    content: "";
    position: absolute;
    top: -20px;
    left: -1px;
    width: calc(100% + 2px);
    height: 20px;
    background: var(--pink);
    border-left: 1px solid #151515;
    border-right: 1px solid #151515;
    border-top: 1px solid #151515;
    display: none;
}

.folder-front-header,
.folder-footer {
    display: flex;
    justify-content: space-between;
    color: #111;
    font-size: 9px;
    letter-spacing: .08em;
}

.folder-front-header {
    border-bottom: 1px solid rgba(0,0,0,.30);
    padding-bottom: 10px;
}

.folder-footer {
    border-top: 1px solid rgba(0,0,0,.30);
    padding-top: 10px;
}

.folder-front-header span:last-child {
    padding: 3px 7px;
    background: var(--paper);
    border: 1px solid #111;
}

.folder-center-info {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-left: 20px;
    gap: 4px;
}

.folder-count {
    position: relative;
    display: inline-block;
    font-size: 46px;
    line-height: .92;
    letter-spacing: -.05em;
    font-weight: 700;
}

.folder-count::after {
    content: "FILES";
    position: absolute;
    left: calc(100% + 10px);
    top: 8px;
    font-size: 9px;
    letter-spacing: .12em;
}

.folder-instruction {
    margin-top: 8px;
    padding: 5px 9px;
    background: #dfff16;
    border: 1px solid #111;
    color: #111;
    font-size: 9px;
    transform: rotate(-1deg);
}

.folder-handnote {
    position: absolute;
    right: 12px;
    bottom: 4px;
    color: var(--paper);
    font-family: "Comic Sans MS", "Bradley Hand", cursive;
    text-transform: none;
    font-size: 17px;
    font-weight: 700;
    transform: rotate(-5deg);
    letter-spacing: 0;
}

.motion-state {
    position: absolute;
    left: 50%;
    top: 146px;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    padding: 6px 10px;
    border: 1px solid #c7c5bb;
    background: rgba(247,245,237,.9);
    color: #7f7d75;
    font-size: 9px;
    letter-spacing: 1px;
    z-index: 50;
}

.state-index {
    color: var(--pink);
    font-weight: bold;
}

.stage-hint {
    position: absolute;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: var(--paper);
    border: 1px solid #c8c6bc;
    color: #6d6b64;
    font-size: 10px;
    letter-spacing: 1px;
    z-index: 500;
}

.bottom-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 45px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    background: rgba(247,245,237,.94);
    backdrop-filter: blur(3px);
    z-index: 1000;
    font-size: 10px;
}

.progress-wrap {
    width: min(720px, 58vw);
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-wrap > label { letter-spacing: .08em; }
.progress-wrap .bar { flex: 1; }
#progressFill { width: 0%; }
.sub-text { color: #8a887f; font-size: 9px; }
#coordsDisplay { font-size: 10px; }

.project-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    z-index: 20000;
    transition: opacity .2s;
}

.project-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(247,245,237,.83);
    backdrop-filter: blur(3px);
}

.overlay-content {
    width: min(580px, 90vw);
    position: relative;
    z-index: 2;
    padding: 32px;
    border: 1px solid #171717;
    background: var(--paper);
    box-shadow: none;
}

.close-overlay-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 26px;
    height: 26px;
    border: 1px solid #111;
    background: #dfff16;
    font-family: inherit;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-content h2 {
    margin: 4px 36px 12px 0;
    font-size: 26px;
    letter-spacing: -.04em;
}

.overlay-content p {
    font-size: 12px;
    line-height: 1.6;
}

.overlay-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.tag {
    padding: 3px 8px;
    background: transparent;
    border: 1px solid #111;
    font-size: 9px;
}

.overlay-visual {
    height: 210px;
    margin: 16px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px dashed #aaa89f;
    background-image:
        linear-gradient(#eceae2 1px, transparent 1px),
        linear-gradient(90deg, #eceae2 1px, transparent 1px);
    background-size: 20px 20px;
    font-size: 18px;
    overflow: hidden;
}

.overlay-visual img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.view-project {
    display: inline-block;
    padding: 9px 14px;
    background: #dfff16;
    color: #111;
    border: 1px solid #111;
    text-decoration: none;
    font-weight: bold;
    transform: rotate(-1deg);
}
/* ======================================================
   TABLET RESPONSIVE (Màn hình dưới 1024px - iPad)
====================================================== */
@media (max-width: 1024px) {
    .ambient-label { display: none; }

    /* Tăng khoảng cách lề an toàn */
    .top-header, .bottom-footer { padding: 0 24px; }
    .homebar { width: calc(100vw - 48px); }
    .category-system { left: 24px; }
    .category-dock { width: min(220px, calc(100vw - 48px)); }

    /* Thu nhỏ Folder so với Desktop */
    .folder-back { width: min(380px, 85vw); height: 240px; }
    .folder-front { 
        width: min(380px, 85vw); 
        height: 180px; 
        top: calc(54% + 65px); 
        padding: 18px; 
    }
    
    /* Thu nhỏ size Project Card */
    .project-card, .project-thumb {
        width: 170px;
        height: 120px;
    }
}

/* ======================================================
   MOBILE RESPONSIVE (Màn hình dưới 768px - Điện thoại)
====================================================== */
@media (max-width: 768px) {
    .top-header, .bottom-footer { padding: 0 16px; }
    .homebar { top: 59px; height: 39px; width: calc(100vw - 32px); }
    .nav-item { font-size: 9px; gap: 5px; }

    .category-system { top: 108px; left: 16px; }
    .category-toggle { width: 140px; }
    .category-dock { width: min(220px, calc(100vw - 32px)); }

    /* Ép nhỏ size Folder tối đa */
    .folder-back { width: min(320px, 85vw); height: 210px; }
    .folder-front { 
        width: min(320px, 85vw); 
        height: 160px; 
        top: calc(54% + 55px); 
        padding: 16px; 
    }

    .folder-count { font-size: 32px; }
    .folder-count::after { font-size: 8px; top: 4px; left: calc(100% + 8px); }
    .folder-handnote { font-size: 14px; right: 10px; bottom: 0; }

    /* Project Cards gọn lại cho Mobile */
    .project-card, .project-thumb {
        width: 140px;
        height: 110px;
    }

    .thumb-mark { right: -10px; top: 14px; padding: 4px 8px; }
    .thumb-label { font-size: 9px; }
    
    .overlay-content { padding: 24px; }
    .overlay-visual { height: 160px; }
}

@media (max-width: 400px) {
    .project-card, .project-thumb {
        width: 130px;
        height: 100px;
    }
    .folder-count { font-size: 28px; }
}

@media (hover: none), (pointer: coarse) {
    body, a, button, .project-card, .folder-front { cursor: auto !important; }
    .custom-cursor { display: none; }
}