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

:root {
  --bg-deep: #0a0e1a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --text-muted: rgba(232, 236, 244, 0.5);
  --accent: #6c9eff;
  --accent-glow: rgba(108, 158, 255, 0.4);
  --accent-2: #a78bfa;
  --success: #34d399;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --glass: blur(20px) saturate(1.4);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg-deep);
  overflow-x: hidden;
}

#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(108, 158, 255, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 20%, rgba(167, 139, 250, 0.1) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 50% 80%, rgba(52, 211, 153, 0.06) 0%, transparent 70%);
  animation: auroraShift 20s ease-in-out infinite alternate;
}

@keyframes auroraShift {
  0% { opacity: 0.6; transform: scale(1) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.05) rotate(1deg); }
  100% { opacity: 0.7; transform: scale(0.98) rotate(-1deg); }
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  animation: fadeIn 0.8s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(108, 158, 255, 0.12), rgba(167, 139, 250, 0.08));
  border: 1px solid rgba(108, 158, 255, 0.2);
  box-shadow: 0 4px 24px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  animation: float 4s ease-in-out infinite;
}

.logo-mark-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.logo-eyebrow {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(108, 158, 255, 0.55);
}

.logo-wordmark {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.logo-ping {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-forge {
  color: var(--text);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Logo mark animations (inline SVG) */
.logo-mark-svg .ping-ring {
  transform-origin: 28px 26px;
  opacity: 0;
  animation: pingPulse 3s ease-out infinite;
}

.logo-mark-svg .ping-ring-1 { animation-delay: 0s; }
.logo-mark-svg .ping-ring-2 { animation-delay: 1s; }
.logo-mark-svg .ping-ring-3 { animation-delay: 2s; }

@keyframes pingPulse {
  0% { opacity: 0.7; transform: scale(0.6); }
  70% { opacity: 0; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(1.3); }
}

.logo-mark-svg .ping-core {
  animation: coreGlow 2s ease-in-out infinite;
}

@keyframes coreGlow {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(52, 211, 153, 0.6)); }
  50% { filter: drop-shadow(0 0 8px rgba(52, 211, 153, 0.9)); }
}

.logo-mark-svg .spark {
  transform-origin: center;
  animation: sparkFlicker 2.5s ease-in-out infinite;
}

.logo-mark-svg .spark-1 { animation-delay: 0s; }
.logo-mark-svg .spark-2 { animation-delay: 0.8s; }
.logo-mark-svg .spark-3 { animation-delay: 1.6s; }

@keyframes sparkFlicker {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

.logo-mark-svg .logo-cloud {
  animation: cloudDrift 5s ease-in-out infinite;
}

@keyframes cloudDrift {
  0%, 100% { transform: translate(8px, 0); }
  50% { transform: translate(8px, -2px); }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-stats {
  display: flex;
  gap: 12px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 6px 6px 14px;
  backdrop-filter: var(--glass);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 500;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.78rem;
}

.stat-pill {
  background: var(--bg-card);
  backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 18px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-value {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
}

.crumb {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.crumb:hover { color: var(--text); background: var(--bg-card); }
.crumb.active { color: var(--accent); font-weight: 500; }

.crumb:not(:last-child)::after {
  content: '›';
  margin-left: 8px;
  color: var(--text-muted);
  opacity: 0.4;
}

/* Upload Zone */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 20px;
  overflow: hidden;
  background: var(--bg-card);
  backdrop-filter: var(--glass);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(108, 158, 255, 0.06);
  transform: scale(1.01);
}

.upload-zone.dragover .upload-glow {
  opacity: 1;
}

.upload-glow {
  position: absolute;
  inset: -2px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  opacity: 0;
  z-index: -1;
  filter: blur(20px);
  transition: opacity 0.4s;
}

.upload-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  color: var(--accent);
}

.upload-icon svg { width: 100%; height: 100%; }

.upload-icon .upload-chevron-1 {
  animation: chevronRise 2s ease-in-out infinite;
}

.upload-icon .upload-chevron-2 {
  animation: chevronRise 2s ease-in-out infinite 0.2s;
}

@keyframes chevronRise {
  0%, 100% { opacity: 0.4; transform: translateY(6px); }
  50% { opacity: 1; transform: translateY(-4px); }
}

.upload-title {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f7fe8);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  backdrop-filter: var(--glass);
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn-danger:hover { background: rgba(248, 113, 113, 0.25); }

/* Files Grid */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  min-height: 120px;
}

.file-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  animation: cardIn 0.4s ease backwards;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.file-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(108, 158, 255, 0.05));
  opacity: 0;
  transition: opacity 0.3s;
}

.file-card:hover {
  transform: translateY(-4px);
  border-color: rgba(108, 158, 255, 0.3);
  box-shadow: var(--shadow), 0 0 30px rgba(108, 158, 255, 0.08);
}

.file-card:hover::before { opacity: 1; }

