:root {
  color-scheme: light dark;

  --bg: #f2f2f7;
  --grouped-bg: #ffffff;
  --label: #000000;
  --secondary-label: rgba(60, 60, 67, 0.6);
  --tertiary-label: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.29);
  --fill: rgba(120, 120, 128, 0.12);
  --accent: #007aff;
  --accent-tint: rgba(0, 122, 255, 0.12);
  --green: #34c759;
  --red: #ff3b30;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --grouped-bg: #1c1c1e;
    --label: #ffffff;
    --secondary-label: rgba(235, 235, 245, 0.6);
    --tertiary-label: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.65);
    --fill: rgba(120, 120, 128, 0.24);
    --accent: #0a84ff;
    --accent-tint: rgba(10, 132, 255, 0.16);
    --green: #30d158;
    --red: #ff453a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

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

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

h1 { margin: 0; }

.subtitle {
  color: var(--secondary-label);
  font-size: 0.86em;
  margin: 2px 0 0;
}

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: rise 0.4s cubic-bezier(0.25, 0.9, 0.35, 1);
}

.login-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.app-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--accent-tint);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.app-icon svg { width: 28px; height: 28px; }

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-card .subtitle {
  margin-bottom: 24px;
}

.login-card input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  background: var(--fill);
  color: var(--label);
  font-size: 17px;
  margin-bottom: 12px;
  text-align: center;
  transition: box-shadow 0.15s ease;
}

.login-card input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

button {
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.login-card button {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 17px;
  font-weight: 600;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.login-card button:active { transform: scale(0.97); opacity: 0.85; }

.error {
  color: var(--red);
  font-size: 0.85em;
  margin: 14px 0 0;
}

/* ---------- App shell ---------- */

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px calc(48px + env(safe-area-inset-bottom));
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  animation: rise 0.35s cubic-bezier(0.25, 0.9, 0.35, 1);
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  padding: 4px 0;
  margin-top: 4px;
}

.text-btn:active { opacity: 0.5; }

/* ---------- Choose Photos button ---------- */

.pick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 28px;
  transition: transform 0.12s ease, opacity 0.12s ease;
  animation: rise 0.4s cubic-bezier(0.25, 0.9, 0.35, 1);
}

.pick-btn:active { transform: scale(0.98); opacity: 0.9; }
.pick-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------- Grouped list ---------- */

.section-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary-label);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0 0 8px 16px;
}

.grouped-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--grouped-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 52px;
  border-bottom: 0.5px solid var(--separator);
  animation: rise 0.3s cubic-bezier(0.25, 0.9, 0.35, 1);
}

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

.upload-item .icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-item .icon svg { width: 100%; height: 100%; }
.icon-done { color: var(--green); }
.icon-error { color: var(--red); }
.icon-waiting { color: var(--tertiary-label); }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--fill);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

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

.upload-item .name {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item .status-line {
  font-size: 13px;
  color: var(--secondary-label);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item .status-line.is-error { color: var(--red); }

.progress-track {
  width: 100%;
  height: 3px;
  background: var(--fill);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.2s ease;
}

.retry-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  padding: 4px 0 4px 8px;
}

.retry-btn:active { opacity: 0.5; }

.empty-hint {
  text-align: center;
  color: var(--tertiary-label);
  font-size: 15px;
  margin-top: 40px;
}

.empty-hint.hidden { display: none; }

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

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