@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a1a;
  --bg-card: #14142b;
  --surface: rgba(20, 20, 50, 0.7);
  --border: rgba(255,255,255,0.06);
  --text: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #5a5a78;
  --accent: #7c5cfc;
  --accent-glow: rgba(124, 92, 252, 0.3);
  --accent2: #4ecdc4;
  --danger: #ff5e7a;
  --success: #4ecdc4;
  --radius: 16px;
  --radius-sm: 10px;
}

html, body {
  height: 100dvh;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124, 92, 252, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 50% 120%, rgba(78, 205, 196, 0.08), transparent),
    var(--bg);
}

#app { height: 100%; display: flex; flex-direction: column; min-height: 0; }

.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.screen.hidden { display: none; }

/* ── Login ── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(124,92,252,0.12) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(78,205,196,0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(124,92,252,0.05) 0%, transparent 70%);
  animation: bgPulse 6s ease-in-out infinite alternate;
}
@keyframes bgPulse {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.05); }
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 32px 36px;
  width: min(360px, 88vw);
  text-align: center;
  animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04) inset;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-avatar {
  font-size: 56px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 12px rgba(124,92,252,0.4));
}
.login-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #e8e8f0 0%, #b8b8d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 6px 0 28px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  margin-bottom: 14px;
  transition: border-color .25s, box-shadow .25s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-icon { font-size: 18px; margin-right: 8px; flex-shrink: 0; }
.input-wrap input {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  color: var(--text);
  font-size: 16px;
  outline: none;
  font-family: inherit;
}
.input-wrap input::placeholder { color: var(--text-muted); }

#login-form button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #9178ff 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s, box-shadow .25s;
  box-shadow: 0 4px 20px rgba(124,92,252,0.35);
}
#login-form button:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(124,92,252,0.25);
}
#login-form button:disabled { opacity: 0.5; pointer-events: none; }

#login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  padding: 12px 12px;
  gap: 8px;
  background: rgba(10,10,26,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.nav-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, border-color .2s;
  font-family: inherit;
}
.nav-btn:active { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); }
.nav-btn.hidden { display: none; }

.top-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.top-title #page-title {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-count {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.top-actions { display: flex; gap: 6px; }

/* ── Search ── */
.search-bar {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  background: rgba(10,10,26,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.search-bar.hidden { display: none; }
.search-bar input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  transition: border-color .25s;
}
.search-bar input:focus { border-color: var(--accent); }

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  background: rgba(10,10,26,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb .crumb {
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .2s;
  font-weight: 500;
}
.breadcrumb .crumb:active { background: rgba(255,255,255,0.08); }
.breadcrumb .crumb.home { font-size: 16px; padding: 4px 8px; }
.breadcrumb .crumb.current {
  color: var(--text);
  font-weight: 600;
  pointer-events: none;
}
.breadcrumb .sep { color: var(--text-muted); margin: 0 2px; }

/* ── Content ── */
.content-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.file-list { padding: 4px 0 40px; }

.file-row {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, transform .1s;
  gap: 12px;
  position: relative;
}
.file-row:active {
  background: rgba(255,255,255,0.04);
  transform: scale(0.985);
}

.file-icon-wrap {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  font-size: 24px;
  flex-shrink: 0;
  position: relative;
}
.file-icon-wrap.folder {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(251, 191, 36, 0.05));
}
.file-icon-wrap.image {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(236, 72, 153, 0.05));
}
.file-icon-wrap.video {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.05));
}
.file-icon-wrap.audio {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.2), rgba(52, 211, 153, 0.05));
}
.file-icon-wrap.archive {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.2), rgba(251, 146, 60, 0.05));
}
.file-icon-wrap.code {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(56, 189, 248, 0.05));
}
.file-icon-wrap.doc {
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.2), rgba(148, 163, 184, 0.05));
}
.file-icon-wrap.exe {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.05));
}

.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.file-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  display: flex; gap: 8px; align-items: center;
}

.file-actions { flex-shrink: 0; }
.dl-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(124,92,252,0.15);
  border: none;
  border-radius: 10px;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.dl-btn:active { background: rgba(124,92,252,0.3); transform: scale(0.9); }

/* ── States ── */
.loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  padding: 60px 0;
  color: var(--text-secondary);
}
.loading.hidden { display: none; }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state, .error-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  padding: 60px 0;
  color: var(--text-secondary);
  font-size: 14px;
}
.empty-state.hidden, .error-state.hidden { display: none; }
.empty-icon, .error-icon { font-size: 48px; }
.error-state { color: var(--danger); }
.error-state #error-text { color: var(--text-secondary); }

.retry-btn {
  margin-top: 8px;
  padding: 10px 24px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}
.retry-btn:active { background: rgba(255,255,255,0.12); }

@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
}
