/* Gift Hub layout. Mobile first; big tap targets and readable text throughout. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--text-base); line-height: 1.5;
}
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.75rem; }
code { font-size: 0.95em; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.5rem 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
.brand-mark { width: 28px; height: 28px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; gap: 0.4rem; }
.topbar-form { margin: 0; }
.page { max-width: 960px; margin: 0 auto; padding: 1rem 16px 3rem; }
.page-title { margin: 0.5rem 0 1rem; }
.back { margin: 0 0 0.5rem; }
.back a { display: inline-flex; min-height: var(--tap); align-items: center; text-decoration: none; font-weight: 600; }

/* Panels, notices */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel.narrow { max-width: 460px; margin: 1.5rem auto; }
.panel-danger { border-color: var(--danger); }
.lede { color: var(--text-muted); }
.notice { padding: 0.75rem 1rem; border-radius: var(--radius-sm); background: var(--ok-bg); color: var(--ok-text); }
.notice-error { background: var(--error-bg); color: var(--error-text); }
.notice-warn { background: var(--warn-bg); color: var(--warn-text); }

/* Forms and buttons */
.stack { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.3rem; font-weight: 600; }
.field input, .field select {
  font: inherit; font-weight: 400; min-height: var(--tap); padding: 0.5rem 0.75rem; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
}
.field input[type="file"] { padding: 0.6rem 0.5rem; }
.check { display: flex; align-items: center; gap: 0.6rem; min-height: var(--tap); }
.check input { width: 1.4rem; height: 1.4rem; accent-color: var(--primary); }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-bottom: 0.75rem; }
.inline-form .field { flex: 1 1 12rem; }
.inline-form .field-wide { flex: 3 1 18rem; }
.prefixed { display: flex; align-items: center; }
.prefixed .prefix { padding: 0 0.4rem 0 0; color: var(--text-muted); font-weight: 400; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: var(--tap); padding: 0.5rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { color: var(--text); border-color: var(--text-muted); }
.button:disabled { opacity: 0.45; cursor: default; }
.button-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.button-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-text); }
.button-quiet { background: transparent; }
.button-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-danger:hover { color: #fff; }
.button-big { font-size: 1.15rem; min-height: 56px; }
.button-small { min-height: 40px; padding: 0.3rem 0.75rem; font-size: 0.95rem; }

/* Avatars */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; }
.avatar-sm { width: 40px; height: 40px; font-size: 0.95rem; }
.avatar-md { width: 56px; height: 56px; font-size: 1.2rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.6rem; }
.avatar-c0 { background: var(--a0); } .avatar-c1 { background: var(--a1); }
.avatar-c2 { background: var(--a2); } .avatar-c3 { background: var(--a3); }
.avatar-c4 { background: var(--a4); } .avatar-c5 { background: var(--a5); }
.avatar-c6 { background: var(--a6); } .avatar-c7 { background: var(--a7); }

/* Home */
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
@media (min-width: 640px) { .people { grid-template-columns: repeat(2, 1fr); } }
.person-card {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.1rem; min-height: 96px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text); text-decoration: none;
}
.person-card:hover { color: var(--text); border-color: var(--primary); }
.person-card-text { display: grid; flex: 1; }
.person-card-name { font-size: 1.35rem; font-weight: 700; }
.person-card-count { color: var(--text-muted); }
.chevron { font-size: 2rem; color: var(--text-muted); }

/* Person page */
.person-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.person-head h1 { margin: 0; }
.app-section { margin-bottom: 2rem; border-top: 6px solid var(--app-accent); padding-top: 0.75rem; }
.app-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.app-head h2 { margin: 0; }
.app-icon { width: 32px; height: 32px; }
.freshness { margin: 0; font-size: 0.95rem; color: var(--text-muted); }
.freshness-stale, .freshness-missing { color: var(--warn-text); background: var(--warn-bg); padding: 0.2rem 0.6rem; border-radius: var(--radius-sm); display: inline-block; }
.empty { color: var(--text-muted); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card {
  display: grid; grid-template-columns: 112px 1fr; grid-template-areas: "media head" "details details";
  gap: 0.75rem 1rem; padding: 1rem; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--app-accent);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0;
}
@media (min-width: 420px) { .card { grid-template-columns: 140px 1fr; } }
.card-media { grid-area: media; display: flex; align-items: flex-start; justify-content: center; }
.card-head { grid-area: head; min-width: 0; overflow-wrap: anywhere; }
.card-details { grid-area: details; min-width: 0; overflow-wrap: anywhere; }
.card-details > :last-child { margin-bottom: 0; }
.card-media img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; background: var(--surface-2); border-radius: var(--radius-sm); }
.card-noimage { width: 100%; aspect-ratio: 1; padding: 25%; background: var(--surface-2); border-radius: var(--radius-sm); }
.card-title { font-size: 1.15rem; margin: 0.15rem 0 0.25rem; }
.card-subtitle { color: var(--text-muted); margin-bottom: 0.4rem; }
.priority { display: inline-block; font-size: 0.85rem; font-weight: 700; padding: 0.1rem 0.55rem; border-radius: 999px; border: 1.5px solid currentColor; }
.priority-1 { color: var(--p1); } .priority-2 { color: var(--p2); } .priority-3 { color: var(--p3); }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.4rem; }
.badge { font-size: 0.85rem; padding: 0.1rem 0.5rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.gift-note { background: var(--warn-bg); color: var(--warn-text); padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); }
.gift-note-label { font-weight: 700; }
.attributes { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.75rem; margin: 0 0 0.75rem; font-size: 0.95rem; }
.attributes div { display: contents; }
.attributes dt { color: var(--text-muted); }
.attributes dd { margin: 0; }
.links { display: grid; gap: 0.5rem; }
.store-link {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.6rem; min-height: var(--tap);
  padding: 0.5rem 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); text-decoration: none; font-weight: 600;
}
.store-link:hover { border-color: var(--app-accent); color: var(--text); }
.store-name { flex: 1 1 auto; }
.store-price { font-variant-numeric: tabular-nums; }
.store-stock { font-size: 0.85rem; font-weight: 500; color: var(--ok-text); }
.store-link-out .store-stock { color: var(--text-muted); }
.card-actions:empty { display: none; }
.volumes { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.75rem; }
.volume { border-top: 1px solid var(--border); padding-top: 0.6rem; }
.volume-title { font-weight: 600; margin-right: 0.4rem; }

/* Admin */
.admin-people { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.5rem; }
.admin-people li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.admin-person-name { font-weight: 700; }
.reorder { margin-left: auto; display: flex; gap: 0.25rem; }
.reorder form, .actions form { margin: 0; }
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.health { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.health th, .health td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.health .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.row-failing td { background: var(--error-bg); }
.row-off td { color: var(--text-muted); }
.avatar-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.sample { margin: 0 0 1rem; }
