/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--white); color: #202124; min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select { font: inherit; }

/* ── Color Tokens ── */
:root {
    --blue-600: #1a73e8;
    --blue-500: #4285f4;
    --blue-100: #d2e3fc;
    --blue-50: #e8f0fe;
    --gray-900: #202124;
    --gray-700: #3c4043;
    --gray-500: #5f6368;
    --gray-300: #dadce0;
    --gray-200: #e8eaed;
    --gray-100: #f1f3f4;
    --gray-50: #f8f9fa;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(60,64,67,.15), 0 1px 3px 1px rgba(60,64,67,.1);
    --shadow-md: 0 1px 3px rgba(60,64,67,.2), 0 4px 8px 3px rgba(60,64,67,.1);
    --radius: 8px;
    --radius-sm: 6px;
}

/* ── Header ── */
.header {
    height: 56px; background: var(--white); border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; padding: 0 16px; gap: 16px; flex-shrink: 0;
}
.header-logo { font-size: 1.25rem; font-weight: 600; color: var(--blue-600); letter-spacing: -.5px; }
.header-search {
    flex: 1; max-width: 560px; height: 36px; background: var(--gray-50); border: 1px solid var(--gray-200);
    border-radius: 20px; padding: 0 16px; display: flex; align-items: center; gap: 8px; transition: all .2s;
    overflow: hidden;
}
.header-search:focus-within { background: var(--white); border-color: var(--blue-600); box-shadow: 0 0 0 2px var(--blue-100); }
.header-search svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--gray-500); }
.header-search input { border: none; outline: none; background: transparent; flex: 1; font-size: .875rem; min-width: 0; }
.header-spacer { flex: 1; }

/* ── Layout (3-column) ── */
.layout { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: 220px; background: var(--white); border-right: 1px solid var(--gray-200);
    display: flex; flex-direction: column; padding: 12px 0; flex-shrink: 0; overflow-y: auto;
}
.sidebar-section { padding: 0 12px; margin-bottom: 8px; }
.sidebar-section-title { font-size: .7rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; padding: 8px 8px 4px; }
.sidebar-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: .875rem; color: var(--gray-700); transition: background .15s; cursor: pointer;
}
.sidebar-item:hover { background: var(--gray-50); }
.sidebar-item.active { background: var(--blue-50); color: var(--blue-600); font-weight: 500; }
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-item.active svg { color: var(--blue-600); }

.btn-new-folder {
    display: flex; align-items: center; gap: 8px; margin: 0 12px 12px;
    padding: 10px 16px; background: var(--white); border: 1px solid var(--gray-200);
    border-radius: 20px; font-size: .875rem; font-weight: 500; color: var(--gray-700);
    box-shadow: var(--shadow-sm); transition: all .15s;
}
.btn-new-folder:hover { background: var(--blue-50); border-color: var(--blue-100); box-shadow: var(--shadow-md); }
.btn-new-folder svg { width: 20px; height: 20px; color: var(--blue-600); }

/* ── Main Content ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* Toolbar */
.toolbar {
    height: 48px; padding: 0 20px; display: flex; align-items: center; gap: 8px;
    background: var(--white); border-bottom: 1px solid var(--gray-200); flex-shrink: 0;
}
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: .875rem; color: var(--gray-500); flex: 1; min-width: 0; }
.breadcrumb-item { cursor: pointer; padding: 4px 6px; border-radius: 4px; white-space: nowrap; transition: background .15s; }
.breadcrumb-item:hover { background: var(--gray-50); }
.breadcrumb-item.current { color: var(--gray-900); font-weight: 500; }
.breadcrumb-sep { color: var(--gray-300); font-size: .75rem; }

.toolbar-actions { display: flex; align-items: center; gap: 4px; }
.toolbar-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border-radius: var(--radius-sm); font-size: .8rem;
    color: var(--gray-700); transition: all .15s;
}
.toolbar-btn:hover { background: var(--gray-50); }
.toolbar-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.toolbar-btn.primary { background: var(--blue-600); color: var(--white); }
.toolbar-btn.primary:hover { background: var(--blue-500); }
.toolbar-btn.danger:hover { background: #fce8e6; color: #d93025; }
.toolbar-btn:disabled { opacity: .4; pointer-events: none; }

.selection-count { font-size: .8rem; color: var(--blue-600); font-weight: 500; padding: 0 8px; white-space: nowrap; }

/* ── Content Area ── */
.content { flex: 1; overflow-y: auto; padding: 0 20px 16px; background: var(--white); }

/* List Header */
.list-header {
    display: grid; grid-template-columns: 28px 1fr 80px 120px 130px;
    align-items: center; padding: 0 12px; height: 36px; font-size: .75rem;
    font-weight: 500; color: var(--gray-500); border-bottom: 1px solid var(--gray-200);
    text-transform: uppercase; letter-spacing: .3px; position: sticky; top: 0;
    background: var(--white); z-index: 1;
}

/* List Item */
.list-item {
    display: grid; grid-template-columns: 28px 1fr 80px 120px 130px;
    align-items: center; padding: 0 12px; height: 44px; border-bottom: 1px solid var(--gray-100);
    cursor: pointer; transition: background .1s; user-select: none;
}
.list-item:hover { background: var(--blue-50); }
.list-item.selected { background: var(--blue-50); }
.list-item.selected:hover { background: var(--blue-100); }
.list-item.detail-active { background: var(--blue-50); border-left: 3px solid var(--blue-600); }

.item-check { width: 16px; height: 16px; accent-color: var(--blue-600); cursor: pointer; }

.item-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: .875rem; }
.item-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-icon { width: 20px; height: 20px; flex-shrink: 0; }
.bookmark-star { width: 14px; height: 14px; flex-shrink: 0; }
.item-icon.folder { color: var(--blue-500); }
.item-icon.file { color: var(--gray-500); }

