/* ReCircle styles. Colours follow docs/branding/README.md and keep to the
   combinations that pass WCAG 2.1 AA:
   Primary #D62C5C, Ink #313757, Muted #8E92A1, Surface #F2F2F4, white. */

@font-face {
  font-family: "Montserrat";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/static/fonts/montserrat-400.woff2") format("woff2");
}

@font-face {
  font-family: "Montserrat";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("/static/fonts/montserrat-700.woff2") format("woff2");
}

:root {
  --primary: #d62c5c;
  --ink: #313757;
  --muted: #8e92a1;
  --surface: #f2f2f4;
  --white: #ffffff;
  /* One corner radius across cards, buttons, inputs and images. */
  --radius: 0.25rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: "Montserrat", sans-serif;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
}

header.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--muted);
  padding: 0.75rem 1rem;
}

.logo {
  display: block;
  width: 12rem;
  max-width: 100%;
}

.logo svg {
  display: block;
  width: 100%;
  height: auto;
}

.logo .symbol {
  fill: var(--primary);
}

.logo .tagline {
  fill: var(--primary);
}

.logo .wordmark {
  fill: var(--ink);
}

main {
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

h1,
h2,
button {
  font-weight: 700;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.125rem;
  margin: 1.5rem 0 0.5rem;
}

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

label {
  flex: 1 1 100%;
  font-weight: 700;
}

/* A label that wraps its field stacks the two, with the form's own gap. */
label:has(> input, > select, > textarea) {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input,
select,
textarea {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  font: inherit;
}

/* Every action is outlined, with its icon beside a short verb. Only the one
   action a screen is for is filled (`primary`); a destructive one has a
   heavier, solid outline (`destructive`). */
button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button.primary,
a.button.primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

button.destructive {
  border-width: 2px;
  border-style: solid;
  border-radius: var(--radius);
}

/* A dialog's Cancel is plain text: no outline, no fill, no icon. It stops;
   the verb beside it, on the right, acts. */
button.plain {
  background: transparent;
  border: 0;
  padding: 0.5rem 0.75rem;
}

/* A field's error sits below the field, in Primary, with an icon. */
p.field-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 100%;
  margin: 0;
  color: var(--primary);
  font-weight: 700;
}

/* A setting that is on or off and takes effect at once is a switch: a track
   with a thumb, then its label. On is filled with Primary and the thumb sits at
   the end; off is an Ink outline and the thumb sits at the start, so the state
   never rests on colour alone. */
button.switch {
  justify-content: flex-start;
  /* The label is read left to right beside the track, never centred. */
  text-align: left;
  min-width: 2.75rem;
  padding: 0.25rem 0.75rem 0.25rem 0.5rem;
  border-width: 1px;
  border-color: transparent;
  background: transparent;
  font-weight: 400;
}

button.switch > span:last-child {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

button.switch .switch-track {
  flex: none;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  width: 2.75rem;
  height: 1.5rem;
  padding: 0.125rem;
  border: 2px solid var(--ink);
  border-radius: 0.75rem;
  background: var(--white);
}

button.switch .switch-thumb {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--ink);
}

button.switch[aria-checked="true"] .switch-track {
  justify-content: flex-end;
  background: var(--primary);
  border-color: var(--primary);
}

button.switch[aria-checked="true"] .switch-thumb {
  background: var(--white);
}

/* A form's submit is the one full-width button. */
form > button.primary {
  flex: 1 1 100%;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

h3 {
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--muted);
}

p.problem {
  margin: 0;
  font-weight: 700;
  /* Above a full-width image that a screen pulls up under its top bar. */
  position: relative;
  z-index: 1;
}

/* An empty list says what goes there and how to fill it, in regular weight,
   with a link to the screen that fills it. */
p.empty {
  margin: 0;
  font-weight: 400;
}

a.empty-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

textarea {
  flex: 1 1 100%;
  resize: vertical;
}

fieldset {
  flex: 1 1 100%;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--muted);
  border-radius: var(--radius);
}

legend {
  font-weight: 700;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
}

.choice label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 400;
}

/* A label with its hint under it, in the row of a radio button. */
.choice-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* A radio button beside a label with its hint sits level with the label's
   first line, not between the two lines. */
.choice:has(> .choice-text) {
  align-items: flex-start;
}

.choice:has(> .choice-text) > input {
  margin-top: 0.5rem;
}

.choice-text {
  padding: 0.5rem 0;
}

/* The radio button stays above the label's cover. */
.choice > input {
  position: relative;
  z-index: 1;
}

