:root {
  --concrete: #d9d8d0;
  --paper: #f4f3ee;
  --ink: #171a1f;
  --muted: #5b5f66;
  --tape: #8db7f0;
  --out: #f59b3d;
  --danger: #a8231b;
  --line: #b9b7ac;
  --font: "Bricolage Grotesque", system-ui, sans-serif;
  --marker: "Caveat Brush", "Segoe Print", cursive;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--concrete);
  color: var(--ink);
  font: 1rem/1.5 var(--font);
  /* Mobile Safari's bottom bar can collapse/expand a beat after scrolling and cover content
     flush with the viewport edge; this buffer keeps bottom actions clear of it. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) calc(env(safe-area-inset-bottom, 0px) + 2rem) env(safe-area-inset-left, 0px);
  overflow-x: hidden;
}
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.wrap { max-width: 56rem; margin: 0 auto; padding: 0 1rem 4rem; }

/* header */
.bar {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1.5rem;
  padding: 1.25rem 0 1rem; border-bottom: 4px solid var(--ink);
}
.mark { font-size: 2rem; font-weight: 800; letter-spacing: -.04em; text-decoration: none; margin-right: auto; }
.bar nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.bar nav a { text-decoration: none; font-weight: 600; padding: .25rem 0; border-bottom: 3px solid transparent; }
.bar nav a[aria-current] { border-bottom-color: var(--ink); }
.count {
  display: inline-block; min-width: 1.4em; margin-left: .35em; padding: 0 .35em;
  background: var(--out); border-radius: 2px; text-align: center; font-size: .85em;
}
.who { color: var(--muted); font-size: .9rem; display: flex; gap: .75rem; align-items: baseline; }

