/* Bothy, "Map, bold" look (prototype/ui-home, verdict 2026-10-28):
   Barlow Condensed / Barlow, 2px ink borders with a 4px hard shadow, OS-magenta accent, map grid paper. */
:root {
  --bg: #fbfbf6; --card: #ffffff; --ink: #1f2a24; --muted: #5f6b65; --line: #d4d9cf;
  --accent: #d1235f; --accent-ink: #ffffff; --soft: #f6e1e9; --tab: #ffffff;
  --contour: #d7ae86; --grid: #a9cde3; --water: #2b86c0; --wood: #4f9a52;
  /* map-area colours, handed to Rooms in order: settlement orange, loch blue, sand, heather, slate blue, woodland green */
  --room-1: #ff8a5b; --room-2: #4fb6e8; --room-3: #ffd15c; --room-4: #c4a6ff; --room-5: #7aa2ff; --room-6: #6cc879;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif; --body: "Barlow", system-ui, sans-serif;
  --radius: 4px; --shadow: 4px 4px 0 var(--ink);
  --contour-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240' fill='none' stroke='%23d7ae86' stroke-width='1.1'%3E%3Cpath d='M120 22c58 0 98 34 92 86s-46 94-98 88S20 158 26 106 62 22 120 22z'/%3E%3Cpath d='M120 46c42 0 72 26 67 64s-35 68-72 64-64-30-60-68 23-60 65-60z'/%3E%3Cpath d='M122 70c28 0 47 17 43 43s-23 45-48 42-42-20-39-45 16-40 44-40z'/%3E%3Cpath d='M124 94c15 0 25 9 22 23s-12 24-25 22-22-10-21-24 9-21 24-21z'/%3E%3C/svg%3E");
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.4;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px; background-position: -1px -1px;
}
body::after { content: ""; position: fixed; inset: 0; background: var(--bg); opacity: .82; z-index: -1; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; }
.muted { color: var(--muted); }

.app {
  max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(20px, env(safe-area-inset-top, 0px));
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 22px;
}

/* ---------- header ---------- */
.hello { display: flex; flex-direction: column; gap: 6px; }
.kicker { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--accent); }
.hello h1 { font-size: 46px; line-height: 1.02; font-weight: 800; text-transform: uppercase; letter-spacing: -.01em; }