/* The label covers the whole row, hint included, so the touch target is the row. */
.choice-text label::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* What a choice does, under its label, in Ink like the label: Muted is never for text. */
.choice .hint {
  display: block;
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--ink);
}

/* The field of one radio option, shown under the options once it is chosen. */
.choice-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 0.5rem;
}

.choice-field label {
  font-weight: 400;
}

input[type="checkbox"],
input[type="radio"] {
  flex: none;
  min-height: 0;
  width: 1.5rem;
  height: 1.5rem;
  accent-color: var(--primary);
}

/* Tables of people are lists too: rows run the whole width of the screen on a
   phone (the negative margin cancels main's side padding) and of the column on
   wider screens, with Muted between rows and no card. Long text wraps. */
.standings table,
.members table {
  border-collapse: collapse;
  width: calc(100% + 2rem);
  margin: 0 -1rem 1rem;
  table-layout: auto;
}

.standings td,
.members td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--muted);
  overflow-wrap: anywhere;
}

.standings tr:last-child td,
.members tr:last-child td {
  border-bottom: 0;
}

/* An email address standing in for a Member's name is never broken inside a
   word: the only place it may break is after the "@" (the <wbr> in the markup).
   The action beside it keeps its width. */
.members td.email {
  overflow-wrap: normal;
  word-break: keep-all;
}

/* On a phone the address and its action do not share a line: the address takes
   the row's width, whole, and the action sits under it. */
.members tr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--muted);
}

.members tr:last-child {
  border-bottom: 0;
}

.members tr td {
  border-bottom: 0;
}

.members td.email {
  flex: 1 1 100%;
  padding-bottom: 0;
}

.members td:last-child {
  white-space: nowrap;
}

@media (min-width: 820px) {
  .members td.email {
    flex: 1 1 0;
    padding-bottom: 0.75rem;
  }
}

ul.member-rows {
  list-style: none;
  margin: 0 -1rem 1rem;
  padding: 0;
  overflow-wrap: anywhere;
}

ul.member-rows li {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--muted);
}

/* A row that opens a Member carries the padding itself, so the whole row is
   the tap target. */
ul.member-rows li:has(> a.row) {
  padding: 0;
}

ul.member-rows li:last-child {
  border-bottom: 0;
}

ul.photos {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* A list is rows, edge to edge, on the Surface: no card. Muted draws the
   dividers between rows and nothing else. On a phone the negative margin
   cancels main's side padding, so rows reach the screen edges. A row that is a link carries the padding itself, so the
   whole row is the tap target. */
ul.circles,
ul.items,
ul.matches,
ul.runs,
.open-matches ul,
.flags ul {
  list-style: none;
  margin: 0 -1rem 1rem;
  padding: 0;
  overflow-wrap: anywhere;
}

ul.circles li,
ul.items li,
ul.matches li,
ul.runs li,
.open-matches ul li,
.flags ul li {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--muted);
}

ul.circles li:last-child,
ul.items li:last-child,
ul.matches li:last-child,
ul.runs li:last-child,
.open-matches ul li:last-child,
.flags ul li:last-child {
  border-bottom: 0;
}

/* A row that is not a link has its own padding. */
ul.circles li:not(:has(> a.row)),
ul.items li:not(:has(> a.row)),
ul.matches li:not(:has(> a.row)),
ul.runs li:not(:has(> a.row)),
.open-matches ul li:not(:has(> a.row)),
.flags ul li:not(:has(> a.row)) {
  padding: 0.75rem 1rem;
}

ul.photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

div.photos {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

/* An Item's photo fills its column, always in one ratio. */
div.photos img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* An Item's photos show one at a time: the chevrons sit inside the picture at
   its side edges, 44px, and nothing else is over it. A sideways swipe is
   handled by photo-strip.js, so the browser keeps only the vertical pan. */
div.photos {
  position: relative;
}

div.photos[data-swipe-photos] {
  touch-action: pan-y;
}

div.photos img {
  display: block;
}

button.photo-chevron {
  position: absolute;
  top: 50%;
  width: 2.75rem;
  height: 2.75rem;
  min-height: 0;
  padding: 0;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
}

button.photo-chevron.previous {
  left: 0;
}

button.photo-chevron.next {
  right: 0;
}

button.photo-chevron.previous .icon {
  transform: scaleX(-1);
}

/* An Item's photo fullscreen: over the whole viewport, bars included, on Ink,
   the photo fitted whole. No touch-action here: pinch and double-tap zoom are
   the browser's own. */
div.photo-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
}

