/* ── Palette ──────────────────────────────────────────────────── */
:root {
    --desk:   #1a1a1a;   /* desktop / page background              */
    --win:    #252525;   /* window / panel background              */
    --face:   #2e2e2e;   /* button / toolbar face                  */
    --hi1:    #666666;   /* outer highlight (top/left)             */
    --hi2:    #505050;   /* inner highlight                        */
    --sh1:    #111111;   /* inner shadow                           */
    --sh2:    #080808;   /* outer shadow (bottom/right)            */
    --text:   #e8e8e8;   /* normal text                            */
    --dis:    #666666;   /* disabled text                          */
    --sel:    #c05a00;   /* selected item background (orange)      */
    --inset:  #181818;   /* sunken control background              */
    --bar1:   #c05a00;   /* title gradient start (orange)          */
    --bar2:   #7a3800;   /* title gradient end (dark orange)       */
    --bar-ia: #383838;   /* inactive title                         */
    --accent: #e07020;   /* accent orange                          */
    --ok:     #5aad5a;
    --err:    #cc4444;
    --text-muted: #999999;
}

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

body {
    background: var(--desk);
    color: var(--text);
    font-family: "MS Sans Serif", Tahoma, "Lucida Sans Unicode", system-ui, sans-serif;
    font-size: 12px;
    line-height: 1.4;
}

/* ── Win95 raise / sunken helpers ──────────────────────────────── */
.raise {
    border-top:    1px solid var(--hi1);
    border-left:   1px solid var(--hi1);
    border-right:  1px solid var(--sh2);
    border-bottom: 1px solid var(--sh2);
    box-shadow: inset 1px 1px 0 var(--hi2), inset -1px -1px 0 var(--sh1);
}
.sunken {
    border-top:    1px solid var(--sh2);
    border-left:   1px solid var(--sh2);
    border-right:  1px solid var(--hi1);
    border-bottom: 1px solid var(--hi1);
    box-shadow: inset 1px 1px 0 var(--sh1), inset -1px -1px 0 var(--hi2);
}

/* ── Window chrome ──────────────────────────────────────────────── */
.win-window {
    background: var(--win);
    border-top:    2px solid var(--hi1);
    border-left:   2px solid var(--hi1);
    border-right:  2px solid var(--sh2);
    border-bottom: 2px solid var(--sh2);
    box-shadow: inset 1px 1px 0 var(--hi2), inset -1px -1px 0 var(--sh1),
                2px 2px 0 var(--sh2);
}

/* ── Title bar ──────────────────────────────────────────────────── */
.titlebar {
    background: linear-gradient(90deg, var(--bar1), var(--bar2));
    padding: 3px 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}
.titlebar-text {
    flex: 1;
    color: #fff;
    font-weight: bold;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
}
.title-btns { display: flex; gap: 2px; }
.title-btn {
    width: 16px; height: 14px;
    font-size: 9px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text);
    border-top:    1px solid var(--hi1);
    border-left:   1px solid var(--hi1);
    border-right:  1px solid var(--sh2);
    border-bottom: 1px solid var(--sh2);
    background: var(--face);
}
.title-btn:active {
    border-color: var(--sh2) var(--hi1) var(--hi1) var(--sh2);
    padding: 1px 0 0 1px;
}

