  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg: #0e0e10;
    --surface: #18181b;
    --surface2: #1e1e22;
    --border: #2a2a2e;
    --text: #e4e4e7;
    --text-dim: #8b8b94;
    --accent: #6d5dfc;
    --accent-hover: #7c6eff;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --radius: 8px;
  }

  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
  }

  /*  Login  */
  .login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
  }
  .login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 360px;
    text-align: center;
  }
  .login-box h1 { font-size: 22px; margin-bottom: 8px; font-weight: 600; }
  .login-box p { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
  .login-box input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
    margin-bottom: 16px;
  }
  .login-box input[type="password"]:focus { border-color: var(--accent); }
  .login-box .error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }
  .login-box button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
  }
  .login-box button:hover { background: var(--accent-hover); }

  /*  Layout  */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .topbar h1 { font-size: 18px; font-weight: 600; }
  .topbar-right { display: flex; align-items: center; gap: 16px; }
  .topbar .stats { color: var(--text-dim); font-size: 13px; }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
  }
  .btn:hover { border-color: var(--accent); color: var(--accent); }
  .btn-danger { border-color: var(--danger); color: var(--danger); }
  .btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
  .btn-sm { padding: 4px 10px; font-size: 12px; }

  .container { max-width: 1280px; margin: 0 auto; padding: 24px; }

  /*  Toolbar  */
  .toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
  }
  .search-box {
    flex: 1;
    min-width: 200px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    outline: none;
  }
  .search-box:focus { border-color: var(--accent); }
  .search-box::placeholder { color: var(--text-dim); }

  .filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
  }
  .filter-btn:hover, .filter-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(109, 93, 252, 0.08); }

  .view-toggle { display: flex; gap: 0; }
  .view-toggle button {
    width: 36px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
  }
  .view-toggle button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
  .view-toggle button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
  .view-toggle button:not(:first-child) { border-left: none; }
  .view-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

  /*  Grid View  */
  .file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }
  .file-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    cursor: pointer;
  }
  .file-card:hover { border-color: var(--accent); }
  .file-card .thumb {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow: hidden;
  }
  .file-card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .file-card .thumb .icon {
    font-size: 40px;
    color: var(--text-dim);
  }
  .file-card .info {
    padding: 10px 12px;
  }
  .file-card .info .name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .file-card .info .meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
  }
  .file-card .card-actions {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    gap: 4px;
  }
  .file-card:hover .card-actions { display: flex; }
  .card-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    backdrop-filter: blur(4px);
  }
  .card-btn:hover { background: var(--accent); }
  .card-btn.del:hover { background: var(--danger); }

  /*  Table View  */
  .file-table {
    width: 100%;
    border-collapse: collapse;
  }
  .file-table th, .file-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
  }
  .file-table th {
    background: var(--surface);
    color: var(--text-dim);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 56px;
  }
  .file-table th.sortable {
    cursor: pointer;
    user-select: none;
  }
  .file-table th.sortable:hover {
    color: var(--accent);
    background: var(--surface2);
  }
  .file-table th.sortable .sort-indicator {
    display: inline-block;
    margin-left: 6px;
    font-size: 10px;
    opacity: 0.5;
  }
  .file-table th.sortable.sort-asc .sort-indicator {
    content: 'â–²';
    opacity: 1;
    color: var(--accent);
  }
  .file-table th.sortable.sort-desc .sort-indicator {
    content: 'â–¼';
    opacity: 1;
    color: var(--accent);
  }
  .file-table tr:hover td { background: var(--surface2); }
  .file-table .fname {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
  }
  .file-table .fname span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .file-table .mini-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg);
  }
  .file-table .mini-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-dim);
    flex-shrink: 0;
  }
  .file-table .actions { display: flex; gap: 6px; }

  /*  Shelf (Card) View  */
  .file-shelf {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 24px 20px;
  }
  .shelf-item {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  .shelf-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
  }
  .shelf-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .shelf-cover .shelf-icon {
    font-size: 42px;
    color: var(--text-dim);
  }
  .shelf-cover .shelf-ext {
    position: absolute;
    bottom: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .shelf-name {
    font-size: 13px;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
  }
  .shelf-item:hover .shelf-cover { border-color: var(--accent); }
  .shelf-item:hover .shelf-name { color: var(--accent); }

  /*  Modal  */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
  }
  .modal-overlay.active { display: flex; }
  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 900px;
    max-height: calc(100vh - 30px);
    width: 90vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
  }
  .modal.modal-tall {
    height: calc(100vh - 30px);
  }
  .modal-header {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 10;
  }
  .modal-header h2 { display: none; }
  .modal-header .close-btn {
    background: rgba(0,0,0,0.45);
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    cursor: pointer;
    padding: 2px 8px;
    line-height: 1;
    border-radius: 6px;
    backdrop-filter: blur(4px);
  }
  .modal-header .close-btn:hover { color: var(--text); background: rgba(0,0,0,0.7); }
  .modal-body {
    padding: 20px;
    overflow: auto;
    text-align: center;
    flex: 1;
    min-height: 0;
    overflow: auto;
  }
  .modal-tall .modal-body {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
  }
  .modal-body img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius);
    display: block;
    margin: auto;
  }

  /*  Custom Video Player  */
  .vp-wrap {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  .vp-wrap video {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
  }
  .vp-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
  }
  .vp-btn {
    width: 34px; height: 34px;
    border: none; border-radius: 50%;
    background: var(--accent);
    color: #fff; font-size: 13px;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .vp-btn:hover { background: var(--accent-hover); }
  .vp-progress {
    flex: 1; height: 4px;
    -webkit-appearance: none; appearance: none;
    background: var(--border); border-radius: 2px; cursor: pointer; outline: none;
  }
  .vp-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
  }
  .vp-progress::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%; border: none;
    background: var(--accent); cursor: pointer;
  }
  .vp-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
  .vp-vol {
    width: 70px; height: 4px;
    -webkit-appearance: none; appearance: none;
    background: var(--border); border-radius: 2px; cursor: pointer; outline: none;
  }
  .vp-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%; background: var(--accent-hover); cursor: pointer;
  }
  .vp-vol::-moz-range-thumb {
    width: 12px; height: 12px;
    border-radius: 50%; border: none;
    background: var(--accent-hover); cursor: pointer;
  }

  /*  Custom Audio Player  */
  .ap-wrap {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 8px;
  }
  .ap-wave {
    width: 100%; height: 110px;
    display: block;
    background: var(--bg);
  }
  .ap-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
  }
  .ap-controls .ap-time {
    font-size: 12px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .ap-controls .ap-vol-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
  }
  .ap-controls .ap-vol-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    border-radius: 50%;
  }
  .ap-controls .ap-vol-icon:hover { color: var(--text); background: rgba(255,255,255,0.06); }

  .modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--radius);
    background: #fff;
  }
  .modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-dim);
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .footer-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
  }
  .modal-footer .footer-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
  }
  .modal-footer .footer-sep {
    color: var(--border);
    flex-shrink: 0;
  }
  .modal-footer .btns { display: flex; gap: 8px; flex-shrink: 0; }

  /*  Scrollbars  */
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
  ::-webkit-scrollbar-thumb:hover { background: #444450; }
  * { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

  /*  Toast  */
  .toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .toast {
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    color: #fff;
    animation: slideIn 0.25s ease;
  }
  .toast.success { background: var(--success); }
  .toast.error { background: var(--danger); }
  @keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

  /*  Video Thumbnails  */
  .video-thumb-wrap {
    width: 100%;
    height: 100%;
    position: relative;
  }
  .video-thumb-wrap .video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .video-play-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    pointer-events: none;
  }
  .audio-wave-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    background: rgba(109,93,252,0.75);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    pointer-events: none;
  }
  .doc-type-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.65);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    pointer-events: none;
    letter-spacing: 0.5px;
  }

  /*  Empty State  */
  .empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
  }
  .empty-state .icon { font-size: 48px; margin-bottom: 16px; }
  .empty-state p { font-size: 15px; }

  /*  Select  */
  .select-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
  }
  .select-bar.active { display: flex; }
  .select-bar button { background: rgba(255,255,255,0.2); border: none; color: #fff; padding: 6px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
  .select-bar button:hover { background: rgba(255,255,255,0.3); }
  .select-bar button.del-sel { background: var(--danger); }
  .select-bar button.del-sel:hover { background: var(--danger-hover); }

  .file-card .checkbox, .file-table .checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
  }

  @media (max-width: 640px) {
    .topbar { padding: 10px 14px; }
    .container { padding: 14px; }
    .file-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .toolbar { gap: 8px; }
    .modal { width: 95vw; }
  }

  /*  Folder Layout  */
  .admin-body {
    display: flex;
    align-items: flex-start;
    gap: 0;
  }

  /*  Folder Sidebar  */
  .folder-sidebar {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    min-height: calc(100vh - 57px);
    padding: 16px 12px;
    background: var(--surface);
    position: sticky;
    top: 57px;
    height: calc(100vh - 57px);
    overflow-y: auto;
  }
  .sidebar-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 8px;
    padding: 0 4px;
  }
  .folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    position: relative;
    user-select: none;
  }
  .folder-item:hover { background: var(--surface2); }
  .folder-item.active { background: rgba(109,93,252,0.15); color: var(--accent); }
  .folder-item .fi-icon { font-size: 15px; flex-shrink: 0; }
  .folder-item .fi-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .folder-item .fi-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    position: relative;
  }
  .folder-item .fi-count {
    font-size: 11px;
    color: var(--text-dim);
    background: var(--border);
    border-radius: 10px;
    padding: 1px 7px;
    flex-shrink: 0;
  }
  .folder-item .fi-actions {
    display: none;
    gap: 3px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
  }
  .folder-item .fi-right:hover .fi-actions { display: flex; }
  .folder-item .fi-right:hover .fi-count { visibility: hidden; }
  .folder-item.drag-over { background: rgba(109,93,252,0.25); border: 1px dashed var(--accent); }
  .folder-item.reorder-over { outline: 2px dashed var(--accent); background: rgba(109,93,252,0.1); }
  .folder-item[draggable] { cursor: pointer; }
  .folder-item[draggable]:active { cursor: pointer; }
  .file-card[draggable], tr[draggable] { cursor: grab; }
  .file-card[draggable]:active, tr[draggable]:active { cursor: grabbing; }
  .emoji-picker {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    width: 320px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  }
  .emoji-picker span {
    font-size: 19px;
    cursor: pointer;
    padding: 3px 4px;
    border-radius: 4px;
    line-height: 1;
  }
  .emoji-picker span:hover { background: var(--surface2); }
  .fi-btn {
    width: 22px; height: 22px;
    border: none; border-radius: 4px;
    background: var(--surface2);
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .fi-btn:hover { background: var(--accent); color: #fff; }
  .fi-btn.del:hover { background: var(--danger); color: #fff; }

  .sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
  }
  .sidebar-new-folder {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dim);
    border: 1px dashed var(--border);
    margin-top: 8px;
  }
  .sidebar-new-folder:hover { border-color: var(--accent); color: var(--accent); }

  /*  Main content area  */
  .main-content {
    flex: 1;
    min-width: 0;
    padding: 24px;
  }

  /*  Breadcrumb  */
  .breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 16px;
  }
  .breadcrumb .bc-link { color: var(--accent); cursor: pointer; }
  .breadcrumb .bc-link:hover { text-decoration: underline; }
  .breadcrumb .bc-sep { color: var(--border); }
  .breadcrumb .bc-current { color: var(--text); font-weight: 500; }

  /*  Move Modal  */
  .move-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 360px;
    padding: 24px;
  }
  .move-modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
  .move-folder-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
  .move-folder-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
  }
  .move-folder-opt:hover { border-color: var(--accent); color: var(--accent); }
  .move-folder-opt.selected { border-color: var(--accent); background: rgba(109,93,252,0.12); color: var(--accent); }
  .move-modal .btns { display: flex; gap: 8px; justify-content: flex-end; }

  /*  Inline name input (rename folder)  */
  .inline-input {
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
    padding: 2px 6px;
    width: 100%;
    outline: none;
  }