div.photo-fullscreen img {
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: auto;
  object-fit: contain;
  border-radius: 0;
}

button.photo-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  border-color: var(--white);
}

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

a {
  color: var(--ink);
  font-weight: 700;
}

/* Links are tapped, so each is a 44px-tall target. */
a {
  display: inline-flex;
  align-items: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
}

.install-prompt {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: var(--white);
  border-left: 4px solid var(--primary);
  color: var(--ink);
}

/* The frame of a signed-in screen: settings in the header, the Items
   segments under it, and the tab bar fixed to the bottom. */
header.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* The top bar of a signed-in screen: the symbol, the title, and on a detail
   or form screen the way back. It stays at the top while the page scrolls. */
body:has(.tab-bar) {
  padding-top: 3.5rem;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 3.5rem;
  padding: 0 0.5rem 0 1rem;
  background: var(--white);
  border-bottom: 1px solid var(--muted);
}

.top-bar a.back {
  justify-content: center;
  min-width: 2.75rem;
  margin-left: -0.5rem;
  color: var(--ink);
}

.top-bar .symbol,
.rail-logo {
  flex: none;
  display: block;
  height: 2rem;
  aspect-ratio: 35.79 / 47.92;
  background: var(--primary);
  -webkit-mask: url("/static/symbol-recircle.svg") center / contain no-repeat;
  mask: url("/static/symbol-recircle.svg") center / contain no-repeat;
}

/* One logo per viewport: the rail carries it from 840px, the list's top bar on
   a phone. A top bar with a back arrow has none, and a detail pane's never does. */
.top-bar:has(a.back) .symbol {
  display: none;
}

.tab-bar .rail-logo {
  display: none;
}

.top-bar-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body:has(.tab-bar) main {
  padding-bottom: 6.5rem;
}

/* The screen's create action floats at the bottom-right, above the tab bar.
   The list leaves room below its last row so the button never covers it. */
.floating-create {
  position: fixed;
  right: 1rem;
  bottom: 4.5rem;
  z-index: 9;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(49, 55, 87, 0.35);
}

body:has(.floating-create) main {
  padding-bottom: 9.5rem;
}

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--muted);
  z-index: 10;
}

.tab-bar a {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  min-height: 3.5rem;
  font-size: 0.75rem;
  color: var(--ink);
  font-weight: 400;
  text-decoration: none;
}

.tab-bar a[aria-current="page"] {
  color: var(--primary);
  font-weight: 700;
  box-shadow: inset 0 3px 0 var(--primary);
}

.tab-bar .count {
  position: absolute;
  top: 0.25rem;
  left: calc(50% + 0.5rem);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 0.75rem;
  background: var(--primary);
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 700;
}

.segments {
  display: flex;
  margin: 0 0 1rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  overflow: hidden;
}

.segments a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 0.25rem;
  min-width: 0;
  color: var(--primary);
  text-decoration: none;
}

.segments a[aria-current="page"] {
  background: var(--primary);
  color: var(--white);
  font-weight: 700;
}

.match-link {
  display: block;
  min-height: 2.75rem;
  color: inherit;
}

/* Mine: a row is one tap target that opens the Item. */
a.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 4rem;
  padding: 0.75rem 1rem;
  color: inherit;
  text-decoration: none;
}

a.row .thumbnail {
  flex: none;
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border-radius: var(--radius);
}

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

/* A row that is not a link, such as a Discarded Item: the text takes the
   space, and the action sits at the end. */
li.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 4rem;
}

li.row .thumbnail {
  flex: none;
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border-radius: var(--radius);
}

li.row .row-text {
  flex: 1;
}

li.row .row-end {
  flex: none;
  margin: 0;
}

/* What a Discarded Item's row says at its end, with Undo under it. */
.row-trailing {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.row-trailing p {
  margin: 0;
}

/* A Discarded Item's row: its Item opens its detail, and Undo sits beside it. */
a.row-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  min-height: 2.75rem;
  color: inherit;
  text-decoration: none;
}

a.row-main .thumbnail {
  flex: none;
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border-radius: var(--radius);
}

/* A link row with something at its end, such as a Valued Item's Valuation. */
a.row .row-text {
  flex: 1;
}

a.row .row-end {
  flex: none;
  margin: 0;
}

.row-valuation {
  font-weight: 700;
  color: var(--ink);
}

/* A navigation row: a place to go, the whole row tappable, a chevron at its end. */
a.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
  /* Edge to edge on a phone, like the list rows: cancel main's padding. */
  margin: 0 -1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  color: var(--ink);
  text-decoration: none;
}

