:root {
  --bg: #0b0d10;
  --bg-soft: #14181d;
  --bg-elev: #1a1f26;
  --border: #262d36;
  --border-strong: #36404c;
  --text: #e6edf3;
  --text-muted: #8b97a8;
  --primary: #5b8cff;
  --primary-hover: #7aa1ff;
  --primary-soft: rgba(91, 140, 255, 0.12);
  --danger: #f97373;
  --danger-soft: rgba(249, 115, 115, 0.12);
  --success: #5fd599;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
  --radius: 14px;
  --radius-sm: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 800px at 80% -20%, rgba(91, 140, 255, 0.10), transparent 60%),
              radial-gradient(900px 600px at -10% 110%, rgba(95, 213, 153, 0.06), transparent 70%),
              var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s, transform 0.05s;
}
button:active { transform: translateY(1px); }
button.primary {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
}
button.primary:hover { background: var(--primary-hover); }
button.ghost {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
button.ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-soft); }
button.danger-ghost {
  padding: 6px 10px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
button.danger-ghost:hover { color: var(--danger); background: var(--danger-soft); }
button.icon-btn {
  padding: 6px 10px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
button.icon-btn:hover { color: var(--text); background: var(--bg-soft); }

input[type="text"], input[type="password"], input[type="search"] {
  font: inherit;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="search"]:focus {
  border-color: var(--primary);
}

.muted { color: var(--text-muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; margin: 0; }

/* App */
.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
}
.brand-large h1 { font-size: 28px; }
.brand-large .brand-mark { width: 40px; height: 40px; font-size: 20px; border-radius: 11px; }

/* Dropzone */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: scale(1.005);
}
.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.dropzone-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(91, 140, 255, 0.15);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 22px;
}
.dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dropzone-text strong { font-size: 16px; }

/* Upload progress */
.upload-progress {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.upload-row .upload-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.upload-row .upload-bar {
  flex: 0 0 120px;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.upload-row .upload-bar-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.2s;
}
.upload-row .upload-status {
  font-size: 12px;
  color: var(--text-muted);
  width: 64px;
  text-align: right;
}
.upload-row.error { border-color: var(--danger); }
.upload-row.error .upload-status { color: var(--danger); }
.upload-row.done .upload-bar-fill { background: var(--success); }

/* Files */
.files { margin-top: 36px; }
.files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.files-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.files-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.files-meta input[type="search"] {
  padding: 6px 12px;
  font-size: 13px;
  width: 180px;
}

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

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}
.file-row:hover { border-color: var(--border-strong); background: var(--bg-elev); }

.file-info { min-width: 0; }
.file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.file-name a { color: inherit; text-decoration: none; }
.file-name a:hover { color: var(--primary); }
.file-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.file-meta code {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

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

.empty {
  text-align: center;
  padding: 32px 0;
}

/* ============== Auth screens ============== */
.auth-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 24px;
  overflow: hidden;
}
.auth-bg {
  position: absolute;
  inset: -20% -10%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 20% 10%, rgba(91, 140, 255, 0.22), transparent 60%),
    radial-gradient(50% 50% at 80% 90%, rgba(95, 213, 153, 0.10), transparent 70%),
    radial-gradient(40% 30% at 50% 50%, rgba(160, 120, 255, 0.06), transparent 70%);
  filter: blur(20px);
  animation: auth-drift 28s ease-in-out infinite alternate;
}
@keyframes auth-drift {
  0%   { transform: translate3d(0, 0, 0); }
  50%  { transform: translate3d(-2%, 1%, 0); }
  100% { transform: translate3d(1%, -1%, 0); }
}
.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.auth-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}
.auth-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, #8aa8ff 100%);
  color: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  box-shadow:
    0 12px 32px rgba(91, 140, 255, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  position: relative;
}
.auth-mark::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(91,140,255,0.4), transparent 60%);
  z-index: -1;
  filter: blur(12px);
}
.auth-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.auth-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 320px;
}

.auth-card {
  background: rgba(20, 24, 29, 0.72);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: block;
}
.field-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Inputs with leading icon (and optional trailing action) */
.input-wrap {
  position: relative;
  display: block;
}
.input-wrap input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.input-wrap:has(.input-action) input { padding-right: 40px; }
.input-wrap input::placeholder { color: var(--text-muted); opacity: 0.55; }
.input-wrap input:hover { border-color: var(--border-strong); }
.input-wrap input:focus {
  border-color: var(--primary);
  background: var(--bg-soft);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}
.input-wrap input[readonly] {
  background: rgba(255,255,255,0.02);
  color: var(--text-muted);
  cursor: default;
}
.input-wrap input[readonly]:focus {
  border-color: var(--border);
  box-shadow: none;
}
.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.9;
}
.input-action {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border-radius: 8px;
}
.input-action:hover { color: var(--text); background: var(--bg-soft); }
.input-action svg { display: block; }

/* Primary button — full-width with arrow + loading state */
.primary-block {
  position: relative;
  width: 100%;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(91, 140, 255, 0.32), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s, opacity 0.15s;
  margin-top: 4px;
}
.primary-block:hover {
  background: var(--primary-hover);
  box-shadow: 0 10px 28px rgba(91, 140, 255, 0.44), inset 0 1px 0 rgba(255,255,255,0.22);
}
.primary-block .btn-arrow { transition: transform 0.15s; }
.primary-block:hover .btn-arrow { transform: translateX(2px); }
.primary-block:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: var(--primary);
}
.primary-block.loading .btn-label,
.primary-block.loading .btn-arrow {
  visibility: hidden;
}
.primary-block.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-error {
  margin: 4px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(249, 115, 115, 0.3);
  border-radius: 8px;
}
.auth-info {
  margin: 4px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--success);
  background: rgba(95, 213, 153, 0.08);
  border: 1px solid rgba(95, 213, 153, 0.25);
  border-radius: 8px;
}
.auth-footer {
  margin-top: 4px;
  text-align: center;
}

button.link {
  padding: 4px 8px;
  color: var(--text-muted);
  font-size: 13px;
  background: transparent;
  border-radius: 6px;
}
button.link:hover { color: var(--primary); }
button.link.link-sm {
  font-size: 12px;
  padding: 2px 0;
  font-weight: 500;
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; }
  .auth-header { margin-bottom: 24px; }
  .auth-title { font-size: 22px; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 100;
  animation: toast-in 0.18s ease-out;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

#signed-in-as {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg-soft);
  border-radius: 999px;
  border: 1px solid var(--border);
}

@media (max-width: 540px) {
  .files-meta input[type="search"] { width: 120px; }
  .file-meta { gap: 6px; }
  .topbar h1 { font-size: 18px; }
  #signed-in-as { display: none; }
}
