/* Giving Log. Mobile first (375 px), light and dark, prints cleanly.
   Appearance (appearance.js) only sets custom properties and data-theme / data-bg / data-text on <html>; with none of
   them set, every value below is the standard look. */
:root {
  --accent: var(--a-l, #2e6b4f); --accent-ink: var(--a-ink-l, #ffffff); --accent2: #1f4e79;
  --bg: #f4f6f3; --card: #ffffff; --text: #1a1f1c; --muted: #5d6762; --line: #dfe5e0;
  --ok: #1e7a46; --ok-bg: #e5f4ea; --miss: #b3261e; --miss-bg: #fdecea; --warn: #8a5a00; --warn-bg: #fff4dc; --info: #1f4e79; --info-bg: #e8f0f8;
  --link: #1f4e79;
  --bg-layer: var(--bgl-l, none);
  /* the update bar (update-check.js): the page's colors reversed, above the tab bar */
  --uc-bg: var(--text); --uc-ink: var(--bg); --uc-btn-bg: var(--bg); --uc-btn-ink: var(--text); --uc-bottom: 72px;
  color-scheme: light dark;
}
/* Dark: the phone's setting, unless Light was chosen; or Dark chosen on a light phone. Keep the two blocks the same. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: var(--a-d, #6cc59a); --accent-ink: var(--a-ink-d, #0d1a13); --accent2: #8ab8e6;
    --bg: #121614; --card: #1c211e; --text: #edf2ee; --muted: #a3ada7; --line: #2f3833;
    --ok: #7fd6a2; --ok-bg: #173323; --miss: #ffb4ab; --miss-bg: #3b1d1a; --warn: #f2c66d; --warn-bg: #352a12; --info: #9cc3ec; --info-bg: #182736;
    --link: #9cc3ec;
    --bg-layer: var(--bgl-d, none);
  }
  :root:not([data-theme="light"]) .bgprev { background: var(--td); }
  :root:not([data-theme="light"]) .swatch .dot { background: var(--sd); }
}
:root[data-theme="dark"] {
  --accent: var(--a-d, #6cc59a); --accent-ink: var(--a-ink-d, #0d1a13); --accent2: #8ab8e6;
  --bg: #121614; --card: #1c211e; --text: #edf2ee; --muted: #a3ada7; --line: #2f3833;
  --ok: #7fd6a2; --ok-bg: #173323; --miss: #ffb4ab; --miss-bg: #3b1d1a; --warn: #f2c66d; --warn-bg: #352a12; --info: #9cc3ec; --info-bg: #182736;
  --link: #9cc3ec;
  --bg-layer: var(--bgl-d, none);
  color-scheme: dark;
}
:root[data-theme="dark"] .bgprev { background: var(--td); }
:root[data-theme="dark"] .swatch .dot { background: var(--sd); }
:root[data-theme="light"] { color-scheme: light; }
html[data-text="small"] { --fs: 15px; }
html[data-text="large"] { --fs: 20px; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs, 17px)/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
/* a chosen background: drawn behind everything, fixed while the page scrolls; cards stay solid */
html[data-bg] body { background: transparent; }
html[data-bg] body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--bg-layer); }
/* over a photo, text that is not on a card sits on a solid plate of the page color, so it reads as well as on plain */
html[data-bg="photo"] main > :is(h1, p):not(.flash, .helper), html[data-bg="photo"] #vglist > p, html[data-bg="photo"] .report > :not(.card) {
  background: var(--bg); border-radius: 10px; padding: 2px 10px; width: fit-content; max-width: 100%; }
