/* The kit stylesheet: classless base plus a few component classes.
   One file, no framework, no build step, no remote reference. */

:root {
  color-scheme: light dark;
  --bg: #ffffff; --fg: #1b1f24; --muted: #566170; --line: #c9d0d8; --card: #f3f5f8;
  --link: #0a58b0; --btn-bg: #0a58b0; --btn-fg: #ffffff; --warn: #9a5b00; --bad: #b42318;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --fg: #e8ebef; --muted: #a3adba; --line: #3a424d; --card: #1e232a;
    --link: #8cb8f5; --btn-bg: #3b82e0; --btn-fg: #08111f; --warn: #e3b341; --bad: #ff8a80;
  }
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0 auto;
  max-width: 42rem;
  padding: 1rem;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
}

h1, h2, h3 { line-height: 1.25; margin: 1.5rem 0 0.75rem; }
h1 { font-size: 1.6rem; margin-top: 1rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p, ul, ol, form, table { margin: 0 0 1rem; }
ul, ol { padding-left: 1.5rem; }
li { margin: 0.25rem 0; }
a { color: var(--link); text-decoration: underline; text-underline-offset: 0.15em; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--card);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* forms: 16 px text (no zoom on iOS) and touch targets of 44 px and more */
label { display: inline-block; }
input, select, textarea, button { font: inherit; font-size: 1rem; color: inherit; }

input[type="text"], input[type="email"], input[type="search"], input[type="password"],
input[type="number"], select, textarea {
  min-height: 2.75rem;
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

input[type="checkbox"], input[type="radio"] { width: 1.5rem; height: 1.5rem; vertical-align: middle; }

button {
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 1rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--link); border: 1px solid var(--line); }

/* filters: one compact block. People: the select and its button on one row. Events: a details
   element named Filters (collapsed on the phone, the active filters as chips in its summary);
   from 900 px the fields are always shown, in one row */
form.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
form.filters > label { display: flex; align-items: center; gap: 0.5rem; }
form.filters select { width: auto; }
form.filters .field { display: flex; flex-direction: column; flex: 1 1 100%; }
form.filters .field select, form.filters .field input { width: 100%; }
details.filters-box { margin: 0 0 1rem; }
details.filters-box > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem;
  min-height: 2.75rem; padding: 0 0.75rem; cursor: pointer; font-weight: 600;
  border: 1px solid var(--line); border-radius: 6px;
}
details.filters-box[open] > summary { margin-bottom: 0.5rem; }
.chip { font-weight: 400; font-size: 0.9rem; padding: 0.1rem 0.5rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--card); }

/* tables scroll sideways inside the column on a narrow screen */
table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
th, td { padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-weight: 600; white-space: nowrap; }
/* a phone number cell keeps the number on one line; a narrow table scrolls inside the column instead */
td.num { white-space: nowrap; }

/* the navigation bar: on the phone the app name and the user menu, then the top items,
   then the sub-tabs of the section; from 900 px the app name, the top items and the user
   menu share one row. Every row wraps, so nothing scrolls sideways. The current page is marked. */
nav { padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); }
nav .bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; }
nav .app { order: 1; font-weight: 700; }
nav .bar > details.actions { order: 2; margin-left: auto; }
nav ul.top { order: 3; flex-basis: 100%; }
nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; list-style: none; margin: 0; padding: 0; }
nav ul.sub { margin-top: 0.5rem; }
nav li { margin: 0; }
nav form { margin: 0; }

nav a {
  display: inline-block;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
}

nav a[aria-current] { background: var(--card); color: var(--fg); font-weight: 700; box-shadow: inset 0 -3px 0 var(--link); }

/* the status strip of the scan page: one card per condition, the glyph beside
   the label, the hint on its own line below it */
#scan-strip, ul.strip { list-style: none; margin: 0 0 1rem; padding: 0; }

#scan-strip li, ul.strip li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.75rem;
  margin: 0 0 0.5rem;
  padding: 0.75rem;
  background: var(--card);
  border-left: 6px solid var(--warn);
  border-radius: 6px;
}

#scan-strip .glyph, ul.strip .glyph { grid-row: 1 / span 2; font-size: 1.5rem; line-height: 1.2; }
#scan-strip li > span:not(.glyph):not(.hint), ul.strip li > span:not(.glyph):not(.hint) { grid-column: 2; font-weight: 600; }
#scan-strip .hint, ul.strip .hint { grid-column: 2; font-size: 0.875rem; color: var(--muted); }

