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

:root {
  --bg-0: #0b0c10;
  --bg-1: #14161c;
  --surface-1: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-header: rgba(18, 19, 24, 0.72);
  --hairline: rgba(255, 255, 255, 0.09);
  --text-main: #f2f3f5;
  --text-muted: #9a9ba5;
  --text-faint: #64656d;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.16);
  --warning: #ff9f0a;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at 15% -10%, #1b1e28 0%, var(--bg-0) 55%), var(--bg-0);
  background-attachment: fixed;
}

/* ---------- loading splash ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-0);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-mark {
  position: relative;
  width: 30px;
  height: 30px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-mark 1.4s ease-in-out infinite;
}

.loader-ring {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--hairline);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

@keyframes pulse-mark {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.88); }
}

/* ---------- app shell ---------- */
.app-shell {
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: 60px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.app-shell.ready {
  opacity: 1;
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--surface-header);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-bottom: 1px solid var(--hairline);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.brand svg {
  color: var(--accent);
  flex-shrink: 0;
}

.add-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.add-btn:hover {
  opacity: 0.88;
}
.add-btn:active {
  transform: scale(0.94);
}

.quota-track {
  height: 3px;
  background: var(--surface-1);
}

.quota-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 4px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

.search-field svg {
  color: var(--text-faint);
  flex-shrink: 0;
}

.search-field input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text-main);
  width: 100%;
  font-family: inherit;
}

.search-field input::placeholder {
  color: var(--text-faint);
}

.segmented {
  display: flex;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.segment {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.segment.active {
  background: var(--accent);
  color: #fff;
}

.segment-count {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.75;
}

/* ---------- content ---------- */
.content {
  padding: 14px 18px 0;
}

.dropzone {
  border: 1.5px dashed var(--hairline);
  border-radius: var(--radius-lg);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:active {
  background: var(--surface-1);
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dropzone-inner svg {
  color: var(--accent);
  margin-bottom: 4px;
}

.drop-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
}

.drop-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.upload-item-body {
  flex: 1;
  min-width: 0;
}

.upload-item-name {
  font-size: 12.5px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.upload-progress-track {
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.15s ease;
}

.upload-item.done .upload-progress-fill { background: #32d74b; }
.upload-item.error .upload-progress-fill { background: var(--danger); }

.upload-status-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}
.upload-item.done .upload-status-icon { display: flex; color: #32d74b; }
.upload-item.error .upload-status-icon { display: flex; color: var(--danger); }

/* ---------- file list ---------- */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 0 10px;
}

.empty-state {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 36px 0;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}

.file-row:hover {
  background: var(--surface-1);
}

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.file-name-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

.file-meta .dot-sep {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.file-meta .expiring.soon {
  color: var(--danger);
  font-weight: 600;
}

.file-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- delete confirmation ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(3px);
}

.overlay.hidden {
  display: none;
}

.alert-box {
  width: 100%;
  max-width: 380px;
  padding: 24px 22px calc(18px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  background: var(--bg-1);
  border: 1px solid var(--hairline);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
}

.alert-icon {
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.alert-box h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.alert-box p {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-main);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.11);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(40, 42, 48, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid var(--hairline);
  backdrop-filter: blur(14px);
  z-index: 60;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

/* ---------- wider screens ---------- */
@media (min-width: 640px) {
  .app-shell {
    max-width: 720px;
    padding-top: 20px;
  }

  .topbar {
    border-radius: var(--radius-lg);
    border: 1px solid var(--hairline);
    top: 20px;
  }

  .toolbar {
    flex-direction: row;
    align-items: center;
  }

  .search-field {
    flex: 1;
  }

  .segmented {
    width: 220px;
    flex-shrink: 0;
  }

  .overlay {
    align-items: center;
  }

  .alert-box {
    border-radius: 16px;
    padding-bottom: 18px;
  }

  .confirm-actions {
    flex-direction: row-reverse;
  }

  .btn {
    flex: 1;
  }
}
