/* ═══════════════════════════════════════════════
   Alfayed Cloud — Styles
   ═══════════════════════════════════════════════ */

/* ── Reset & Root ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --sky: #0ea5e9;
  --sky-hover: #0284c7;
  --sky-light: #7dd3fc;
  --sky-bg: #f0f9ff;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -2px rgba(0,0,0,0.03);
  --transition: 200ms ease;
  --bg: #f0f9ff;
  --bg-card: #ffffff;
  --bg-elevated: #f0f9ff;
  --bg-hover: #e0f2fe;
  --bg-input: #ffffff;
  --text: #0c4a6e;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #bae6fd;
  --border-light: #e0f2fe;
  --scrollbar: #bae6fd;
  --toast-bg: #1f2937;
  --overlay: rgba(0,0,0,0.15);
}
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Login ── */
#login-page {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg); padding: 20px;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.3s ease both;
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; justify-content: center; }
.login-logo svg { color: var(--sky); }
.login-logo h1 { font-size: 24px; font-weight: 700; }
.login-card .input-group { margin-bottom: 16px; }
.login-card label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text); font-size: 14px; font-family: var(--font);
  transition: border-color var(--transition);
}
.login-card input:focus { outline: none; border-color: var(--sky); }
.login-card .error-msg { color: var(--red); font-size: 13px; margin-top: 4px; display: none; }
.login-btn {
  width: 100%; padding: 12px; border: none; border-radius: var(--radius-sm);
  background: var(--sky); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: var(--font); transition: background 0.2s ease, transform 0.1s ease; margin-top: 8px;
}
.login-btn:hover { background: var(--sky-hover); }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── App Layout ── */
#app { display: none; height: 100vh; flex-direction: column; }

/* Top Bar */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 20px; height: 56px;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  position: relative; z-index: 100; flex-shrink: 0;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  background: color-mix(in srgb, var(--bg-card) 85%, transparent);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; cursor: pointer; flex-shrink: 0; }
.topbar-brand svg { color: var(--sky); }
.topbar-search {
  flex: 1; max-width: 360px; position: relative;
}
.topbar-search input {
  width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--bg-input); color: var(--text); font-size: 13px; font-family: var(--font);
  transition: all var(--transition);
}
.topbar-search input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(var(--sky-rgb), 0.15); }
.topbar-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }
.topbar-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-secondary); border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
}
.topbar-btn:hover { background: var(--bg-hover); color: var(--text); }
.topbar-btn.active { background: var(--bg-hover); color: var(--sky); }
.user-menu-btn {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border: none; background: transparent; color: var(--text); border-radius: var(--radius-sm);
  cursor: pointer; font-family: var(--font); font-size: 13px; transition: background var(--transition);
}
.user-menu-btn:hover { background: var(--bg-hover); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--sky);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 13px;
}

/* User Dropdown */
.user-dropdown {
  position: absolute; top: 48px; right: 16px; z-index: 100;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); min-width: 200px; display: none; overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-dropdown .dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer;
  font-size: 13px; color: var(--text); transition: background var(--transition);
  border: none; background: none; width: 100%; font-family: var(--font); text-align: left;
}
.user-dropdown .dropdown-item:hover { background: var(--bg-hover); }
.user-dropdown .dropdown-item svg { color: var(--text-secondary); width: 16px; height: 16px; }
.user-dropdown .dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.user-dropdown .dropdown-userinfo { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.user-dropdown .dropdown-userinfo .name { font-weight: 600; font-size: 14px; }
.user-dropdown .dropdown-userinfo .role { font-size: 12px; color: var(--text-muted); }

/* Main Container */
.main-container { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 260px; background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  overflow: hidden; transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* Header */
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(135deg, rgba(var(--sky-rgb), 0.04) 0%, rgba(var(--sky-rgb), 0.01) 100%);
}
.sidebar-logo { color: var(--sky); flex-shrink: 0; filter: drop-shadow(0 1px 2px rgba(var(--sky-rgb), 0.2)); }
.sidebar-title { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.sidebar-close {
  margin-left: auto; border: none; background: none;
  color: var(--text-muted); cursor: pointer; font-size: 22px;
  display: none; padding: 2px 8px; border-radius: 6px; line-height: 1;
  transition: all 0.15s;
}
.sidebar-close:hover { background: rgba(0,0,0,0.05); color: var(--text); }

/* Navigation items (shortcuts) */
.sidebar-nav {
  display: flex; flex-direction: column; gap: 1px;
  padding: 10px 10px 6px; flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-secondary);
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: var(--font); text-align: left;
  transition: all 0.2s ease; width: 100%; position: relative;
}
.nav-item:hover { background: rgba(var(--sky-rgb), 0.06); color: var(--sky); }
.nav-item.active {
  background: rgba(var(--sky-rgb), 0.1); color: var(--sky);
  font-weight: 600; box-shadow: inset 3px 0 0 var(--sky);
}
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-muted); transition: color 0.2s; }
.nav-item.active .nav-icon { color: var(--sky); }
.nav-item:hover .nav-icon { color: var(--sky); }

/* Divider */
.sidebar-divider {
  height: 1px; background: linear-gradient(90deg, transparent, var(--border-light), transparent);
  margin: 4px 14px; flex-shrink: 0;
}

/* Section label */
.sidebar-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--sky);
  padding: 6px 18px 4px; flex-shrink: 0;
}

/* Folder tree */
.folder-tree { flex: 1; overflow-y: auto; padding: 2px 10px 8px; }
.tree-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: pointer; border-radius: 8px;
  font-size: 12.5px; color: var(--text-secondary);
  transition: all 0.2s ease; width: 100%;
  border: none; background: none; font-family: var(--font); text-align: left;
}
.tree-item:hover { background: rgba(var(--sky-rgb), 0.05); color: var(--text); }
.tree-item.active { background: rgba(var(--sky-rgb), 0.1); color: var(--sky); font-weight: 600; }
.tree-item .arrow {
  width: 14px; height: 14px; transition: transform 0.2s ease;
  flex-shrink: 0; color: var(--text-muted);
}
.tree-item .arrow.expanded { transform: rotate(90deg); }
.tree-item .icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--sky); }
.tree-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-children { display: none; }
.tree-children.show { display: block; }
.tree-children .tree-item { padding-left: 34px; }

/* Content */
.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.breadcrumb {
  display: flex; align-items: center; gap: 4px; padding: 10px 8px;
  font-size: 13px; overflow-x: auto; flex-shrink: 0;
  white-space: nowrap; transition: opacity 0.2s ease;
}
.breadcrumb a {
  color: var(--text-secondary); cursor: pointer; text-decoration: none;
  transition: color var(--transition);
}
.breadcrumb a:hover { color: var(--sky); }
.breadcrumb .separator { color: var(--text-muted); margin: 0 2px; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 20px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap;
}
.toolbar-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-family: var(--font); font-weight: 500;
  transition: all var(--transition);
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--text-muted); }
.toolbar-btn svg { width: 16px; height: 16px; }
.toolbar-btn.primary { background: var(--sky); color: #fff; border-color: var(--sky); }
.toolbar-btn.primary:hover { background: var(--sky-hover); }
.upload-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-secondary);
  font-size: 13px; font-family: var(--font); cursor: pointer;
  text-align: left; transition: all 0.15s ease;
}
.upload-menu-item:hover { background: var(--bg-hover); color: var(--text); }
.upload-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.toolbar-btn-primary {
  background: var(--sky); color: #fff; border-color: var(--sky);
}
.toolbar-btn-primary:hover { background: var(--sky-hover); }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.sort-select {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text-secondary); font-size: 12px; font-family: var(--font);
  cursor: pointer;
}

/* File List */
.file-area { flex: 1; overflow-y: auto; padding: 8px; scroll-behavior: smooth; }
.file-area.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); gap: 12px;
}
.file-area.empty svg { width: 64px; height: 64px; opacity: 0.3; }
.file-area.empty p { font-size: 14px; }