/* the photo button: a label that looks like a big button over a visually hidden file input */
.photo-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.photo-button:focus-within { outline: 3px solid var(--link); outline-offset: 2px; }

.check label { display: flex; align-items: center; gap: 0.6rem; min-height: 2.75rem; }
.check input { width: 1.4rem; height: 1.4rem; }

/* not display:none: the input stays focusable and a test can still set its file */
.photo-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* a small pill, and the empty state */
.badge, .flag {
  display: inline-block;
  padding: 0.05rem 0.6rem;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}

.flag { color: var(--bad); border-color: var(--bad); }
.empty { padding: 1rem; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 6px; }

/* the assign page rows: each board or room is a link that is a touch target on the phone */
main[data-step] li > a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.25rem 0.5rem;
}

/* the Actions menu of a list row: a details element, its summary is the button */
details.actions { position: relative; }
details.actions summary {
  display: list-item;
  white-space: nowrap; /* the body breaks words anywhere, a narrow table cell would break "Actions" */
  width: fit-content;
  min-height: 2.75rem;
  min-width: 2.75rem;
  line-height: 2.75rem;
  padding: 0 1rem;
  text-align: center;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
details.actions summary::-webkit-details-marker { display: none; }
details.actions summary::marker { content: ""; }
details.actions button { white-space: nowrap; }
details.actions ul { list-style: none; margin: 0.5rem 0 0; padding: 0; }
details.actions li { margin: 0 0 0.5rem; }
details.actions form { margin: 0; }
details.actions a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0 0.75rem;
  white-space: nowrap;
}
details.actions li:has(> form > button.destructive) { padding-top: 0.5rem; border-top: 1px solid var(--line); }

/* the menu of the top bar and of a page title opens over the page, at the right edge */
nav details.actions[open] > ul, .titlerow details.actions[open] > ul {
  position: absolute;
  right: 0;
  z-index: 10;
  min-width: 12rem;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

nav details.actions[open] > ul button, .titlerow details.actions[open] > ul button { width: 100%; text-align: left; }

/* the title row: the page title and its Actions button */
.titlerow { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.result { padding: 0.5rem 0.75rem; background: var(--card); border-left: 6px solid var(--link); border-radius: 6px; }
.result form { display: inline; }

/* The desktop layout, from 900 px: the page uses the width and the controls are
   sized for a pointer. Up to 899 px the rules above are the whole sheet (the phone
   layout: the 42rem column and the 2.75rem targets). */
@media (min-width: 900px) {
  body { max-width: 90rem; padding: 1rem 2rem; }

  input[type="text"], input[type="email"], input[type="search"], input[type="password"],
  input[type="number"], select, textarea { min-height: 2rem; max-width: 36rem; padding: 0.2rem 0.5rem; }
  button { min-height: 2rem; min-width: 2rem; padding: 0.2rem 0.9rem; }
  .check label { min-height: 2rem; }
  details.actions summary { min-height: 2rem; min-width: 2rem; line-height: 2rem; padding: 0 0.9rem; }
  nav a { min-height: 2rem; min-width: 2rem; padding: 0.25rem 0.75rem; }
  details.actions a { min-height: 2rem; min-width: 2rem; }
  nav ul.top { order: 2; flex: 1 1 auto; }
  nav .bar > details.actions { order: 3; }
  main[data-step] li > a { min-height: 2rem; }
  .photo-button { min-height: 2.5rem; width: auto; display: inline-flex; padding: 0.4rem 1rem; font-size: 1rem; }

  /* the Events filter: always shown, one row, no summary */
  details.filters-box::details-content { content-visibility: visible; }
  details.filters-box > summary { display: none; }
  form.filters { align-items: flex-end; }
  form.filters .field { flex: 0 1 auto; }
  form.filters .field input, form.filters .field select { width: 11rem; }
  form.filters .field input[inputmode="numeric"] { width: 8rem; }

  table { display: table; width: 100%; overflow-x: visible; }
  th { white-space: normal; }

  /* Boards and Places: one wrapper, the list on the left and the form on the right */
  .split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); column-gap: 2rem; align-items: start; }
  .split > * { grid-column: 2; }
  .split > table, .split > ul.boards, .split > .empty { grid-column: 1; grid-row: 1 / span 40; }
  .split > h2:first-child { margin-top: 0; }
}