/* ---------- cards ---------- */
.card, .empty {
  position: relative; overflow: hidden; padding: 18px; border-radius: var(--radius);
  background: var(--card); border: 2px solid var(--ink); box-shadow: var(--shadow);
}
.empty { color: var(--muted); }
.empty::before {
  content: ""; position: absolute; inset: 0; background: rgb(43 134 192 / .25); pointer-events: none;
  -webkit-mask: var(--contour-svg) no-repeat 85% 20% / 240px; mask: var(--contour-svg) no-repeat 85% 20% / 240px;
}
.empty > * { position: relative; }
.empty b { display: block; font-family: var(--display); font-size: 28px; font-weight: 800; text-transform: uppercase; color: var(--ink); line-height: 1.1; margin-bottom: 4px; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form p { margin: 0; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); }
.field { width: 100%; font: inherit; font-size: 20px; padding: 14px; border-radius: var(--radius); border: 2px solid var(--ink); background: var(--card); color: var(--ink); font-weight: 400; letter-spacing: normal; text-transform: none; }
.primary {
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 17px; border-radius: var(--radius);
  min-height: 56px; border: 2px solid var(--ink); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
}
.primary:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.error { color: var(--accent); font-weight: 700; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  padding: 0 max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.tabbar-in {
  pointer-events: auto; max-width: 460px; margin: 0 auto; display: flex; align-items: flex-end; background: var(--tab);
  border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 4px 8px;
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px;
  font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .tb-ico { height: 28px; width: 52px; display: grid; place-items: center; border-radius: 999px; }
.tabbar a[aria-current="page"] .tb-ico { background: var(--soft); }
.tabbar .add { flex: 0 0 auto; margin-inline: 6px; }
.tabbar .add span {
  width: 62px; height: 62px; display: grid; place-items: center; margin-top: -26px;
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
.tabbar .add:active span { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

/* ---------- passkeys and settings ---------- */
.passkeys h2, .settings h2, .integrations h2, .notifications h2 { font-family: var(--display); font-size: 28px; font-weight: 800; text-transform: uppercase; line-height: 1.1; }
.passkey-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.passkey-list:empty { display: none; }
.passkey-list li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--soft); }
.passkey-list li > b { grid-column: 1; }
.passkey-list li > span { grid-column: 1; font-size: 14px; }
.passkey-list form { grid-column: 2; grid-row: 1 / span 2; }
.quiet { font: inherit; font-weight: 700; color: var(--accent); background: none; border: 0; padding: 12px 4px; min-height: 44px; }
.primary:disabled { opacity: .6; }

.ok { color: var(--wood); font-weight: 700; }
.settings { display: flex; flex-direction: column; gap: 14px; }
.settings p { margin: 0; }
.notify-list { list-style: none; margin: 0; padding: 0; }
.notify-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 10px 0; border-top: 1px solid var(--soft); }
.notify-list li > b { flex-basis: 100%; }
.notify-list label { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.notify-list input { width: 22px; height: 22px; accent-color: var(--accent); }
.people-list { list-style: none; margin: 0; padding: 0; }
.people-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 16px; padding: 10px 0; border-top: 1px solid var(--soft); }
.people-list li > b, .people-list li > span { flex-basis: 100%; }
.people-list form { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.people-list label { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.people-list input { width: 22px; height: 22px; accent-color: var(--accent); }
a.primary { text-decoration: none; }
.row-link { display: flex; flex-direction: column; gap: 2px; padding: 14px 0 4px; text-decoration: none; min-height: 44px; }
.row-link b { font-size: 18px; }
.todo-lists { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.todo-list { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 10px 0 10px 12px; border-top: 1px solid var(--soft); border-left: 8px solid var(--room, transparent); }
.todo-list .tick { flex-direction: row; align-items: center; gap: 10px; font-size: 18px; text-transform: none; letter-spacing: normal; font-weight: 600; color: var(--ink); min-height: 44px; }
.todo-list .tick input { width: 22px; height: 22px; accent-color: var(--accent); }
.todo-list .colour, .device .colour { width: auto; font-size: 16px; padding: 8px; }
.device { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--soft); font-size: 18px; font-weight: 600; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Rooms: map-area cards, contours through a mask so each card can sit on its own terrain ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.rooms { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.room, .roomhead {
  position: relative; overflow: hidden; border-radius: var(--radius); border: 2px solid var(--ink); box-shadow: var(--shadow);
  background-color: var(--rc, var(--card)); color: var(--ink);
}
.room::before, .roomhead::before {
  content: ""; position: absolute; inset: 0; background: rgb(0 0 0 / .2); pointer-events: none;
  -webkit-mask: var(--contour-svg) no-repeat var(--cx, 40%) var(--cy, 30%) / var(--cs, 240px);
  mask: var(--contour-svg) no-repeat var(--cx, 40%) var(--cy, 30%) / var(--cs, 240px);
}
.room > *, .roomhead > * { position: relative; }
.room { padding: 14px; min-height: 160px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; }
.room:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.room .rname { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.gref { font-size: 12px; font-weight: 700; letter-spacing: .06em; opacity: .7; }
.room .big { font-family: var(--display); font-size: 56px; line-height: .95; font-weight: 800; font-variant-numeric: tabular-nums; }
.room .sub { font-size: 14px; }
.room.clear { background-color: var(--card); border-color: var(--wood); box-shadow: 4px 4px 0 var(--wood); }
.room.clear::before { background: rgb(79 154 82 / .45); }
.room.clear .big { color: var(--wood); font-size: 26px; padding-block: 12px 6px; text-transform: uppercase; }
.room.clear .big::before { content: "▲ "; }
.room.wide, .roomhead.wide { grid-column: 1 / -1; min-height: 0; background-color: var(--card); }
.room.wide::before, .roomhead.wide::before { background: rgb(43 134 192 / .3); }
.minis { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.mini { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 2px solid var(--ink); background: var(--card); }
.mini[data-state="on"] { background: #ffd15c; }
.mini[data-state="unavailable"] { opacity: .5; text-decoration: line-through; }

/* Bothy of the day: a real map reference on the heather, links as map-key chips */
.bothy { display: flex; flex-direction: column; gap: 6px; }
.bothy::before {
  content: ""; position: absolute; inset: 0; background: rgb(196 166 255 / .45); pointer-events: none;
  -webkit-mask: var(--contour-svg) no-repeat 105% 30% / 260px; mask: var(--contour-svg) no-repeat 105% 30% / 260px;
}
.bothy > * { position: relative; }
.bothy .bname { font-size: 36px; font-weight: 800; text-transform: uppercase; line-height: 1; }
.bothy .bname::before { content: "⌂ "; color: var(--accent); }
.bothy .where { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.bothy .gref { opacity: 1; color: var(--accent); }
.bothy .about { margin: 4px 0 0; }
.bothy-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.bothy-links a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); font-weight: 700; text-decoration: none;
}
.bothy-links a::after { content: " ↗"; white-space: pre; }
.bothy-links a:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

/* ---------- a Room's Chores ---------- */
.roomhead { display: flex; align-items: center; gap: 12px; padding: 14px; }
.roomhead h1 { font-size: 40px; font-weight: 800; text-transform: uppercase; line-height: 1; }
.back { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 999px; background: var(--card); border: 2px solid var(--ink); }
.label { font-family: var(--body); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.chores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chore { display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 8px 14px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--ink); }
.chore form { display: contents; }
.chore .name { flex: 1; min-width: 0; }
.tick {
  width: 30px; height: 30px; flex: none; border: 0; padding: 0; display: grid; justify-items: center; background: var(--ink);
  clip-path: polygon(50% 4%, 100% 96%, 0 96%); transition: transform .15s;
}
.tick::before { content: ""; width: 20px; height: 18px; margin-top: 7px; background: var(--card); clip-path: polygon(50% 8%, 100% 100%, 0 100%); }
.tick:active { transform: scale(.85); }
.chore.done { opacity: .6; }
.chore.queued { opacity: .6; border-style: dashed; }
.chore.queued .name::after { content: " · waiting to send"; color: var(--muted); font-size: 14px; }
.signal { margin: 0; padding: 10px 14px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--card); font-weight: 600; }
.chore.done .name { text-decoration: line-through; }
.chore.done .tick, .chore.done .tick::before { background: var(--rc, var(--accent)); }
.done { margin-top: 14px; }
.done summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; color: var(--muted); cursor: pointer; }
.done summary::before { content: "▸"; margin-right: 6px; }
.done[open] summary::before { content: "▾"; }
.clearmsg { padding: 22px; text-align: center; border-radius: var(--radius); border: 2px dashed var(--wood); background: var(--card); color: var(--muted); }
.clearmsg b { display: block; font-family: var(--display); font-size: 28px; font-weight: 800; text-transform: uppercase; color: var(--wood); }

/* ---------- Tiles ---------- */
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  width: 100%; min-height: 124px; padding: 14px; border-radius: var(--radius); background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  font: inherit; text-align: left; cursor: pointer; transition: background .2s;
}
.tile:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.tile .ico { width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; background: var(--ink); color: #ffffff; }
.tile b { font-weight: 700; display: block; line-height: 1.2; }
.tile .state { font-size: 13px; opacity: .8; }
.tile.on { background: #ffd15c; }
.tile.on .ico { color: #ffd15c; }

/* ---------- Add a Chore ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin: 0; padding: 0; }
.chips legend { padding: 0; margin-bottom: 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); }
.form .chip {
  flex-direction: row; align-items: center; padding: 10px 16px; min-height: 44px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--card); font-size: 16px; font-weight: 600; letter-spacing: normal; text-transform: none; color: var(--ink); cursor: pointer;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--rc); }
.chip:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- SUMMIT ---------- */
.stamp {
  position: fixed; z-index: 35; left: 50%; top: 42%; pointer-events: none; font-family: var(--display); font-size: 44px; font-weight: 800;
  color: var(--ink); background: var(--rc, var(--bg)); border: 4px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); padding: 4px 16px; border-radius: 8px;
  transform: translate(-50%, -50%) rotate(-10deg); animation: stamp 1.3s ease forwards;
}
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-10deg) scale(2); }
  20% { opacity: 1; transform: translate(-50%, -50%) rotate(-10deg) scale(1); }
  80% { opacity: 1; } 100% { opacity: 0; }
}
.fx { position: fixed; z-index: 35; inset: 0; pointer-events: none; }
.fx i { position: absolute; width: 9px; height: 9px; border-radius: 2px; animation: burst .9s ease-out forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }

/* ---------- Money ---------- */
.contribution { display: flex; flex-direction: column; gap: 6px; }
.contribution h2 { font-size: 22px; font-weight: 800; text-transform: uppercase; }
.contribution .total { font-family: var(--display); font-size: 52px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.money-list, .split-list, .bill-list { list-style: none; margin: 0; padding: 0; }
.money-list li, .split-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--soft); font-variant-numeric: tabular-nums; }
.split-list b { font-family: var(--display); font-size: 28px; font-weight: 800; }
.bill-list li { border-top: 1px solid var(--soft); }
.bill-list .status, .bill-list .change, .amounts .change, .drops { font-size: 14px; font-weight: 700; color: var(--accent); }
.drops { list-style: none; margin: 0; padding: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.inline-form .field { flex: 1 1 120px; width: auto; font-size: 16px; padding: 10px; }
.bill-form .chips { --rc: var(--room-3); }
.bill-form:has(input[name="method"][value="fixed"]:checked) .when-split,
.bill-form:not(:has(input[name="method"][value="fixed"]:checked)) .when-fixed { display: none; }
.when-split { display: flex; flex-direction: column; gap: 6px; }
.bill-list + .category, .settings h3.category { font-size: 15px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); font-family: var(--body); margin-top: 6px; }
.own-head, .all-together { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.own-head .own-total { color: var(--ink); font-variant-numeric: tabular-nums; }
.all-together { margin: 4px 0 0; padding-top: 10px; border-top: 2px solid var(--ink); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 14px; }
.all-together .grand-total { font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: normal; font-variant-numeric: tabular-nums; }
.money-list li > a { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; text-decoration: none; }
.money-list li > a span::after { content: " ›"; color: var(--muted); }
.bill-row b { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.bill-row .edit { font-family: var(--body); font-size: 14px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.money-list li > .gone { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.paid-in { margin: 0; font-weight: 700; color: var(--wood); }
.pay-in, .undo-paid-in { margin: 0; }
.pay-in .primary { width: 100%; }
.history .pay-in, .history .undo-paid-in { flex-basis: 100%; }
.locked { margin: 0; padding: 10px 12px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--card); font-size: 14px; }
.locked b { text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-right: 4px; }
.history { list-style: none; margin: 0; padding: 0; }
.history .when { flex-basis: 100%; font-size: 14px; color: var(--muted); }

/* ---------- Desk ---------- */
.tickets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ticket a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-height: 58px; padding: 10px 14px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--ink); text-decoration: none; }
.ticket .subject { flex-basis: 100%; font-size: 18px; }
.ticket .muted { font-size: 14px; }
.ticket .status, .ticket-head .status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 2px solid var(--ink); background: var(--soft); }
.ticket-head { display: flex; align-items: center; gap: 12px; }
.ticket-head h1 { font-size: 30px; line-height: 1.05; font-weight: 800; }
.latest { display: flex; flex-direction: column; gap: 8px; }
.latest p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- Install ---------- */
.install {
  position: fixed; z-index: 20; left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(112px + env(safe-area-inset-bottom, 0px)); max-width: 448px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px;
}
.install b { font-family: var(--display); font-size: 26px; font-weight: 800; text-transform: uppercase; line-height: 1.05; }
.install p { margin: 0; color: var(--muted); }
.install .later { background: none; border: 0; min-height: 44px; font-weight: 700; color: var(--muted); }
