/* ThingsToDo interface.
 *
 * Written for a phone held in one hand, and widened from there. Two rules
 * shape most of what follows:
 *
 *   * nothing has a fixed pixel width, and every flex or grid child that holds text
 *     carries min-width: 0. Task names, list names and usernames are written by
 *     people, and one of them will be forty characters with no spaces in it. Without
 *     those two, that one name decides the width of the whole document and the fixed
 *     bottom navigation slides off the screen with it;
 *
 *   * the tap targets on the list screen are large, because they are used while
 *     walking, holding a basket, with one thumb.
 *
 * Both themes are defined here in full. The light one is not an afterthought: half
 * of the use of this app happens under supermarket strip lighting.
 */

/* -------------------------------------------------------------------- tokens */

:root {
  color-scheme: dark;

  --bg: #0c1116;
  --surface: #141c24;
  --surface-2: #1c2731;
  --surface-3: #253340;
  --text: #eaf1f6;
  --muted: #9bacba;
  --line: #2b3a48;
  --line-strong: #3a4d5e;

  --brand: #7fd4a3;
  --brand-strong: #4cba81;
  --brand-ink: #06120c;
  --accent: #f0b45a;
  --danger: #ff8189;
  --danger-strong: #e5525d;

  --radius: 0.9rem;
  --radius-lg: 1.2rem;
  --shadow: 0 1rem 2.5rem rgb(0 0 0 / 0.35);

  /* Room the fixed bottom navigation needs, so the last item is never under it. */
  --nav-height: 4.4rem;

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f2f6f8;
  --surface: #ffffff;
  --surface-2: #eaf1f4;
  --surface-3: #dde8ed;
  --text: #14212b;
  --muted: #55707f;
  --line: #cddbe3;
  --line-strong: #b3c7d2;

  --brand: #17845a;
  --brand-strong: #0f6a47;
  --brand-ink: #ffffff;
  --accent: #92570a;
  --danger: #b3283a;
  --danger-strong: #8f1c2c;

  --shadow: 0 1rem 2.5rem rgb(20 60 80 / 0.12);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;

    --bg: #f2f6f8;
    --surface: #ffffff;
    --surface-2: #eaf1f4;
    --surface-3: #dde8ed;
    --text: #14212b;
    --muted: #55707f;
    --line: #cddbe3;
    --line-strong: #b3c7d2;

    --brand: #17845a;
    --brand-strong: #0f6a47;
    --brand-ink: #ffffff;
    --accent: #92570a;
    --danger: #b3283a;
    --danger-strong: #8f1c2c;

    --shadow: 0 1rem 2.5rem rgb(20 60 80 / 0.12);
  }
}

