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

:root {
  --bg: #09090b;
  --bg-card: #111113;
  --bg-elevated: #18181b;
  --bg-hover: #1c1c21;
  --bg-input: #0c0c0e;
  --border: #27272a;
  --border-subtle: #1e1e22;
  --border-focus: #6c5ce7;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-dim: #3f3f46;
  --accent: #6c5ce7;
  --accent-hover: #7c6ef7;
  --accent-dim: rgba(108, 92, 231, 0.12);
  --accent-glow: rgba(108, 92, 231, 0.08);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.1);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.08);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.1);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.screen { display: none; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ============ LOGIN SCREEN ============ */
.login-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.login-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 80px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  top: -40%;
  left: -30%;
  width: 160%;
  height: 160%;
  background: radial-gradient(ellipse at 30% 50%, rgba(108, 92, 231, 0.06) 0%, transparent 60%);
  pointer-events: none;
}

.login-left::after {
  content: '';
  position: absolute;
  bottom: -30%;
  right: -20%;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 70% 70%, rgba(59, 130, 246, 0.04) 0%, transparent 60%);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  position: relative;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.brand h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 420px;
  margin-bottom: 40px;
  position: relative;
}

.features {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

.feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.feature-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.feature-desc {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}

.login-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: linear-gradient(180deg, rgba(108, 92, 231, 0.02) 0%, transparent 50%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.login-card h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-grow { flex: 1; }

.port-field {
  width: 85px;
  flex-shrink: 0;
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input::placeholder {
  color: var(--text-dim);
}

.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 44px;
}

.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  border-radius: 4px;
  transition: color 0.15s;
}

.toggle-password:hover { color: var(--text-secondary); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
  margin-top: 4px;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-primary:hover {
  opacity: 0.92;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
}

.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.error-msg {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 13px;
  line-height: 1.4;
}

/* ============ BROWSER SCREEN ============ */
#browserScreen {
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-small {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.brand-icon-small {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.connection-info {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: var(--green-dim);
  border: 1px solid rgba(34, 197, 94, 0.15);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.btn-disconnect {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.12);
  border-radius: var(--radius-xs);
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-disconnect:hover {
  background: rgba(239, 68, 68, 0.15);
}

.browser-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
  overflow: hidden;
}

.browser-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  flex-wrap: wrap;
}

.breadcrumb {
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  font-weight: 500;
  white-space: nowrap;
}

.breadcrumb:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.breadcrumb.active {
  color: var(--text);
  background: var(--bg-elevated);
}

.breadcrumb-sep {
  color: var(--text-dim);
  font-size: 11px;
  user-select: none;
}

.toolbar-actions {
  display: flex;
  gap: 6px;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-action:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}

.btn-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-zip {
  background: var(--accent-dim);
  border-color: rgba(108, 92, 231, 0.2);
  color: var(--accent);
}

.btn-zip:hover:not(:disabled) {
  background: rgba(108, 92, 231, 0.18);
  color: var(--accent-hover);
}

/* ============ FILE LIST ============ */
.file-list-container {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.file-list-header {
  display: grid;
  grid-template-columns: 40px 1fr 100px 160px 80px;
  padding: 0 16px;
  height: 40px;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  flex-shrink: 0;
  background: var(--bg-card);
}

.col-check {
  display: flex;
  align-items: center;
  justify-content: center;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  border-radius: 3px;
}

.file-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.file-list::-webkit-scrollbar {
  width: 5px;
}

.file-list::-webkit-scrollbar-track {
  background: transparent;
}

.file-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.file-item {
  display: grid;
  grid-template-columns: 40px 1fr 100px 160px 80px;
  padding: 0 16px;
  height: 48px;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
  cursor: default;
}

.file-item:last-child {
  border-bottom: none;
}

.file-item:hover {
  background: var(--bg-hover);
}

.file-item.selected {
  background: var(--accent-glow);
}

.file-item.selected:hover {
  background: var(--accent-dim);
}

.file-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-icon.folder {
  background: var(--orange-dim);
  color: var(--orange);
}

.file-icon.file {
  background: var(--blue-dim);
  color: var(--blue);
}

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

.file-name-text.clickable {
  cursor: pointer;
  transition: color 0.15s;
}

.file-name-text.clickable:hover {
  color: var(--accent);
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.file-modified {
  font-size: 12px;
  color: var(--text-muted);
}

.file-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.btn-icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.btn-icon.folder-download {
  color: var(--accent);
  opacity: 0.6;
}

.btn-icon.folder-download:hover {
  background: var(--accent-dim);
  color: var(--accent);
  opacity: 1;
}

/* Empty & Loading states */
.empty-state,
.loading-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
}

.spinner circle {
  color: var(--accent);
}

/* Status bar */
.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: slideUp 0.25s ease;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.toast-spinner circle {
  color: var(--accent);
}

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

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 90%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: modalSlide 0.25s ease;
  overflow: hidden;
}

.modal-compact {
  max-width: 380px;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 0;
}

.modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-icon.success {
  background: var(--green-dim);
  color: var(--green);
}

.modal-header h3 {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-body {
  padding: 16px 24px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-elevated);
  border-radius: 20px;
}

.meta-item svg {
  color: var(--text-dim);
}

.modal-link-box {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.modal-link-box input {
  flex: 1;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  outline: none;
}

.btn-copy {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-copy:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-copy.copied {
  color: var(--green);
}

.modal-footer {
  padding: 0 24px 20px;
}

.modal-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

/* Preparing modal */
.preparing-content {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.preparing-spinner {
  margin-bottom: 4px;
}

.preparing-spinner .spinner circle {
  color: var(--accent);
}

.preparing-content h3 {
  font-size: 16px;
  font-weight: 600;
}

.preparing-content p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.preparing-hint {
  font-size: 12px !important;
  color: var(--text-dim) !important;
  margin-top: 4px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .login-container { flex-direction: column; }
  .login-left {
    padding: 40px 24px 24px;
    min-height: auto;
  }
  .login-right { padding: 0 24px 40px; }
  .features { display: none; }
  .tagline { margin-bottom: 20px; }

  .file-list-header,
  .file-item {
    grid-template-columns: 40px 1fr 80px 60px;
  }
  .col-modified,
  .file-modified {
    display: none;
  }
}

@media (max-width: 600px) {
  .browser-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .toolbar-actions {
    width: 100%;
    overflow-x: auto;
  }
  .topbar {
    padding: 0 16px;
  }
  .browser-content {
    padding: 12px 16px;
  }
  .file-list-header,
  .file-item {
    grid-template-columns: 36px 1fr 56px;
  }
  .col-size, .file-size,
  .col-modified, .file-modified {
    display: none;
  }
  .connection-info span:not(.status-dot) {
    display: none;
  }
  .brand-small span {
    display: none;
  }
}