/* List View */
.list-view { display: flex; flex-direction: column; }
.list-header {
  display: flex; align-items: center; padding: 8px 12px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); gap: 8px;
}
.list-header .col-name { flex: 1; cursor: pointer; }
.list-header .col-size { width: 100px; cursor: pointer; text-align: right; }
.list-header .col-date { width: 180px; cursor: pointer; text-align: right; }
.list-header .col-actions { width: 40px; }
.list-item {
  display: flex; align-items: center; padding: 10px 14px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.2s ease, transform 0.15s ease; gap: 10px;
  position: relative; animation: fadeIn 0.2s ease both;
  margin: 0 4px; border-bottom: 1px solid var(--border-light);
}
.list-item:hover { background: var(--bg-hover); }
.list-item:active { transform: scale(0.99); background: var(--bg-hover); }
.list-item .item-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--text-muted); }
.list-item .item-icon.folder { color: var(--sky); }
.list-item .item-icon.image { color: var(--green); }
.list-item .item-icon.video { color: var(--sky); }
.list-item .item-icon.music { color: var(--sky-light); }
.list-item .item-icon.archive { color: var(--red); }
.list-item .item-icon.code { color: var(--green); }
.list-item .col-name { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .col-size { width: 100px; font-size: 12px; color: var(--text-muted); text-align: right; }
.list-item .col-date { width: 180px; font-size: 12px; color: var(--text-muted); text-align: right; }
.list-item .col-actions {
  width: 40px; text-align: center; opacity: 0; transition: opacity var(--transition);
}
.list-item:hover .col-actions { opacity: 1; }
.list-item .list-thumb {
  width: 32px; height: 32px; border-radius: 6px;
  overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
}
.list-item .list-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-item .list-thumb svg { width: 18px; height: 18px; }
.list-item .action-btn {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-secondary); border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
}
.list-item .action-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Grid View */
.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; padding: 16px; cursor: grab; scroll-behavior: smooth; }
.grid-view:active { cursor: grabbing; }
.grid-item {
  display: flex; flex-direction: columns; border-radius: var(--radius-lg); cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1); overflow: hidden;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  animation: fadeIn 0.25s ease both;
}
.grid-item:hover { border-color: var(--sky); box-shadow: 0 8px 25px rgba(var(--sky-rgb), 0.12); transform: translateY(-3px); }
.grid-item:active { transform: scale(0.97); }
.up-item:hover { background: rgba(var(--sky-rgb), 0.1) !important; }
.list-item.up-item:hover { background: rgba(var(--sky-rgb), 0.1) !important; transform: none; box-shadow: none; }
.grid-item .grid-thumb {
  width: 100%; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated); position: relative; overflow: hidden;
}
.grid-item .grid-thumb img { width: 100%; height: 100%; object-fit: cover; }
.grid-item .grid-thumb svg.type-icon { width: 48px; height: 48px; stroke: var(--sky); }
.grid-item .grid-thumb svg.folder-icon { width: 48px; height: 48px; color: var(--sky); }
.grid-item .grid-info { padding: 10px 12px; }
.grid-item .grid-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.grid-item .grid-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.grid-type { padding: 1px 6px; border-radius: 3px; background: var(--bg-hover); color: var(--text-secondary); font-size: 10px; font-weight: 600; }

/* File Badge */
.file-badge { position: absolute; bottom: 6px; right: 6px; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; background: rgba(0,0,0,0.6); color: #fff; backdrop-filter: blur(4px); }

/* Upload Progress */
.upload-overlay {
  position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px;
  max-width: 360px;
}
.upload-item {
  background: var(--toast-bg); padding: 12px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  animation: slideUp 0.25s ease;
}
.upload-item .upload-name { font-size: 12px; font-weight: 500; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .upload-bar { height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.upload-item .upload-fill { height: 100%; background: var(--sky); border-radius: 2px; transition: width 0.3s; }
.upload-item .upload-pct { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-align: right; }

/* Context Menu */
.context-menu {
  position: fixed; z-index: 300; min-width: 180px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 4px; display: none;
}
.context-menu.show { display: block; animation: scaleIn 0.15s ease; }
.context-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer;
  font-size: 13px; color: var(--text); border-radius: 4px; border: none; background: none;
  width: 100%; font-family: var(--font); text-align: left; transition: background var(--transition);
}
.context-item:hover { background: var(--bg-hover); }
.context-item svg { width: 16px; height: 16px; color: var(--text-secondary); }
.context-item.danger { color: var(--red); }
.context-item.danger svg { color: var(--red); }
.context-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Toast */
.toast-container {
  position: fixed; top: 70px; right: 20px; z-index: 250; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--toast-bg); padding: 12px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 13px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s ease; min-width: 280px; max-width: 400px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--sky); }
