/* Splitpea on the web.
   Same palette and type as the marketing site, but laid out as an app: a bottom
   tab bar on a phone, a sidebar once there is room for one. */

:root {
  color-scheme: light dark;
  --pea: #16b894;
  --pea-deep: #0e8f74;
  --pea-soft: rgba(22, 184, 148, .12);
  --ink: #10201c;
  --ink-soft: #5c706a;
  --ink-faint: #8a9b95;
  --paper: #ffffff;
  --card: #ffffff;
  --wash: #f4f8f6;
  --line: #e2eae7;
  --red: #d9534f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 28, .05), 0 8px 24px rgba(16, 32, 28, .06);
  --tabbar: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9f2ee;
    --ink-soft: #9fb3ac;
    --ink-faint: #6f827b;
    --paper: #0b1210;
    --card: #131c19;
    --wash: #0f1715;
    --line: #22302b;
    --red: #ff6b63;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

/* A class that sets `display` beats the UA rule for [hidden], and then hiding an
   element by setting .hidden silently does nothing. Say it once, here. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--pea-deep); text-decoration: none; }
@media (prefers-color-scheme: dark) { a { color: var(--pea); } }

.boot { display: grid; place-items: center; height: 100vh; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--pea);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }

.sidebar { display: none; }

@media (min-width: 860px) {
  .sidebar {
    display: flex; flex-direction: column; gap: .25rem;
    position: sticky; top: 0; align-self: flex-start;
    width: 232px; height: 100vh; padding: 1.1rem .8rem;
    background: var(--paper); border-right: 1px solid var(--line);
  }
  .sidebar .brand {
    display: flex; align-items: center; gap: .55rem;
    padding: .3rem .5rem 1.2rem; color: var(--ink); font-weight: 680; font-size: 1.05rem;
  }
  .sidebar .brand img { border-radius: 8px; }
  .sidebar a {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .7rem; border-radius: 10px;
    color: var(--ink-soft); font-weight: 550; font-size: .95rem;
  }
  .sidebar a:hover { background: var(--wash); color: var(--ink); }
  .sidebar a.on { background: var(--pea-soft); color: var(--pea-deep); }
  .sidebar .spacer { flex: 1; }
}

.main { flex: 1; min-width: 0; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
@media (min-width: 860px) { .main { padding-bottom: 0; } }

.page { max-width: 760px; margin-inline: auto; padding: 1rem 1rem 2.5rem; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.15rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back, .topbar .act {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.topbar .back:hover, .topbar .act:hover { background: var(--wash); color: var(--ink); }

/* ------------------------------------------------------------------ tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar); color: var(--ink-faint); font-size: .66rem; font-weight: 560;
}
.tabbar a.on { color: var(--pea-deep); }
@media (prefers-color-scheme: dark) { .tabbar a.on { color: var(--pea); } }
.tabbar .fab-slot svg { width: 30px; height: 30px; }

/* This has to come after the .tabbar rule above, not up with the sidebar: both
   selectors have the same specificity, so whichever is written last wins. */
@media (min-width: 860px) {
  .tabbar { display: none; }
}

/* ------------------------------------------------------------------ bits */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card + .card { margin-top: .9rem; }
.card-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1rem; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); flex: 1; }
.pad { padding: 1rem; }

.row {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  padding: .8rem 1rem; border: 0; background: transparent; text-align: left; cursor: pointer;
  color: inherit;
}
.row + .row { border-top: 1px solid var(--line); }
.row:hover { background: var(--wash); }
.row.flat { cursor: default; }
.row.flat:hover { background: transparent; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: .84rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { text-align: right; white-space: nowrap; }
.row .amt .big { font-weight: 620; }
.row .amt .lbl { display: block; font-size: .72rem; color: var(--ink-soft); }
.chev { color: var(--ink-faint); flex: none; }

.pos { color: var(--pea-deep); }
.neg { color: var(--red); }
.zero { color: var(--ink-soft); }
@media (prefers-color-scheme: dark) { .pos { color: var(--pea); } }

.avatar {
  flex: none; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  color: #fff; font-weight: 640; font-size: .9rem; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: .74rem; }
.avatar.lg { width: 74px; height: 74px; font-size: 1.6rem; }

.cat { flex: none; display: grid; place-items: center; width: 38px; height: 38px;
       border-radius: 10px; background: var(--wash); font-size: 1.1rem; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink-soft); font-size: .84rem; cursor: pointer;
}
.chip.on { background: var(--pea-soft); border-color: var(--pea); color: var(--pea-deep); }
@media (prefers-color-scheme: dark) { .chip.on { color: var(--pea); } }

.empty { padding: 2.6rem 1.4rem; text-align: center; color: var(--ink-soft); }
.empty .big { font-size: 2rem; }
.empty p { margin: .5rem auto 1.1rem; max-width: 34ch; }

/* ------------------------------------------------------------------ forms */
.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; margin-bottom: .32rem; font-size: .82rem; font-weight: 560; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%; padding: .7rem .8rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  outline: 0;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--pea); box-shadow: 0 0 0 3px var(--pea-soft);
}
.field textarea { min-height: 76px; resize: vertical; }
.two { display: grid; gap: .9rem; grid-template-columns: 1fr 1fr; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .72rem 1.1rem; border: 1px solid transparent; border-radius: 999px;
  background: var(--pea); color: #fff; font-weight: 620; cursor: pointer;
  /* Two of these side by side at 390px wide will wrap "Add expense" onto a
     second line and grow the row; let the padding give instead. */
  white-space: nowrap; min-width: 0;
}
@media (max-width: 420px) { .btn { padding-inline: .8rem; } }
.btn:hover { background: var(--pea-deep); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--wash); border-color: var(--pea); }
.btn.danger { background: transparent; border-color: var(--line); color: var(--red); }
.btn.sm { padding: .42rem .85rem; font-size: .88rem; }

