/* HERO: the search line */
/* One large field on a hairline, a quiet placeholder, nothing above it until results arrive. */
/* Refined minimal: Telegram's surfaces, one brass accent, hairlines instead of boxes, an 8 px rhythm.
   One family, Manrope. Type ramp: 11 labels, 13 hints, 15 body, 20 item, 24 place and the search line. */

@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(fonts/manrope-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(fonts/manrope-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

[hidden] { display: none !important; }
:root {
  --bg: var(--tg-theme-bg-color, #fbfaf7);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f0eb);
  --text: var(--tg-theme-text-color, #1b1a17);
  --hint: var(--tg-theme-hint-color, #6f6c66);
  --accent: #8a6d3b;
  --danger: #a3341f; /* expired notifications only (ISC-57) */
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --edge: color-mix(in srgb, var(--text) 24%, transparent);
  --body: "Manrope", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  /* Telegram's full-screen overlay (Back, chevron, dots) and the device's notch and home indicator.
     telegram-web-app.js sets these from its safe-area events; outside Telegram they are 0. */
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
  --safe-left: calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px));
  --safe-right: calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px));
  color-scheme: light;
}
/* app.ts sets .dark from Telegram's colorScheme (and on themeChanged). The fallbacks follow it, so a
   surface Telegram leaves unset never pairs a light default with a dark one. */
:root.dark { --bg: var(--tg-theme-bg-color, #1c1c1e); --bg2: var(--tg-theme-secondary-bg-color, #2c2c2e);
  --text: var(--tg-theme-text-color, #f2f2f7); --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: #c9a86a; --danger: #f08a75; color-scheme: dark; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--body);
  padding: var(--safe-top) var(--safe-right) calc(80px + var(--safe-bottom)) var(--safe-left);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons: text in the accent, one filled primary per screen. */
button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: none; color: var(--accent);
  font-weight: 600; letter-spacing: 0.01em; cursor: pointer; }
button.primary { background: var(--accent); color: var(--bg); padding: 0 24px; }
button.danger { color: var(--text); }
button:disabled { opacity: 0.4; cursor: default; }
button.icon { width: 44px; padding: 0; display: inline-grid; place-items: center; color: var(--hint); flex: none; }
.ico { display: inline-grid; place-items: center; width: 20px; height: 20px; color: var(--hint); flex: none; }
.ico svg { display: block; }

/* Fields: a hairline under the text, the accent under the focused one. */
input, textarea { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 8px 0; }
input:focus, textarea:focus { outline: none; border-bottom-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
textarea { resize: vertical; min-height: 72px; }
/* A read-only member's item fields: text, not inputs. */
input[readonly], textarea[readonly] { border-bottom-color: transparent; box-shadow: none; resize: none; }
::placeholder { color: var(--hint); opacity: 1; }
label, .section { display: block; color: var(--hint); font: 600 11px/16px var(--body); letter-spacing: 0.14em; text-transform: uppercase; }
label { margin: 24px 0 0; }
.section { margin: 32px 0 8px; }

/* The search line. Stuck at the very top, it reaches up under the overlay so rows never show through it. */
#top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; margin: calc(-1 * var(--safe-top)) 16px 0;
  padding: calc(16px + var(--safe-top)) 0 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
#top:focus-within { border-bottom-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
#q { flex: 1; min-width: 0; border: 0; box-shadow: none; padding: 0; height: 48px;
  font: 500 24px/48px var(--body); letter-spacing: -0.01em; -webkit-appearance: none; appearance: none; }
#q::-webkit-search-decoration { -webkit-appearance: none; }
/* The current household's alias (ISC-42). With two or more households it is the switcher (ISC-43):
   a 44 px tap target with a hairline chevron, opening the gear menu's picker. */
#hh { flex: 0 1 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--hint); font-size: 13px; }
#hh.switch { position: relative; padding: 13px 16px 13px 0; line-height: 18px; color: var(--text); cursor: pointer; }
#hh.switch::after { content: ""; position: absolute; right: 3px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
  border: solid var(--hint); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
#hh.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The hero art (approved 2026-10-15, evidence/miniapp/hero-art-preview.html) fills the 128 px hero gap, 6 px
   from its top and bottom, under the overlay inset like the line itself. Brass marks only the magnifier ring and
   the drawer handle. Narrow only: the wide #top keeps its 24 px top and the tree pane sticks at 89 px under it. */
#top .art { display: none; position: absolute; left: 0; top: calc(6px + var(--safe-top)); width: 100%; height: 116px;
  color: var(--hint); pointer-events: none; }
#top .art .brass { stroke: var(--accent); }
/* The bell (ISC-57): a brass dot on its shoulder when a stage began since it was last opened. */
#bell { position: relative; }
#bell-dot { position: absolute; top: 10px; right: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

#note { margin: 8px 16px 0; color: var(--hint); font-size: 13px; }
#app { padding: 0 16px; }
/* 8 px plus the 44 px icon row centring the 32 px line: the title text starts about 14 px under the overlay. */
h2 { display: flex; align-items: center; gap: 16px; margin: 8px 0 0; font: 600 24px/32px var(--body); letter-spacing: -0.01em; }
h2 .grow { flex: 1; min-width: 0; }
h2 .th { width: 56px; height: 56px; }
.hint { color: var(--hint); font-size: 13px; line-height: 20px; }
h2 + .hint { margin-top: 4px; }
#app > p.hint, section > p.hint { margin: 24px 0; }

/* Home: two quiet links under the line until results arrive. */
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px -16px 8px; }
.links button { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; }

/* Home favorites: two text tabs on a hairline, the active one in text colour on a brass hairline. */
.tabs { display: flex; gap: 24px; margin: 8px 0 0; border-bottom: 1px solid var(--line); }
.tabs button { min-height: 44px; padding: 0; border-radius: 0; color: var(--hint); font-weight: 600; letter-spacing: 0;
  border-bottom: 1px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
#app p.fav-empty { margin: 24px 0; }

/* The favorite star: outline in the hint colour, filled brass when on. */
button.star.on { color: var(--accent); }
button.star.on svg { fill: currentColor; }
.titled { display: flex; align-items: center; gap: 8px; }
.titled input { flex: 1; min-width: 0; }

/* Lists: rows on hairlines. */
.row { display: flex; align-items: center; gap: 16px; min-height: 72px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.row .txt { flex: 1; min-width: 0; }
.row .name, .row .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .go { color: var(--hint); font-size: 20px; }
.row.cur .name { color: var(--accent); font-weight: 600; }
.th { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); object-fit: cover; flex: none; display: grid; place-items: center; }

/* Notifications: rows without thumbnails, the date at the right; expired in the one red. */
.row .date { flex: none; color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.row.expired .name, .row.expired .date { color: var(--danger); }
.section.expired { color: var(--danger); }

/* Items in a place: rows too; long-press selects. */
.tile { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.tile .check { position: relative; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; }
.tile.sel .name { color: var(--accent); }
.tile.sel .check { background: var(--accent); border-color: var(--accent); }
.tile.sel .check::after { content: ""; position: absolute; left: 6.5px; top: 3px; width: 5px; height: 10px;
  border: solid var(--bg); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }

/* Multi-item add: one block per proposed thing on a hairline, the round tick of select mode on the left. */
/* The whole group photo, uncropped: every proposed thing stays in view. */
.photos.whole img { width: 100%; max-width: 100%; height: auto; max-height: 264px; object-fit: contain; }
.proposal { display: grid; grid-template-columns: 22px 1fr; gap: 0 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.proposal .fields { min-width: 0; }
.proposal label { margin-top: 8px; }
.proposal textarea { min-height: 48px; }
.proposal input[type="number"] { width: 96px; }
.proposal.off .fields { opacity: 0.4; }
.proposal input[type="checkbox"] { appearance: none; -webkit-appearance: none; position: relative; width: 22px; height: 22px; margin: 5px 0 0; padding: 0;
  border: 1.5px solid var(--line); border-radius: 50%; box-shadow: none; cursor: pointer; }
.proposal input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.proposal input[type="checkbox"]:checked::after { content: ""; position: absolute; left: 6.5px; top: 3px; width: 5px; height: 10px;
  border: solid var(--bg); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.proposal input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Action buttons: one even block of equal cells, the primary filled, the rest on a hairline. */
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 32px 0 16px; }
.actions > :only-child { grid-column: 1 / -1; }
.actions button, #bar button { height: 44px; padding: 0 8px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions button:not(.primary), #bar button:not(.primary) { color: var(--text); border: 1px solid var(--edge); }
.photos { scrollbar-width: none; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; margin: 24px -16px 0; padding: 0 16px; }
.photos img { height: 264px; max-width: 88%; border-radius: 12px; border: 1px solid var(--line); object-fit: cover; scroll-snap-align: start; background: var(--bg2); }
input.title { font: 600 20px/32px var(--body); letter-spacing: -0.01em; }
/* The picker's field: a smaller echo of the search line. */
#app input[type="search"] { margin-top: 16px; font: 500 20px/32px var(--body); }
.path { margin-top: 24px; padding: 12px 0; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }

/* Select mode, and a place's two actions outside it: a hairline-topped strip pinned to the screen bottom.
   61 px plus the inset, so the body's 80 px plus the inset keeps the last row clear of it. */
#bar, .actions.pin { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; margin: 0;
  padding: 8px calc(16px + var(--safe-right)) calc(8px + max(env(safe-area-inset-bottom, 0px), var(--safe-bottom))) calc(16px + var(--safe-left)); background: var(--bg); border-top: 1px solid var(--line); }
#bar { display: grid; grid-template-columns: repeat(2, 1fr); align-items: center; gap: 8px 12px; }
#bar .grow { grid-column: 1 / -1; font-size: 13px; color: var(--hint); }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--text); width: min(calc(100vw - 32px), 420px); padding: 24px; }
dialog::backdrop { background: color-mix(in srgb, var(--bg) 80%, transparent); }
dialog p { margin: 0 0 16px; font: 600 20px/28px var(--body); letter-spacing: -0.01em; }
dialog menu { display: flex; flex-direction: row-reverse; gap: 8px; padding: 0; margin: 24px 0 0; }
/* The place's gear menu: rows on hairlines, no padding, so a tap outside the rows is the backdrop. */
/* menu() sets top and right from the gear's rect */
#more { padding: 0; inset: auto; margin: 0; width: max-content; min-width: 220px; max-width: calc(100vw - 32px); overflow: hidden; outline: none; }
#more button { display: block; width: 100%; white-space: nowrap; min-height: 56px; padding: 0 24px; border-radius: 0; text-align: left; color: var(--text); font-weight: 400; }
#more button + button { border-top: 1px solid var(--line); }
#more button:active { background: var(--bg2); color: var(--accent); }
#more button.current { color: var(--accent); font-weight: 600; }

/* The one motion: a new view or result set fades and rises, 80 ms apart, ten rows at most. */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
#app.enter .row { animation: rise 350ms var(--ease) both; animation-delay: 720ms; }
#app.enter .row:nth-child(1 of .row) { animation-delay: 0ms; }
#app.enter .row:nth-child(2 of .row) { animation-delay: 80ms; }
#app.enter .row:nth-child(3 of .row) { animation-delay: 160ms; }
#app.enter .row:nth-child(4 of .row) { animation-delay: 240ms; }
#app.enter .row:nth-child(5 of .row) { animation-delay: 320ms; }
#app.enter .row:nth-child(6 of .row) { animation-delay: 400ms; }
#app.enter .row:nth-child(7 of .row) { animation-delay: 480ms; }
#app.enter .row:nth-child(8 of .row) { animation-delay: 560ms; }
#app.enter .row:nth-child(9 of .row) { animation-delay: 640ms; }
@media (prefers-reduced-motion: reduce) { #app.enter .row { animation: none; } }

@media (max-width: 799px) {
  /* Home with nothing searched: the line sits low and alone. */
  #top.hero { padding-top: calc(128px + var(--safe-top)); }
  #top.hero .art { display: block; }
}
@media (min-width: 800px) {
  #top { padding-top: calc(24px + var(--safe-top)); }
  .actions, #bar { grid-template-columns: repeat(3, 1fr); }
  /* ponytail: stuck to the screen bottom inside the main column, so it never covers the tree pane. */
  #app.wide .actions.pin { position: sticky; margin-top: 32px; padding-left: 0; padding-right: 0; }
  #bar .grow { grid-column: auto; }
  #app.wide { display: grid; grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
  #app.wide aside { position: sticky; top: calc(89px + var(--safe-top)); height: calc(100vh - 89px - var(--safe-top)); overflow-y: auto; padding: 0 24px 24px 0; border-right: 1px solid var(--line); }
  #app.wide section { padding: 0 0 24px 32px; max-width: 760px; }
  #app.wide section > .row:first-child, #app.wide section > h2:first-child { margin-top: 32px; }
  .photos { margin: 32px 0 0; padding: 0; }
  .photos img { height: 360px; }
}