main { padding-top: 1.5rem; }
main > * + * { margin-top: 1.5rem; }
h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.sub { color: var(--muted); }
.head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* item rows: a strip of tape on a shelf line */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: minmax(0, 19rem) 1fr auto;
  gap: .5rem 1.5rem; align-items: start;
  padding: 1.5rem .5rem; border-bottom: 2px solid var(--line);
}
.tape {
  --tilt: 0deg;
  background: var(--tape); transform: rotate(var(--tilt));
  justify-self: start; padding: .35rem 1rem .25rem; font: 1.4rem/1.15 var(--marker); overflow-wrap: anywhere;
  clip-path: polygon(0 0, 100% 0, 98% 25%, 100% 50%, 98% 75%, 100% 100%, 0 100%, 2% 75%, 0 50%, 2% 25%);
  transition: background-color .35s;
}
.tape.out { background: var(--out); }
.meta { min-width: 0; display: grid; gap: .4rem; justify-items: start; }
.meta p { margin: 0; }
.meta .notes { overflow-wrap: anywhere; font-size: 1.1rem; }
.meta .status { color: var(--muted); font-size: 1.1rem; line-height: 1.5; }
.meta .status b { color: var(--ink); font-weight: 600; }
.meta .late { color: var(--danger); font-weight: 600; }
.lead { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.thumb { flex: none; width: 4.5rem; height: 4.5rem; object-fit: cover; border: 2px solid var(--ink); border-radius: 3px; }
.acts { display: flex; gap: .5rem; align-self: center; flex-wrap: wrap; justify-content: flex-end; }

/* controls */
button, input, textarea { font: inherit; color: inherit; }
.btn {
  background: var(--ink); color: var(--paper); border: 2px solid var(--ink);
  padding: .4rem .9rem; border-radius: 3px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
a.btn { text-decoration: none; display: inline-block; }
.btn.quiet { background: transparent; color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn:hover { filter: brightness(1.25); }
.btn.quiet:hover, .btn.danger:hover { filter: none; background: rgba(0,0,0,.07); }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-weight: 600; margin-bottom: .75rem; }
input[type=text], input[type=password], textarea, select {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 3px; font-weight: 400;
}
/* name suggestions */
.suggest-wrap { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + .2rem); z-index: 5; max-height: 11rem; overflow-y: auto;
  margin: 0; padding: .25rem; list-style: none; background: var(--paper); font-weight: 400;
  border: 2px solid var(--ink); border-radius: 3px; box-shadow: 3px 3px 0 rgba(0,0,0,.2);
}
.suggest[hidden] { display: none; }
.suggest li { padding: .6rem .6rem; min-height: 2.6rem; box-sizing: border-box; border-radius: 3px; cursor: pointer; }
.suggest li:hover { background: var(--ink); color: var(--paper); }
input[type=date], input[type=file] { display: block; margin-top: .25rem; font-weight: 400; }
/* iOS Safari paints type=date wider than its CSS box and adds native chrome; strip it (tap still opens the picker). */
input[type=date] { appearance: none; -webkit-appearance: none; width: 100%; min-width: 0; min-height: 2.6rem; padding: .5rem .6rem; background: var(--paper); border: 2px solid var(--ink); border-radius: 3px; }
label.check { display: flex; gap: .4rem; align-items: center; font-weight: 400; }
select { width: 100%; }
textarea { resize: vertical; min-height: 4.5rem; }
.filters { display: flex; gap: 1rem 1.5rem; flex-wrap: wrap; align-items: center; }
.filters input[type=text] { margin: 0; max-width: 20rem; }
.filters select { margin: 0; width: auto; }
.filters label { display: flex; gap: .4rem; align-items: center; margin: 0; font-weight: 400; }

.empty { padding: 2rem 0; color: var(--muted); }

/* auth + dialog */
.auth { max-width: 24rem; margin: 12vh auto 0; padding: 0 1rem; }
.auth h1 { font-size: 3rem; font-weight: 800; letter-spacing: -.05em; line-height: 1; }
.auth p { margin: .5rem 0 1.5rem; color: var(--muted); }
.error { color: var(--danger); font-weight: 600; margin-bottom: .75rem; }
dialog {
  width: min(28rem, calc(100vw - 2rem)); padding: 1.5rem; background: var(--concrete);
  border: 4px solid var(--ink); border-radius: 3px; color: var(--ink);
}
dialog::backdrop { background: rgba(23,26,31,.55); }
dialog form { display: block; }
.thumb { cursor: zoom-in; }
dialog.lightbox { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; padding: 0; background: none; border: 0; overflow: hidden; }
dialog.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox img { display: block; max-width: calc(100vw - 2rem); max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); border: 4px solid var(--ink); border-radius: 3px; cursor: zoom-out; }
.notice { padding: .6rem .8rem; border-radius: 6px; background: var(--bg-soft, rgba(128,128,128,.15)); }
.dlg-acts { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.dlg-acts .danger { margin-right: auto; }

.invite { display: flex; gap: .75rem; align-items: center; padding: .6rem 0; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.invite code { flex: 1 1 18rem; min-width: 0; overflow-wrap: anywhere; }
.invite .used { color: var(--muted); }

#toast {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 0 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px)); pointer-events: none;
  opacity: 0; transform: translateY(1rem); transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: none; }
#toast span { background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: 3px; max-width: 100%; }

/* iOS zooms on focus when a field renders under 16px; floor it rather than disabling pinch-zoom. */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}
/* Touch: bigger tap targets, no hover-dependent styling. */
@media (pointer: coarse) {
  .btn, .bar nav a { min-height: 44px; display: inline-flex; align-items: center; }
  .bar nav a { padding: 0; }
  a.btn { display: inline-flex; }
}
.btn, .thumb { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* Mobile: nav and account collapse behind a hamburger; route() re-renders on navigation, which closes it. */
.menu-btn { display: none; }
@media (max-width: 768px) {
  .menu-btn {
    display: inline-flex; align-items: center; order: 1; min-width: 44px; min-height: 44px; justify-content: center;
    font: inherit; font-size: 1.5rem; background: none; border: 0; color: inherit; cursor: pointer;
  }
  .bar nav, .bar .who { display: none; order: 2; flex-basis: 100%; }
  .bar.open nav { display: flex; flex-direction: column; gap: 0; }
  .bar.open .who { display: flex; justify-content: space-between; align-items: center; }
}
@media (max-width: 48rem) {
  .row { grid-template-columns: 1fr; }
  .acts { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
[hidden] { display: none !important; }
fieldset { border: 0; padding: 0; margin: 0 0 .75rem; } legend { padding: 0; font-weight: 700; margin-bottom: .25rem; }
fieldset label.check { padding: .3rem 0; min-height: 2.2rem; }