.item-size { font-size: .8rem; color: var(--gray-500); }
.item-date { font-size: .8rem; color: var(--gray-500); }
.item-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.item-shortcut {
    width: 28px; height: 28px; display: none; align-items: center; justify-content: center;
    border-radius: 50%; transition: background .15s;
}
.item-shortcut svg { width: 15px; height: 15px; color: var(--gray-400); }
.item-shortcut:hover { background: var(--gray-200); }
.item-shortcut:hover svg { color: var(--gray-600); }
.list-item:hover .item-shortcut { display: flex; }
.item-more {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background .15s;
}
.item-more:hover { background: var(--gray-200); }
.item-more svg { width: 16px; height: 16px; color: var(--gray-500); }

/* ── Detail Panel (Right) ── */
.detail-panel {
    width: 340px; background: var(--white); border-left: 1px solid var(--gray-200);
    display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;
}

.detail-header {
    height: 48px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--gray-200); flex-shrink: 0;
}
.detail-header-title { font-size: .9rem; font-weight: 600; color: var(--gray-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-close { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; }
.detail-close:hover { background: var(--gray-100); }
.detail-close svg { width: 16px; height: 16px; color: var(--gray-500); }

/* Detail Preview */
.detail-preview {
    padding: 16px; display: flex; align-items: center; justify-content: center;
    border-bottom: 1px solid var(--gray-100); background: var(--gray-50);
}
.detail-preview img { max-width: 100%; max-height: 240px; border-radius: 6px; border: 1px solid var(--gray-200); }
.detail-preview-placeholder {
    width: 100%; height: 180px; display: flex; align-items: center; justify-content: center;
    color: var(--gray-300);
}
.detail-preview-placeholder svg { width: 48px; height: 48px; }

/* Detail Tabs */
.detail-tabs {
    display: flex; border-bottom: 1px solid var(--gray-200); flex-shrink: 0;
}
.detail-tab {
    flex: 1; padding: 10px 0; text-align: center; font-size: .8rem; color: var(--gray-500);
    cursor: pointer; border-bottom: 2px solid transparent; transition: all .15s;
}
.detail-tab:hover { color: var(--gray-700); }
.detail-tab.active { color: var(--blue-600); border-bottom-color: var(--blue-600); font-weight: 500; }

.detail-tab-content { flex: 1; overflow-y: auto; padding: 16px; }
.detail-tab-panel { display: none; }
.detail-tab-panel.active { display: block; }

/* Detail Info */
.detail-info-row { display: flex; padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: .82rem; }
.detail-info-label { width: 80px; color: var(--gray-500); flex-shrink: 0; }
.detail-info-value { flex: 1; color: var(--gray-900); word-break: break-all; }

/* Detail Empty */
.detail-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; color: var(--gray-500); padding: 40px; }
.detail-empty svg { width: 40px; height: 40px; color: var(--gray-300); margin-bottom: 8px; }
.detail-empty p { font-size: .82rem; }

/* ── Empty State ── */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 80px 20px; color: var(--gray-500);
}
.empty-state svg { width: 80px; height: 80px; color: var(--gray-300); margin-bottom: 16px; }
.empty-state p { font-size: .95rem; margin-bottom: 4px; }
.empty-state small { font-size: .8rem; color: var(--gray-500); }

/* ── Drop Zone ── */
.drop-overlay {
    display: none; position: fixed; inset: 0; z-index: 100;
    background: rgba(26,115,232,.08); border: 3px dashed var(--blue-600);
    align-items: center; justify-content: center;
}
.drop-overlay.active { display: flex; }
.drop-overlay-label {
    padding: 20px 40px; background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow-md); font-size: 1rem; color: var(--blue-600); font-weight: 500;
}