.toast .toast-icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--green); }
.toast.error .toast-icon { color: var(--red); }
.toast.info .toast-icon { color: var(--sky); }
.toast .toast-close { margin-left: auto; cursor: pointer; background: none; border: none; color: var(--text-muted); font-size: 16px; padding: 0 4px; }
.toast.removing { animation: toastOut 0.25s ease forwards; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 400; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.show { opacity: 1; visibility: visible; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; padding: 24px;
  transform: scale(0.92) translateY(10px); opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal-overlay.show .modal {
  transform: scale(1) translateY(0); opacity: 1;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal .input-group { margin-bottom: 14px; }
.modal label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.modal input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text); font-size: 14px; font-family: var(--font);
  transition: border-color var(--transition);
}
.modal input:focus { outline: none; border-color: var(--sky); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.settings-section { margin-top: 18px; }
.settings-section h3 { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.4px; }
.profile-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 14px; }
.profile-row span { color: var(--text-muted); }
.profile-row b { color: var(--text); font-weight: 600; }
.quota-bar { height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.quota-fill { height: 100%; border-radius: 3px; background: var(--sky); transition: width 0.8s ease; }
.quota-text { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.modal-btn {
  padding: 8px 20px; border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: var(--font); transition: all var(--transition);
}
.modal-btn.primary { background: var(--sky); color: #fff; }
.modal-btn.primary:hover { background: var(--sky-hover); }
.modal-btn.secondary { background: var(--bg-hover); color: var(--text); }
.modal-btn.secondary:hover { background: var(--border); }
.modal-btn.danger { background: var(--red); color: #fff; }

.cm-folder-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-radius: 4px;
  transition: background 0.15s; margin: 0 4px;
}
.cm-folder-item:hover { background: var(--bg-hover); }
.cm-folder-item:active { background: var(--border-light); }

/* Selection mode */
.selection-active .grid-item,
.selection-active .list-item { cursor: pointer; }
.grid-item.selected,
.list-item.selected { background: rgba(var(--sky-rgb), 0.08) !important; border-color: var(--sky) !important; }
.selection-checkbox {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
  border: 2px solid var(--border); border-radius: 4px; background: rgba(255,255,255,0.9);
  display: none; align-items: center; justify-content: center; z-index: 2;
}
.grid-item .selection-checkbox,
.list-item .selection-checkbox { display: none; }
.grid-item.selected .selection-checkbox,
.list-item.selected .selection-checkbox { display: flex; background: var(--sky); border-color: var(--sky); }
.grid-item.selected .selection-checkbox::after,
.list-item.selected .selection-checkbox::after { content: ''; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-top: -2px; }
.selection-bar {
  display: none; align-items: center; gap: 12px; padding: 8px 16px;
  background: var(--sky); color: #fff; border-radius: var(--radius); margin: 0 16px;
  font-size: 13px; font-weight: 500; flex-shrink: 0;
}
.selection-bar.show { display: flex; }
.selection-bar .sel-count { flex: 1; }
.selection-bar .sel-btn {
  padding: 4px 12px; border: none; border-radius: 4px; cursor: pointer;
  font-size: 12px; font-weight: 500; font-family: var(--font);
  transition: opacity 0.15s;
}
.selection-bar .sel-btn-cancel { background: rgba(255,255,255,0.2); color: #fff; }
.selection-bar .sel-btn-cancel:hover { background: rgba(255,255,255,0.3); }
.selection-bar .sel-btn-delete { background: #fff; color: var(--red); }
.selection-bar .sel-btn-delete:hover { background: #fee2e2; }
.selection-bar .sel-btn-copy { background: #fff; color: var(--sky); }
.selection-bar .sel-btn-copy:hover { background: #e0f2fe; }
.selection-bar .sel-btn-select-all { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.28); }
.selection-bar .sel-btn-select-all:hover { background: rgba(255,255,255,.25); }
.selection-bar .sel-btn-move { background: #fff; color: var(--green); }
.selection-bar .sel-btn-move:hover { background: #d1fae5; }
.selection-bar .sel-btn-danger { background: var(--red); color: #fff; }
.selection-bar .sel-btn-danger:hover { background: #dc2626; }

/* Upload button hidden input */
#file-input { display: none; }
#folder-input { display: none; }

/* Media Viewer Overlay */
.media-overlay {
  position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.media-overlay.show { opacity: 1; visibility: visible; pointer-events: all; }
.media-close {
  position: fixed; top: 16px; right: 16px; z-index: 510;
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: #fff; cursor: pointer;
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.media-close:hover { background: rgba(255,255,255,0.3); }
.media-viewer {
  display: flex; flex-direction: column; align-items: center;
  max-width: 95vw; max-height: 95vh; position: relative;
}
.video-wrapper, .audio-wrapper {
  display: flex; flex-direction: column; align-items: center;
  position: relative; max-width: 95vw;
}
.video-wrapper video {
  max-width: 95vw; max-height: 85vh; border-radius: var(--radius);
  background: #000; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.audio-wrapper {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 40px; border: 1px solid var(--border); min-width: 360px;
}
.audio-wrapper .audio-art {
  width: 120px; height: 120px; border-radius: 50%;
  background: var(--sky); display: flex; align-items: center;
  justify-content: center; margin-bottom: 24px;
}
.audio-wrapper .audio-art svg { width: 56px; height: 56px; color: #fff; }
.audio-wrapper .audio-info {
  font-size: 16px; font-weight: 600; margin-bottom: 20px;
  text-align: center; color: var(--text); word-break: break-all;
}
.audio-wrapper audio { width: 100%; }
.image-wrapper {
  display: flex; align-items: center; justify-content: center;
  max-width: 95vw; max-height: 85vh; position: relative;
  cursor: zoom-in;
}
.image-wrapper img {
  max-width: 95vw; max-height: 85vh; border-radius: var(--radius);
  object-fit: contain; transition: transform 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.image-wrapper img.zoomed { cursor: zoom-out; }
.media-toolbar {
  display: flex; align-items: center; gap: 8px; margin-top: 16px;
  padding: 8px 16px; background: rgba(0,0,0,0.5); border-radius: var(--radius);
}
.media-nav-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.1); color: #fff; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.media-nav-btn:hover { background: rgba(255,255,255,0.25); }
.media-counter { color: #fff; font-size: 13px; min-width: 60px; text-align: center; }
.media-toolbar-spacer { flex: 1; }
.media-action-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: none;
  background: rgba(255,255,255,0.1); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.media-action-btn:hover { background: rgba(255,255,255,0.25); }
.media-action-btn svg { width: 18px; height: 18px; }
.media-loading {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; z-index: 2;
}
.spinner {
  width: 40px; height: 40px; border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.slideshow-active .media-action-btn[data-slideshow] { background: var(--sky); }

/* Animations */
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* Sidebar Quota */
.sidebar-quota {
  padding: 10px 18px 14px; border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}
.sidebar-quota .quota-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted); margin-bottom: 6px;
}
.sidebar-quota .quota-label svg { width: 12px; height: 12px; color: var(--sky); }
.sidebar-quota .quota-bar {
  height: 4px; background: var(--bg-hover);
  border-radius: 2px; overflow: hidden;
}
.sidebar-quota .quota-fill {
  height: 100%; border-radius: 2px;
  background: var(--sky); transition: width 0.8s ease;
}
.sidebar-quota .quota-text {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-muted); margin-top: 4px;
}

/* ── Smooth Enhancements ── */

/* Sidebar grabber */
.sidebar-resizer {
  width: 4px; cursor: col-resize; flex-shrink: 0;
  background: transparent; position: relative; z-index: 10;
  transition: background 0.2s ease;
}
.sidebar-resizer:hover,
.sidebar-resizer.active { background: var(--sky); }

/* Entrance animations */
.login-card { animation: slideUp 0.4s ease; }
.user-dropdown.show { animation: scaleIn 0.15s ease; }
.topbar-brand { animation: fadeIn 0.3s ease; }

/* ── Category Tabs ── */
.category-tabs {
  display: flex; gap: 4px; padding: 8px 20px 0;
  border-bottom: none; flex-shrink: 0; overflow-x: auto;
}
.cat-tab {
  padding: 6px 14px; border: none; border-radius: 8px 8px 0 0;
  background: transparent; color: var(--text-secondary);
  font-size: 12px; font-weight: 500; cursor: pointer;
  font-family: var(--font); transition: all var(--transition);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.cat-tab:hover { background: var(--bg-hover); color: var(--text); }
.cat-tab.active {
  background: var(--bg-card); color: var(--sky);
  border: 1px solid var(--border); border-bottom: 2px solid var(--sky);
}
.cat-tab svg { width: 16px; height: 16px; }

/* ── Text Preview ── */
.text-preview-modal { width: 100%; }
.text-preview-modal code { display: block; }

/* ── Hamburger ── */
.hamburger { display: none; border: none; background: none; color: var(--sky); cursor: pointer; padding: 6px; border-radius: 6px; }
.hamburger:hover { background: var(--bg-hover); }
.hamburger svg { width: 22px; height: 22px; }

/* ── Responsive ── */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .sidebar { width: 240px; }
  .grid-view { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
}

/* Tablet kecil / HP besar (768px) */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 8px; top: 64px; bottom: 8px; z-index: 50;
    margin-left: -300px; width: 280px; border-radius: 14px;
    box-shadow: 0 8px 40px rgba(var(--sky-rgb), 0.12), 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.open { margin-left: 0; }
  .sidebar.open::after {
    content: ''; position: fixed; inset: 0; z-index: -1;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
  }
  .sidebar-close { display: block; }
  .hamburger { display: flex; }

  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar-search { max-width: 140px; }
  .topbar-search input { font-size: 12px; padding: 6px 10px 6px 30px; }
  .topbar-brand span { display: none; }

  .list-item .col-date { display: none; }
  .list-header .col-date { display: none; }
  .grid-view { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 10px; }

  .category-tabs { padding: 6px 12px 0; gap: 2px; }
  .cat-tab { padding: 5px 10px; font-size: 11px; }
  .cat-tab svg { width: 14px; height: 14px; }

  .toolbar { padding: 6px 12px; }
  .toolbar-btn { padding: 5px 10px; }
  .toolbar-btn span { display: none; }
  .breadcrumb { padding: 8px 4px; font-size: 12px; }
  .file-area { padding: 4px; }

  .video-wrapper video { max-width: 98vw; max-height: 65vh; }
  .image-wrapper img { max-width: 98vw; max-height: 65vh; }
  .audio-wrapper { min-width: auto; width: 92vw; padding: 20px; }
  .media-toolbar { flex-wrap: wrap; justify-content: center; }

  .modal { max-width: 95vw !important; margin: 10px; }
  .text-preview-modal code { font-size: 12px; }
}

/* HP kecil (480px) */
@media (max-width: 480px) {
  .topbar { padding: 6px 10px; gap: 6px; height: 50px; padding-top: calc(6px + env(safe-area-inset-top, 0px)); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  body { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .topbar-search { max-width: 100px; }
  .user-menu-btn span { display: none; }
  .user-avatar { width: 26px; height: 26px; font-size: 11px; }

  .grid-view { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; padding: 8px; }
  .grid-item { border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
  .grid-item .grid-thumb { aspect-ratio: 1; border-radius: 12px 12px 0 0; }
  .grid-item .grid-info { padding: 8px; }
  .grid-item .grid-name { font-size: 11px; }
  .grid-item .grid-meta { font-size: 10px; flex-direction: column; gap: 2px; }
  .grid-item:hover { transform: translateY(-2px); }

  .list-item { min-height: 48px; padding: 6px 10px; border-radius: 10px; margin-bottom: 2px; }
  .list-item .item-icon { width: 24px; height: 24px; }
  .list-item .col-name { font-size: 13px; }
  .breadcrumb { padding: 6px 2px; font-size: 11px; overflow-x: auto; min-height: 36px; }
  .category-tabs { padding: 4px 10px 0; overflow-x: auto; gap: 4px; }
  .cat-tab { padding: 8px 12px; font-size: 10px; white-space: nowrap; min-height: 36px; }
  .cat-tab span { display: none; }
  .cat-tab svg { width: 16px; height: 16px; margin: 0; }

  .toolbar { padding: 6px 10px; gap: 6px; }
  .toolbar-btn { padding: 6px 10px; font-size: 11px; min-height: 36px; }
  .toolbar-btn-primary { min-height: 36px; }
  .file-area { padding: 4px; }

  .video-wrapper video { max-height: 45vh; }
  .image-wrapper img { max-height: 45vh; }
  .media-counter { font-size: 10px; min-width: 30px; }
  .audio-wrapper .audio-art { width: 60px; height: 60px; }
  .audio-wrapper .audio-art svg { width: 28px; height: 28px; }
  .audio-wrapper { padding: 16px; }
  .media-close { width: 32px; height: 32px; font-size: 16px; top: 8px; right: 8px; }

  .sidebar { width: 280px; margin-left: -290px; top: 0; left: 0; bottom: 0; border-radius: 0 16px 16px 0; border-left: none; padding-top: 8px; }
  .sidebar.open::after { background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

  .selection-bar { padding: 4px 10px; gap: 4px; overflow-x: auto; }
  .sel-btn { padding: 8px 12px; font-size: 12px; min-height: 36px; white-space: nowrap; }
  .sel-count { font-size: 12px; min-height: 36px; display: flex; align-items: center; }

  .modal { padding: 20px; max-width: 94vw; border-radius: 16px; }
  .modal h2 { font-size: 16px; margin-bottom: 12px; }
  .settings-section { margin-top: 14px; }
  .profile-row { font-size: 13px; padding: 10px 0; }
  .theme-mode-btn { font-size: 12px; padding: 12px 6px; flex: 1 1 auto; min-height: 44px; }
  .theme-swatch { min-height: 48px; min-width: 48px; }
  .theme-accent-grid { gap: 10px; }
  .modal-actions { margin-top: 16px; flex-direction: column; }
  .modal-actions button { width: 100%; }
  .modal-btn { padding: 14px 16px; font-size: 14px; min-height: 44px; }
  .modal input { font-size: 16px !important; padding: 12px !important; min-height: 44px; }

  .toast { min-width: auto; max-width: 90vw; font-size: 12px; border-radius: 12px; }
  .toast-container { right: 10px; top: 60px; left: 10px; }

  .upload-overlay { bottom: 12px; right: 12px; left: 12px; max-width: none; }
  .upload-item { padding: 8px 10px; font-size: 12px; border-radius: 10px; }
  .context-menu { padding: 6px; border-radius: 14px; min-width: 180px; }
  .context-item { padding: 10px 12px; font-size: 13px; min-height: 40px; }
  .context-item svg { width: 18px; height: 18px; }
}

.theme-mode-row { display:flex; gap:10px; flex-wrap:wrap; }
.theme-mode-btn { flex:1; padding:10px; border-radius:var(--radius); border:2px solid var(--border); background:var(--bg-input); color:var(--text); font-size:13px; font-weight:600; cursor:pointer; transition:var(--transition); }
.theme-mode-btn:hover { border-color:var(--accent); }
.theme-mode-btn.active { border-color:var(--accent); background:var(--bg-hover); color:var(--accent); }
.theme-accent-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.theme-swatch { aspect-ratio:1; border-radius:var(--radius); border:3px solid transparent; cursor:pointer; position:relative; transition:var(--transition); display:flex; align-items:center; justify-content:center; }
.theme-swatch:hover { transform:scale(1.05); }
.theme-swatch.active { border-color:var(--text); }
.theme-swatch.active::after { content:'✓'; color:#fff; font-weight:700; font-size:18px; text-shadow:0 1px 2px rgba(0,0,0,0.4); }
/* Ukuran thumbnail */
body.thumb-sm .grid-thumb { width:64px; height:64px; }
body.thumb-sm .grid-item { padding:8px; }
body.thumb-md .grid-thumb { width:96px; height:96px; }
body.thumb-md .grid-item { padding:12px; }
body.thumb-lg .grid-thumb { width:140px; height:140px; }
body.thumb-lg .grid-item { padding:16px; }
body.thumb-lg .grid-name { font-size:14px; }
/* Density */
body.density-compact .grid-view { gap:6px; }
body.density-compact .grid-item { padding:6px; }
body.density-compact .list-item { padding:6px 10px; }
body.density-compact .list-header { padding:6px 10px; }

/* ── Drag & Drop Overlay ── */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drop-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.drop-zone {
  background: var(--bg-card);
  border: 3px dashed var(--sky);
  border-radius: 20px;
  padding: 50px 60px;
  text-align: center;
  max-width: 440px;
  width: 90%;
  transform: scale(0.92);
  transition: transform 0.25s ease, border-color 0.2s ease, background 0.2s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.drop-overlay.active .drop-zone {
  transform: scale(1);
}
.drop-zone.dragover {
  border-color: var(--green);
  background: rgba(16,185,129,0.06);
  transform: scale(1.03);
}
.drop-icon {
  color: var(--sky);
  margin-bottom: 12px;
  transition: color 0.2s ease;
}
.drop-zone.dragover .drop-icon {
  color: var(--green);
}
.drop-title {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
}
.drop-desc {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}
.drop-desc strong {
  color: var(--sky);
}

/* ═══════════════════════════════════════════════
   Mobile-first polish — v1.3
   ═══════════════════════════════════════════════ */

:root {
  --radius-xs: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --tap: 44px;
  --mobile-nav-height: 72px;
  --shadow-soft: 0 10px 35px rgba(15, 23, 42, 0.08);
  --shadow-float: 0 20px 55px rgba(15, 23, 42, 0.18);
}

html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[role="button"]:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(var(--sky-rgb), 0.28);
  outline-offset: 2px;
}
.modal-open { overflow: hidden; }

/* Login */
#login-page {
  min-height: 100dvh;
  height: auto;
  background:
    radial-gradient(circle at 15% 12%, rgba(var(--sky-rgb), .16), transparent 34%),
    radial-gradient(circle at 88% 90%, rgba(var(--sky-rgb), .10), transparent 32%),
    var(--bg);
}
.login-card {
  max-width: 420px;
  padding: 38px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-float);
}
.login-logo { margin-bottom: 10px; }
.login-logo svg { filter: drop-shadow(0 5px 12px rgba(var(--sky-rgb), .22)); }
.login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
  max-width: 310px;
  margin: 0 auto 28px;
}
.login-card input { min-height: var(--tap); padding: 11px 14px; }
.login-card input:focus { box-shadow: 0 0 0 3px rgba(var(--sky-rgb), .13); }
.password-field { position: relative; }
.password-field input { padding-right: 92px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 34px; padding: 0 10px; border: 0; border-radius: 7px;
  color: var(--sky); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer;
}
.password-toggle:hover { background: var(--bg-hover); }
.login-btn { min-height: 46px; border-radius: 9px; box-shadow: 0 8px 18px rgba(var(--sky-rgb), .20); }

/* Shell */
.topbar { height: 62px; padding: 8px 22px; }
.topbar-brand {
  border: 0; background: transparent; color: var(--text); font-family: var(--font);
  min-height: var(--tap); padding: 0 4px; border-radius: 8px;
}
.topbar-brand:hover { color: var(--sky); }
.topbar-search { max-width: 460px; min-width: 120px; }
.topbar-search input { height: 40px; border-radius: 12px; padding-left: 38px; }
.topbar-btn { min-width: 40px; min-height: 40px; }
.user-menu-btn { min-height: 42px; }
.pathbar {
  display: flex; align-items: center; gap: 4px; padding: 0 20px 0 10px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; min-height: 46px;
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
}
.sidebar { box-shadow: 3px 0 20px rgba(15,23,42,.03); }
.content { min-width: 0; }
.toolbar { min-height: 52px; background: color-mix(in srgb, var(--bg-card) 60%, transparent); }
.toolbar-btn, .sort-select { min-height: 36px; }
.upload-menu { overflow: hidden; }
.upload-menu-item { min-height: 40px; }

/* File cards */
.grid-view {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-content: start; gap: 14px; padding: 16px 20px 28px; cursor: default;
}
.grid-view:active { cursor: default; }
.grid-item,
body.thumb-sm .grid-item,
body.thumb-md .grid-item,
body.thumb-lg .grid-item {
  flex-direction: column; padding: 0; min-width: 0; position: relative;
  border-radius: 15px; overflow: hidden;
}
.grid-item .grid-thumb,
body.thumb-sm .grid-thumb,
body.thumb-md .grid-thumb,
body.thumb-lg .grid-thumb {
  width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 0;
}
.grid-item .grid-info { width: 100%; padding: 11px 12px 12px; min-width: 0; }
.grid-item .grid-name { font-size: 13px; line-height: 1.35; }
.grid-item .grid-meta { align-items: center; gap: 6px; }
.grid-item .grid-size { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-action-btn {
  position: absolute; z-index: 4; top: 8px; right: 8px; width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,.42); border-radius: 10px;
  background: rgba(15,23,42,.58); color: #fff; backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: 0; transform: translateY(-3px); transition: opacity .16s ease, transform .16s ease, background .16s ease;
}
.grid-action-btn svg { width: 18px; height: 18px; }
.grid-item:hover .grid-action-btn, .grid-action-btn:focus-visible { opacity: 1; transform: none; }
.grid-action-btn:hover { background: rgba(15,23,42,.78); }
.up-item { border: 1px dashed var(--border) !important; box-shadow: none; }
.up-item .grid-name { color: var(--sky); }

.list-view { padding: 4px 12px 24px; }
.list-header { margin: 0 4px; }
.list-item { min-height: 54px; margin: 0 4px; padding: 8px 12px; border-bottom-color: var(--border-light); }
.list-item:hover { background: color-mix(in srgb, var(--bg-hover) 72%, transparent); }
.list-item .col-actions { opacity: .55; }
.list-item:hover .col-actions, .list-item:focus-within .col-actions { opacity: 1; }

/* Empty and error states */
.empty-state {
  min-height: 100%; padding: 32px 20px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; color: var(--text);
}
.empty-visual {
  width: 94px; height: 94px; display: grid; place-items: center; border-radius: 28px;
  margin-bottom: 18px; color: var(--sky); background: linear-gradient(145deg, rgba(var(--sky-rgb), .16), rgba(var(--sky-rgb), .05));
  border: 1px solid rgba(var(--sky-rgb), .18);
}
.empty-visual svg { width: 48px; height: 48px; }
.empty-visual.search { font-size: 36px; }
.empty-icon.error {
  width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 14px;
  border-radius: 18px; background: rgba(239,68,68,.12); color: var(--red); font-size: 28px; font-weight: 800;
}
.empty-state h2 { font-size: 18px; margin-bottom: 7px; letter-spacing: -.2px; }
.empty-state p { color: var(--text-secondary); font-size: 13px; line-height: 1.55; max-width: 390px; }
.empty-actions { display: flex; gap: 9px; margin-top: 18px; }
.empty-primary, .empty-secondary {
  min-height: 42px; padding: 0 16px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.empty-primary { border: 1px solid var(--sky); background: var(--sky); color: #fff; }
.empty-secondary { border: 1px solid var(--border); background: var(--bg-card); color: var(--text); }

/* Skeleton loading */
.skeleton { display: block; background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 45%, var(--bg-elevated) 65%); background-size: 220% 100%; animation: skeletonShimmer 1.35s ease-in-out infinite; }
.skeleton-grid { pointer-events: none; }
.skeleton-card { border: 1px solid var(--border-light); border-radius: 15px; overflow: hidden; background: var(--bg-card); padding-bottom: 12px; }
.skeleton-media { width: 100%; aspect-ratio: 4/3; }
.skeleton-card .skeleton-line { height: 12px; margin: 12px 12px 8px; border-radius: 8px; }
.skeleton-short { width: 42%; height: 9px; margin: 0 12px; border-radius: 8px; }
.skeleton-list { padding-top: 8px; }
.skeleton-row { display: flex; gap: 12px; align-items: center; min-height: 58px; padding: 8px 12px; }
.skeleton-thumb { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto; }
.skeleton-row .skeleton-line { height: 12px; border-radius: 8px; flex: 1; }
.skeleton-meta { width: 100px; height: 10px; border-radius: 8px; }
@keyframes skeletonShimmer { to { background-position: -220% 0; } }

/* Upload queue */
.upload-overlay { width: min(390px, calc(100vw - 32px)); max-width: none; max-height: min(62vh, 520px); overflow-y: auto; padding: 2px; }
.upload-item {
  padding: 11px 12px 10px; color: #fff; border: 0; border-radius: 13px;
  background: rgba(15,23,42,.94); backdrop-filter: blur(12px); box-shadow: var(--shadow-float);
}
.upload-row { display: flex; align-items: center; gap: 10px; }
.upload-file-icon {
  width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden;
  padding: 2px; border-radius: 9px; background: rgba(var(--sky-rgb), .22); color: #bae6fd; font-size: 8px; font-weight: 800;
}
.upload-copy { min-width: 0; flex: 1; }
.upload-item .upload-name { margin: 0; color: #fff; font-size: 12px; }
.upload-meta { color: #cbd5e1; font-size: 10px; margin-top: 3px; }
.upload-action {
  min-width: 30px; height: 30px; padding: 0 7px; border: 0; border-radius: 8px;
  background: rgba(255,255,255,.1); color: #fff; font-size: 12px; cursor: pointer;
}
.upload-action:hover { background: rgba(255,255,255,.2); }
.upload-item .upload-bar { margin-top: 9px; height: 4px; }
.upload-item.success .upload-fill { background: var(--green); }
.upload-item.error .upload-fill { background: var(--red); }
.upload-item.cancelled { opacity: .72; }

/* Modal refinements */
.modal-overlay { background: rgba(15,23,42,.42); backdrop-filter: blur(5px); }
.modal { border-radius: 18px; box-shadow: var(--shadow-float); }
.modal-description { margin: -7px 0 18px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.field-hint { display: block; margin-top: 6px; color: var(--text-muted); font-size: 11px; }
.modal input:focus { box-shadow: 0 0 0 3px rgba(var(--sky-rgb), .12); }
.modal-btn { min-height: 40px; border-radius: 9px; }
.modal-btn:disabled { opacity: .55; cursor: not-allowed; }
.confirm-dialog { text-align: center; }
.confirm-dialog p { color: var(--text-secondary); font-size: 13px; line-height: 1.55; }
.confirm-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 18px; font-size: 26px; font-weight: 800; }
.confirm-icon.warning { color: var(--amber); background: rgba(245,158,11,.13); }
.share-dialog { text-align: center; padding: 10px; }
.share-options { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; text-align: left; margin-bottom: 14px; }
.share-actions { justify-content: center; position: static; margin: 0; padding: 0; border: 0; }
.share-link-result { display: flex; gap: 7px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--bg-elevated); }
.share-list { max-height: 430px; overflow-y: auto; }
.share-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border-light); }
.share-row-info { flex: 1; min-width: 0; }
.share-row-path { color: var(--text); font-size: 12px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-row-meta { color: var(--text-muted); font-size: 11px; margin-top: 3px; }
.share-row-actions { display: flex; gap: 6px; }
.share-row-actions .modal-btn { min-height: 34px; padding: 5px 10px; font-size: 11px; }

/* Mobile-only layers (hidden on desktop) */
.mobile-nav, .quick-create-sheet, .app-scrim { display: none; }

/* Better toast contrast */
.toast { color: #fff; border-color: transparent; }
.toast .toast-close { color: #cbd5e1; min-width: 30px; min-height: 30px; }

@media (max-width: 1024px) {
  .grid-view { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
}

@media (max-width: 768px) {
  :root { --mobile-nav-height: 72px; }
  #app { height: 100dvh; }
  .topbar { height: 58px; padding: calc(7px + env(safe-area-inset-top, 0px)) 10px 7px; gap: 7px; }
  .hamburger { width: 40px; height: 40px; align-items: center; justify-content: center; flex: 0 0 auto; }
  .topbar-brand { width: 36px; padding: 0; justify-content: center; }
  .topbar-brand span { display: none; }
  .topbar-search { flex: 1; max-width: none; min-width: 0; }
  .topbar-search input { height: 40px; font-size: 16px; padding: 8px 10px 8px 34px; }
  .topbar-actions { margin-left: 0; }
  .topbar-action-secondary { display: none; }
  .user-menu-btn { width: 40px; height: 40px; padding: 4px; justify-content: center; }
  .user-menu-btn span { display: none; }
  .user-avatar { width: 32px; height: 32px; }
  .user-dropdown { position: fixed; top: calc(58px + env(safe-area-inset-top, 0px)); right: 10px; width: min(280px, calc(100vw - 20px)); }

  .sidebar {
    z-index: 360; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); margin-left: -340px;
    padding-top: env(safe-area-inset-top, 0px); border-radius: 0 18px 18px 0;
    box-shadow: var(--shadow-float); border-left: 0;
  }
  .sidebar.open::after { display: none; }
  .sidebar-resizer { display: none; }
  .sidebar-header { min-height: 58px; }
  .sidebar-close { min-width: 40px; min-height: 40px; }
  .nav-item, .tree-item { min-height: 42px; }

  .app-scrim {
    position: fixed; inset: 0; z-index: 340; width: 100%; height: 100%; border: 0;
    background: rgba(15,23,42,.46); backdrop-filter: blur(3px); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .app-scrim.show { display: block; opacity: 1; pointer-events: auto; }

  .main-container { padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px)); }
  .pathbar { min-height: 42px; padding: 0 10px; }
  #back-btn { width: 34px; height: 34px; padding: 0 !important; justify-content: center; font-size: 0 !important; }
  #back-btn svg { width: 18px; height: 18px; }
  .breadcrumb { font-size: 12px; min-height: 40px; padding: 8px 2px; }
  .category-tabs { padding: 6px 10px 2px; gap: 6px; scrollbar-width: none; }
  .category-tabs::-webkit-scrollbar { display: none; }
  .cat-tab { min-height: 38px; padding: 7px 12px; border-radius: 10px; }
  .cat-tab.active { border-bottom-width: 1px; }

  .toolbar { min-height: 46px; padding: 5px 10px; }
  #toolbar > .upload-dropdown, #toolbar > .toolbar-btn { display: none; }
  .toolbar-right { width: 100%; margin: 0; justify-content: flex-end; }
  .toolbar-right #fs-btn { display: none; }
  .sort-select { min-height: 38px; font-size: 13px; flex: 0 1 140px; }
  #sort-order-btn { min-width: 40px; min-height: 40px; }

  .file-area { padding: 0; }
  .grid-view { grid-template-columns: repeat(auto-fill, minmax(142px, 1fr)); gap: 10px; padding: 10px 10px 28px; }
  .grid-action-btn { opacity: 1; transform: none; width: 36px; height: 36px; }
  .grid-item:hover { transform: none; box-shadow: var(--shadow); }
  .list-view { padding: 3px 6px 24px; }
  .list-header { display: none; }
  .list-item { min-height: 58px; padding: 8px 8px; margin: 0 2px; }
  .list-item .col-size { width: auto; max-width: 86px; }
  .list-item .col-actions { opacity: 1; width: 38px; }
  .list-item .action-btn { width: 36px; height: 36px; }
  .list-item:active, .grid-item:active { transform: scale(.985); }

  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 370;
    left: 0; right: 0; bottom: 0; height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--bg-card) 94%, transparent); border-top: 1px solid var(--border);
    backdrop-filter: blur(18px); box-shadow: 0 -8px 24px rgba(15,23,42,.08);
  }
  .mobile-nav > button {
    min-width: 0; min-height: 52px; border: 0; background: transparent; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border-radius: 10px; font-size: 10px; font-weight: 650; cursor: pointer;
  }
  .mobile-nav > button:active { background: var(--bg-hover); color: var(--sky); }
  .mobile-nav svg { width: 21px; height: 21px; }
  .mobile-nav .mobile-add { position: relative; overflow: visible; }
  .mobile-nav .mobile-add > span {
    position: absolute; top: -20px; width: 52px; height: 52px; display: grid; place-items: center;
    border-radius: 17px; background: var(--sky); color: #fff; border: 5px solid var(--bg-card);
    box-shadow: 0 9px 22px rgba(var(--sky-rgb), .34);
  }
  .mobile-nav .mobile-add svg { width: 23px; height: 23px; }
  body.selection-mode .mobile-nav { display: none; }

  .quick-create-sheet {
    display: block; position: fixed; z-index: 365; left: 8px; right: 8px;
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
    padding: 8px 16px 18px; border: 1px solid var(--border); border-radius: 22px;
    background: var(--bg-card); box-shadow: var(--shadow-float);
    transform: translateY(calc(100% + 110px)); opacity: 0; pointer-events: none;
    transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .18s ease;
  }
  .quick-create-sheet.show { transform: none; opacity: 1; pointer-events: auto; }
  .sheet-handle { width: 38px; height: 4px; margin: 0 auto 12px; border-radius: 4px; background: var(--border); }
  .sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .sheet-eyebrow { display: block; color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .6px; }
  .sheet-header h2 { margin-top: 2px; font-size: 16px; }
  .sheet-close { width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--bg-hover); color: var(--text); font-size: 24px; }
  .quick-create-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
  .quick-create-grid button { min-width: 0; min-height: 94px; padding: 10px 6px; border: 1px solid var(--border-light); border-radius: 14px; background: var(--bg-elevated); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 11px; font-weight: 650; }
  .quick-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--sky); background: rgba(var(--sky-rgb), .13); }
  .quick-icon svg { width: 20px; height: 20px; }

  .selection-bar.show {
    position: fixed; z-index: 375; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    margin: 0; min-height: 62px; padding: 8px 10px; border-radius: 17px; box-shadow: var(--shadow-float);
    overflow-x: auto; flex-wrap: nowrap;
  }
  .selection-bar .sel-count { min-width: 72px; }
  .selection-bar .sel-btn { min-height: 42px; padding: 7px 11px; white-space: nowrap; }

  .context-menu.show {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px; position: fixed;
    z-index: 366; left: 8px !important; right: 8px; top: auto !important;
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
    max-height: 58dvh; overflow-y: auto; padding: 10px; border-radius: 20px;
    animation: mobileSheetIn .2s ease both;
  }
  .context-item { min-height: 48px; border-radius: 11px; }
  .context-divider { display: none; }
  @keyframes mobileSheetIn { from { transform: translateY(20px); opacity: 0; } }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none !important; width: 100%; max-height: min(88dvh, 720px); margin: 0;
    padding: 24px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 0 0; border-bottom: 0;
    transform: translateY(35px); transition: transform .24s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
  }
  .modal-overlay.show .modal { transform: translateY(0); }
  .modal-actions { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom, 0px)); margin-left: -18px; margin-right: -18px; margin-bottom: calc(-20px - env(safe-area-inset-bottom, 0px)); padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg-card); border-top: 1px solid var(--border-light); z-index: 2; }
  .modal input, .modal select, .modal textarea { font-size: 16px !important; min-height: 46px; }
  .modal-btn { min-height: 46px; }
  .share-dialog { padding: 0; }
  .share-options { grid-template-columns: 1fr; }
  .share-actions { position: sticky; margin: 12px -18px calc(-20px - env(safe-area-inset-bottom, 0px)); padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border-light); }
  .share-link-result { align-items: stretch; flex-direction: column; }
  .share-link-result .modal-btn { width: 100%; }
  .share-row { align-items: stretch; flex-direction: column; }
  .share-row-actions { width: 100%; }
  .share-row-actions .modal-btn { flex: 1; min-height: 42px; }

  .toast-container { top: calc(66px + env(safe-area-inset-top, 0px)); right: 10px; left: 10px; }
  .toast { width: 100%; max-width: none; min-width: 0; }
  .upload-overlay { left: 10px; right: 10px; bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 10px); width: auto; max-height: 42dvh; }
  .empty-state { padding-bottom: 100px; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 22px; border-radius: 20px; }
  .login-logo h1 { font-size: 22px; }
  .topbar { gap: 5px; }
  .topbar-brand { display: none; }
  .topbar-search input { padding-left: 33px; }
  .grid-view { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 9px; }
  .grid-item .grid-thumb, body.thumb-sm .grid-thumb, body.thumb-md .grid-thumb, body.thumb-lg .grid-thumb { aspect-ratio: 1 / 1; }
  .grid-item .grid-info { padding: 9px 10px 10px; }
  .grid-item .grid-name { font-size: 12px; }
  .grid-item .grid-meta { flex-direction: row; font-size: 9px; }
  .grid-action-btn { top: 6px; right: 6px; }
  .list-item .col-size { display: none; }
  .cat-tab { font-size: 11px; padding: 7px 11px; }
  .cat-tab svg { width: 15px; height: 15px; }
  .toolbar-right > span { display: none; }
  .sort-select { flex: 1; }
  .empty-actions { width: min(100%, 300px); flex-direction: column; }
  .empty-primary, .empty-secondary { width: 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .quick-create-grid button { min-height: 88px; }
  .context-menu.show { grid-template-columns: 1fr 1fr; }
  .audio-wrapper { width: calc(100vw - 20px); }
  .media-toolbar { max-width: calc(100vw - 20px); overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 360px) {
  .grid-view { gap: 7px; padding: 7px; }
  .grid-item .grid-name { font-size: 11px; }
  .grid-type { display: none; }
  .mobile-nav > button { font-size: 9px; }
  .selection-bar .sel-count { min-width: 60px; }
}

@media (hover: none) {
  .grid-action-btn { opacity: 1; transform: none; }
  .grid-item:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ==================================================
   Interface refresh - desktop and mobile
   ================================================== */

:root {
  --bg: #f6f8fc;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-hover: #eaf6fd;
  --bg-input: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #dbe3ee;
  --border-light: #edf1f7;
  --scrollbar: #cbd5e1;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius-sm: 9px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 5px 18px rgba(15, 23, 42, .05);
  --shadow-lg: 0 18px 45px rgba(15, 23, 42, .12);
  --shadow-soft: 0 14px 40px rgba(15, 23, 42, .07);
  --shadow-float: 0 24px 64px rgba(15, 23, 42, .18);
}

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  background: var(--bg);
  color: var(--text);
  letter-spacing: -.006em;
}

/* Login */
#login-page {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 28px;
  background:
    radial-gradient(circle at 8% 12%, rgba(var(--sky-rgb), .17), transparent 28%),
    radial-gradient(circle at 92% 88%, rgba(var(--sky-rgb), .11), transparent 30%),
    linear-gradient(145deg, var(--bg), color-mix(in srgb, var(--bg) 82%, var(--sky) 18%));
}
#login-page::before,
#login-page::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(var(--sky-rgb), .14);
  border-radius: 72px;
  transform: rotate(24deg);
}
#login-page::before { top: -170px; right: -80px; }
#login-page::after { bottom: -185px; left: -70px; transform: rotate(-18deg); }
.login-card {
  width: min(100%, 430px);
  max-width: 430px;
  padding: 42px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 28px;
  background: color-mix(in srgb, var(--bg-card) 94%, transparent);
  box-shadow: 0 26px 80px rgba(15, 23, 42, .14);
  backdrop-filter: blur(22px);
}
.login-logo { flex-direction: column; gap: 13px; margin-bottom: 10px; }
.login-logo svg {
  width: 54px;
  height: 54px;
  padding: 14px;
  border: 1px solid rgba(var(--sky-rgb), .18);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(var(--sky-rgb), .16), rgba(var(--sky-rgb), .06));
  filter: none;
}
.login-logo h1 { font-size: clamp(24px, 3vw, 28px); letter-spacing: -.035em; }
.login-subtitle { margin-bottom: 30px; font-size: 13.5px; }
.login-card label { margin-bottom: 8px; color: var(--text-secondary); font-weight: 650; }
.login-card input {
  min-height: 48px;
  border-color: var(--border);
  border-radius: 12px;
  background: var(--bg-input);
}
.login-card input:hover { border-color: color-mix(in srgb, var(--sky) 42%, var(--border)); }
.login-card input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(var(--sky-rgb), .12);
}
.login-btn {
  min-height: 49px;
  margin-top: 10px;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(var(--sky-rgb), .24);
}

/* Application shell */
.topbar {
  height: 68px;
  gap: 14px;
  padding: 10px 24px;
  border-bottom-color: var(--border-light);
  background: color-mix(in srgb, var(--bg-card) 91%, transparent);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .03);
}
.topbar-brand { min-width: 180px; gap: 10px; font-size: 16px; letter-spacing: -.025em; }
.topbar-brand svg {
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 11px;
  background: rgba(var(--sky-rgb), .12);
}
.topbar-search { max-width: 560px; }
.topbar-search input {
  height: 44px;
  padding-left: 42px;
  border-color: transparent;
  border-radius: 13px;
  background: var(--bg-elevated);
}
.topbar-search input:hover { border-color: var(--border); background: var(--bg-input); }
.topbar-search input:focus { background: var(--bg-input); box-shadow: 0 0 0 4px rgba(var(--sky-rgb), .11); }
.topbar-search svg { left: 14px; width: 18px; height: 18px; }
.topbar-actions { gap: 6px; }
.topbar-btn {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 11px;
}
.topbar-btn:hover { border-color: var(--border); background: var(--bg-card); box-shadow: var(--shadow); }
.user-menu-btn { min-height: 42px; padding: 5px 8px 5px 6px; border: 1px solid transparent; border-radius: 12px; }
.user-menu-btn:hover { border-color: var(--border); background: var(--bg-card); box-shadow: var(--shadow); }
.user-avatar { width: 32px; height: 32px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); }
.user-dropdown,
.context-menu,
.upload-menu {
  border-color: var(--border) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow-lg) !important;
}

.main-container { background: var(--bg); }
.sidebar {
  width: 272px;
  border-right-color: var(--border-light);
  background: linear-gradient(180deg, var(--bg-card), color-mix(in srgb, var(--bg-card) 90%, var(--bg) 10%));
  box-shadow: none;
}
.sidebar-header { min-height: 62px; padding: 15px 18px; background: transparent; }
.sidebar-logo {
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 11px;
  background: rgba(var(--sky-rgb), .12);
  filter: none;
}
.sidebar-title { font-size: 15px; }
.sidebar-nav { gap: 5px; padding: 13px 12px 8px; }
.nav-item { min-height: 43px; padding: 9px 12px; border-radius: 11px; font-weight: 600; }
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active {
  background: rgba(var(--sky-rgb), .12);
  box-shadow: none;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 20px;
  border-radius: 0 4px 4px 0;
  background: var(--sky);
}
.sidebar-divider { margin: 7px 16px; background: var(--border-light); }
.sidebar-label { padding: 7px 18px 5px; color: var(--text-muted); letter-spacing: .11em; }
.tree-item { min-height: 38px; border-radius: 9px; }
.sidebar-quota { margin-top: auto; padding: 14px 18px 17px; }
.sidebar-quota .quota-bar { height: 6px; border-radius: 99px; }
.sidebar-quota .quota-fill { border-radius: 99px; }
.sidebar-resizer { width: 3px; }

.content { background: var(--bg); }
.pathbar {
  min-height: 47px;
  padding: 0 24px;
  border-bottom: 0;
  background: var(--bg-card);
}
.breadcrumb { min-height: 47px; padding: 9px 0; }
.breadcrumb .current { font-weight: 700; }
.category-tabs {
  gap: 7px;
  padding: 8px 24px 9px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
}
.cat-tab {
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 650;
}
.cat-tab:hover { border-color: var(--border); background: var(--bg-elevated); }
.cat-tab.active {
  border: 1px solid rgba(var(--sky-rgb), .18);
  background: rgba(var(--sky-rgb), .11);
  color: var(--sky);
  box-shadow: none;
}
.toolbar {
  min-height: 58px;
  padding: 9px 24px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
}
.toolbar-btn,
.sort-select { min-height: 39px; border-radius: 10px; font-weight: 600; }
.toolbar-btn { padding: 7px 13px; }
.toolbar-btn:hover { border-color: color-mix(in srgb, var(--sky) 36%, var(--border)); }
.toolbar-btn-primary { box-shadow: 0 8px 18px rgba(var(--sky-rgb), .18); }
.sort-select { padding: 6px 32px 6px 11px; }

/* Files */
.file-area { padding: 20px 24px 32px; background: var(--bg); }
.grid-view {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 17px;
  padding: 0;
}
.grid-item,
body.thumb-sm .grid-item,
body.thumb-md .grid-item,
body.thumb-lg .grid-item {
  border-color: var(--border-light);
  border-radius: 17px;
  box-shadow: var(--shadow);
}
.grid-item:hover {
  border-color: rgba(var(--sky-rgb), .48);
  box-shadow: 0 16px 38px rgba(15, 23, 42, .11);
  transform: translateY(-3px);
}
.grid-item:focus-visible { border-color: var(--sky); }
.grid-item .grid-thumb,
body.thumb-sm .grid-thumb,
body.thumb-md .grid-thumb,
body.thumb-lg .grid-thumb {
  aspect-ratio: 16 / 11;
  background:
    radial-gradient(circle at 30% 20%, rgba(var(--sky-rgb), .13), transparent 44%),
    var(--bg-elevated);
}
.grid-item .grid-thumb svg.folder-icon { width: 54px; height: 54px; filter: drop-shadow(0 8px 14px rgba(var(--sky-rgb), .14)); }
.grid-item .grid-info { padding: 13px 14px 14px; }
.grid-item .grid-name { font-size: 13.5px; font-weight: 700; }
.grid-item .grid-meta { margin-top: 7px; }
.grid-type { padding: 3px 7px; border-radius: 6px; background: var(--bg-elevated); }
.grid-action-btn { top: 9px; right: 9px; border-radius: 11px; }

.list-view {
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
}
.list-header { min-height: 44px; margin: 0; padding: 8px 16px; background: var(--bg-elevated); }
.list-item { min-height: 58px; margin: 0; padding: 9px 16px; border-radius: 0; }
.list-item .list-thumb { width: 38px; height: 38px; border-radius: 10px; }
.list-item .col-name { font-size: 13.5px; font-weight: 600; }
.list-item:last-child { border-bottom: 0; }

.empty-state { min-height: calc(100% - 8px); }
.empty-visual { box-shadow: inset 0 0 0 8px rgba(var(--sky-rgb), .035); }
.empty-primary,
.empty-secondary { min-height: 44px; border-radius: 11px; }
.empty-primary { box-shadow: 0 9px 20px rgba(var(--sky-rgb), .20); }

.modal { border: 1px solid var(--border); }
.modal input,
.modal select,
.modal textarea { border-radius: 11px; }
.modal-btn { border-radius: 10px; font-weight: 700; }

/* Tablet */
@media (max-width: 1100px) {
  .topbar-brand { min-width: auto; }
  .sidebar { width: 248px; }
  .grid-view { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* Mobile */
@media (max-width: 768px) {
  :root { --mobile-nav-height: 76px; }
  .topbar {
    height: calc(62px + env(safe-area-inset-top, 0px));
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
    gap: 7px;
  }
  .hamburger { width: 44px; height: 44px; border: 1px solid var(--border-light); background: var(--bg-card); }
  .topbar-brand { min-width: 40px; width: 40px; }
  .topbar-brand svg { width: 36px; height: 36px; }
  .topbar-search input { height: 42px; border: 1px solid var(--border-light); border-radius: 12px; }
  .user-menu-btn { width: 44px; height: 44px; border-color: var(--border-light); background: var(--bg-card); }
  .user-avatar { width: 32px; height: 32px; }
  .user-dropdown { top: calc(62px + env(safe-area-inset-top, 0px)); }

  .sidebar { width: min(88vw, 330px); margin-left: -350px; border-radius: 0 22px 22px 0; }
  .sidebar-header { min-height: 64px; }

  .pathbar { min-height: 42px; padding: 0 12px; }
  .breadcrumb { min-height: 42px; }
  .category-tabs { gap: 6px; padding: 7px 10px 8px; }
  .cat-tab { min-height: 44px; padding: 8px 13px; border-color: var(--border-light); background: var(--bg-card); }
  .cat-tab.active { border-color: rgba(var(--sky-rgb), .22); }

  .toolbar { min-height: 50px; padding: 6px 10px; }
  .sort-select, #sort-order-btn { min-height: 44px; }
  .file-area { padding: 11px 10px 28px; }
  .grid-view { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid-item,
  body.thumb-sm .grid-item,
  body.thumb-md .grid-item,
  body.thumb-lg .grid-item { border-radius: 15px; box-shadow: 0 2px 12px rgba(15, 23, 42, .06); }
  .grid-item .grid-thumb,
  body.thumb-sm .grid-thumb,
  body.thumb-md .grid-thumb,
  body.thumb-lg .grid-thumb { aspect-ratio: 1 / .82; }
  .grid-item .grid-info { padding: 10px 11px 11px; }
  .grid-item .grid-name { font-size: 12.5px; }
  .grid-item .grid-meta { margin-top: 5px; }
  .grid-action-btn { width: 44px; height: 44px; }

  .list-view { border: 0; border-radius: 13px; }
  .list-item { min-height: 62px; padding: 9px 10px; }
  .list-item .list-thumb { width: 40px; height: 40px; }

  .mobile-nav {
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 7px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top-color: var(--border-light);
    background: color-mix(in srgb, var(--bg-card) 96%, transparent);
    box-shadow: 0 -10px 30px rgba(15, 23, 42, .09);
  }
  .mobile-nav > button { min-height: 56px; font-weight: 700; }
  .mobile-nav .mobile-add > span { top: -21px; width: 54px; height: 54px; border-radius: 18px; }
  .quick-create-sheet { left: 10px; right: 10px; border-radius: 24px; }
  .quick-create-grid button { min-height: 98px; }

  .modal { border-radius: 24px 24px 0 0; }
}

@media (max-width: 480px) {
  #login-page { padding: 16px; }
  .login-card { padding: 32px 22px; border-radius: 24px; }
  .login-logo svg { width: 50px; height: 50px; }
  .topbar-brand { display: none; }
  .topbar-search input { padding-left: 37px; }
  .grid-view { gap: 9px; }
  .grid-item .grid-thumb,
  body.thumb-sm .grid-thumb,
  body.thumb-md .grid-thumb,
  body.thumb-lg .grid-thumb { aspect-ratio: 1 / .9; }
  .grid-item .grid-meta { font-size: 9.5px; }
  .grid-type { padding: 2px 5px; }
  .cat-tab { font-size: 11px; }
}

@media (max-width: 360px) {
  .topbar { padding-left: 7px; padding-right: 7px; }
  .hamburger, .user-menu-btn { width: 40px; }
  .file-area { padding-left: 7px; padding-right: 7px; }
  .grid-view { gap: 7px; }
  .grid-item .grid-info { padding: 9px; }
}
