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

:root {
  --theme-color-start: #667eea;
  --theme-color-end: #764ba2;
  --theme-surface-opacity: 0.95;
  --theme-surface-radius: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, var(--theme-color-start) 0%, var(--theme-color-end) 100%);
  min-height: 100vh;
  overflow: hidden;
}

/* Login Page Styles */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-box {
  background: rgba(255, 255, 255, var(--theme-surface-opacity));
  backdrop-filter: blur(20px);
  border-radius: var(--theme-surface-radius);
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  color: #667eea;
}

.login-box h2 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-weight: 600;
}

.form-group {
  margin-bottom: 20px;
}

.form-group input {
  width: 100%;
  padding: 15px 20px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s;
  background: white;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-box button {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--theme-color-start) 0%, var(--theme-color-end) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-box button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.error-message {
  color: #e74c3c;
  text-align: center;
  margin-top: 15px;
  font-size: 14px;
  min-height: 20px;
}

/* Checkbox styles */
.checkbox-group {
  margin-bottom: 15px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #666;
  font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

/* File Browser Styles */
.hidden {
  display: none !important;
}

.desktop {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.toolbar {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.toolbar-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.toolbar-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.path-display {
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 16px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.file-grid {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 25px;
  align-content: start;
}

.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
}

.file-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-4px);
  border-color: rgba(102, 126, 234, 0.5);
}

.file-item.selected {
  background: #667eea !important;
  border: 3px solid #fff !important;
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.8) !important;
  transform: translateY(-4px) scale(1.05) !important;
  z-index: 10 !important;
}

.file-item.selected .file-name,
.file-item.selected .file-info {
  color: #fff !important;
}

.file-item.dragging {
  opacity: 0.5;
}

.file-item.drag-over {
  background: rgba(102, 126, 234, 0.3);
  border-color: #667eea;
  transform: scale(1.05);
}

.file-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 48px;
}

.file-icon svg {
  width: 64px;
  height: 64px;
}

.file-name {
  color: white;
  font-size: 13px;
  text-align: center;
  word-break: break-word;
  line-height: 1.4;
  max-width: 100%;
}

.file-info {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  margin-top: 4px;
}

/* Icon colors */
.folder-icon {
  color: #ffd93d;
}

.file-icon-default {
  color: #6c757d;
}

.image-icon {
  color: #4ecdc4;
}

.video-icon {
  color: #ff6b6b;
}

.audio-icon {
  color: #a855f7;
}

.document-icon {
  color: #3b82f6;
}

.archive-icon {
  color: #f59e0b;
}

/* Scrollbar */
.file-grid::-webkit-scrollbar {
  width: 8px;
}

.file-grid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.file-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.file-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: white;
  font-size: 18px;
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: rgba(255, 255, 255, var(--theme-surface-opacity));
  backdrop-filter: blur(20px);
  border-radius: var(--theme-surface-radius);
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
  color: #333;
  font-size: 24px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 5px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.modal-body h3 {
  color: #333;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: #333;
  font-size: 14px;
}

.setting-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.modal-body button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--theme-color-start) 0%, var(--theme-color-end) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.modal-body button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

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

.modal-buttons button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn {
  background: linear-gradient(135deg, var(--theme-color-start) 0%, var(--theme-color-end) 100%);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
  filter: brightness(1.1);
}

.secondary-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.danger-btn {
  background: #e74c3c;
  color: white;
}

.danger-btn:hover {
  background: #c0392b;
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(231, 76, 60, 0.4);
}

#delete-message {
  color: #333;
  font-size: 16px;
  text-align: center;
  margin-bottom: 20px;
}

/* Drop zone styles */
.drop-zone {
  border: 2px dashed #667eea;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: rgba(102, 126, 234, 0.05);
  position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
  background: rgba(102, 126, 234, 0.1);
  border-color: #764ba2;
}

.drop-zone svg {
  color: #667eea;
  margin-bottom: 15px;
}

.drop-zone p {
  color: #666;
  font-size: 14px;
}

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

#folder-input {
  display: none;
}

.upload-picker-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.upload-picker-actions .secondary-btn {
  flex: 1;
}

/* Upload progress styles */
.upload-progress {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  width: 0%;
  transition: width 0.3s;
}

#upload-status {
  color: #666;
  font-size: 14px;
  text-align: center;
}

/* Context menu styles */
.context-menu {
  position: fixed;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  padding: 8px 0;
  min-width: 180px;
  z-index: 2000;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
  color: #333;
  font-size: 14px;
}

.context-menu-item:hover {
  background: rgba(102, 126, 234, 0.1);
}

.context-menu-item svg {
  color: #666;
}

.context-menu-item.danger {
  color: #e74c3c;
}

.context-menu-item.danger svg {
  color: #e74c3c;
}

.context-menu-item.danger:hover {
  background: rgba(231, 76, 60, 0.1);
}

.context-menu-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  margin: 8px 0;
}

/* Selection box styles */
.selection-box {
  position: absolute;
  border: 1px solid rgba(102, 126, 234, 0.8);
  background: rgba(102, 126, 234, 0.2);
  pointer-events: none;
  z-index: 100;
}

body.selection-active {
  user-select: none;
  cursor: crosshair;
}

.toast-notification {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -120%);
  background: rgba(24, 24, 35, 0.92);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  z-index: 3000;
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  pointer-events: none;
}

.toast-notification.show {
  transform: translate(-50%, 20px);
  opacity: 1;
}

.transfer-progress-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
}

