:root {
  color-scheme: light;
  --paper: #f3f5f0;
  --ink: #1c3028;
  --muted: #4e6258;
  --line: #d7e1d8;
  --forest: #183c32;
  --accent: #28664d;
  --pale: #e7f0e9;
  --white: #fff;
  font: 100%/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); }
a { color: var(--accent); text-underline-offset: .22em; }
a:hover { color: var(--forest); }
button, input, select, textarea { font: inherit; }
button, .button, input, select, textarea { border: 1px solid #b9cbbf; border-radius: .65rem; }
button, .button {
  min-height: 2.75rem; padding: .5rem .85rem; display: inline-flex; align-items: center;
  justify-content: center; gap: .35rem; background: var(--white); color: var(--forest);
  font-weight: 620; text-decoration: none; cursor: pointer;
}
button:hover, .button:hover { background: var(--pale); }
button:disabled { opacity: .48; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover { background: var(--forest); color: white; }
:focus-visible { outline: 3px solid #bc681a; outline-offset: 3px; }
h1, h2, h3, p, dl, ul, figure { margin: 0; }
h1, h2, h3 { overflow-wrap: anywhere; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.12; letter-spacing: -.055em; }
h2, h3 { font-size: 1.17rem; line-height: 1.3; letter-spacing: -.015em; }
input, select, textarea {
  min-width: 0; width: 100%; color: var(--ink); min-height: 2.75rem; background: white; padding: .5rem .65rem;
}
textarea { resize: vertical; }
input[type="file"] { padding: .4rem; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; min-height: auto; accent-color: var(--accent); flex: none; }
label { display: grid; min-width: 0; gap: .32rem; font-size: .94rem; font-weight: 600; }
label input, label textarea, label select { font-size: 1rem; font-weight: 400; }
.top { background: var(--forest); color: white; }
.top-inner { max-width: 74rem; margin: auto; min-height: 4.4rem; display: flex; padding: .5rem 1.5rem; gap: .7rem 2rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.brand { color: white; font-size: 1.27rem; letter-spacing: -.025em; font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand span { display: inline-grid; place-items: center; margin-right: .38rem; width: 2rem; height: 2rem; font-size: 1.5rem; background: #d8e9dc; color: var(--forest); border-radius: .55rem; }
.top a:hover { color: white; }
nav { display: flex; gap: .2rem; flex-wrap: wrap; }
nav a { display: flex; align-items: center; min-height: 2.75rem; padding: .48rem .7rem; border-radius: .55rem; color: #e0ebe3; text-decoration: none; font-weight: 620; }
nav a:hover, nav a[aria-current] { color: white; background: #31574a; }
main { max-width: 74rem; margin: auto; padding: clamp(1rem, 4vw, 2.75rem) 1.5rem 4rem; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 1rem; padding: clamp(1rem, 3vw, 1.45rem); min-width: 0; }
.diary-layout { display: grid; grid-template-columns: minmax(17rem, 20rem) minmax(0, 1fr); align-items: start; gap: clamp(1rem, 3vw, 2rem); }
.day-column, .entries, .stack, .report { display: grid; gap: 1rem; min-width: 0; }
.day-head { display: grid; gap: .3rem; padding: .35rem .1rem .45rem; }
.day-totals { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin-top: .55rem; color: var(--muted); font-size: .91rem; }
.day-totals span { display: inline-flex; align-items: center; gap: .42rem; }
.day-totals span + span::before { content: ''; width: .3rem; height: .3rem; border-radius: 50%; background: #6a8c79; }
.month { display: flex; align-items: center; justify-content: space-between; gap: .45rem; margin-bottom: .7rem; }
.month h2 { text-align: center; }
.month-step { min-width: 2.5rem; font-size: 1.45rem; padding: 0 .45rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .2rem; text-align: center; }
.weekday { font-size: .85rem; color: var(--muted); padding: .3rem 0; }
.cal-day { display: grid; place-items: start center; padding-top: .4rem; min-height: 2.5rem; position: relative; border-radius: .5rem; text-decoration: none; color: var(--ink); font-variant-numeric: tabular-nums; }
.cal-day:hover, .cal-day.today { background: var(--pale); }
.cal-day[aria-current] { background: var(--forest); color: white; font-weight: 700; }
.cal-day.has-entries::after, .legend span { background: var(--accent); border-radius: 50%; width: .36rem; height: .36rem; }
.cal-day.has-entries::after { content: ''; position: absolute; bottom: .28rem; left: calc(50% - .18rem); }
.cal-day[aria-current]::after { background: #cbe4d3; }
.legend { color: var(--muted); font-size: .86rem; display: flex; align-items: center; gap: .5rem; margin-top: .65rem; }
.date-jump { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .45rem; margin: 1.15rem 0 .7rem; }
.add-panel { background: #eaf1eb; }
.add-options { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .7rem; }
.add-options .selected { color: white; background: var(--forest); border-color: var(--forest); }
.empty { padding: 2.15rem 1.35rem; text-align: center; }
.empty p, .muted { color: var(--muted); }
.empty p { margin-top: .45rem; }
.small { font-size: .875rem; }
.notice, .error { border-radius: .6rem; padding: .75rem 1rem; margin-bottom: .8rem; }
.notice { background: #dceee0; color: #16482d; }
.error { background: #f9e6de; color: #7d3326; }
.login { max-width: 28rem; margin: clamp(.5rem, 5vw, 3rem) auto; }
.login h1 { margin-bottom: 1.2rem; font-size: clamp(1.7rem, 5vw, 2.45rem); }
.logout { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .65rem 1rem; }
.editor .heading-row { margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { margin: 0; padding: .75rem; min-width: 0; border: 1px solid var(--line); border-radius: .65rem; }
legend { padding: 0 .35rem; font-weight: 650; }
.people-list { display: grid; gap: .75rem; margin-bottom: .75rem; }
.entry-group { margin-top: .35rem; }
.entry-group > h2 { padding: .2rem .15rem 0; }
.work-fields { display: grid; gap: .65rem; }
.person-combobox { position: relative; }
.person-combobox > label { margin-bottom: .32rem; }
.person-control { display: flex; align-items: center; border: 1px solid #b9cbbf; border-radius: .65rem; background: white; }
.person-control:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.person-control-items { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: .25rem; padding: .25rem; min-width: 0; }
.person-control .person-query { flex: 1 1 8rem; width: auto; min-height: 2.3rem; padding: .25rem .4rem; border: 0; outline: none; }
.person-chip { display: inline-flex; align-items: center; gap: .2rem; max-width: 100%; padding: 0 .1rem 0 .55rem; background: var(--pale); border: 1px solid var(--line); border-radius: .45rem; font-size: .9rem; }
.person-chip > span { min-width: 0; overflow-wrap: anywhere; }
.person-chip button, .person-toggle { border: 0; background: transparent; padding: 0; min-width: 2.35rem; min-height: 2.35rem; }
.person-chip button { font-size: 1.15rem; }
.person-toggle { flex: none; min-height: 2.75rem; }
.person-toggle span { display: block; width: .5rem; height: .5rem; border-right: 2px solid; border-bottom: 2px solid; transform: translateY(-2px) rotate(45deg); }
.person-query[aria-expanded="true"] { border-color: var(--accent); }
.person-dropdown { position: absolute; z-index: 3; inset: auto 0 auto; margin-top: .3rem; padding: .25rem; background: white; border: 1px solid #b9cbbf; border-radius: .65rem; box-shadow: 0 .4rem 1rem #183c3222; }
.person-results { display: grid; max-height: 12.5rem; overflow: auto; }
.person-result { display: block; width: 100%; border: 0; text-align: left; min-height: 2.6rem; overflow-wrap: anywhere; }
.person-result[aria-selected="true"] { background: var(--pale); }
.person-create { color: var(--accent); border-top: 1px solid var(--line); }
.person-empty { padding: .45rem .6rem; }
.person-error { margin-top: .4rem; }
.person-admin { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: .5rem .85rem; }
.person-admin .check { align-items: center; min-height: 2.75rem; margin: 0; }
.upload-selection { padding: .35rem 0 .1rem 1.4rem; overflow-wrap: anywhere; }
.submit-row { display: grid; justify-items: start; gap: .45rem; }
.upload-progress { accent-color: var(--accent); width: min(100%, 24rem); height: 1rem; }
.upload-status { color: var(--muted); }
.upload-error { margin-bottom: 0; }
.person-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; background: var(--paper); border-radius: .6rem; padding: .75rem; align-items: end; }
.person-row button { justify-self: start; }
details { border: 1px solid var(--line); border-radius: .65rem; padding: .65rem .75rem; }
summary { cursor: pointer; font-weight: 650; min-height: 1.7rem; }
.upload, details p, .check { margin-top: .6rem; }
.check { display: flex; align-items: flex-start; gap: .45rem; overflow-wrap: anywhere; }
.entry { scroll-margin-top: 1rem; overflow-wrap: anywhere; }
.entry-kind { color: var(--accent); font-weight: 750; font-size: .83rem; margin-bottom: .27rem; }
.entry-kind.cost { color: #8d521b; }
.entry-kind.visit, .entry-kind.loan { color: #4e5e90; }
.entry-value { flex: none; padding: .3rem .6rem; background: var(--pale); border-radius: .5rem; font-variant-numeric: tabular-nums; }
.entry-category { color: var(--muted); margin-top: .35rem; }
.entry-notes { margin-top: .65rem; white-space: pre-wrap; }
.facts:not(:empty) { display: flex; flex-wrap: wrap; gap: .45rem 1.4rem; margin-top: .8rem; }
.facts dt { color: var(--muted); font-size: .87rem; }
.facts dd { margin: 0; }
.people-summary { margin-top: .7rem; background: var(--paper); border-radius: .55rem; padding: .65rem .8rem .65rem 1.9rem; }
.entry-footer { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem 1rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .5rem; margin-top: .95rem; font-size: .88rem; }
.entry-footer span { margin-right: auto; }
.entry-footer a, .text-button { min-height: 2.5rem; display: inline-flex; align-items: center; }
.text-button { padding: 0 .2rem; border: 0; background: transparent; color: #873e34; text-decoration: underline; }
.attachments { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .9rem; align-items: start; }
.gallery-item { display: block; width: 7rem; max-width: calc(50% - .3rem); aspect-ratio: 1; background: var(--paper); border-radius: .55rem; overflow: hidden; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video { display: grid; width: min(100%, 22rem); gap: .3rem; }
.video video { width: 100%; background: #101914; border-radius: .55rem; max-height: 19rem; }
.document { max-width: 100%; overflow-wrap: anywhere; }
.pdf-attachment { display: grid; gap: .35rem; max-width: 14rem; min-width: 0; overflow-wrap: anywhere; }
.pdf-attachment img { display: block; object-fit: contain; background: var(--paper); border: 1px solid var(--line); border-radius: .4rem; margin-bottom: .35rem; }
.custom-cost-choice { margin-top: .5rem; }
[aria-invalid="true"] { border-color: #9b392c; }
.field-error { color: #8e2f23; font-size: .88rem; }
.timeline-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.media-overview { max-width: 74rem; }
.media-date .date-jump { max-width: 21rem; margin-block: .6rem 0; }
.media-date > a { display: inline-block; margin-top: .5rem; }
.media-day .attachments { margin-top: .5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 6rem), 7rem)); gap: .4rem; }
.media-overview .gallery-item, .media-overview .video, .media-overview .pdf-attachment { width: 100%; max-width: none; }
.media-overview .video video, .media-overview .pdf-attachment img { width: 100%; aspect-ratio: 1; height: auto; }
.media-overview .video video { object-fit: cover; }
.media-overview .video a, .media-overview .pdf-attachment a { font-size: .78rem; }
@media (max-width: 36rem) {
  .media-day .attachments { grid-template-columns: repeat(auto-fill, minmax(5rem, 1fr)); }
}
body:has(#gallery[open]) { overflow: hidden; }
#gallery { position: fixed; inset: 0; width: 100%; height: 100%; max-height: none; max-width: none; padding: 0; margin: 0; border: 0; color: white; background: #0e1712; }
#gallery[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.gallery-toolbar, .gallery-footer, .gallery-controls { display: flex; align-items: center; gap: .5rem; }
.gallery-toolbar, .gallery-footer { padding: .6rem .75rem; }
.gallery-toolbar span { margin-right: auto; }
.gallery-footer { flex-wrap: wrap; justify-content: center; }
.gallery-controls { justify-content: center; }
.gallery-controls select { width: auto; }
.gallery-controls button { min-width: 2.75rem; }
#gallery-help { flex-basis: 100%; text-align: center; font-size: .88rem; color: #d3ded7; }
#gallery-angle-control { display: flex; align-items: center; flex-wrap: wrap; }
#gallery-angle { width: 8rem; min-height: 2.75rem; padding: 0; accent-color: #9bd5b5; }
#gallery figure { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: .45rem; padding: 0 .65rem; text-align: center; overflow: hidden; }
#gallery-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; touch-action: none; user-select: none; cursor: grab; }
#gallery-stage:active { cursor: grabbing; }
#gallery-stage:focus-visible { outline-offset: -3px; }
#gallery-image { position: absolute; top: 50%; left: 50%; display: block; max-width: none; pointer-events: none; transform: translate(-50%, -50%); }
#gallery-panorama { display: block; width: 100%; height: 100%; }
#gallery-status { position: absolute; left: 0; right: 0; top: 50%; pointer-events: none; text-shadow: 0 1px 3px #000; }
#gallery-caption { overflow-wrap: anywhere; font-size: .9rem; }
.report { max-width: 58rem; margin: auto; }
.report-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.metric > strong { display: block; font-size: clamp(1.55rem, 5vw, 2.1rem); letter-spacing: -.035em; margin: .25rem 0; }
.breakdown div, .expense-row { display: flex; gap: .65rem; align-items: baseline; justify-content: space-between; padding: .55rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.breakdown div:last-child, .expense-row:last-child { border-bottom: 0; }
.breakdown dd { margin: 0; flex: none; }
.expenses h2 { margin-bottom: .4rem; }
.expense-row strong { flex: none; }
@media (max-width: 51rem) {
  .diary-layout { grid-template-columns: minmax(0, 1fr); }
  .calendar { max-width: 34rem; width: 100%; }
}
@media (max-width: 34rem) {
  main, .top-inner { padding-inline: .8rem; }
  .top-inner { padding-block: .55rem; }
  nav a { padding-inline: .45rem; }
  .person-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .person-row label:first-child { grid-column: 1 / -1; }
  .report-totals { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 24rem) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .add-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-options .button { padding-inline: .35rem; text-align: center; }
  .person-admin { grid-template-columns: minmax(0, 1fr) auto; }
  .person-admin > label:first-of-type { grid-column: 1 / -1; }
}
