:root {
  /* Miyamoto blue #0091CC, the page background; --accent is a deeper
     shade of it for buttons and links, so white text on it stays readable */
  --page: #0091CC;
  --on-page: #ffffff;
  --on-page-muted: rgba(255, 255, 255, .85);
  --bg: #f4f5f7;
  --card: #ffffff;
  --fg: #1b1f24;
  --muted: #5e6670;
  --line: #d9dde3;
  --accent: #00709F;
  --accent-fg: #ffffff;
  --danger: #b42318;
  --ok-bg: #e7f5ec; --ok-fg: #17603a;
  --warn-bg: #fff4e0; --warn-fg: #8a5300;
  --err-bg: #fdecea; --err-fg: #a61b12;
  --t-work: #2f6fb5;
  --t-observed: #2e8a57;
  --t-asbuilt: #b7791f;
  --t-deficiency: #c23a2b;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #005C82; --on-page-muted: rgba(255, 255, 255, .8);
    --bg: #14171b; --card: #1d2126; --fg: #e8eaed; --muted: #9aa3ad; --line: #333a42;
    --accent: #4DB8E8; --accent-fg: #0d1117; --danger: #ff7b72;
    --ok-bg: #12301f; --ok-fg: #7ee2a8; --warn-bg: #3a2a0c; --warn-fg: #f5c46b;
    --err-bg: #3d1512; --err-fg: #ffa198;
    --t-work: #5b9be6; --t-observed: #4cc38a; --t-asbuilt: #e0a943; --t-deficiency: #ff7b72;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1rem; margin: 0 0 .6rem; }
code { font: .85em ui-monospace, Consolas, monospace; background: var(--bg); padding: .05em .3em; border-radius: 4px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 96px; color: var(--on-page); }
/* on the blue page outside cards: white text; inside cards: normal colors */
main.wrap .muted, main.wrap .crumbs, main.wrap .crumbs a, main.wrap .pagehead a { color: var(--on-page-muted); }
main.wrap .card, main.wrap .list, dialog { color: var(--fg); }
main.wrap .card .muted, main.wrap .list .muted, dialog .muted { color: var(--muted); }
main.wrap .card a:not(.btn):not(.obsrow):not(.listrow) { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.spaced { margin-top: 1rem; }
.offscreen { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.topbar { background: var(--page); border-bottom: 1px solid rgba(255, 255, 255, .25); color: var(--on-page); }
.topbar-in { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--on-page); text-decoration: none; min-width: 0; }
.brand .logo { height: 24px; width: auto; display: block; }
.brand .logo + span { padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .5); font-weight: 600; font-size: .95rem; white-space: nowrap; }
@media (max-width: 400px) { .brand .logo + span { display: none; } }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: .9rem; }
.topnav a { text-decoration: none; color: var(--on-page); }
.topnav form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.topnav .linklike { color: var(--on-page); }

