/* ================================================================
   Alerts: one neutral ramp, and three small colours that each mean one thing:
   a sign-up, money in, money that did not come in.
   ================================================================ */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --bg-sub: #fbfbfc;
  --surface: #f4f4f6;
  --surface-2: #ebebee;
  --line: #e7e7ea;
  --line-2: #d8d8dd;

  --text: #16161a;
  --text-2: #5c5c66;
  --text-3: #9a9aa4;

  --flip-bg: #16161a;
  --flip-text: #fbfbfc;

  --signup: #3b6fe0;
  --signup-soft: rgb(59 111 224 / 0.1);
  --paid: #17915a;
  --paid-soft: rgb(23 145 90 / 0.1);
  --failed: #d23c3c;
  --failed-soft: rgb(210 60 60 / 0.1);

  --ring: #16161a;
  --shadow-1: 0 1px 2px rgb(16 16 20 / 0.06), 0 1px 1px rgb(16 16 20 / 0.04);
  --shadow-3: 0 16px 48px rgb(16 16 20 / 0.16), 0 2px 8px rgb(16 16 20 / 0.08);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --page: 52rem;

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --tap: 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #131315;
    --bg-sub: #0d0d0f;
    --surface: #1c1c20;
    --surface-2: #26262b;
    --line: #232328;
    --line-2: #32323a;

    --text: #f2f2f4;
    --text-2: #a4a4b0;
    --text-3: #6f6f7b;

    --flip-bg: #f2f2f4;
    --flip-text: #131315;

    --signup: #7aa2ff;
    --signup-soft: rgb(122 162 255 / 0.14);
    --paid: #4cc98c;
    --paid-soft: rgb(76 201 140 / 0.14);
    --failed: #ff7a7a;
    --failed-soft: rgb(255 122 122 / 0.14);

    --ring: #d8d8e0;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.5);
    --shadow-3: 0 18px 56px rgb(0 0 0 / 0.7), 0 2px 10px rgb(0 0 0 / 0.5);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.booting {
  min-height: 100vh;
}

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

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

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.top h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-3);
}

.live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}

.live.on::before {
  background: var(--paid);
  box-shadow: 0 0 0 3px var(--paid-soft);
}

.spacer {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--tap), border-color var(--tap);
}

.btn:hover {
  background: var(--surface);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn.primary {
  background: var(--flip-bg);
  border-color: var(--flip-bg);
  color: var(--flip-text);
}

.btn.primary:hover {
  opacity: 0.9;
}

.btn.icon {
  width: 34px;
  padding: 0;
}

.btn.quiet {
  border-color: transparent;
  color: var(--text-2);
}

.btn svg {
  width: 17px;
  height: 17px;
}

/* ---------------------------------------------------------------- nudge */

.nudge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-sub);
  font-size: 14px;
  color: var(--text-2);
}

.nudge p {
  margin: 0;
  flex: 1;
}

/* ---------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg);
  min-width: 0;
}

.stat .label {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.stat .value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat .sub {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------------------------------------------------------------- filters */

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface);
  gap: 2px;
}

.tabs button {
  border: 0;
  background: none;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
}

.tabs button[aria-pressed='true'] {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-1);
  font-weight: 500;
}

.search {
  flex: 1;
  min-width: 160px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--bg);
}

/* ---------------------------------------------------------------- feed */

.day {
  margin: 20px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.feed {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.item + .item {
  border-top: 1px solid var(--line);
}

.row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  background: var(--bg);
  text-align: left;
  cursor: pointer;
}

.row:hover {
  background: var(--bg-sub);
}

.item.fresh .row {
  animation: fresh 2.4s ease-out;
}

@keyframes fresh {
  from {
    background: var(--surface-2);
  }
}

.mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.mark svg {
  width: 15px;
  height: 15px;
}

.mark.sign_up {
  background: var(--signup-soft);
  color: var(--signup);
}

.mark.payment {
  background: var(--paid-soft);
  color: var(--paid);
}

.mark.payment_failed {
  background: var(--failed-soft);
  color: var(--failed);
}

.what {
  min-width: 0;
}

.what .title {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.what .meta {
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.when {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.when .amount {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.amount.payment_failed {
  color: var(--failed);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  vertical-align: 1px;
}

.more {
  padding: 0 14px 14px 54px;
  background: var(--bg);
}

.more dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 16px;
  margin: 0 0 10px;
  font-size: 13.5px;
}

.more dt {
  color: var(--text-2);
}

.more dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.more a {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  margin-top: 16px;
}

.empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.load-more {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.notice {
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--failed-soft);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------- sheet */

.scrim {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.32);
  display: flex;
  justify-content: flex-end;
  z-index: 10;
  animation: fade 160ms ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.sheet {
  width: min(28rem, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
  box-shadow: var(--shadow-3);
  padding: calc(env(safe-area-inset-top) + 18px) 20px calc(env(safe-area-inset-bottom) + 32px);
  animation: slide 220ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes slide {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

.sheet header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.sheet h2 {
  font-size: 18px;
  margin: 0;
  flex: 1;
}

.sheet h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 24px 0 8px;
}

.sheet p.hint {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: var(--text-2);
}

.prefs {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.prefs th {
  font-weight: 500;
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
  padding: 0 0 6px;
}

.prefs th:first-child,
.prefs td:first-child {
  text-align: left;
}

.prefs td {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  text-align: center;
}

.switch {
  appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: var(--line-2);
  position: relative;
  cursor: pointer;
  vertical-align: middle;
  margin: 0;
  transition: background var(--tap);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform var(--tap);
}

.switch:checked {
  background: var(--flip-bg);
}

.switch:checked::after {
  transform: translateX(14px);
  background: var(--flip-text);
}

.switch:disabled {
  opacity: 0.4;
  cursor: default;
}

.list {
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.list > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.list > div + div {
  border-top: 1px solid var(--line);
}

.list .grow {
  flex: 1;
  min-width: 0;
}

.list small {
  display: block;
  color: var(--text-3);
  font-size: 12.5px;
}

.secret {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.secret code {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  font: 12.5px var(--mono);
  overflow-wrap: anywhere;
}

.row-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.row-form input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--bg);
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--r);
  background: var(--flip-bg);
  color: var(--flip-text);
  font-size: 14px;
  box-shadow: var(--shadow-3);
  animation: fade 160ms ease-out;
}

.stuck {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.stuck p {
  color: var(--text-2);
}

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