/* The colors a list can be tinted with. One custom property, set per card. */
[data-colour="default"] { --tint: var(--brand); }
[data-colour="green"]   { --tint: #58c98a; }
[data-colour="blue"]    { --tint: #5aa9f0; }
[data-colour="purple"]  { --tint: #b18cf0; }
[data-colour="amber"]   { --tint: #f0b45a; }
[data-colour="red"]     { --tint: #f07f86; }

/* ---------------------------------------------------------------- foundation */

*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
  overflow-wrap: anywhere;
}

html,
body {
  margin: 0;
  padding: 0;
  /* Never hide horizontal overflow here. It masks the fault instead of fixing it, breaks
   * position: sticky in every descendant, and does not even stop the scroll in
   * Safari on iOS. */
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p, ul, ol, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  max-width: 100%;
  height: auto;
}

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

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

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

.topbar__brand {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  min-width: 0;
}

.topbar__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.6rem;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.topbar__name {
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.topbar__account {
  flex: 0 1 auto;
  min-width: 0;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.topbar__username {
  display: block;
  min-width: 0;
  max-width: 11rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 1.5rem);
}

.main:focus {
  outline: none;
}

/* ---------------------------------------------------------------- navigation */

.nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  min-width: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
}

.nav__item {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0.55rem 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.nav__item--active {
  color: var(--brand);
}

.nav__icon {
  width: 1.4rem;
  height: 1.4rem;
  background: currentColor;
  /* One mask per icon keeps them monochrome and theme-aware with no icon font and
   * no second network request. */
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.nav__icon[data-icon="list"] {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E");
}

.nav__icon[data-icon="invite"] {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M19 8v6M22 11h-6'/%3E%3C/svg%3E");
}

.nav__icon[data-icon="admin"] {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 4 6v6c0 5 3.4 8.4 8 9 4.6-.6 8-4 8-9V6z'/%3E%3C/svg%3E");
}

.nav__icon[data-icon="settings"] {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.9-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1A1.7 1.7 0 0 0 9 19.4a1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.9 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1A1.7 1.7 0 0 0 4.6 9a1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.9.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z'/%3E%3C/svg%3E");
}

.nav__label {
  min-width: 0;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav__badge {
  position: absolute;
  top: 0.3rem;
  left: 50%;
  transform: translateX(0.4rem);
  min-width: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--accent);
  color: #10161c;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.1rem;
  text-align: center;
}

/* -------------------------------------------------------------------- screen */

.screen {
  display: grid;
  gap: 1.1rem;
  min-width: 0;
}

.screen__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: flex-end;
  justify-content: space-between;
  min-width: 0;
}

.screen__head--detail {
  align-items: flex-start;
  padding-left: 0.85rem;
  border-left: 4px solid var(--tint, var(--brand));
}

.screen__title-block {
  flex: 1 1 14rem;
  min-width: 0;
}

.screen__title {
  min-width: 0;
  font-size: 1.65rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.screen__copy,
.screen__meta {
  min-width: 0;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.screen__meta {
  font-size: 0.85rem;
}

.screen__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}

.eyebrow {
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.back-link {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------ controls */

.button {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.button--primary {
  background: var(--brand);
  color: var(--brand-ink);
}

.button--primary:hover {
  background: var(--brand-strong);
}

.button--ghost {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.button--ghost:hover {
  background: var(--surface-2);
}

.button--danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.button--danger:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.button--small {
  min-height: 2.1rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
}

.button--wide {
  flex: 0 1 auto;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.input {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  /* 1rem or more, or iOS Safari zooms the whole page in on focus and leaves it
   * there, which looks exactly like the horizontal overflow bug. */
  font-size: 1rem;
}

.input--area {
  min-height: 5rem;
  resize: vertical;
}

.field {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.field__label {
  font-size: 0.88rem;
  font-weight: 700;
}

.field__hint {
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.toggle {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.toggle input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--brand);
}

/* The color strip on the list dialog. */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}

.swatch {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}

.swatch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.swatch__dot {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--tint, var(--brand));
}

.swatch:has(.swatch__input:checked) {
  border-color: var(--text);
}

.swatch:has(.swatch__input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- notices, toast */

.notice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.notice--warning {
  border-color: var(--accent);
  color: var(--accent);
}

.notice--invite {
  border-color: var(--brand);
  color: var(--text);
}

.notice__go {
  flex: none;
  color: var(--brand);
  font-weight: 700;
}

.toast-stack {
  position: fixed;
  right: 0.75rem;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 0.75rem);
  left: 0.75rem;
  z-index: 60;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  pointer-events: none;
}

.toast {
  min-width: 0;
  max-width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-3);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.toast--success { border-color: var(--brand); }
.toast--warning { border-color: var(--accent); }
.toast--error   { border-color: var(--danger); }

/* --------------------------------------------------------------- list screen */

.list-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr;
  min-width: 0;
}

@media (min-width: 40rem) {
  .list-grid {
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  }
}

.list-card {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--tint, var(--brand));
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.list-card:hover {
  border-color: var(--line-strong);
  border-left-color: var(--tint, var(--brand));
}

.list-card--archived {
  opacity: 0.62;
}

.list-card__head {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
}

.list-card__name {
  min-width: 0;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.list-card__copy,
.list-card__stamp {
  min-width: 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.list-card__stamp {
  font-size: 0.78rem;
}

.list-card__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  min-width: 0;
  font-size: 0.85rem;
}

.list-card__count {
  min-width: 0;
  font-weight: 700;
}

.list-card__count--done {
  color: var(--brand);
}

.list-card__people,
.list-card__owner {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.badge {
  flex: none;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge--owner {
  border-color: var(--brand);
  color: var(--brand);
}

.badge--member {
  color: var(--muted);
}

.badge--pending {
  border-color: var(--accent);
  color: var(--accent);
}

/* --------------------------------------------------------------------- tasks */

.add-task {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.add-form {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  min-width: 0;
}

.add-form .input {
  flex: 1 1 auto;
  min-width: 0;
}

.add-form .button {
  flex: none;
}

.queue-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.queue-status__message {
  min-width: 0;
  overflow-wrap: anywhere;
}

.task-list {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.task {
  display: flex;
  gap: 0.15rem;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.task--high {
  border-left: 3px solid var(--accent);
}

.task--low {
  opacity: 0.85;
}

.task--completed .task__name {
  color: var(--muted);
  text-decoration: line-through;
}

/* The completion target stays large enough for comfortable use on a phone. */
/* The drag grip.
 *
 * touch-action: none is what makes dragging possible at all on a phone. Without it
 * the browser claims the vertical gesture for scrolling and stops sending pointer
 * moves halfway through. It is set on the grip alone, so the list still scrolls
 * everywhere else.
 */
.task__grip {
  flex: none;
  width: 1.9rem;
  height: 3rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: grab;
  touch-action: none;
}

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

.task__grip:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.task--dragging {
  opacity: 0.75;
  box-shadow: var(--shadow);
  cursor: grabbing;
}

/* Without this the drag paints the whole list blue under the finger. */
.task-list--reordering {
  user-select: none;
}

.task__tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  cursor: pointer;
}

.task__check {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.task__box {
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border: 2px solid var(--line-strong);
  border-radius: 0.45rem;
}

.task__check:checked + .task__box {
  border-color: var(--brand);
  background: var(--brand);
}

.task__check:checked + .task__box::after {
  content: "";
  width: 0.75rem;
  height: 0.42rem;
  border-bottom: 2.5px solid var(--brand-ink);
  border-left: 2.5px solid var(--brand-ink);
  transform: rotate(-45deg) translate(1px, -1px);
}

.task__check:focus-visible + .task__box {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.task__body {
  flex: 1 1 auto;
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.6rem 0.35rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.task__name {
  min-width: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.task__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.task__meta > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.task__due-date {
  padding: 0 0.35rem;
  border-radius: 0.4rem;
  background: var(--surface-2);
  font-weight: 700;
}

.task__notes {
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.task__delete {
  flex: none;
  width: 2.6rem;
  height: 2.6rem;
  margin-right: 0.2rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.task__delete:hover {
  background: var(--surface-2);
  color: var(--danger);
}

.completed {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
}

.completed__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.completed__title {
  min-width: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.task-list--completed .task {
  background: var(--surface-2);
}

/* ------------------------------------------------------------------- sharing */

.member-list {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.member {
  display: grid;
  gap: 0.3rem 0.6rem;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.member__who {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
}

.member__name {
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.member__stamp {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.share-invite {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  padding-bottom: 0.4rem;
}

/* --------------------------------------------------------------- invitations */

.invitation-list {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
}

.invitation {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--brand);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.invitation__body {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.invitation__from {
  min-width: 0;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.invitation__name {
  min-width: 0;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.invitation__copy,
.invitation__meta {
  min-width: 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.invitation__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}

.invitation__actions .button {
  flex: 1 1 8rem;
}

/* --------------------------------------------------------------------- cards */

.card-stack {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.card {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.card__title {
  min-width: 0;
  font-size: 1.05rem;
}

.card__copy {
  min-width: 0;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}

.identity {
  min-width: 0;
}

.identity__value {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  padding: 0.3rem 0.6rem;
  border-radius: 0.5rem;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------- admin */

.stat-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  min-width: 0;
}

.stat {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat__value {
  min-width: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat__label {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

/* A wide table scrolls inside its own box rather than dragging the document. */
.table-wrap {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th,
.table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.cell--name {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
}

.cell__username {
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: normal;
}

.row--inactive .cell__username,
.row--inactive td {
  color: var(--muted);
}

.row--inactive .button,
.row--inactive .badge {
  opacity: 1;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.pagination__status {
  min-width: 0;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------- dialogs */

.dialog {
  width: 100%;
  max-width: 32rem;
  max-height: calc(100dvh - 1rem);
  min-width: 0;
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}

.dialog__body {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
  padding: 1.1rem;
  overflow-y: auto;
}

.dialog__title {
  min-width: 0;
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}

.dialog__subtitle {
  min-width: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dialog__fields {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.dialog__row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
  min-width: 0;
}

@media (min-width: 30rem) {
  .dialog__row {
    grid-template-columns: 1fr 1fr;
  }
}

.dialog__copy {
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.dialog__error {
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.dialog__rule {
  width: 100%;
  margin: 0.2rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  min-width: 0;
}

.dialog__actions .button {
  flex: 1 1 8rem;
}

/* --------------------------------------------------- empty, loading and boot */

.empty-state {
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  min-width: 0;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty-state--inline {
  padding: 1.6rem 1rem;
}

.empty-state__icon {
  width: 2.6rem;
  height: 2.6rem;
  background: var(--muted);
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.empty-state__icon[data-icon="tasks"] {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 6 2 2 4-4M3 13l2 2 4-4M3 20l2 2 4-4M12 6h9M12 13h9M12 20h9'/%3E%3C/svg%3E");
}

.empty-state__icon[data-icon="check"] {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.empty-state__icon[data-icon="invite"] {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m2 7 10 6 10-6'/%3E%3C/svg%3E");
}

.empty-state__title {
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.empty-state__copy {
  min-width: 0;
  max-width: 32rem;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.loading {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 3rem 1rem;
  color: var(--muted);
}

.loading__spinner {
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loading__spinner {
    animation: none;
  }
}

.fatal {
  display: grid;
  gap: 0.7rem;
  justify-items: center;
  min-width: 0;
  padding: 3rem 1rem;
  text-align: center;
}

.fatal__title {
  min-width: 0;
  font-size: 1.3rem;
  overflow-wrap: anywhere;
}

.fatal__copy {
  min-width: 0;
  max-width: 32rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.boot-screen {
  display: grid;
  gap: 0.8rem;
  place-content: center;
  min-height: 100dvh;
  min-width: 0;
  justify-items: center;
}

.boot-mark {
  display: grid;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 0.9rem;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 800;
}

.boot-text {
  color: var(--muted);
}

/* Below 360px the padding is what is left to give back. */
@media (max-width: 22.5rem) {
  .main {
    padding-right: 0.7rem;
    padding-left: 0.7rem;
  }

  .screen__title {
    font-size: 1.4rem;
  }

  .task__tick {
    width: 2.6rem;
  }

  .task__grip {
    width: 1.5rem;
  }
}