.crumbs { font-size: .85rem; margin: 14px 0 0; color: var(--muted); }
.crumbs a { text-decoration: none; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.pagehead.stepper { flex-wrap: nowrap; }
.pagehead.stepper h1 { text-align: center; flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.card.narrow { max-width: 420px; margin: 32px auto; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: .6rem; }
.cardhead h2 { margin: 0; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▸"; float: right; color: var(--muted); }
details.card[open] > summary::after { content: "▾"; }
details.card[open] > summary { margin-bottom: .8rem; }

.flash { border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-size: .92rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok-fg); }
.flash.warn { background: var(--warn-bg); color: var(--warn-fg); }
.flash.error { background: var(--err-bg); color: var(--err-fg); }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }

/* forms */
.stack > * + * { margin-top: 10px; }
.field { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, textarea, select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 11px; font: inherit; font-size: 16px;
  color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.field.compact { font-weight: 500; }
.field.compact input, .field.compact select { padding: 8px 10px; }
textarea { resize: vertical; min-height: 6rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .95rem; }
.check input { width: 20px; height: 20px; }
.inlineform { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 10px; }
.inlineform input[type=file] { flex: 1; min-width: 0; font-size: .9rem; }
.inlineform .field { flex: 1; min-width: 200px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.ghost { background: var(--card); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 11px; font-size: .88rem; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .4; cursor: default; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btnrow form { margin: 0; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list:not(.flush) { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list li + li { border-top: 1px solid var(--line); }
.listrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: inherit; text-decoration: none; }
.list.flush .listrow { padding: 10px 0; }
.listrow b { display: block; }
.listrow form { margin: 0; }
.excluded { opacity: .55; }

.obslist { list-style: none; margin: 0; padding: 0; }
.obslist li { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); }
.obslist li:first-child { border-top: 0; }
.obsrow { flex: 1; min-width: 0; display: flex; gap: 12px; padding: 10px 0; color: inherit; text-decoration: none; }
.obsrow .desc { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; background: var(--bg); }
.thumb.empty { display: grid; place-items: center; font-size: .65rem; color: var(--muted); border: 1px dashed var(--line); }
.reorder { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.reorder .btn { min-height: 30px; padding: 0 9px; }
.type { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.type.t-work { color: var(--t-work); } .type.t-observed { color: var(--t-observed); }
.type.t-asbuilt { color: var(--t-asbuilt); } .type.t-deficiency { color: var(--t-deficiency); }
h3.section { margin: 14px 0 2px; padding-left: 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
  border-left: 4px solid var(--line); }
h3.section:first-of-type { margin-top: 4px; }
h3.t-work { border-color: var(--t-work); } h3.t-observed { border-color: var(--t-observed); }
h3.t-asbuilt { border-color: var(--t-asbuilt); } h3.t-deficiency { border-color: var(--t-deficiency); }

/* type chips */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip { position: relative; display: block; cursor: pointer; }
.chip input { position: absolute; opacity: 0; }
.chip span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; padding: 6px 10px;
  border: 1.5px solid var(--line); border-radius: 10px; font-weight: 600; font-size: .92rem;
}
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip input:checked + span { color: #fff; border-color: transparent; }
.chip.t-work input:checked + span { background: var(--t-work); }
.chip.t-observed input:checked + span { background: var(--t-observed); }
.chip.t-asbuilt input:checked + span { background: var(--t-asbuilt); }
.chip.t-deficiency input:checked + span { background: var(--t-deficiency); }

/* photos */
.photos { list-style: none; margin: 0 0 12px; padding: 0; }
.photos li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; display: block; }
.photos .btnrow { margin-top: 8px; }

.savebar {
  position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--page) 75%, transparent);
}
.savebar .btn { flex: 1; }
.savebar .btn.primary { box-shadow: 0 0 0 2px var(--on-page); }

.uploading { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; }
.uploading[hidden] { display: none; }
.uploading div { background: var(--card); padding: 18px 26px; border-radius: 12px; font-weight: 600; }

.tabs { display: flex; gap: 14px; }
main.wrap .tabs a { text-decoration: none; color: var(--on-page-muted); font-weight: 600; padding-bottom: 2px; }
main.wrap .tabs a.on { color: var(--on-page); border-bottom: 2px solid var(--on-page); }
table.vars { border-collapse: collapse; width: 100%; font-size: .88rem; }
table.vars td { padding: 6px 8px 6px 0; border-top: 1px solid var(--line); vertical-align: top; }

/* upload status in the header, and problems in the Capture queue */
.syncwrap { display: flex; justify-content: flex-end; }
.syncwrap:has(.syncpill[hidden]) { display: none; }
.syncpill { margin-top: 10px; font-size: .8rem; font-weight: 600; padding: 4px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .2); color: var(--on-page); white-space: nowrap; }
.syncpill.warn { background: #fff4e0; color: #8a5300; }
.syncpill[hidden] { display: none; }
.problem { color: var(--danger); }
.topnav { white-space: nowrap; }
@media (max-width: 400px) { .topnav { gap: 10px; font-size: .85rem; } }

/* opened from the home-screen icon: keep clear of the phone's status bar */
.standalone .topbar { padding-top: env(safe-area-inset-top); }
.installcard h2 { margin-bottom: .3rem; }

fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain[disabled] .chip span, fieldset.plain[disabled] textarea,
fieldset.plain[disabled] input:not([type=radio]), fieldset.plain[disabled] select { opacity: .85; cursor: default; }
fieldset.plain[disabled] .chip input { opacity: 0; }
#people .listrow { flex-wrap: wrap; row-gap: 6px; }
#people .listrow > .grow { min-width: 60%; }
.caption-text { margin: 0; }
.seg { display: inline-flex; gap: 4px; }
.seg .btn[aria-pressed="true"] { opacity: 1; }