/* ── Menu bar ───────────────────────────────────────────────────── */
.menubar {
    display: flex;
    padding: 1px 2px 2px;
    border-bottom: 1px solid var(--sh1);
}
.mitem {
    padding: 2px 10px;
    cursor: default;
    color: var(--text);
}
.mitem:hover { background: var(--sel); color: #fff; }

/* ── Win95 button ───────────────────────────────────────────────── */
.btn95 {
    min-width: 22px; height: 22px; padding: 0 10px;
    background: var(--face);
    border-top:    1px solid var(--hi1);
    border-left:   1px solid var(--hi1);
    border-right:  1px solid var(--sh2);
    border-bottom: 1px solid var(--sh2);
    box-shadow: inset 1px 1px 0 var(--hi2), inset -1px -1px 0 var(--sh1);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    cursor: default;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    user-select: none;
    text-decoration: none;
}
.btn95:not([disabled]):hover { background: #3a3a3a; }
.btn95:not([disabled]):active {
    border-color: var(--sh2) var(--hi1) var(--hi1) var(--sh2);
    box-shadow: inset 1px 1px 0 var(--sh1), inset -1px -1px 0 var(--hi2);
    padding: 1px 9px 0 11px;
}
.btn95[disabled] { color: var(--dis); cursor: default; }

/* ── Logout button variant ─────────────────────────────────────── */
.btn95.danger { color: #e07070; }
.btn95.danger:not([disabled]):hover { background: #3a2020; color: #ff8888; }

/* ── Toolbar ────────────────────────────────────────────────────── */
.toolbar {
    padding: 3px 5px;
    display: flex;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid var(--sh1);
    background: var(--win);
}
.tsep {
    width: 1px; height: 20px;
    background: var(--sh1);
    margin: 0 2px;
    box-shadow: 1px 0 0 var(--hi2);
}

/* ── Path bar ──────────────────────────────────────────────────── */
.pathbar {
    padding: 2px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--sh1);
    background: var(--win);
}
.pathbar-label { color: var(--dis); white-space: nowrap; }
.path-input {
    flex: 1; height: 18px; padding: 0 4px;
    background: var(--inset);
    color: var(--accent);
    font-family: "Courier New", monospace;
    font-size: 11px;
    border-top:    1px solid var(--sh2);
    border-left:   1px solid var(--sh2);
    border-right:  1px solid var(--hi1);
    border-bottom: 1px solid var(--hi1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── File area ──────────────────────────────────────────────────── */
.filearea {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--inset);
    border-top:    1px solid var(--sh2);
    border-left:   1px solid var(--sh2);
    border-right:  1px solid var(--hi1);
    border-bottom: 1px solid var(--hi1);
    margin: 3px 5px;
    padding: 6px;
    min-height: 200px;
}

/* ── Grid ───────────────────────────────────────────────────────── */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px;
    align-content: flex-start;
}

/* ── File icon ──────────────────────────────────────────────────── */
.item {
    padding: 4px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    cursor: default;
    user-select: none;
    border: 1px solid transparent;
    text-decoration: none;
    color: inherit;
}
.item:hover:not(.sel) {
    background: rgba(192,90,0,0.15);
    border-color: rgba(224,112,32,0.3);
}
.item.folder:hover {
    background: rgba(192,90,0,0.2);
    border-color: rgba(224,112,32,0.4);
}

/* Thumbnail */
.item-thumb {
    width: 100%;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--face);
    overflow: hidden;
    position: relative;
}
.item-thumb img,
.item-thumb video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: none;
    border-radius: 0;
    object-fit: cover;
    display: block;
}
.item-thumb .file-icon {
    font-size: 2.5rem;
    padding: 0;
    display: block;
    opacity: 0.6;
}

/* Label */
.name {
    font-size: 11px;
    text-align: center;
    color: var(--text);
    word-break: break-all;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    margin-top: 0;
}
.item.folder .name { color: var(--accent); font-weight: bold; }

/* ── Status bar ──────────────────────────────────────────────────── */
.statusbar {
    padding: 2px 5px;
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    background: var(--win);
    border-top: 1px solid var(--sh1);
}
.sbpanel {
    height: 17px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    border-top:    1px solid var(--sh2);
    border-left:   1px solid var(--sh2);
    border-right:  1px solid var(--hi1);
    border-bottom: 1px solid var(--hi1);
    white-space: nowrap;
    font-size: 11px;
    color: var(--dis);
}
.sbpanel:first-child { flex: 1; color: var(--text); }

/* ── Full-window layout ─────────────────────────────────────────── */
.main-win {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 16px; }
::-webkit-scrollbar-track { background: var(--inset); border-left: 1px solid var(--sh2); }
::-webkit-scrollbar-thumb {
    background: var(--face);
    border-top: 1px solid var(--hi1); border-left: 1px solid var(--hi1);
    border-right: 1px solid var(--sh2); border-bottom: 1px solid var(--sh2);
}
::-webkit-scrollbar-button {
    display: block; height: 16px;
    background: var(--face);
    border-top: 1px solid var(--hi1); border-left: 1px solid var(--hi1);
    border-right: 1px solid var(--sh2); border-bottom: 1px solid var(--sh2);
}

/* ── Context Menu ───────────────────────────────────────────────── */
.cmenu {
    position: absolute;
    background: var(--win);
    border-top: 1px solid var(--hi1); border-left: 1px solid var(--hi1);
    border-right: 1px solid var(--sh2); border-bottom: 1px solid var(--sh2);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    z-index: 1000;
    min-width: 150px;
    padding: 2px;
}
.cmenu-item {
    padding: 4px 10px;
    cursor: default;
    color: var(--text);
    user-select: none;
}
.cmenu-item:hover {
    background: var(--sel);
    color: #fff;
}

/* ── Preview wrapper (legacy compat) ────────────────────────────── */
.preview-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}
