:root {
  color-scheme: light dark;
  /* The journal's and the books app's palette, unchanged: these are all one
     family of apps on one domain and should not look like several. */
  --bg: #f7f7fa;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8a8a93;
  --faint: #b6b6c0;
  /* Indigo. The one saturated colour, spent on focus, the view you are on
     and folders -- the things worth the eye. */
  --accent: #4c3fd6;
  --on-accent: #ffffff;
  --miss: #b8412f;
  --hairline: rgba(0, 0, 0, 0.1);
  --chip-bg: #ffffff;
  --chip-shadow: 0 1px 4px 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);
  --tag-bg: rgba(0, 0, 0, 0.05);
  --press: rgba(0, 0, 0, 0.04);
  --good: #248a3d;
  --warn: #b25f00;

  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #93939c;
    --faint: #55555e;
    --accent: #7c6ffb;
    --on-accent: #ffffff;
    --miss: #ff7c66;
    --hairline: rgba(255, 255, 255, 0.12);
    --chip-bg: #2c2c2e;
    --chip-shadow: none;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 32px -18px rgba(0, 0, 0, 0.8);
    --tag-bg: rgba(255, 255, 255, 0.08);
    --press: rgba(255, 255, 255, 0.06);
    --good: #30d158;
    --warn: #ff9f0a;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

/* One readable column, whatever the window. A list stretched across a laptop
   is a list whose dates are a long way from their titles. */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top, 0px), 12px) 16px
           max(env(safe-area-inset-bottom, 0px), 24px);
}

.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 4px 14px;
}

.head-text {
  min-width: 0;
}

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

.sub {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* The scraper's state, as a dot before the words. */
.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--faint);
}

.dot.is-good { background: var(--good); }
.dot.is-warn { background: var(--warn); }
.dot.is-bad { background: var(--miss); }

/* --------------------------------------------------------------------------
   The views: a segmented control, as in the books app's audiobooks/ebooks
   -------------------------------------------------------------------------- */

.views {
  display: flex;
  margin: 0 0 6px;
  padding: 3px;
  border-radius: 12px;
  background: var(--tag-bg);
}

.view-link {
  position: relative;
  flex: 1;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
}

.view-link[aria-current="page"] {
  background: var(--card);
  box-shadow: var(--chip-shadow);
  color: var(--text);
}

.view-link:focus-visible {
  outline: 2px solid var(--accent);
}

/* An account whose last run failed: worth a look from the other two views. */
.view-alert {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 5px;
  border-radius: 4px;
  background: var(--miss);
  vertical-align: 2px;
}

.status {
  margin: 10px 4px 0;
  font-size: 14px;
  color: var(--muted);
}

.status.is-error {
  color: var(--miss);
}

/* --------------------------------------------------------------------------
   Lists
   -------------------------------------------------------------------------- */

/* The journal's section label. */
.list-head {
  display: flex;
  justify-content: space-between;
  margin: 22px 4px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.list-count {
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

/* A month is drawn only when it is near the screen: years of bills are
   thousands of rows, and a phone should not lay out all of them to show
   this month's. */
.month {
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
}

/* One card per section with the rows inside it, rather than a card per row:
   there are too many documents for each to be an object of its own. */
.card {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card > .run + .run {
  border-top: 1px solid var(--hairline);
}

/* Between rows, a hairline that starts where the text does, as in the
   phone's own lists, so the day column reads as a margin. A pseudo-element
   rather than a border so a pressed row's tint does not paint over it. */
.card > li {
  position: relative;
}

.card > li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 66px;
  right: 0;
  height: 1px;
  background: var(--hairline);
  pointer-events: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 11px 16px;
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
}

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

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

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

/* The date, as a calendar leaf: the number to find a bill by, and the day or
   month under it. */
.day {
  flex: none;
  width: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.day-num {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.day-under {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

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

.row-title {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row-meta {
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Not a PDF: said, since it will open as something else. */
.type {
  flex: none;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.chev {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   Folders
   -------------------------------------------------------------------------- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  margin: 16px 4px 0;
  font-size: 15px;
}

.crumb {
  padding: 2px 0;
  color: var(--accent);
  text-decoration: none;
}

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

.crumb[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.crumb-sep {
  color: var(--faint);
}

.folder-icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 13%, var(--card));
  color: var(--accent);
}

.folder-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   The search
   -------------------------------------------------------------------------- */

.search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 8px 0 2px;
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search-field {
  flex: 1;
  min-width: 0;
  padding: 10px 38px;
  border: 0;
  border-radius: 12px;
  background: var(--tag-bg);
  color: var(--text);
  font: inherit;
  /* 16px or iOS zooms the page in when the field takes focus. */
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

.search-field::placeholder {
  color: var(--muted);
}

.search-field:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* The browsers that draw a clear button of their own put it where ours is. */
.search-field::-webkit-search-cancel-button,
.search-field::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  position: absolute;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.search-clear:hover {
  color: var(--text);
}

.search-cross {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.full-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 9px 4px 0;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.full-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Accounts
   -------------------------------------------------------------------------- */

/* One card per account, the head a row inside it rather than a title above
   it. Folded, the name is at one end of the row and how long ago it was
   scraped at the other, with a hand's width of nothing in between: proximity
   cannot tie them together at that distance, so the card's own background
   does it. The head is a <summary>, so the whole row folds the history away,
   and the account reads the same either way. */
.acct {
  margin-top: 10px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.acct:first-child {
  margin-top: 18px;
}

.acct-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 13px 16px;
  cursor: pointer;
  /* Both spellings of "no disclosure triangle of your own": there is a
     chevron of ours at the end of the row instead. */
  list-style: none;
}

.acct-head::-webkit-details-marker {
  display: none;
}

/* Open, the head and the history below it need telling apart. */
.acct[open] > .acct-head {
  border-bottom: 1px solid var(--hairline);
}

.acct-head:focus-visible {
  outline: 2px solid var(--accent, currentColor);
  outline-offset: 3px;
  border-radius: 6px;
}

.acct-chevron {
  flex: none;
  align-self: center;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.acct[open] > .acct-head .acct-chevron {
  transform: rotate(-135deg);
}

@media (prefers-reduced-motion: reduce) {
  .acct-chevron { transition: none; }
}

/* The error rides in the head, outside the fold, so a broken account still
   says why when its history is folded away. */
.acct-head > .acct-error {
  flex-basis: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: auto;
}

.acct-name {
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.acct-user {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

.acct-ago {
  flex: none;
  font-size: 13px;
  color: var(--muted);
}

.acct-ago.is-warn { color: var(--warn); }
.acct-ago.is-bad { color: var(--miss); }

.acct-summary {
  padding: 13px 16px;
  font-size: 15px;
}

.acct-summary + .run,
.acct-body > .run + .run {
  border-top: 1px solid var(--hairline);
}

.acct-error {
  padding: 12px 16px;
  background: color-mix(in srgb, var(--miss) 8%, var(--card));
  color: var(--miss);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.acct-error-since {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  opacity: 0.8;
}

.run {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 16px;
  font-size: 14px;
}

.run .dot {
  align-self: center;
}

.run-when {
  flex: none;
  width: 92px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.run-what {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.run-what.is-bad {
  color: var(--miss);
}

/* --------------------------------------------------------------------------
   Nothing to show, and the footer
   -------------------------------------------------------------------------- */

.empty {
  margin: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.empty a {
  color: var(--accent);
}

.foot {
  padding: 28px 4px 8px;
}

.account-line {
  font-size: 13px;
  color: var(--faint);
  text-align: center;
}

.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;
}
