:root {
  --bg: #f1f5f9;
  --bg-gradient: radial-gradient(circle at top, #dbeafe 0%, #f8fafc 55%);
  --surface: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.96);
  --card-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --surface-2: #e2e8f0;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-text: #b91c1c;
  --success: #059669;
  --success-text: #047857;
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-gradient: radial-gradient(circle at top, #172554 0%, #0b1120 55%);
  --surface: #111827;
  --card-bg: rgba(17, 24, 39, 0.92);
  --card-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --surface-2: #1f2937;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-text: #fca5a5;
  --success: #10b981;
  --success-text: #6ee7b7;
}

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

html, body {
  overscroll-behavior-y: contain;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  padding: calc(16px + env(safe-area-inset-top)) 14px calc(36px + env(safe-area-inset-bottom));
  transition: background 0.2s ease, color 0.2s ease;
}

.app-shell {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-switch {
  position: relative;
  width: 58px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: background 0.28s ease, border-color 0.28s ease;
  flex-shrink: 0;
}

.theme-switch:hover {
  border-color: var(--primary);
}

.theme-switch-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  transform: translateX(0);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s ease;
}

[data-theme="dark"] .theme-switch {
  background: #1e293b;
}

[data-theme="dark"] .theme-switch-thumb {
  transform: translateX(28px);
  background: #0f172a;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: transparent;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand h1 {
  font-family: "Myriad Pro", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  font-style: italic;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.user-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--card-shadow);
}

.card + .card {
  margin-top: 18px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h2, .card-header h3 {
  font-size: 1.05rem;
}

.auth-card {
  max-width: 440px;
  margin: 16px auto 0;
  width: 100%;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg);
  padding: 5px;
  border-radius: 10px;
  margin-bottom: 18px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 9px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--surface-2);
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.88rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 13px;
  font-size: 0.96rem;
  outline: none;
}

.send-to-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.send-to-row label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.search-row {
  margin-bottom: 12px;
}

.transfer-badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.3);
  margin-left: 6px;
  vertical-align: middle;
}

input:focus {
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.82rem;
}

.btn-full {
  width: 100%;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.quick-code-form {
  display: flex;
  gap: 8px;
}

.quick-code-form input {
  text-transform: uppercase;
  letter-spacing: 1px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 34px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.dropzone-icon {
  font-size: 2.2rem;
}

.dropzone p {
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-progress {
  margin-top: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.upload-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.progress-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  transition: width 0.15s linear;
}

.upload-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.83rem;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
}

.file-check {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
}

.select-all-label input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.file-info {
  min-width: 200px;
  flex: 1;
}

.file-name {
  font-weight: 600;
  word-break: break-word;
}

.file-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 3px;
}

.file-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.empty-state, .muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.error-msg {
  color: var(--danger-text);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-top: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 360px;
  width: 100%;
}

.qr-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.qr-body img {
  border-radius: 10px;
  background: #fff;
  padding: 6px;
}

.code-pill {
  font-family: monospace;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
}

.copy-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.instant-share-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.instant-share-item {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.instant-share-qr {
  width: 140px;
  height: 140px;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  flex-shrink: 0;
}

.instant-share-details {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instant-share-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-menu-wrap {
  position: relative;
}

.user-menu-trigger {
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.user-menu-trigger:hover {
  border-color: var(--primary);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--surface-2);
}

.dropdown-danger {
  color: var(--danger-text);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.success-msg {
  color: var(--success-text);
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-top: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.stat-box strong {
  font-size: 1.25rem;
}

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

.select-input,
input[type="number"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 13px;
  font-size: 0.96rem;
  outline: none;
}

.sendto-wrap {
  position: relative;
  width: 100%;
}

.input-popover {
  margin-top: 6px;
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.45);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}

.input-popover.popover-success {
  color: var(--success-text);
  border-color: rgba(16, 185, 129, 0.45);
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  animation: toastIn 0.2s ease-out;
}

.toast.toast-success {
  border-left-color: var(--success);
}

.toast.toast-error {
  border-left-color: var(--danger);
}

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

.hidden {
  display: none !important;
}

/* Native-like proportional layout on mobile screens (Android APK / WebView) */
@media (max-width: 600px) {
  .app-shell {
    gap: 14px;
  }

  .topbar {
    gap: 10px;
  }

  .brand h1 {
    font-size: 1.3rem;
  }

  .subtitle {
    font-size: 0.78rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .auth-hint {
    display: none;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .dropzone {
    padding: 24px 14px;
  }

  .dropzone h2 {
    font-size: 1.05rem;
  }

  .file-item {
    padding: 12px;
  }

  .file-actions {
    width: 100%;
  }

  .file-actions .btn {
    flex: 1;
    text-align: center;
  }

  .quick-code-form {
    flex-direction: column;
  }

  .instant-share-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .instant-share-meta {
    justify-content: center;
  }
}
