/* =========================================================================
   [2] style.css : 다크모드, 크기 등 피부와 옷
   ========================================================================= */

:root {
    --bg: #008080; 
    --bar: #c0c0c0; 
    --text: #000; 
    --win: #000080; 
    --win-locked: #555555;
    --folder-color: #fdda6b; 
    --tb-height: 32px;
    --outset: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
    --inset: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px #808080;
    --input-bg: #fff; 
    --input-text: #000;
}

body.dark { 
    --bg: #000; 
    --bar: #3a3a3a; 
    --text: #fff; 
    --win: #1a1a1a; 
    --win-locked: #222; 
    --folder-color: #ffcc00;
    --input-bg: #2a2a2a; 
    --input-text: #fff;
}

* { 
    box-sizing: border-box !important; 
    user-select: none; 
    -webkit-user-select: none; 
    font-family: "MS Sans Serif", Tahoma, sans-serif; 
}

html, body { 
    margin: 0; 
    padding: 0; 
    width: 100%; 
    height: 100%; 
    overflow: hidden; 
    background: var(--bg); 
    color: var(--text); 
    touch-action: none; 
}

body.show-grid #viewport {
    background-image: 
        linear-gradient(to right, rgba(0, 0, 0, 0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: top left;
}
body.dark.show-grid #viewport {
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: top left;
}

iframe, input, textarea, select { 
    user-select: auto !important; 
    -webkit-user-select: auto !important; 
    pointer-events: auto !important; 
    touch-action: auto !important; 
    border:none; 
    outline:none; 
}

input[type="text"], select, textarea, input[type="number"], input[type="url"] { 
    background: var(--input-bg); 
    color: var(--input-text); 
}

.w-btn { 
    background: var(--bar); 
    box-shadow: var(--outset); 
    color: var(--text); 
    border: none; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}
.w-btn:active, .w-btn.active { 
    box-shadow: var(--inset); 
    padding: 2px 0 0 2px; 
}

#taskbar { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    height: var(--tb-height); 
    background: var(--bar); 
    z-index: 100000 !important; 
    display: flex; 
    padding: 2px 4px; 
    box-shadow: inset 0 1px #fff; 
    border-top: 1px solid #dfdfdf; 
    align-items: center;
}

.start-btn { 
    background: linear-gradient(180deg, #444, #222); 
    border: 1px solid #111; 
    border-radius: 4px;
    padding: 0 12px; 
    height: 26px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.2), 0 1px 2px rgba(0,0,0,0.4);
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}
.start-btn:active, .start-btn.active { 
    background: #222; 
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6); 
    transform: scale(0.96); 
}