.err {
  margin-bottom: .9rem; padding: .65rem .85rem; border-radius: 10px;
  background: color-mix(in srgb, var(--red) 12%, transparent);
  color: var(--red); font-size: .9rem;
}

/* ------------------------------------------------------------------ auth */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 1.2rem; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box .logo { display: flex; align-items: center; gap: .6rem; justify-content: center; margin-bottom: 1.4rem; }
.auth-box .logo img { border-radius: 10px; }
.auth-box .logo span { font-size: 1.3rem; font-weight: 680; }
.auth-box h1 { font-size: 1.45rem; text-align: center; margin-bottom: .35rem; }
.auth-box .lede { text-align: center; color: var(--ink-soft); font-size: .94rem; margin: 0 0 1.5rem; }
.auth-box .swap { margin-top: 1.1rem; text-align: center; font-size: .9rem; color: var(--ink-soft); }

/* A rule with the word "or" sitting in the gap. */
.or { display: flex; align-items: center; gap: .8rem; margin: 1.2rem 0 1rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.or span { color: var(--ink-faint); font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; }

.stack { display: flex; flex-direction: column; gap: .55rem; }
.stack .btn { justify-content: center; }

/* The code goes in one field, spaced out so six digits are easy to check. */
.code-input {
  text-align: center;
  font-size: 1.7rem !important;
  font-weight: 650;
  letter-spacing: .34em;
  text-indent: .34em;      /* the last letter-spacing gap would push it off-centre */
  font-variant-numeric: tabular-nums;
}

/* A button that should read as a link. */
.linkish {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--pea-deep); font: inherit; font-size: .9rem;
}
.linkish:hover { text-decoration: underline; }
.linkish:disabled { color: var(--ink-faint); cursor: default; text-decoration: none; }
@media (prefers-color-scheme: dark) { .linkish { color: var(--pea); } }

/* ------------------------------------------------------------------ misc */
.hero-balance { text-align: center; padding: 1.6rem 1rem 1.3rem; }
.hero-balance .num { font-size: 2.3rem; font-weight: 700; letter-spacing: -.03em; }
.hero-balance .cap { font-size: .86rem; color: var(--ink-soft); }
.split3 { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.split3 div { padding: .85rem 1rem; text-align: center; }
.split3 div + div { border-left: 1px solid var(--line); }
.split3 .n { font-weight: 620; }
.split3 .l { font-size: .76rem; color: var(--ink-soft); }

.fab {
  position: fixed; right: 1rem; z-index: 21;
  bottom: calc(var(--tabbar) + 1rem + env(safe-area-inset-bottom));
  display: grid; place-items: center; width: 54px; height: 54px;
  border: 0; border-radius: 50%; background: var(--pea); color: #fff; cursor: pointer;
  box-shadow: 0 8px 22px rgba(22, 184, 148, .4);
}
@media (min-width: 860px) { .fab { bottom: 1.5rem; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 1.4rem); transform: translateX(-50%);
  z-index: 60; max-width: min(90vw, 420px);
  padding: .7rem 1.1rem; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-size: .9rem; box-shadow: var(--shadow);
}
@media (min-width: 860px) { .toast { bottom: 1.6rem; } }

.sheet-back {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center;
  background: rgba(8, 16, 14, .45); padding: 0;
}
@media (min-width: 640px) { .sheet-back { place-items: center; padding: 1.2rem; } }
.sheet {
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
  background: var(--paper); border-radius: 18px 18px 0 0; padding: 1.2rem 1.1rem calc(1.4rem + env(safe-area-inset-bottom));
}
@media (min-width: 640px) { .sheet { border-radius: 18px; } }
.sheet h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.people { display: flex; flex-direction: column; gap: .1rem; }
.person { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; }
.person .grow { flex: 1; min-width: 0; }
.person input[type=number] { width: 104px; text-align: right; padding: .45rem .6rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.person input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--pea); }

.list-note { padding: .65rem 1rem; font-size: .82rem; color: var(--ink-soft); background: var(--wash); }
.sep { height: 1px; background: var(--line); margin: 1.1rem 0; }
.muted { color: var(--ink-soft); font-size: .88rem; }
