:root {
  --bg: #FBF8F1; --ink: #2E3A50; --muted: #6A7184; --soft: #4F5668;
  --line: #DDD5C4; --line2: #EFE9DC; --line3: #D9CFB8; --gold: #C9A75A; --gold-ink: #8A7442;
  --amber: #8A5B00; --green: #2E7A4F; --green-bg: #E2F1E7; --green-line: #8CC4A0; --link: #2C5A93; --red: #A0391B;
  --serif: 'Source Serif 4', Georgia, serif; --sans: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
img { display: block; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }
.main { padding: calc(20px + env(safe-area-inset-top)) 18px calc(110px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.main.no-nav { padding-bottom: 40px; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 30vh; color: var(--muted); }

/* headers */
.head { display: flex; flex-direction: column; gap: 10px; }
.head-row { display: flex; align-items: center; gap: 12px; }
.head-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.eyebrow { font-size: 10.5px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--gold-ink); }
.h1 { font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1.15; margin: 0; }
.h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.2; margin: 0; }
.sub { font-size: 13px; color: var(--muted); }
.rule { height: 3px; border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); opacity: .8; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--gold); background: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0; }
.section-label { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
.section-label > span:first-child { font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--gold-ink); }
.section-label.amber > span:first-child { color: var(--amber); }
.section-label .line { flex: 1; height: 1px; background: var(--line3); }
.section-label.amber .line { background: #E7D7A8; }
.count { font-size: 12px; color: var(--muted); }

/* cards and rows */
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.card.accent { border-left: 3px solid var(--gold); border-radius: 6px; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; width: 100%; }
.row + .row { border-top: 1px solid var(--line2); }
button.row { min-height: 60px; background: none; border: 0; text-align: left; }
button.row + button.row, .row + button.row, button.row + .row { border-top: 1px solid var(--line2); }
.row-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-title { font-size: 14px; font-weight: 600; }
.row-sub { font-size: 12px; color: var(--muted); }
.chev { font-size: 18px; color: #A9A190; }
.empty { font-size: 14px; color: var(--muted); padding: 10px 0; }

/* buttons */
.btn { min-height: 46px; border-radius: 8px; border: 1px solid var(--ink); background: #fff; color: var(--ink); font-size: 15px; font-weight: 700; padding: 6px 16px; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:disabled { opacity: .45; }
.btn-quiet { border-color: #CFC5B0; color: var(--soft); }
.btn-sm { min-height: 36px; font-size: 13px; padding: 4px 12px; border-radius: 6px; }
.btn-xs { min-height: 30px; font-size: 12px; padding: 2px 10px; border-radius: 6px; border-color: #CFC5B0; color: var(--muted); }
.link { min-height: 36px; padding: 0; border: 0; background: none; color: var(--link); font-size: 14px; font-weight: 600; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }
.btn-block { width: 100%; }

/* progress and grid */
.status-title { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.status-title.ok { color: var(--green); }
.segments { display: flex; gap: 3px; }
.segments span { flex: 1; height: 8px; border-radius: 2px; background: #EDE6D6; }
.segments span.on { background: #4E9A6B; }
.grid-head, .grid-row { display: grid; grid-template-columns: 104px repeat(4, minmax(0, 1fr)); align-items: center; padding: 6px 10px; }
.grid-head { align-items: end; padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
.grid-row + .grid-row { border-top: 1px solid var(--line2); }
.col-head { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; font-size: 9.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--gold-ink); }
.unit-name { display: flex; flex-direction: column; min-width: 0; }
.unit-name b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-name span { font-size: 11px; font-weight: 600; color: var(--amber); }
.unit-name span.ok { color: var(--green); }
.cell { justify-self: center; width: 44px; height: 44px; border: 0; background: none; padding: 0; display: flex; align-items: center; justify-content: center; }
.mark { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; }
.mark.done { background: var(--green-bg); border: 1px solid var(--green-line); color: var(--green); }
.mark.need { background: #FFFBF0; border: 1.5px dashed var(--gold); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { min-height: 104px; padding: 12px 6px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.tile + .tile { border-left: 1px solid var(--line2); }
.tile b { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1; }
.tile span { font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); line-height: 1.3; }

.quote { display: flex; gap: 12px; align-items: flex-start; }
.quote q { font-family: var(--serif); font-size: 15px; line-height: 1.55; font-style: italic; quotes: '“' '”'; }
.meta { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid #BFE0CB; border-radius: 10px; color: var(--green); font-weight: 600; font-size: 14px; }
.note { padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 6px; font-size: 14px; color: var(--soft); }

/* segmented controls */
.seg { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { min-height: 44px; border: 0; background: #fff; font-size: 14px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg.filters { display: flex; }
.seg.filters button { flex: 1; min-height: 40px; font-size: 13px; }
.seg.filters button + button { border-left: 1px solid var(--line); }
.seg.two button:nth-child(2n) { border-left: 1px solid var(--line); }
.seg.two button:nth-child(n+3) { border-top: 1px solid var(--line); }

/* toast */
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 13px; }
.toast span { flex: 1; }
.toast button { min-height: 32px; padding: 2px 10px; border: 1px solid #fff; border-radius: 6px; background: transparent; color: #fff; font-size: 13px; font-weight: 700; }
.error { padding: 10px 14px; border: 1px solid #E6C3B5; border-left: 3px solid var(--red); border-radius: 6px; background: #FFF7F3; color: var(--red); font-size: 14px; }

/* report detail */
.field { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; }
.field + .field { border-top: 1px solid var(--line2); }
.field-label, .lab { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold-ink); }
.field-value { font-size: 15px; white-space: pre-wrap; }
.field-value.serif { font-family: var(--serif); font-size: 16px; line-height: 1.55; }
.confirm { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid #CFC5B0; border-left: 3px solid var(--gold); border-radius: 8px; background: #FFFBF0; }
.hidden-box { background: #F5F1E8; border: 1px dashed #CFC5B0; border-radius: 10px; }
.hidden-box .row + .row { border-top: 1px dashed #CFC5B0; }
.hidden-box .row-text { color: var(--muted); }
.hidden-box img { opacity: .6; }

/* forms */
label.lab { display: flex; flex-direction: column; gap: 6px; }
.input, .select { min-height: 46px; width: 100%; border: 0; border-bottom: 1px solid #B9AF9A; border-radius: 0; padding: 8px 2px; font-size: 16px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink); background: transparent; }
.select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8A7442 50%), linear-gradient(135deg, #8A7442 50%, transparent 50%); background-position: calc(100% - 12px) 21px, calc(100% - 7px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 22px; }
.textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 16px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink); background: #fff; resize: vertical; }
.textarea.ruled { font-family: var(--serif); line-height: 26px; background-image: repeating-linear-gradient(transparent, transparent 25px, var(--line2) 25px, var(--line2) 26px); background-position: 0 9px; background-attachment: local; }
.two-col { display: flex; gap: 10px; }
.two-col > * { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: var(--muted); }
.mic { min-height: 54px; display: flex; align-items: center; gap: 12px; padding: 8px 14px; border: 1px dashed #C9C2B2; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; text-align: left; }
.mic b { color: var(--ink); }
.mic img { opacity: .7; }
.form-actions { display: flex; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-actions > * { flex: 1; min-height: 50px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 20px; height: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 19px; background: #fff; font-size: 14px; }
.chip input { width: 18px; height: 18px; margin: 0; }

/* done */
.done-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding-top: 40px; }
.pill { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 6px; border: 1px solid; }
.pill.blue { color: var(--link); border-color: #C9D6EA; }
.pill.green { color: var(--green); border-color: #BFE0CB; }
.tag { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .5px; padding: 3px 8px; border-radius: 4px; border: 1px solid; }
.tag.ok { color: var(--green); border-color: #BFE0CB; }
.tag.watch { color: var(--amber); border-color: #E7D7A8; }
.tag.needs { color: var(--red); border-color: #E6C3B5; }
.marks { display: flex; gap: 6px; }
.marks img.off { opacity: .28; filter: grayscale(1); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 18px; }

/* code reveal */
.code-box { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--gold); border-radius: 10px; background: #FFFBF0; }
.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 30px; font-weight: 700; letter-spacing: 3px; text-align: center; padding: 6px 0; user-select: all; }

/* login */
.login { display: flex; flex-direction: column; gap: 18px; padding-top: 8vh; }
.login .crest { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.code-input { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 24px; letter-spacing: 3px; text-align: center; text-transform: uppercase; }

/* nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; height: calc(76px + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom); border-top: 1px solid var(--gold); background: #fff; display: flex; align-items: center; justify-content: space-around; z-index: 10; }
.nav-btn { min-width: 72px; min-height: 52px; border: 0; border-bottom: 2px solid transparent; background: none; font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #8A90A0; opacity: .75; }
.nav-btn[aria-current="page"] { color: var(--ink); opacity: 1; border-bottom-color: var(--gold); }
.nav-record { width: 62px; height: 62px; margin-top: -20px; border-radius: 50%; border: 1px solid var(--gold); outline: 3px solid var(--bg); background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.nav-record span:first-child { font-size: 26px; line-height: 1; font-weight: 300; }

@media (min-width: 700px) {
  .main { padding-top: 32px; }
}

.bar { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: #EDE6D6; overflow: hidden; }
.bar span { display: block; height: 100%; background: #4E9A6B; }

/* voice */
.voice-row { display: flex; gap: 10px; align-items: flex-end; }
.voice-row .mic { flex: 1; cursor: pointer; border-style: solid; border-color: var(--gold); background: #FFFBF0; color: var(--soft); }
.voice-row .mic img { opacity: 1; }
.voice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--gold); border-radius: 8px; background: #FFFBF0; font-size: 14px; }
.voice.recording { border-color: #D98C7A; background: #FFF5F2; }
.voice .dot { width: 14px; height: 14px; border-radius: 50%; background: #C0392B; flex: none; animation: pulse 1.2s ease-in-out infinite; }
.spinner { width: 22px; height: 22px; flex: none; border: 2px solid #E7D7A8; border-top-color: var(--gold); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.85); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .voice .dot, .spinner { animation: none; } }
.ai-note { padding: 12px 14px; border: 1px solid #C9D6EA; border-left: 3px solid var(--link); border-radius: 6px; background: #F5F8FD; font-size: 14px; color: var(--soft); }
.ai-note ul { margin: 4px 0 0; padding-left: 18px; }
.original { border: 1px dashed #CFC5B0; border-radius: 8px; background: #F5F1E8; padding: 8px 12px; font-size: 13px; color: var(--soft); }
.original summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.original p { margin: 6px 0 2px; white-space: pre-wrap; font-family: var(--serif); font-size: 15px; line-height: 1.5; }

.placeholder { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px dashed var(--gold); border-radius: 10px; background: #FFFDF6; font-size: 14px; color: var(--soft); }
.placeholder b { color: var(--ink); }
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top)); z-index: 20; width: min(528px, calc(100% - 24px)); display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(46,58,80,.25); }
.update-bar span { flex: 1; }
.update-bar button { min-height: 36px; padding: 2px 12px; border: 1px solid #fff; border-radius: 6px; background: transparent; color: #fff; font-weight: 700; }

/* personal ministering */
.minister { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-left: 3px solid #CFC5B0; border-radius: 8px; }
.minister img { filter: grayscale(1); opacity: .6; transition: filter .3s, opacity .3s; }
.minister.done { border-color: #BFE0CB; border-left-color: #4E9A6B; background: #F6FBF7; }
.minister.done img { filter: none; opacity: 1; }
.minister-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--green-line); background: var(--green-bg); color: var(--green); font-size: 20px; font-weight: 700; }
.hc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 12px 6px; padding: 14px 10px; }
.hc-chip { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hc-ring { position: relative; width: 48px; height: 48px; border-radius: 50%; border: 1.5px dashed #C9C2B2; background: #F5F1E8; color: #9AA0AE; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; transition: background .3s, border-color .3s, color .3s; }
.hc-chip.done .hc-ring { border: 1.5px solid #4E9A6B; background: #4E9A6B; color: #fff; }
.hc-ring i { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: #fff; font-size: 11px; font-style: normal; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.hc-name { font-size: 12px; color: var(--soft); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 76px; }
