html {
  scrollbar-gutter: stable;
  overflow-y: scroll;
}

:root {
  --primary: #3b82f6;
  --ph: #2563eb;
  --bgc: #ffffff;
  --tx: #1e293b;
  --cb: rgba(255, 255, 255, 0.65);
  --cd: rgba(0, 0, 0, 0.08);
  --tb: rgba(59, 130, 246, 0.15);
  --sp: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bgc);
  color: var(--tx);
  margin: 0;
  padding: 15px 10px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-layer {
  content: "";
  position: fixed;
  top: -5%;
  left: -5%;
  width: 110vw;
  height: calc(var(--app-height, 100vh) * 1.1);
  pointer-events: none;
  z-index: -3;
  background-image: var(--user-bg-url);
  background-size: cover;
  background-position: center;
  filter: blur(20px) brightness(1.05) saturate(110%);
  opacity: var(--bg-op, 0);
  transition: opacity 0.4s ease;
}

button, input, .card, .folder-card, .file-card, .modal-content, .nav-tab, .upload-box {
  transition: all 0.3s var(--sp);
  will-change: transform;
}

.container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

body.modal-open .container {
  pointer-events: none;
}

.card, .folder-card, .file-card, .modal-content {
  background: var(--cb);
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  border: 1px solid var(--cd);
  margin-bottom: 14px;
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--cd);
  padding-bottom: 10px;
  flex-wrap: wrap;
  gap: 5px;
}

.nav-tabs {
  display: flex;
  position: relative;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px;
  border-radius: 12px;
  overflow-x: auto;
  white-space: nowrap;
  z-index: 1;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  background: var(--primary);
  border-radius: 10px;
  transition: transform 0.4s var(--sp), width 0.4s var(--sp);
  z-index: -1;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.35);
}

.nav-tab {
  padding: 8px 16px;
  border-radius: 10px;
  color: var(--tx);
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  border: none;
  font-size: 13px;
}

.nav-tab.active {
  color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--primary);
  color: #fff !important;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.btn:hover {
  background: var(--ph);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.btn:active {
  transform: scale(0.96);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-outline {
  background: transparent;
  color: var(--tx) !important;
  border: 1px solid var(--cd);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.btn-outline:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-danger {
  background: #ef4444;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-warn {
  background: #f59e0b;
}

.btn-warn:hover {
  background: #d97706;
}

.btn-success {
  background: #10b981;
}

.btn-success:hover {
  background: #059669;
}

input, select {
  padding: 12px;
  border: 1px solid var(--cd);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.03);
  color: var(--tx);
  font-size: 14px;
  width: 100%;
  outline: 0;
  margin-bottom: 5px;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.folder-card, .file-card {
  cursor: pointer;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.folder-card:hover, .file-card:hover {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--primary);
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.15);
}

.file-preview {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 45px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.file-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-name {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  color: gray;
  font-size: 11px;
}

.progress-container {
  width: 100%;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  height: 12px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px inset var(--cd);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 10px;
  transition: width 0.2s;
}

.upload-box {
  border: 2px dashed var(--cd);
  padding: 30px 10px;
  text-align: center;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
  position: relative;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.upload-box:hover {
  border-color: var(--primary);
  background: var(--tb);
  transform: scale(1.01);
}

.upload-box input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(16px) brightness(1.15) saturate(120%);
  -webkit-backdrop-filter: blur(16px) brightness(1.15) saturate(120%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  margin: 0;
  scrollbar-gutter: stable;
}

.flex-row {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.flex-1 {
  flex: 1;
  text-align: center;
  justify-content: center;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

@keyframes dash {
  0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: var(--cd);
  border-radius: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}