a.nav-row .icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* A navigation row's title with an icon before it: both on one line. */
a.nav-row .row-title.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* The first navigation row under the top bar, as Settings' Display name is,
   sits right under it: main's top padding is no gap above a row. */
.top-bar + a.nav-row,
.top-bar + img.cover,
.top-bar + .cover-placeholder.cover {
  margin-top: -1.5rem;
}

/* A full-width image, or a form's cover chooser, that is the first block of a
   screen sits right under the top bar too: an Item's detail, Item to value, a
   Flag to review, a Match's detail, Create a Circle and Edit Circle. The usual
   gap follows it. */
.top-bar + .photos,
.top-bar + * > .photos:first-child,
.top-bar + section > .item-photo:first-child,
.top-bar + div > ul.matches > li.match > .photos:first-child,
.top-bar + form > .cover-field:first-child,
.top-bar + div > form > .cover-field:first-child {
  margin-top: -1.5rem;
}

/* A problem above the screen fills the place under the top bar: the photos
   follow it, so they do not slide up over it. */
p.problem ~ * .photos:first-child,
p.problem ~ * .item-photo:first-child {
  margin-top: 0;
}

/* A Match's detail has no padding above its photos. */
.top-bar + div > ul.matches > li.match {
  padding-top: 0;
}

.cover-field:first-child {
  margin-bottom: 0.5rem;
}

.cover-field:first-child .cover-frame {
  margin-top: 0;
}

/* A section right under the top bar starts the usual gap too: its first
   element's own top margin (an empty state's paragraph) would add to it. */
.top-bar + section > :first-child {
  margin-top: 0;
}

/* Settings' blocks (rows, the Language box, Notifications, Root's group, Sign
   out) never touch: each is a gap below the one before. The Display name row
   keeps sitting right under the top bar. */
.settings-list > * + * {
  margin-top: 1rem;
}

/* Runs: the explanation, the buttons (Run now and Dry Run, side by side
   where they fit) and what follows are a gap apart. */
.run-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.run-actions > button:disabled {
  cursor: progress;
}

/* A navigation row's title and its supporting line, one above the other. */
a.nav-row .row-text > span {
  display: block;
}

/* A navigation row's count and chevron sit together at its end. */
a.nav-row .row-end {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

.row-value {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tasks {
  margin: 1rem 0;
}

.member-count {
  margin: 0 0 1rem;
}

.row-title,
.row-status {
  margin: 0;
  overflow-wrap: break-word;
}

.row-title {
  font-weight: 700;
}

.row-status {
  font-size: 0.875rem;
  /* Rows sit in links, which are bold: a supporting line is regular weight. */
  font-weight: 400;
}

/* A row's supporting line is one whole line: when it is longer than the room
   beside the photo and the row's end, it is cut with an ellipsis, never wrapped
   into a narrow column. */
.row-text > .row-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A mark such as Changed or Received sits under a row's supporting line, so
   it never narrows the row's text. */
.row-mark {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  font-weight: 700;
}

/* A control at a row's end: an icon with an accessible name, 44px square. */
button.icon-button {
  flex: none;
  width: 2.75rem;
  min-width: 2.75rem;
  padding: 0;
}

a.back {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

/* A Member's screen: each control, then the sentence saying what it does, in Ink like any text. */
.member .actions {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.member .actions .hint {
  margin: 0 0 0.75rem;
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--ink);
}

.confirm {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--muted);
  border-radius: var(--radius);
}

.confirm p {
  flex-basis: 100%;
  margin: 0;
}

/* A dialog's two buttons share one row in every language: Cancel keeps its
   size and the verb takes the rest, wrapping its words if it must. */
.confirm > button {
  min-width: 0;
}

.confirm > button.plain {
  flex: none;
}

.confirm > button:not(.plain) {
  flex: 1 1 0;
}

/* Remove, Withdraw and Discard Forever ask in this one modal dialog: the page
   behind is dimmed with the Ink colour and can't be used. */
dialog.confirm:not([open]) {
  display: none;
}

dialog.confirm::backdrop {
  background: rgba(49, 55, 87, 0.6);
}

/* The dialog sits in the middle of the screen, above the tab bar. */
dialog.confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 2rem);
  max-width: 24rem;
  margin: 0;
  background: var(--white);
  color: var(--ink);
  border: 2px solid var(--ink);
  z-index: 30;
}