.file-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 1.4rem;
  position: relative;
}

.file-icon.folder {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.1));
  color: #fbbf24;
}

.file-icon.image {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.2), rgba(16, 185, 129, 0.1));
  color: var(--success);
}

.file-icon.video {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(139, 92, 246, 0.1));
  color: var(--accent-2);
}

.file-icon.doc {
  background: linear-gradient(135deg, rgba(108, 158, 255, 0.2), rgba(59, 130, 246, 0.1));
  color: var(--accent);
}

.file-icon.other {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.file-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.file-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.file-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.2s;
}

.file-card:hover .file-actions {
  opacity: 1;
  transform: translateY(0);
}

.action-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.action-btn:hover { background: rgba(0, 0, 0, 0.6); }
.action-btn.delete:hover { background: rgba(248, 113, 113, 0.4); color: var(--danger); }
.action-btn.share:hover { background: rgba(108, 158, 255, 0.4); color: var(--accent); }

.shared-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 0.65rem;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-cloud {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
  opacity: 0.5;
}

/* Loading */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

.loading-cloud {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}

.loading-cloud span {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

.loading-cloud span:nth-child(2) { animation-delay: 0.2s; }
.loading-cloud span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: rgba(20, 24, 40, 0.9);
  backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.85rem;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: var(--shadow);
}

.toast.success { border-color: rgba(52, 211, 153, 0.3); }
.toast.error { border-color: rgba(248, 113, 113, 0.3); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  position: relative;
  background: rgba(20, 24, 40, 0.95);
  backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 400px;
  animation: modalIn 0.3s ease;
  box-shadow: var(--shadow);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.modal-content input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.modal-content input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Preview */
.preview-content {
  max-width: 80vw;
  max-height: 85vh;
  overflow: auto;
  padding: 20px;
}

.preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  z-index: 1;
}

.preview-content img,
.preview-content video {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 8px;
}

.preview-content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 16px;
  border-radius: 8px;
  overflow: auto;
  font-size: 0.8rem;
  max-height: 60vh;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Upload Progress */
.upload-progress {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: rgba(20, 24, 40, 0.95);
  backdrop-filter: var(--glass);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: none;
  align-items: center;
  gap: 16px;
}

.upload-progress.active { display: flex; flex-wrap: wrap; }

.progress-bar {
  flex: 1;
  min-width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  transition: width 0.3s ease;
}

#progressText {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 280px;
  text-align: right;
}

@media (max-width: 600px) {
  #progressText { min-width: 100%; text-align: left; font-size: 0.72rem; }
}

/* Auth */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 16, 0.7);
  backdrop-filter: blur(12px);
}

.auth-overlay.open { display: flex; }

.auth-card {
  background: rgba(20, 24, 40, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow);
  animation: modalIn 0.4s ease;
}

.auth-logo { margin-bottom: 12px; }
.auth-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }

.telegram-login {
  display: flex;
  justify-content: center;
  min-height: 48px;
}

.tg-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  border: none;
  border-radius: 10px;
  background: #2AABEE;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  box-shadow: 0 4px 16px rgba(42, 171, 238, 0.35);
}

.tg-login-btn:hover {
  background: #229ED9;
  transform: translateY(-1px);
}

.auth-steps {
  margin-top: 20px;
  text-align: center;
}

.auth-waiting {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  animation: pulse 1.5s ease infinite;
}

.telegram-login {
  display: flex;
  justify-content: center;
  min-height: 48px;
}

.auth-fallback {
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.auth-fallback a {
  color: var(--accent);
  text-decoration: none;
}

.auth-fallback a:hover { text-decoration: underline; }

.auth-setup {
  text-align: left;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
}

.auth-setup code {
  background: rgba(108, 158, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--accent);
}

.auth-setup ol { margin: 10px 0 0 18px; }
.auth-setup li { margin-bottom: 6px; }
.auth-setup a { color: var(--accent); }

/* Share modal */
.share-file-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  word-break: break-all;
}

.share-link-box {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.share-link-box input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
}

.share-expiry {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Share page */
.share-page .share-container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.share-card {
  background: rgba(20, 24, 40, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  backdrop-filter: var(--glass);
  box-shadow: var(--shadow);
  animation: fadeIn 0.6s ease;
}

.share-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 28px;
}

.share-file-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.share-card h2 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  word-break: break-all;
}

.share-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.share-download {
  width: 100%;
  justify-content: center;
  margin-bottom: 10px;
  text-decoration: none;
}

.share-tg { width: 100%; justify-content: center; }

/* Responsive */
@media (max-width: 600px) {
  .app { padding: 20px 16px 48px; }
  .upload-zone { padding: 28px 16px; }
  .files-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .header { flex-direction: column; align-items: flex-start; }
  .header-right { width: 100%; justify-content: space-between; }
  .share-link-box { flex-direction: column; }
}