:root {
  color-scheme: light dark;
  /* The stuff app's palette, which is the documents app's, the journal's and
     the books app's: one family of apps on one domain, and this is its front
     door. */
  --bg: #f7f7fa;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8a8a93;
  --faint: #b6b6c0;
  --accent: #4c3fd6;
  --hairline: rgba(0, 0, 0, 0.1);
  --card-shadow: 0 1px 2px rgba(20, 20, 40, 0.06), 0 10px 30px -18px rgba(20, 20, 40, 0.4);
  --press: rgba(0, 0, 0, 0.04);

  --radius: 14px;
  --alarm: #c7372f;
  /* What the page pads for the notch, and how far down they start. The
     logged-out bar takes the notch itself and pushes the page below it. */
  --top-inset: env(safe-area-inset-top, 0px);
  --top-offset: 0px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #93939c;
    --faint: #55555e;
    --accent: #7c6ffb;
    --hairline: rgba(255, 255, 255, 0.12);
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 32px -18px rgba(0, 0, 0, 0.8);
    --press: rgba(255, 255, 255, 0.06);
    --alarm: #b3261e;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* Logged out: a bar across the top of everything, and the page moved down
   to make room rather than covered. */
.signedout {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(env(safe-area-inset-top, 0px) + 44px);
  padding: env(safe-area-inset-top, 0px) max(env(safe-area-inset-right, 0px), 16px) 0
           max(env(safe-area-inset-left, 0px), 16px);
  background: var(--alarm);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

/* One line: the bar's height is what the page is moved down by. */
.signedout span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signedout-in {
  flex: none;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  text-decoration: none;
}

.signedout-in:active {
  background: rgba(255, 255, 255, 0.16);
}

.signedout[hidden] {
  display: none;
}

body.is-signedout {
  --top-inset: 0px;
  --top-offset: calc(env(safe-area-inset-top, 0px) + 44px);
  padding-top: var(--top-offset);
}

/* One readable column, whatever the window. */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: max(var(--top-inset), 12px) 16px
           max(env(safe-area-inset-bottom, 0px), 24px);
}

.head {
  padding: 12px 4px 20px;
}

.title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* The apps, as one grouped list on a card: icon, name, and what it is for. */
.apps {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.apps a {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  padding: 10px 16px;
  color: inherit;
  text-decoration: none;
}

.apps a:active {
  background: var(--press);
}

@media (hover: hover) {
  .apps a:hover {
    background: var(--press);
  }
}

.apps a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius);
}

/* Hairlines start at the text, not the icon, as iOS lists draw them. */
.apps li {
  position: relative;
}

.apps li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 74px;
  right: 0;
  border-top: 1px solid var(--hairline);
}

.apps img {
  grid-row: 1 / 3;
  width: 44px;
  height: 44px;
  /* The icons are full bleed, as a phone expects; this is the phone's
     rounding, at this size. */
  border-radius: 10px;
  /* Some are white, and would otherwise run into the card. */
  box-shadow: 0 0 0 0.5px var(--hairline);
}

.name {
  align-self: end;
  font-size: 17px;
  font-weight: 600;
}

.what {
  align-self: start;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
}

/* The stuff app's footer, less its sync line. */
.foot {
  padding: 28px 4px 8px;
  text-align: center;
}

.account-line {
  min-height: 1.3em;
  font-size: 13px;
  color: var(--faint);
}

.account-line form {
  display: inline;
}

.text-link {
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