/* A confirmation floats above the tab bar and goes away by itself. It never
   catches a tap meant for what is under it. */
.toast {
  position: fixed;
  left: 1rem;
  right: 1rem;
  /* Above the tab bar and above the floating button, which sits at 4.5rem. */
  bottom: 8rem;
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--white);
  border-radius: var(--radius);
  pointer-events: none;
  z-index: 20;
  animation: toast-away 0.3s ease 5s forwards;
}

@keyframes toast-away {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* Tablet and up: the extra width holds the lists in columns. */
@media (min-width: 820px) {
  main {
    max-width: 56rem;
    padding: 1.5rem 1.5rem 2rem;
  }
}

/* Rows span the content column: there is no side padding to cancel. */
@media (min-width: 820px) {
  ul.circles,
  ul.items,
  ul.matches,
  ul.runs,
  .open-matches ul,
.flags ul,
  ul.member-rows {
    margin: 0 0 1rem;
  }

  a.nav-row {
    margin: 0;
  }

  /* Settings' rows' text starts where the headings' and the other content's does. */
  .settings-list a.nav-row {
    padding-left: 0;
    padding-right: 0;
  }

  .standings table,
  .members table {
    width: 100%;
    margin: 0 0 1rem;
  }
}

/* Desktop and up. */
@media (min-width: 1440px) {
  main {
    max-width: 72rem;
  }
}

/* Offered: a row is dragged sideways to Discard it. `swipe.js` moves it with
   the pointer; the browser keeps scrolling up and down. */
[data-swipe-discard] {
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

/* The Undo in a toast catches taps, though the toast itself does not. */
.toast .undo {
  pointer-events: auto;
  background: transparent;
  color: var(--white);
  border-color: var(--white);
  margin-left: 0.75rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
}

/* Flag is a secondary control in an Item's detail. */
.flag-menu {
  margin: 1rem 0;
}

.flag-menu summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  cursor: pointer;
}

/* Two panes. Below 840px one pane shows at a time: the list on the Circles
   tab, the Circle (or its task) otherwise. */
.panes[data-show="detail"] .pane-list,
.panes[data-show="list"] .pane-detail {
  display: none;
}

a.row[aria-current="true"],
li.row[aria-current="true"] {
  background: var(--white);
  box-shadow: inset 4px 0 0 var(--primary);
}

/* From 840px the tab bar is a rail on the leading edge, with the same
   destinations, icons and labels, and the list stays beside the open Circle.
   The 820px tablet keeps the phone's single pane and bottom bar. */
@media (min-width: 840px) {
  :root {
    --rail: 5.5rem;
    --list: 22rem;
  }

  body:has(.tab-bar) {
    padding-left: var(--rail);
  }

  body:has(.tab-bar) main {
    padding-bottom: 2rem;
  }

  .top-bar {
    left: var(--rail);
  }

  .tab-bar {
    top: 0;
    right: auto;
    bottom: 0;
    width: var(--rail);
    flex-direction: column;
    justify-content: flex-start;
    border-top: 0;
    border-right: 1px solid var(--muted);
  }

  .tab-bar a {
    flex: none;
    min-height: 4.5rem;
  }

  .tab-bar a[aria-current="page"] {
    box-shadow: inset 3px 0 0 var(--primary);
  }

  .floating-create {
    bottom: 1.5rem;
  }

  /* Inside the list pane, above its floating button. */
  .toast {
    left: calc(var(--rail) + 1rem);
    right: calc(100vw - var(--rail) - var(--list) + 1rem);
    bottom: 5.5rem;
  }

  .top-bar .symbol {
    display: none;
  }

  .tab-bar .rail-logo {
    display: block;
    height: 2.5rem;
    margin: 0.75rem auto;
  }

  /* An empty list shows its empty state and nothing beside it. */
  .panes:has(.pane-list p.empty) .pane-detail .choose-an-item {
    display: none;
  }

  /* Detail content and every form sit in a column, not across the pane. */
  .pane-detail > :not(.top-bar),
  form {
    max-width: 40rem;
  }

  /* The panes own the whole window under the top bar: no strip of page
     below them, so the rail, the list and the detail all end together. This
     is as specific as the `main` padding rule above, and comes after it. */
  body:has(.tab-bar) main.with-panes {
    padding-bottom: 0;
  }

  main.with-panes {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .panes {
    display: grid;
    grid-template-columns: var(--list) minmax(0, 1fr);
    min-height: calc(100vh - 3.5rem);
  }

  .panes[data-show] .pane-list,
  .panes[data-show] .pane-detail {
    display: block;
  }

  .pane-list {
    padding: 1.5rem 1rem 6rem;
    border-right: 1px solid var(--muted);
  }

  .pane-list .top-bar {
    right: auto;
    width: var(--list);
    border-right: 1px solid var(--muted);
  }

  .pane-list ul.circles,
  .pane-list ul.items,
  .pane-list ul.matches {
    margin: 0 -1rem 1rem;
  }

  .pane-list .floating-create {
    right: auto;
    left: calc(var(--rail) + var(--list) - 1rem);
    transform: translateX(-100%);
  }

  .pane-detail {
    padding: 1.5rem;
  }

  .pane-detail .top-bar {
    left: calc(var(--rail) + var(--list));
  }
}

/* A Circle's cover image: cropped to fill its space, never stretched. On the
   Circle's detail it is at most 16:9 of the width, so the name and the first
   rows show on the first phone screen. */
img.cover,
.cover-placeholder.cover {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 0 0 1rem;
}

/* A form's cover field takes the form's width and no more. */
.cover-field {
  flex: 1 1 100%;
  min-width: 0;
}

/* The frame of a cover image in a form is the chooser: the picture fills it
   and a small round badge sits on its bottom-right corner; with no picture it
   is an outlined empty box of the same size. A gap below the field above. */
.cover-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  max-width: 20rem;
  aspect-ratio: 16 / 9;
  margin: 0.5rem 0 0;
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
}

.cover-frame img.cover {
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  border-radius: inherit;
}

.cover-frame .cover-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  text-align: center;
  font-weight: 700;
}