.transfer-progress-window {
  width: min(440px, 92vw);
  border-radius: 10px;
  border: 1px solid #b9c6db;
  background: linear-gradient(180deg, #f5f8ff 0%, #ffffff 100%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  padding: 14px 16px;
}

.transfer-progress-title {
  font-size: 15px;
  font-weight: 600;
  color: #233047;
  margin-bottom: 10px;
}

.transfer-progress-status {
  font-size: 13px;
  color: #3f516f;
  margin-bottom: 10px;
}

.transfer-progress-bar {
  width: 100%;
  height: 16px;
  border-radius: 8px;
  background: #d8e0ec;
  overflow: hidden;
  border: 1px solid #c0ccdf;
}

.transfer-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #76a7ff 0%, #5f8de6 100%);
  transition: width 0.22s ease;
}

.transfer-progress-text {
  margin-top: 8px;
  font-size: 12px;
  color: #425270;
  text-align: right;
}

.upload-queue-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 24px));
  border-radius: 14px;
  border: 1px solid rgba(73, 92, 132, 0.35);
  background: linear-gradient(180deg, rgba(250, 252, 255, 0.98) 0%, rgba(241, 247, 255, 0.98) 100%);
  box-shadow: 0 18px 36px rgba(15, 24, 44, 0.26);
  padding: 12px 14px;
  z-index: 2600;
}

.upload-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

#upload-queue-title {
  font-size: 14px;
  font-weight: 700;
  color: #223356;
}

.upload-queue-cancel {
  border: 1px solid rgba(76, 97, 139, 0.35);
  background: #ffffff;
  color: #2d4069;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.upload-queue-status {
  font-size: 12px;
  color: #3f5278;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-queue-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(95, 120, 170, 0.3);
  background: #e4ebf7;
  overflow: hidden;
}

.upload-queue-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #5f97ff 0%, #72b5ff 100%);
  transition: width 0.2s ease;
}

.upload-queue-text {
  margin-top: 7px;
  text-align: right;
  font-size: 12px;
  color: #3f5278;
}

@media (max-width: 900px) {
  .toolbar {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .toolbar-left {
    gap: 10px;
  }

  .path-display {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    padding: 8px 12px;
  }

  .toolbar-right {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .toolbar-btn {
    justify-content: center;
    padding: 9px 8px;
    font-size: 12px;
  }

  .file-grid {
    padding: 16px;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  }

  .file-item {
    padding: 14px 8px;
    border-radius: 12px;
  }

  .file-icon {
    width: 62px;
    height: 62px;
    margin-bottom: 8px;
  }

  .file-icon svg {
    width: 52px;
    height: 52px;
  }

  .file-name {
    font-size: 12px;
  }

  .context-menu {
    min-width: min(280px, calc(100vw - 24px));
  }

  .context-menu-item {
    padding: 12px 14px;
  }
}

@media (max-width: 600px) {
  .toolbar-btn {
    flex-direction: column;
    gap: 4px;
    line-height: 1.2;
    min-height: 54px;
    font-size: 11px;
  }

  .file-grid {
    padding: 12px;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  }

  .file-item {
    padding: 12px 6px;
  }

  .file-icon {
    width: 56px;
    height: 56px;
  }

  .file-icon svg {
    width: 46px;
    height: 46px;
  }

  .file-info {
    font-size: 10px;
  }

  .upload-queue-panel {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

@media (hover: none) {
  .file-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: none;
    border-color: transparent;
  }
}

/* Mobile multi-select toolbar */
.mobile-multi-select-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mobile-multi-select-toolbar.hidden {
  display: none;
}

.mobile-toolbar-left {
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.mobile-toolbar-right {
  display: flex;
  gap: 8px;
}

.mobile-toolbar-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.mobile-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.mobile-toolbar-btn:active {
  background: rgba(255, 255, 255, 0.4);
}

.mobile-toolbar-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.12);
}

.mobile-toolbar-btn.exit-btn {
  background: rgba(255, 100, 100, 0.3);
}

.mobile-toolbar-btn.exit-btn:hover {
  background: rgba(255, 100, 100, 0.4);
}

.mobile-more-menu {
  position: fixed;
  top: 58px;
  right: 16px;
  z-index: 1001;
  background: rgba(30, 30, 48, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.mobile-more-menu.hidden {
  display: none;
}

.mobile-more-item {
  border: none;
  background: transparent;
  color: #fff;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.mobile-more-item:hover {
  background: rgba(255, 255, 255, 0.16);
}

.mobile-more-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#details-content {
  display: grid;
  gap: 10px;
}

.details-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 10px;
  font-size: 14px;
  line-height: 1.4;
}

.details-label {
  color: #666;
  font-weight: 600;
}

.details-value {
  color: #222;
  word-break: break-all;
}

.settings-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.settings-action-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--theme-color-start) 0%, var(--theme-color-end) 100%);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.settings-panel {
  margin: 8px 0 16px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
}

.settings-panel h4 {
  margin-bottom: 10px;
  color: #2a2a2a;
}

.theme-color-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.theme-color-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #333;
}

.theme-color-row input[type="color"] {
  width: 100%;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
}

body.theme-style-flat {
  --theme-surface-opacity: 1;
  --theme-surface-radius: 10px;
}

body.theme-style-flat .modal-content,
body.theme-style-flat .login-box {
  backdrop-filter: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

body.theme-style-contrast {
  --theme-surface-opacity: 1;
  --theme-surface-radius: 14px;
}

body.theme-style-contrast .toolbar {
  background: rgba(0, 0, 0, 0.35);
  border-bottom-color: rgba(255, 255, 255, 0.28);
}

body.theme-style-contrast .file-item {
  border-color: rgba(255, 255, 255, 0.38);
}

@media (min-width: 901px) {
  .mobile-multi-select-toolbar {
    display: none !important;
  }
}

@media (max-width: 900px) {
  .file-grid.mobile-multi-select-active {
    padding-top: 80px;
  }
}
