:root {
  color-scheme: light dark;
  --ground: #f2f2f7;
  --surface: #ffffff;
  --text: #000000;
  --muted: #6c6c70;
  --line: #d1d1d6;
  --faint: #b0b0b5;
  --fill: #e5e5ea;
  --accent: #0066cc;
  --button: #0066cc;
  --button-pressed: #0052a3;
  --danger: #d70015;
  --danger-wash: rgb(215 0 21 / 0.1);
  --edge: rgb(0 0 0 / 0.08);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #000000;
    --surface: #1c1c1e;
    --text: #ffffff;
    --muted: #98989f;
    --line: #38383a;
    --faint: #5a5a5f;
    --fill: #2c2c2e;
    --accent: #409cff;
    --button: #0071e3;
    --button-pressed: #0a84ff;
    --danger: #ff453a;
    --danger-wash: rgb(255 69 58 / 0.18);
    --edge: rgb(255 255 255 / 0.1);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 17px/22px -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

[hidden] { display: none !important; }

/* Screens: one at a time, each slides in when shown */
/* minmax(0, 1fr): a wide input must not stretch the column past the screen */
.screen { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; animation: enter 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.screen.center { min-height: 76vh; align-content: center; }
.screen.center > h1 { font-size: 22px; line-height: 28px; letter-spacing: 0; text-align: center; }
.screen.center > .lead { text-align: center; }
.screen.center > .spinner, .screen.center > .icon { justify-self: center; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }

h1 { margin: 0 4px; font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
h2 { margin: 8px 16px -6px; font-size: 13px; line-height: 18px; font-weight: 400; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
p { margin: 0; }
.lead { margin: 0 4px; font-size: 15px; line-height: 20px; color: var(--muted); text-wrap: pretty; }
.note { margin: 0 16px; font-size: 13px; line-height: 18px; color: var(--muted); text-wrap: pretty; }
.note a { color: var(--accent); overflow-wrap: anywhere; }
.error { margin: 0 16px; font-size: 15px; line-height: 20px; color: var(--danger); }
.detail { font-size: 15px; line-height: 20px; color: var(--muted); text-align: center; }

/* The tile above a screen title */
.mark {
  width: 48px; height: 48px; margin: 0 4px; border-radius: 11px;
  display: grid; place-items: center; background: var(--button); color: #fff;
}
.mark svg { width: 28px; height: 28px; }
.mark.danger { border-radius: 50%; background: var(--danger-wash); color: var(--danger); }

.group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.card, .fields { background: var(--surface); border-radius: var(--radius); }

/* Form fields: rows of one card with the label on the left, like a Settings group */
.field { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; border-radius: inherit; }
/* the hairline between rows starts at the text, as in iOS lists */
.field + .field { background: linear-gradient(var(--line), var(--line)) no-repeat 16px 0 / 100% 1px; border-top-left-radius: 0; border-top-right-radius: 0; }
.field:not(:last-child) { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.field span { flex: none; width: 84px; }
.field input, .search input {
  flex: 1; min-width: 0; border: 0; padding: 0; background: none; color: inherit;
  font: inherit; outline: none;
}
.field input::placeholder, .search input::placeholder { color: var(--muted); }
.field:focus-within, .search:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.field.tall { min-height: 52px; }
.field input.code { font-size: 22px; font-weight: 600; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }

/* A field with its button in the same row */
.search { display: flex; align-items: center; padding-left: 16px; }
.search input { min-height: 44px; }
.search .plain { font-size: 17px; font-weight: 600; }

/* Buttons */
button, a.primary { font: inherit; cursor: pointer; border: 0; -webkit-appearance: none; appearance: none; }

.primary, .secondary {
  display: flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 10px 20px; border-radius: var(--radius);
  font-weight: 600; text-decoration: none; text-align: center;
  transition: transform 0.12s, background-color 0.12s;
}
.primary { background: var(--button); color: #fff; }
.primary:active { background: var(--button-pressed); transform: scale(0.98); }
.secondary { background: var(--surface); color: var(--accent); }
.secondary:active { background: var(--fill); transform: scale(0.98); }
.plain { min-height: 44px; padding: 0 16px; background: none; color: var(--accent); font-size: 15px; justify-self: start; text-align: left; }
.plain.middle { justify-self: center; }
.plain:active { opacity: 0.5; }
.plain.danger { color: var(--danger); }
button:disabled { opacity: 0.45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The list of apps */
.rows { display: grid; overflow: hidden; }
.row {
  display: grid; grid-template-columns: 40px 1fr 8px; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 8px 16px; background: none; color: inherit; text-align: left;
}
.row + .row { background-image: linear-gradient(var(--line), var(--line)); background-repeat: no-repeat; background-size: 100% 1px; background-position: 68px 0; }
.row:active { background-color: var(--fill); }
.row b { display: block; font-weight: 400; }
.row small { display: block; font-size: 13px; line-height: 18px; color: var(--muted); }
.row::after {
  content: ""; width: 8px; height: 8px;
  border-right: 2px solid var(--faint); border-top: 2px solid var(--faint); transform: rotate(45deg);
}

.icon { display: block; width: 40px; height: 40px; border-radius: 22.5%; }
img.icon { object-fit: cover; outline: 1px solid var(--edge); outline-offset: -1px; }
span.icon { display: grid; place-items: center; color: #fff; font-size: 19px; font-weight: 700; }
.icon.big { width: 72px; height: 72px; }
.tint-0 { background: linear-gradient(hsl(212 78% 60%), hsl(212 78% 48%)); }
.tint-1 { background: linear-gradient(hsl(262 60% 64%), hsl(262 60% 52%)); }
.tint-2 { background: linear-gradient(hsl(344 70% 62%), hsl(344 70% 50%)); }
.tint-3 { background: linear-gradient(hsl(27 85% 58%), hsl(27 85% 47%)); }
.tint-4 { background: linear-gradient(hsl(146 50% 46%), hsl(146 50% 37%)); }
.tint-5 { background: linear-gradient(hsl(188 65% 44%), hsl(188 65% 35%)); }

.account { display: flex; align-items: center; padding-left: 16px; }
.who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .plain { font-size: 17px; }

/* The prepared app */
.app { display: grid; justify-items: center; gap: 6px; text-align: center; padding-top: 8px; }
.app img { border-radius: 22.5%; background: var(--surface); outline: 1px solid var(--edge); outline-offset: -1px; }
.app h1 { margin: 8px 0 0; font-size: 22px; line-height: 28px; letter-spacing: 0; }

/* Numbered steps and plain points inside a card */
.steps, .points { margin: 0; padding: 0 16px; list-style: none; font-size: 15px; line-height: 20px; counter-reset: step; }
.steps li, .points li { padding: 12px 0; text-wrap: pretty; }
.steps li + li, .points li + li { border-top: 1px solid var(--line); }
.steps li { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; }
.steps li::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center; width: 22px; height: 22px; margin-top: -1px; border-radius: 50%;
  background: var(--fill); font-size: 13px; font-weight: 700;
}

/* Progress of a long operation: figures above a bar, and the steps of a download */
.meter { display: grid; gap: 10px; padding: 14px 16px; }
.figures { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; line-height: 20px; font-variant-numeric: tabular-nums; }
.figures b { font-weight: 400; }
.figures span { color: var(--muted); }
.meter.big b { font-size: 28px; line-height: 34px; font-weight: 700; }
.meter p { font-size: 15px; line-height: 20px; color: var(--muted); text-wrap: pretty; }
progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: 3px; background: var(--fill); overflow: hidden; }
progress::-webkit-progress-bar { background: none; }
progress::-webkit-progress-value { background: var(--accent); transition: width 0.4s; }
progress::-moz-progress-bar { background: var(--accent); }

.phases { margin: 0; padding: 0 16px; list-style: none; }
.phases li { display: flex; align-items: center; gap: 12px; min-height: 44px; color: var(--muted); }
.phases li + li { border-top: 1px solid var(--line); }
.phases li::before { content: ""; flex: none; box-sizing: border-box; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--faint); }
.phases li.done::before {
  content: "\2713\FE0E"; display: grid; place-items: center; border: 0;
  background: var(--button); color: #fff; font-size: 13px; line-height: 1; font-weight: 700;
}
.phases li.now { color: var(--text); font-weight: 600; }
.phases li.now::before { border: 3px solid var(--fill); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }

.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--fill); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .spinner, .phases li.now::before { animation-duration: 3s; }
  .primary, .secondary { transition: none; }
}