.cover-frame:not(:has(img)) {
  border: 2px solid var(--ink);
  background: var(--white);
}

/* Ink on white, 44px, the only thing over the picture. */
.cover-badge {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
}

/* The input is invisible and fills the frame, under the picture and the
   badge: it is the frame's tap target and the keyboard's one focus stop, and
   nothing is drawn over the picture but the badge. */
.cover-frame input.cover-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.cover-frame img.cover,
.cover-frame .cover-empty {
  position: relative;
  z-index: 1;
}

.cover-frame .cover-empty {
  pointer-events: none;
}

.cover-badge {
  z-index: 2;
}

.cover-frame:has(input:focus-visible) {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

/* In a row it is a small square, like an Item's thumbnail. */
.row-cover {
  flex: none;
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border-radius: var(--radius);
}

/* No cover image: the Circle's initial in Ink, on white or on Surface, with a
   Muted border. Never the ReCircle symbol, never a Primary fill. */
.cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-weight: 700;
  border: 1px solid var(--muted);
}

.cover-placeholder.on-white {
  background: var(--white);
}

.cover-placeholder.on-surface {
  background: var(--surface);
}

.row-cover.cover-placeholder {
  font-size: 1.5rem;
}

.cover.cover-placeholder {
  font-size: 3rem;
}

/* "Add photos": a label that looks like a button, over a visually hidden
   file input, so the browser's own control text never shows. The input keeps
   the keyboard focus, and the label shows it. */
label.add-photos {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

label.add-photos input.add-photos-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

label.add-photos:has(input:focus-visible) {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

li.photo-to-list {
  position: relative;
}

li.photo-to-list button.remove-photo {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
}

/* A label: a short word or two that says what something is, such as the
   reason of a Flag or a Member's role. Ink on a white pill, outlined in Ink. */
.chip {
  display: inline-block;
  margin: 0.25rem 0 0;
  padding: 0.125rem 0.625rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.chips {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.chips .chip {
  margin: 0;
}

/* A Member's initial in a circle, before their name. */
.initial {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
}

ul.member-rows li.row,
ul.member-rows a.row {
  min-height: 4rem;
}

ul.member-rows .row-text {
  flex: 1;
}

/* An Item's photo on the screen of a Flag or an open Match. */
.item-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0 0 1rem;
  object-fit: cover;
  border-radius: var(--radius);
}

/* On a phone the images of a card or a detail run to the screen's sides:
   they cancel main's side padding and have square corners. */
@media (max-width: 819px) {
  div.photos,
  img.cover,
  .cover-placeholder.cover,
  .item-photo {
    margin-left: -1rem;
    margin-right: -1rem;
  }

  div.photos img,
  img.cover,
  .cover-placeholder.cover,
  .item-photo {
    max-width: none;
    border-radius: 0;
  }

  img.cover,
  .cover-placeholder.cover,
  .item-photo {
    width: calc(100% + 2rem);
  }
}
