:root {
  --peg: #e7e5df;
  --peg-dot: #cfccc3;
  --yellow: #f6c945;
  --ink: #1c1b18;
  --ink-2: #5d5a51;
  --ink-3: #807c70;
  --manila: #f7ecd2;
  --manila-2: #efe0bc;
  --manila-line: #d9c797;
  --out: #fbe3d3;
  --out-line: #e6b598;
  --rust: #a8410f;
  --green: #1d6b43;
  --red: #a72a1c;
  --red-bg: #fbe5e0;
  --display: "Barlow Condensed", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --sans: "Barlow", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 400 15px/1.4 var(--sans);
  background-color: var(--peg);
  /* a pegboard */
  background-image: radial-gradient(circle at 12px 12px, var(--peg-dot) 2.6px, transparent 3.2px);
  background-size: 24px 24px;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- top ---- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--yellow);
  border-bottom: 3px solid var(--ink);
}
.top-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 28px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}
.title h1 {
  margin: 0;
  font: 700 34px/1 var(--display);
  letter-spacing: -0.005em;
}
.counts { margin: 2px 0 0; font-weight: 500; font-size: 14px; }
.search { position: relative; }
.search svg {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
}
.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffdf5;
  font-size: 15.5px;
}
.search input:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
.top-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.who { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who b { font-weight: 600; }
.add-open {
  height: 44px;
  padding: 0 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: var(--yellow);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.add-open:hover { background: #33312b; }

/* ---- board: every item is a hang tag on the pegboard ---- */
.board { max-width: 1240px; margin: 0 auto; padding: 26px 28px 60px; }
.sync { margin: 0 0 12px; font-weight: 500; color: var(--rust); }
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 22px 20px;
  align-items: start;
}
.tag-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 218px;
  padding: 14px 16px 12px;
  background: var(--manila);
  border: 1px solid var(--manila-line);
  /* clipped top corners, like a luggage tag */
  clip-path: polygon(22px 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%, 0 22px);
  filter: drop-shadow(0 2px 2px rgba(60, 50, 20, 0.2));
}
.tag-card.is-out { background: var(--out); border-color: var(--out-line); }
.eyelet {
  position: absolute;
  top: 9px; left: 50%;
  width: 14px; height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--peg);
  border: 2.5px solid #a99a70;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.25);
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px 0 8px; }
.asset { font: 500 12.5px/1 var(--mono); letter-spacing: 0.02em; color: var(--ink-2); margin: 0; overflow-wrap: anywhere; }
.status { font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-in { color: var(--green); }
.status-out { color: var(--rust); }
.gear-name {
  margin: 14px 0 0;
  font: 600 25px/1.05 var(--display);
  overflow-wrap: anywhere;
}
.gear-type { margin: 2px 0 10px; color: var(--ink-3); font-size: 13.5px; }

.out-form { display: flex; gap: 6px; margin-top: auto; }
.out-form input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 9px;
  border: 1.5px solid #bda977;
  border-radius: 6px;
  background: #fffdf6;
}
.out-form input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-out:hover:not(:disabled) { background: #33312b; }
.holder { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.holder-line { margin: 0; min-width: 0; }
.holder-name { display: block; font-weight: 600; font-size: 16px; overflow-wrap: anywhere; line-height: 1.2; }
.holder-since { display: block; color: var(--ink-2); font-size: 13px; }
.btn-in { background: transparent; color: var(--ink); }
.btn-in:hover:not(:disabled) { background: var(--ink); color: #fff; }
.history-link {
  align-self: flex-start;
  margin: 9px 0 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 13.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.history-link:hover { color: var(--ink); }
.err { margin: 7px 0 0; color: var(--red); font-size: 13.5px; font-weight: 500; overflow-wrap: anywhere; }
.err a { font-weight: 600; }
.err-block {
  flex-basis: 100%;
  padding: 9px 11px;
  border-radius: 7px;
  background: var(--red-bg);
}
.empty {
  grid-column: 1 / -1;
  padding: 44px 20px;
  text-align: center;
  background: rgba(255, 253, 245, 0.85);
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* ---- dialogs ---- */
.sheet {
  width: min(460px, calc(100vw - 28px));
  max-height: min(86vh, 720px);
  padding: 18px 20px 20px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fffaf0;
  color: var(--ink);
}
.sheet::backdrop { background: rgba(28, 27, 24, 0.5); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet h2 { margin: 0; font: 600 28px/1.05 var(--display); overflow-wrap: anywhere; }
.sheet .asset { margin-bottom: 5px; }
.close {
  flex: none;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.close:hover { background: #efe6d1; }
.sheet form label { display: block; margin: 0 0 4px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.sheet form input, .sheet form select {
  display: block;
  width: 100%;
  height: 40px;
  margin-bottom: 12px;
  padding: 0 10px;
  border: 1.5px solid #bda977;
  border-radius: 6px;
  background: #fff;
}
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.primary {
  width: 100%;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--yellow);
  font-weight: 600;
  cursor: pointer;
}
.primary:hover { background: #fbd768; }
.primary:disabled { opacity: 0.6; cursor: progress; }

.timeline { list-style: none; margin: 0 0 4px; padding: 0 0 0 14px; border-left: 2px solid #d9c797; }
.timeline li { position: relative; padding: 0 0 12px 8px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -20px; top: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fffaf0;
  border: 2px solid #a99a70;
}
.timeline li.is-open::before { background: var(--rust); border-color: var(--rust); }
.tl-person { display: block; font-weight: 600; overflow-wrap: anywhere; }
.tl-dates { display: block; color: var(--ink-2); font-size: 13.5px; }
.tl-dates b { color: var(--rust); font-weight: 600; }
.tl-empty { margin: 4px 0 10px; color: var(--ink-2); }
.remove { margin-top: 12px; padding-top: 12px; border-top: 1px solid #e6dcc4; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.remove-q { flex-basis: 100%; font-weight: 500; overflow-wrap: anywhere; }
.remove-actions { display: flex; gap: 8px; }
.btn-quiet { background: transparent; color: var(--ink-2); border-color: #bdb29b; font-weight: 500; }
.btn-quiet:hover { color: var(--ink); border-color: var(--ink); }
.btn-danger { background: var(--red); border-color: var(--red); }

/* ---- phones ---- */
@media (max-width: 860px) {
  .top { position: static; }
  .top-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title right" "search search";
    padding: 12px 16px 14px;
    gap: 10px 12px;
  }
  .title { grid-area: title; min-width: 0; }
  .title h1 { font-size: 29px; }
  .search { grid-area: search; }
  .top-right { grid-area: right; flex-direction: column-reverse; align-items: flex-end; gap: 4px; }
  .add-open { height: 38px; padding: 0 12px; }
  .who { max-width: 120px; font-size: 13px; }
  .board { padding: 18px 16px 72px; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .tag-card { min-height: 0; }
  .out-form { margin-top: 2px; }
  .holder { margin-top: 2px; }
}