html[data-bg="photo"] main > label { display: block; background: var(--bg); border-radius: 12px; padding: 6px 10px; }
html[data-bg="photo"] .ghost { background: var(--card); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
h1 { font-size: 1.5rem; margin: 6px 0 12px; }
h2 { font-size: .95rem; margin: 0 0 8px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
h2.mt { margin-top: 14px; }
p { margin: 6px 0; overflow-wrap: anywhere; }
ul, ol { margin: 6px 0; padding-left: 22px; } li { margin: 4px 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }

/* top bar and tabs */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-size: 1.1rem; white-space: nowrap; }
.grow { flex: 1 1 auto; }
.hb { flex: 0 0 auto; background: var(--card); color: var(--accent); border: 1px solid var(--line); border-radius: 20px; padding: 6px 14px; font-weight: 600; min-height: 40px; }
.hb.lang { font-size: .85rem; padding: 6px 10px; }
.yearpick select { width: auto; min-height: 40px; padding: 6px 28px 6px 10px; border-radius: 20px; font-weight: 600; background: var(--card); }
main { padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 680px; margin: 0 auto; }
main.center { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { background: none; border: 0; padding: 8px 0 6px; min-height: 56px; font-size: .7rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 1.3rem; line-height: 1; }
.tabs button.on { color: var(--accent); font-weight: 700; }

/* cards and buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 0 12px; display: block; width: 100%; text-align: left; }
button.card { cursor: pointer; }
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 10px 16px; min-height: 44px; font-weight: 600; text-decoration: none; text-align: center; cursor: pointer; }
.ghost, .btn.ghost, button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-height: 44px; }
button.ghost.small { padding: 4px 10px; min-height: 36px; font-size: .8rem; }
.ghost.danger, .danger { color: var(--miss) !important; }
.wide { display: flex; width: 100%; margin: 4px 0 14px; }
button.link { background: none; border: 0; color: var(--link); text-decoration: underline; padding: 0; min-height: 0; cursor: pointer; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.row > label { flex: 1 1 130px; min-width: 0; }
.row.end { margin: 4px 0 12px; }
button[disabled] { opacity: .5; }
.flash { background: var(--ok-bg); color: var(--ok); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.banner { padding: 10px 16px; font-weight: 600; }
.danger-bg { background: var(--miss-bg); color: var(--miss); }
.warnbox { border-color: var(--warn); background: var(--warn-bg); }
.warn { color: var(--warn); }
.review { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn); border-radius: 8px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; }
.src { font-size: .8rem; white-space: nowrap; }

/* home */
.hero { background: linear-gradient(135deg, var(--hero1, #2e6b4f), var(--hero2, #1f4e79)); color: #fff; border: 0; }
.muted-on { color: rgba(255, 255, 255, .85); margin: 0; }
.big-number { font-size: 2.2rem; font-weight: 800; margin: 2px 0 10px; letter-spacing: -.01em; }
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kinds div { background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 8px 10px; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; }
.kinds span { grid-row: span 2; font-size: 1.3rem; }
.kinds small { color: rgba(255, 255, 255, .85); font-size: .75rem; }
.addgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.addbtn { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; min-height: 44px; cursor: pointer; }
.addbtn span { font-size: 1.5rem; }
.addbtn small { color: var(--muted); font-size: .75rem; }
.addgrid.compact { margin-top: 8px; } .addgrid.compact .addbtn { flex-direction: row; align-items: center; gap: 8px; font-size: .85rem; }
.addgrid.compact .addbtn span { font-size: 1.2rem; }
.openbox { display: flex; flex-direction: column; gap: 2px; border-left: 6px solid var(--ok); }
.openbox.has { border-left-color: var(--miss); }
.chipsrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 7px 14px; min-height: 40px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.guide p { margin: 8px 0; }

/* lists */
.gift { display: flex; gap: 12px; align-items: center; }
.gicon { font-size: 1.6rem; flex: 0 0 auto; }
.gmain { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gmain .small { overflow: hidden; text-overflow: ellipsis; }
.gval { flex: 0 0 auto; font-weight: 700; white-space: nowrap; }
.badge { align-self: flex-start; font-size: .72rem; font-weight: 700; border-radius: 10px; padding: 1px 8px; margin-top: 2px; }
.badge.open { background: var(--miss-bg); color: var(--miss); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.add { text-align: center; color: var(--accent); font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv > span:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.kv a { word-break: break-all; }

/* forms */
input, select, textarea { width: 100%; padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.form label { display: block; margin-bottom: 12px; font-size: .85rem; color: var(--muted); }
.form label input, .form label select, .form label textarea { margin-top: 4px; font-size: 1rem; }
label.inline { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; margin: 6px 0; }
label.inline input, .have input { width: 24px; height: 24px; min-height: 0; flex: 0 0 auto; accent-color: var(--accent); margin: 0; }
fieldset.q { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 0 0 12px; }
fieldset.q legend { font-size: .9rem; padding: 0 4px; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 0 0 12px; }
details summary { cursor: pointer; font-weight: 600; min-height: 32px; display: list-item; }
.sub { margin: 0 0 12px; }
.item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.itemmain { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px 0; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.total { text-align: right; margin: 10px 0; }
.helper { background: var(--info-bg); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; color: var(--text); }
.helper ul { padding-left: 18px; }
.filebtn { cursor: pointer; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 10px; }
.thumbs figure { position: relative; margin: 0; width: 84px; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.thumbs figure button { position: absolute; top: -8px; right: -8px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 50%; width: 30px; height: 30px; padding: 0; line-height: 1; cursor: pointer; }

/* checklist rows */
.rule { display: flex; gap: 10px; padding: 10px; border-radius: 12px; margin-bottom: 8px; background: var(--bg); border-left: 5px solid var(--line); }
.rule p { margin: 4px 0 0; }
.ri { flex: 0 0 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; color: #fff; }
.rule.ok { border-left-color: var(--ok); } .rule.ok .ri { background: var(--ok); color: var(--card); }
.rule.missing { border-left-color: var(--miss); background: var(--miss-bg); } .rule.missing .ri { background: var(--miss); color: var(--card); }
.rule.warn { border-left-color: var(--warn); background: var(--warn-bg); } .rule.warn .ri { background: var(--warn); color: var(--card); }
.rule.info { border-left-color: var(--info); } .rule.info .ri { background: var(--info); color: var(--card); }
.rule .st { font-weight: 700; }
.rule.missing .st { color: var(--miss); } .rule.ok .st { color: var(--ok); } .rule.warn .st { color: var(--warn); } .rule.info .st { color: var(--info); }
.have { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 600; min-height: 32px; }

/* report */
.sendbox { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.bring { font-weight: 700; font-size: 1.05rem; }
.rep-title { margin-top: 18px; }
.rep-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rep-table th, .rep-table td { text-align: left; padding: 5px 6px 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.rep-table .num { text-align: right; white-space: nowrap; }
.rep-table tr.tot td { font-weight: 800; border-top: 2px solid var(--text); }
.openlist li { margin: 8px 0; }
.rep-gift { padding: 6px 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.rep-gift .kv { border: 0; padding: 0; }
.rep-gift p { margin: 2px 0 0; }
.report section { overflow-x: auto; }

@media (min-width: 560px) {
  .kinds { grid-template-columns: repeat(4, 1fr); }
  .addgrid { grid-template-columns: repeat(4, 1fr); }
}
/* import and export */
.mapgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 10px; }
.mapgrid select { width: 100%; }
.implist { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 6px 0; }
.improw { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-bottom: 1px solid var(--line); margin: 0; font-weight: 400; }
.improw:last-child { border-bottom: 0; }
.improw input { width: 22px; height: 22px; flex: 0 0 auto; margin-top: 2px; }
.improw .impmain { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.improw.noDate, .improw.noAmount, .improw.noCharity, .improw.notMoney { opacity: .7; }

/* value guide */
.scrollx { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.scrollx .chip { flex: 0 0 auto; white-space: nowrap; }
details.vgitem { padding: 0; }
details.vgitem summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; list-style: none; }
details.vgitem summary::-webkit-details-marker { display: none; }
details.vgitem .vgname { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
details.vgitem .vgrange { white-space: nowrap; font-weight: 700; color: var(--accent); }
details.vgitem ul, details.vgitem .btn { margin: 0 12px 12px; }
details.vgitem ul { padding-left: 18px; }
input[type=search] { -webkit-appearance: none; appearance: none; }

/* appearance */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; margin: 0 0 12px; }
.swatch, .bgtile { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; padding: 8px 6px; min-height: 44px;
  background: var(--card); color: var(--text); border: 2px solid var(--line); border-radius: 14px; font-size: .8rem; cursor: pointer; text-align: center; }
.swatch.on, .bgtile.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 700; }
.swatch .dot { width: 34px; height: 34px; border-radius: 50%; background: var(--sl); border: 1px solid var(--line); }
.bgtile .bgprev { display: block; width: 100%; height: 54px; border-radius: 10px; border: 1px solid var(--line); background: var(--tl); }
.bgtile .bgprev.photo { display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.swatch .tick, .bgtile .tick { color: var(--accent); }
.textsizes .chip:nth-child(1) { font-size: .85rem; } .textsizes .chip:nth-child(3) { font-size: 1.15rem; }

@media print {
  /* :root three times outranks the dark-theme rules above, so a printout is always black on white */
  :root:root:root { --bg: #fff; --card: #fff; --text: #000; --muted: #444; --line: #bbb; --ok: #000; --miss: #000; --warn: #000; --info: #000; }
  html, body { background: #fff; color: #000; font-size: 10.5pt; }
  html[data-bg] body::before { display: none; }
  .top, .tabs, .noprint, .flash, .banner, #update-bar { display: none !important; }
  main { padding: 0; max-width: none; }
  .card.rep { border: 1px solid #bbb; break-inside: avoid; page-break-inside: avoid; }
  .review { border: 1px solid #000; background: none; color: #000; }
  a { color: #000; text-decoration: none; }
  .src { display: none; }
}
[hidden] { display: none !important; }