.win-logo { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 14px; height: 14px; }
.win-logo div { background: #00A4EF; border-radius: 1px; }
.start-btn:hover .win-logo div { background: #33C4FF; }

#taskbar-apps { flex: 1; display: flex; gap: 4px; margin: 0 6px; overflow-x: auto; scrollbar-width: none; }
.tb-app { flex: 1; min-width: 40px; max-width: 80px; height: 100%; font-weight: bold; font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0 4px; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0;}
.tb-app i { font-size: 13px; flex-shrink: 0; }
.tb-app.active { box-shadow: var(--inset); background: var(--input-bg); color: var(--input-text); }

#tray { display: flex; align-items: center; padding: 0 8px; box-shadow: var(--inset); font-size: 14px; font-weight: bold; height: 100%; background: var(--bar); color: var(--text); font-family: "Courier New", monospace; letter-spacing: -0.5px;}
#tray-icons { display: flex; align-items: center; gap: 6px; margin-right: 6px; }
#page-dots { cursor: pointer; color: #00ff00; text-shadow: 1px 1px 0 #000; }
#conn-status { margin: 0 4px; cursor: pointer; font-weight: bold; transition: color 0.3s; }
#clock { cursor: pointer; color: #00ff00; text-shadow: 1px 1px 0 #000; }

@keyframes blink { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }
.status-blink { animation: blink 1.5s infinite; }

#start-menu { 
    position: fixed; 
    bottom: var(--tb-height); 
    left: 0; 
    width: max-content; 
    min-width: 220px; 
    max-width: 85vw; 
    background: var(--bar); 
    box-shadow: var(--outset); 
    z-index: 100001 !important; 
    display: none; 
    flex-direction: row; 
    color: var(--text); 
    height: auto; 
    max-height: 80vh; 
    overflow: hidden;
}

/* 콤팩트해진 왼쪽 바 */
.sm-header { 
    background: linear-gradient(180deg, var(--win), #33C4FF); 
    padding: 10px 0; 
    color: white; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: flex-start;
    gap: 8px; 
    border-right: 1px solid rgba(0,0,0,0.1); 
    width: 32px; 
    flex-shrink: 0; 
}

.sm-list { 
    display: flex; 
    flex-direction: column; 
    padding: 2px; 
    flex: 1; 
    overflow-y: auto; 
}

/* 그룹 빈 공간 제거 및 유동적 높이 설정 */
.sm-group { 
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #808080; 
    border-top: 1px solid var(--bar); 
    padding: 0; 
}
.sm-group:empty { display: none !important; }
.sm-group:first-child { border-top: none; }
.sm-group:last-child { border-bottom: none; }

.sm-item { 
    padding: 10px 14px; 
    display: flex; 
    align-items: center; 
    justify-content: flex-start; 
    gap: 8px; 
    font-size: 12px; 
    font-weight: bold; 
    cursor: pointer; 
    position: relative; 
    white-space: nowrap; 
}
.sm-icon-box { width: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sm-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-arrow { margin-left: auto; opacity: 0.6; font-size: 14px; }
.sm-item:hover { background: var(--win); color: white; }

.sm-sub { display: none; position: absolute; left: 100%; bottom: 0; background: var(--bar); box-shadow: var(--outset); width: max-content; min-width: 150px; max-width: 60vw; flex-direction: column; z-index: 10002; color: var(--text); max-height: 80vh; overflow-y: auto;}
.sm-item:hover .sm-sub { display: flex; }

#viewport { position: absolute; top: 0; left: 0; right: 0; bottom: var(--tb-height); overflow: hidden; touch-action: none; }
#pages-container { position: absolute; width: 100%; height: 100%; top: 0; left: 0; will-change: transform; }
.page { position: absolute; top: 0; width: 100vw; height: 100%; box-sizing: border-box; overflow: hidden; }

#windows-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8500; }

.icon-wrapper { position: absolute; display: flex; flex-direction: column; align-items: center; width: 70px; cursor: pointer; z-index: 50; }
.icon-wrapper i { font-size: 32px; color: white; filter: drop-shadow(1px 1px 0 #000); pointer-events: none; }
.icon-wrapper.folder-icon i { color: var(--folder-color); }
.icon-wrapper span { font-size: 11px; color: white; margin-top: 4px; text-shadow: 1px 1px 0 #000; text-align: center; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }

.window-box, .widget-box { 
    position: absolute; 
    background: var(--bar); 
    box-shadow: var(--outset); 
    display: flex; 
    flex-direction: column; 
    min-width: 250px; 
    min-height: 200px; 
    color: var(--text); 
    pointer-events: auto; 
    will-change: left, top, width, height; 
}

.is-dragging { box-shadow: none !important; opacity: 0.8; }
.is-dragging iframe { pointer-events: none !important; }

.window-box { z-index: 9000; }
.widget-box { z-index: 8000; padding: 2px; }

.window-box.maximized, .widget-box.maximized { top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; transform: none !important; border: none; }

.title-bar { background: var(--win); color: white; padding: 2px 4px; font-size: 12px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; height: 28px; cursor: move; touch-action: none; }
.widget-box .title-bar { background: var(--win-locked); cursor: move; }

.title-text { display: flex; align-items: center; gap: 6px; pointer-events: none; overflow: hidden; white-space: nowrap; }
.win-controls { display: flex; gap: 4px; align-items: center; }
.ctrl-btn { width: 24px; height: 22px; font-size: 11px; font-weight: bold; padding: 0; display: flex; align-items: center; justify-content: center; z-index: 10000; position: relative; cursor: pointer;}
.folder-ctrl-btn { width: 26px; height: 22px; font-size: 15px; font-weight: bold; padding: 0; z-index: 10000; position: relative; cursor: pointer;}

.win-content { flex: 1; background: var(--input-bg); box-shadow: var(--inset); margin: 2px; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.win-content iframe { width: 100%; height: 100%; border: none; flex: 1; pointer-events: auto; }

.scale-dot { position: absolute; bottom: -5px; right: -5px; width: 30px; height: 30px; cursor: nwse-resize; z-index: 100; touch-action: none; background: transparent;}
.scale-dot::after { content: ''; position: absolute; bottom: 5px; right: 5px; width: 10px; height: 10px; background: var(--bar); box-shadow: var(--outset); pointer-events: none; }

.scale-dot-tl { position: absolute; top: -5px; left: -5px; width: 30px; height: 30px; cursor: nwse-resize; z-index: 100; touch-action: none; background: transparent;}
.scale-dot-tl::after { content: ''; position: absolute; top: 5px; left: 5px; width: 10px; height: 10px; background: var(--bar); box-shadow: var(--outset); pointer-events: none; }

.window-box.maximized .scale-dot, .window-box.maximized .scale-dot-tl { display: none !important; }
.widget-box .scale-dot, .widget-box .scale-dot-tl { display: none !important; }

.folder-grid { display: grid; gap: 15px; padding: 15px; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); align-content: start; overflow-y: auto; height: 100%; background: var(--input-bg);}
.folder-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; cursor: pointer; padding: 5px; text-align: center; }
.folder-item:hover { background: rgba(0,0,128,0.1); border-radius: 4px; }
.folder-item i { font-size: 32px; margin-bottom: 4px; pointer-events: none; color: var(--win);}
.folder-item span { word-break: break-all; line-height: 1.2; color: var(--input-text); font-size: 11px; pointer-events: none;}
.folder-item-del { position: absolute; top: -5px; left: -5px; width: 20px; height: 20px; color: white; background: red; border: 1px solid darkred; font-weight: bold; font-size: 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; z-index: 10; box-shadow: 0 1px 3px rgba(0,0,0,0.3);}

#ctx-menu { position: absolute; z-index: 11000; background: var(--bar); box-shadow: var(--outset); padding: 2px; display: none; flex-direction: column; min-width: 160px; color: var(--text); border: 1px solid var(--bg); }
.ctx-item { padding: 10px 12px; font-size: 12px; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--text); }
.ctx-item:hover { background: var(--win); color: white; }

#modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: var(--tb-height); background: rgba(0,0,0,0.4); z-index: 11000; display: none; align-items: center; justify-content: center; }
.sys-modal { background: var(--bar); box-shadow: var(--outset); padding: 2px; width: 90%; max-width: 440px; display: none; flex-direction: column; max-height: 90%; color: var(--text); }
.sys-body { padding: 15px; background: var(--bar); overflow-y: auto; color: var(--text); }

.icon-gallery { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; height: 150px; overflow-y: auto; background: var(--input-bg); box-shadow: var(--inset); padding: 5px; margin-bottom: 10px; }
.icon-gallery i { font-size: 20px; color: var(--input-text); cursor: pointer; padding: 8px 0; text-align: center; border-radius: 3px; }
.icon-gallery i:hover { background: rgba(0,0,128,0.1); }
.icon-gallery i.selected { background: var(--win); color: white; }

#icon-tabs::-webkit-scrollbar { display: none; }
#icon-tabs { -ms-overflow-style: none; scrollbar-width: none; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 11px; margin-top: 5px; }
#drag-overlay { display:none; position:fixed; top:0; left:0; width:100%; height:100%; z-index:99998; touch-action:none; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bar); box-shadow: var(--inset); transition: .3s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: var(--text); transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: var(--win); box-shadow: inset 0 0 5px rgba(0,0,0,0.5); }
input:checked + .slider:before { transform: translateX(16px); background-color: white; }

#ctx-menu, #modal-overlay { z-index: 100001 !important; }

.nav-select {
    width: 100%; padding: 8px; font-size: 12px; border: 1px solid var(--bar);
    backgroun/* 기본 테마 및 초기화 */
:root {
    --bg: #008080; --bar: #c0c0c0; --text: #000; --win: #000080;
    --folder-color: #fdda6b; --tb-height: 32px;
    --outset: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
    --inset: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px #808080;
}
* { box-sizing: border-box; font-family: "Tahoma", sans-serif; user-select: none; }
body { margin: 0; background: var(--bg); overflow: hidden; height: 100vh; }

/* 시작 메뉴 스타일 */
#start-menu { 
    position: fixed; bottom: var(--tb-height); left: 0; 
    background: var(--bar); box-shadow: var(--outset); 
    display: none; flex-direction: row; z-index: 100001; 
}
.sm-header { 
    background: linear-gradient(180deg, var(--win), #33C4FF); 
    width: 32px; padding: 10px 0; color: white; 
    display: flex; flex-direction: column; align-items: center; 
}
.sm-list { display: flex; flex-direction: column; padding: 2px; min-width: 180px; }
.sm-item { 
    padding: 8px 12px; display: flex; align-items: center; 
    font-size: 12px; font-weight: bold; cursor: pointer; position: relative; 
}
.sm-item:hover { background: var(--win); color: white; }
.sm-icon-box { width: 24px; text-align: center; margin-right: 8px; }
.sm-arrow { margin-left: auto; font-size: 10px; }

/* 핵심: 서브 메뉴 (Fly-out) 및 스크롤 */
.sm-sub { 
    display: none; position: absolute; left: 100%; bottom: -2px;
    background: var(--bar); box-shadow: var(--outset); 
    min-width: 180px; flex-direction: column; padding: 2px;
    /* 앱 10개 높이 제한 (약 350px) */
    max-height: 350px; overflow-y: auto; overflow-x: hidden;
    border: 1px solid #808080;
}
.sm-item:hover > .sm-sub { display: flex; }

/* 작업표시줄 및 기타 */
#taskbar { position: fixed; bottom: 0; width: 100%; height: var(--tb-height); background: var(--bar); display: flex; align-items: center; padding: 2px; box-shadow: inset 0 1px #fff; z-index: 100000; }
.start-btn { height: 26px; padding: 0 8px; background: var(--bar); box-shadow: var(--outset); border: 0; font-weight: bold; display: flex; align-items: center; gap: 4px; }
.start-btn:active { box-shadow: var(--inset); }
.win-logo { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; width: 12px; }
.win-logo div { width: 5px; height: 5px; background: #000; }d: var(--input-bg); color: var(--input-text); box-shadow: var(--inset);
    margin-top: 5px; font-weight: bold;
}