/* ── Preview Modal ── */
.preview-overlay {
    display: none; position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,.5); align-items: center; justify-content: center;
}
.preview-overlay.open { display: flex; }
.preview-modal {
    width: 80vw; height: 85vh; background: var(--white); border-radius: 12px;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.preview-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--gray-200);
    font-size: .9rem; font-weight: 600;
}
.preview-modal-close {
    font-size: 1.4rem; width: 32px; height: 32px; display: flex;
    align-items: center; justify-content: center; border-radius: 50%;
}
.preview-modal-close:hover { background: var(--gray-100); }
.preview-modal-body { flex: 1; position: relative; overflow: hidden; }
.preview-modal-iframe { width: 100%; height: 100%; border: none; }
.preview-loading {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    color: var(--gray-500); font-size: .85rem;
}
.preview-spinner {
    width: 32px; height: 32px; border: 3px solid var(--gray-200);
    border-top-color: var(--blue-600); border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Context Menu ── */
.ctx-menu {
    display: none; position: fixed; z-index: 200; min-width: 180px; padding: 6px 0;
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.ctx-menu.open { display: block; }
.ctx-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: .85rem;
    color: var(--gray-700); transition: background .1s; cursor: pointer;
}
.ctx-item:hover { background: var(--gray-50); }
.ctx-item.danger { color: #d93025; }
.ctx-item.danger:hover { background: #fce8e6; }
.ctx-item svg { width: 16px; height: 16px; }
.ctx-sep { height: 1px; background: var(--gray-200); margin: 4px 0; }

/* ── Modal ── */
.modal-backdrop {
    display: none; position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,.35); align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
    width: 400px; max-width: 90vw; background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow-md); overflow: hidden;
}
.modal-title { padding: 20px 24px 0; font-size: 1rem; font-weight: 600; color: var(--gray-900); }
.modal-body { padding: 16px 24px; }
.modal-body input {
    width: 100%; height: 38px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    padding: 0 12px; font-size: .875rem; outline: none; transition: border .2s;
}
.modal-body input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 2px var(--blue-100); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 24px 20px; }
.modal-btn {
    height: 34px; padding: 0 20px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 500; transition: all .15s;
}
.modal-btn.cancel { color: var(--gray-700); }
.modal-btn.cancel:hover { background: var(--gray-100); }
.modal-btn.confirm { background: var(--blue-600); color: var(--white); }
.modal-btn.confirm:hover { background: var(--blue-500); }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 10px 20px; background: var(--gray-900); color: var(--white); border-radius: 6px;
    font-size: .85rem; box-shadow: var(--shadow-md); animation: toast-in .25s ease;
}
.toast.error { background: #d93025; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Upload Progress ── */
.upload-bar {
    display: none; position: fixed; bottom: 24px; right: 24px; z-index: 350;
    width: 320px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-md);
    overflow: hidden;
}
.upload-bar.active { display: block; }
.upload-bar-header { padding: 12px 16px; font-size: .85rem; font-weight: 500; color: var(--gray-900); }
.upload-bar-progress { height: 3px; background: var(--gray-100); }
.upload-bar-progress-inner { height: 100%; background: var(--blue-600); transition: width .3s; width: 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

/* ── Mobile Menu Button ── */
.mobile-menu-btn { display: none; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; }
.mobile-menu-btn:hover { background: var(--gray-100); }
.mobile-menu-btn svg { width: 20px; height: 20px; color: var(--gray-700); }

.mobile-sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 49; background: rgba(0,0,0,.35); }
.mobile-sidebar-overlay.open { display: block; }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .detail-panel { width: 280px; }
    .list-header, .list-item { grid-template-columns: 28px 1fr 80px 130px; }
    .item-date { display: none; }
}
@media (max-width: 768px) {
    /* Header */
    .mobile-menu-btn { display: flex; }
    .header { padding: 0 12px; gap: 8px; }
    .header-search { max-width: none; flex: 1; }
    .header-spacer { display: none; }

    /* Sidebar → 슬라이드 드로어 */
    .sidebar {
        display: flex; position: fixed; left: -260px; top: 0; bottom: 0;
        width: 260px; z-index: 50; box-shadow: var(--shadow-md);
        transition: left .25s ease;
    }
    .sidebar.mobile-open { left: 0; }

    /* Detail Panel → 오버레이 */
    .detail-panel {
        display: flex; position: fixed; right: -100%; top: 0; bottom: 0;
        width: 100%; z-index: 50; box-shadow: var(--shadow-md);
        transition: right .25s ease;
    }
    .detail-panel.mobile-open { right: 0; }

    /* List */
    .list-header, .list-item { grid-template-columns: 28px 1fr 100px; }
    .item-size, .item-date { display: none; }
    .item-shortcut { display: flex !important; }

    /* Toolbar */
    .toolbar { padding: 0 12px; }
    .toolbar-btn span, .toolbar-btn:not(.primary):not(.danger) { font-size: .75rem; }
    .content { padding: 0 12px 16px; }

    /* Preview Modal */
    .preview-modal { width: 100vw; height: 100vh; border-radius: 0; }

    /* Context Menu */
    .ctx-menu { min-width: 160px; }
}
