:root {
  color-scheme: light;
  --page-bg: #f5f5f7;
  --footer-bg: #f2f2f2;
  --text: rgba(0, 0, 0, .88);
  --text-secondary: rgba(0, 0, 0, .56);
  --divider: rgba(0, 0, 0, .15);
  --key: #007aff;
  --segment-track: rgba(0, 0, 0, .06);
  --segment-active: #fff;
  --segment-shadow: 0 1px 2px rgba(0, 0, 0, .16);
  --store-bg: #fbfbfd;
  --store-border: rgba(0, 0, 0, .18);
  --store-text: rgba(0, 0, 0, .82);
  --store-text-secondary: rgba(0, 0, 0, .52);
  --neu-raised: 2px 2px 5px rgba(0, 0, 0, .1), -2px -2px 5px #fff;
  --neu-raised-hover: 3px 3px 8px rgba(0, 0, 0, .15), -3px -3px 8px #fff;
  --neu-pressed: inset 1px 1px 3px rgba(0, 0, 0, .18), inset -1px -1px 3px #fff;
  --gutter: 25px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page-bg: #2e231b;
    --footer-bg: #3d3026;
    --text: rgba(255, 255, 255, .92);
    --text-secondary: rgba(255, 255, 255, .64);
    --divider: rgba(255, 255, 255, .1);
    --segment-track: rgba(255, 255, 255, .08);
    --segment-active: rgba(255, 255, 255, .16);
    --segment-shadow: none;
    --store-bg: #e8eaed;
    --store-border: transparent;
    --neu-raised: 2px 2px 6px rgba(0, 0, 0, .32), -1px -1px 4px rgba(255, 255, 255, .06);
    --neu-raised-hover: 3px 3px 9px rgba(0, 0, 0, .42), -2px -2px 6px rgba(255, 255, 255, .09);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #2e231b;
  --footer-bg: #3d3026;
  --text: rgba(255, 255, 255, .92);
  --text-secondary: rgba(255, 255, 255, .64);
  --divider: rgba(255, 255, 255, .1);
  --segment-track: rgba(255, 255, 255, .08);
  --segment-active: rgba(255, 255, 255, .16);
  --segment-shadow: none;
  --store-bg: #e8eaed;
  --store-border: transparent;
  --neu-raised: 2px 2px 6px rgba(0, 0, 0, .32), -1px -1px 4px rgba(255, 255, 255, .06);
  --neu-raised-hover: 3px 3px 9px rgba(0, 0, 0, .42), -2px -2px 6px rgba(255, 255, 255, .09);
}

@media (min-width: 1000px) {
  :root { --gutter: 40px; }
}

* { box-sizing: border-box; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font: 400 13px/1.3846 -apple-system, BlinkMacSystemFont, "Apple Color Emoji", "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main, .footer-inner {
  width: 100%;
  max-width: 1140px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main { flex-grow: 1; }

/* Header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding-block: 11px;
}

h1 {
  font-size: 26px;
  font-weight: 700;
  line-height: 34px;
  letter-spacing: -.5px;
}

/* Theme switch */
.theme-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 0;
  border-radius: 9px;
  background: var(--segment-track);
}

.theme-switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.theme-switch label {
  position: relative;
  cursor: pointer;
}

.theme-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-switch span {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  transition: background-color .14s ease-out, color .14s ease-out;
}

.theme-switch svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-switch label:hover span { color: var(--text); }

.theme-switch input:checked + span {
  background: var(--segment-active);
  box-shadow: var(--segment-shadow);
  color: var(--text);
}

.theme-switch input:focus-visible + span {
  outline: 2px solid var(--key);
  outline-offset: 1px;
}

/* Shelves */
.shelf { padding-top: 13px; padding-bottom: 32px; }
.page-header + .shelf { padding-top: 8px; }

@media (min-width: 1000px) {
  .page-header + .shelf { padding-top: 16px; }
}

h2 {
  margin-bottom: 13px;
  font-size: 17px;
  font-weight: 700;
  line-height: 22px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr));
  gap: 24px 20px;
  padding: 0;
  list-style: none;
}

/* App lockup */
.lockup {
  display: flex;
  align-items: center;
}

.lockup > img,
.app-icon {
  display: block;
  flex-shrink: 0;
  width: 85px;
  height: 85px;
  margin-inline-end: 16px;
}

.app-icon { border-radius: 22%; }

.app-icon img {
  display: block;
  width: 100%;
  height: 100%;
}

.app-icon:focus-visible {
  outline: 2px solid var(--key);
  outline-offset: 2px;
}

.metadata {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

h3, .subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h3 {
  font-size: 15px;
  font-weight: 400;
  line-height: 20px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 15px;
}

.store-buttons {
  display: flex;
  gap: 5px;
  margin-top: 7px;
}

/* Soft raised button in the page colour (neumorphism). */
.store-button {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding-inline: 5px 6px; /* 1px less each side, so the border keeps the button's size. */
  border: 1px solid var(--store-border);
  border-radius: 7px;
  background: var(--store-bg);
  box-shadow: var(--neu-raised);
  color: var(--store-text);
  text-decoration: none;
  transition: box-shadow .16s ease-out;
}

/* Both logos share one height, matching the two lines of text beside them. */
.store-button svg,
.store-button img {
  display: block;
  flex-shrink: 0;
  height: 14px;
}

.store-button svg { width: 11.4px; }
.store-button img { width: 12.7px; }

.store-button svg { fill: currentColor; }

.store-label {
  display: flex;
  flex-direction: column;
  padding-bottom: 1px; /* Optically centres the text, whose descenders sit low. */
  font-size: 8.5px;
  font-weight: 600;
  line-height: 9px;
  white-space: nowrap;
}

.store-label small {
  color: var(--store-text-secondary);
  font-size: 6px;
  font-weight: 500;
  line-height: 7px;
}

.store-button:hover { box-shadow: var(--neu-raised-hover); }
.store-button:active { box-shadow: var(--neu-pressed); }

.store-button:focus-visible {
  outline: 2px solid var(--key);
  outline-offset: 2px;
}

.icon-sprite { display: none; }

/* Keeps both store buttons on one line on small phones. */
@media (max-width: 400px) {
  :root { --gutter: 16px; }
  .lockup > img,
  .app-icon { width: 72px; height: 72px; margin-inline-end: 12px; }
}

/* Footer */
footer {
  flex-shrink: 0;
  border-top: .5px solid var(--divider);
  background: var(--footer-bg);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 14px;
}

.footer-inner { padding-block: 24px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
