body { font-family: system-ui, sans-serif; margin: 0; background: #fafafa; color: #222; }
main { max-width: 32rem; margin: 3rem auto; padding: 0 1rem; }
#avatar { border-radius: 50%; vertical-align: middle; }
#error { color: #b00020; }
button { padding: .5rem 1rem; }

/* Contact list */
button, input, textarea { font: inherit; }
button { min-height: 44px; min-width: 44px; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .75rem 0; }
.toolbar input[type="search"] { flex: 1; min-width: 0; }
input, textarea { min-height: 44px; padding: .4rem .6rem; box-sizing: border-box; width: 100%; border: 1px solid #888; border-radius: .25rem; }
#contact-list { list-style: none; margin: 0; padding: 0; }
#contact-list li { border-bottom: 1px solid #ddd; }
.contact { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; padding: .75rem .25rem; cursor: pointer; font-size: 1rem; }
.contact span { color: #555; }
:lang(zh-Hant) { line-height: 1.7; }
dialog { width: min(32rem, calc(100vw - 2rem)); border: 1px solid #888; border-radius: .5rem; padding: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
dialog label { display: block; margin: .6rem 0; font-size: 1rem; }
dialog label input, dialog label textarea { margin-top: .25rem; }
.danger { color: #b00020; margin-left: auto; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #1a56db; outline-offset: 2px; }

/* Offers & wants */
select { font: inherit; min-height: 44px; width: 100%; margin-top: .25rem; box-sizing: border-box; }
#listing-list, #match-list { list-style: none; margin: 0; padding: 0; }
#listing-list li, #match-list li { border-bottom: 1px solid #ddd; padding: .6rem .25rem; }
#listing-list li.closed { opacity: .6; }
#matches h2, dialog h2 { font-size: 1.15rem; }

/* Reminders */
#contact-reminder-list, #reminder-list { list-style: none; margin: 0; padding: 0; }
#contact-reminder-list li, #reminder-list li { border-bottom: 1px solid #ddd; padding: .6rem .25rem; }
li.overdue strong { color: #b00020; }

/* Data tools */
#data-status.error { color: #b00020; }
#erase { margin-left: 0; }

/* Print booklet: A5 pages. On screen it is a preview overlay; on paper only the pages print. */
#booklet-view { position: fixed; inset: 0; overflow-y: auto; background: #d8d8d8; z-index: 10; }
.bk-toolbar { background: #fafafa; padding: .75rem 1rem; border-bottom: 1px solid #888; position: sticky; top: 0; z-index: 1; }
.bk-toolbar form { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .25rem 1rem; }
.bk-toolbar label.check { display: flex; align-items: center; gap: .5rem; }
.bk-toolbar label.check input { width: auto; min-height: 0; margin: 0; }
.bk-hint { font-size: .85rem; color: #555; margin: .5rem 0 0; }
#booklet-pages { box-sizing: border-box; width: 148mm; max-width: 100%; min-height: 210mm; margin: 1rem auto; background: #fff; padding: 12mm; color: #000; font-size: 10pt; line-height: 1.5; font-family: "PingFang HK", "Noto Sans HK", system-ui, sans-serif; }
.bk-cover { text-align: center; padding: 55mm 0; break-after: page; }
.bk-cover h1 { font-size: 24pt; margin: 0 0 6mm; }
.bk-cover p { font-size: 13pt; margin: 2mm 0; }
.bk-cover .bk-meta { font-size: 10pt; color: #555; margin-top: 10mm; }
.bk-group { margin-bottom: 4mm; }
.bk-group h2 { font-size: 12pt; margin: 4mm 0 2mm; padding-bottom: 1mm; border-bottom: 1.5pt solid #000; break-after: avoid; }
.bk-entry { break-inside: avoid; padding: 2mm 0; border-bottom: .5pt solid #bbb; }
.bk-entry h3 { font-size: 11pt; margin: 0; }
.bk-sub { color: #333; }
.bk-label { font-weight: 600; }
body.booklet-open { overflow: hidden; }

@page { size: A5; margin: 12mm; }
@media print {
  body { background: #fff; overflow: visible; }
  body > *:not(#booklet-view) { display: none !important; }
  #booklet-view { position: static; overflow: visible; background: none; }
  .bk-toolbar { display: none; }
  #booklet-pages { width: auto; min-height: 0; margin: 0; padding: 0; }
}

/* Quick capture and contact actions */
button.primary { background: #1a56db; color: #fff; border: 0; border-radius: .25rem; font-weight: 600; }
.chips button { flex: 1; }
#quick-dialog textarea { margin-top: .25rem; }
#quick-error { color: #b00020; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; padding: 0 .25rem .75rem; }
.actions a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .9rem; border: 1px solid #888; border-radius: .25rem; color: #1a56db; text-decoration: none; background: #fff; }
