:root {
  --bg: #f6f4ee; --card: #fff; --ink: #1f2933; --muted: #6b7280; --line: #e5e1d8;
  --green: #16805c; --amber: #f59e0b; --red: #dc2626;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }   /* .icon's display:inline-flex otherwise wins over hidden */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
/* Pinned to the window, not sized by 100dvh (homelists#43: in the installed app on Denis's Android 10, 100dvh reached
   under the navigation bar and hid the box and the status line). FoxChat's #app does the same and shows on that phone. */
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg);
       display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; right: 0; }
/* All text selectable (skills/shippable-app), buttons included where they hold words. */
body { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.icon { width: 44px; height: 44px; border-radius: 22px; font-size: 22px; display: inline-flex; align-items: center; justify-content: center; }
.icon:active { background: rgba(0,0,0,.06); }
.link { color: var(--green); text-decoration: underline; font-size: inherit; }

#top { display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--green); color: #fff; min-height: 56px; }
#top h1 { flex: 1; margin: 0 6px; font-size: 20px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#me { font-size: 22px; }

main { flex: 1; overflow-y: auto; padding: 10px 10px 16px; overscroll-behavior: contain; }

/* Home: Keep-like cards, two columns. */
/* A grid, not columns, so the order reads left to right, row by row, the way a drag moves it (homelists#47). */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
.card { position: relative; -webkit-user-select: none; user-select: none; touch-action: pan-y; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 0 0 10px; display: block; width: 100%; text-align: start; }
.card h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.card ul { list-style: none; margin: 0; padding: 0; font-size: 14px; color: #374151; }
.card li { padding: 1px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .more { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card.new { border-style: dashed; color: var(--muted); text-align: center; }
.section { margin: 18px 4px 8px; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.empty { color: var(--muted); text-align: center; margin: 40px 20px; }

/* A list. */
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.item { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 2px; border-top: 1px solid var(--line); min-height: 52px; }
.item:first-child { border-top: 0; }
.tick { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.tick span { width: 24px; height: 24px; border: 2px solid #9ca3af; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; color: #fff; }
.item.bought .tick span { background: var(--green); border-color: var(--green); }
.item .body { flex: 1; min-width: 0; padding: 4px 0; }
.item .text { word-wrap: break-word; }
.item.bought .text { text-decoration: line-through; color: var(--muted); }
.item .meta { font-size: 12px; color: var(--muted); }
.item .who { font-size: 16px; flex: none; opacity: .8; }
.item.pending .who::after { content: "⏳"; font-size: 11px; }
.badge { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 8px; margin-inline-end: 4px; color: #fff; }
.badge.now { background: var(--red); } .badge.soon { background: var(--amber); } .badge.later { background: #9ca3af; }
.qty { font-weight: 600; margin-inline-end: 4px; }

#bottom { background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px calc(4px + var(--safe-b)); }
#composer { display: flex; align-items: flex-end; gap: 6px; }
#box { flex: 1; resize: none; font: inherit; padding: 10px 14px; border: 1px solid var(--line); border-radius: 22px; max-height: 8.5em; background: #fbfaf7; }
#box:focus { outline: 2px solid var(--green); outline-offset: -1px; }
.send { color: var(--green); }
#status { font-size: 12px; color: var(--muted); text-align: center; padding-top: 3px; }
#sync.offline { color: var(--red); } #sync.pending { color: var(--amber); }

#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 10; }
#sheet[hidden] { display: none; }
.panel { background: var(--card); width: 100%; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); max-height: 85dvh; overflow-y: auto; }
.panel h3 { margin: 0 0 10px; }
.panel label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.panel input, .panel textarea, .panel select { width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fbfaf7; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn { padding: 10px 16px; border-radius: 22px; border: 1px solid var(--line); background: #fff; }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.danger { color: var(--red); }
.choices { display: flex; gap: 6px; flex-wrap: wrap; }
.choices .btn.on { background: var(--green); color: #fff; border-color: var(--green); }
pre.raw { white-space: pre-wrap; word-break: break-all; font-size: 11px; background: #f3f4f6; padding: 8px; border-radius: 8px; max-height: 40dvh; overflow: auto; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + var(--safe-b)); background: #111827; color: #fff; padding: 10px 14px; border-radius: 22px; z-index: 20; display: flex; gap: 12px; align-items: center; max-width: 92vw; }
#toast[hidden] { display: none; }
#toast button { color: #86efac; font-weight: 600; }

#notices { background: #fff7ed; border-bottom: 1px solid #fed7aa; padding: 8px 12px; font-size: 14px; }
.row.small { margin-top: 2px; gap: 14px; font-size: 13px; }
.dots { color: var(--muted); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
#mic.recording { color: #fff; background: var(--red); }
#me { font-size: 22px; }

table.receipt { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
table.receipt td { padding: 5px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.receipt td.num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.receipt tr.missing td { color: var(--muted); }
.ok { color: var(--green); margin: 8px 0; } .warn { color: #b45309; margin: 8px 0; }
.matches { background: #ecfdf5; border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.matches ul, ul.plain { list-style: none; margin: 4px 0 8px; padding: 0; }
ul.plain li { padding: 8px 0; border-top: 1px solid var(--line); }
#attach { font-size: 20px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 8px; }
.chip { flex: none; padding: 6px 12px; border-radius: 16px; border: 1px solid var(--line); background: #fff; font-size: 14px; }
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }
.arrival { font-size: 13px; color: #374151; background: #eef6f2; border-radius: 10px; padding: 6px 10px; margin: 0 0 8px; }
/* Shop mode: one shop's items while buying, bigger to hit with a thumb. */
.items.shopmode .item { min-height: 64px; font-size: 18px; }
.items.shopmode .tick span { width: 30px; height: 30px; }

.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; }
.items.shopmode .thumb { width: 72px; height: 72px; }
img.big { width: 100%; max-height: 60dvh; object-fit: contain; border-radius: 12px; background: #f3f4f6; }

.card.out { grid-column: 1 / -1; border-color: #fdba74; background: #fff7ed; margin-bottom: 12px; }
.card.out li { white-space: normal; padding: 3px 0; }

/* The update fills the bottom line (homelists#37, as FoxChat). */
#status { --upd: 0%; border-radius: 8px; }
#status.updating { background: linear-gradient(90deg, #d1fae5 var(--upd), transparent var(--upd)); color: var(--green); }
#status.updfailed { color: #b45309; }
#status.updated #version { color: var(--green); font-weight: 600; }

/* ⋮ at the card's right, room kept on the right whatever the title's direction (homelists#62: inline-end padding of
   a Hebrew title is on its left, so the title ran under the ⋮ and the menu looked like part of a letter). */
.card .cardmenu { position: absolute; top: 2px; right: 2px; width: 36px; height: 36px; font-size: 20px; color: var(--muted); border-radius: 18px; background: var(--card); z-index: 1; }
.card h2 { padding-right: 30px; }
.card.dragging { z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,.25); transform-origin: center; opacity: .95; }
.memory .note { padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }

/* ↶ ↷ always in the top bar (homelists#53). */
#top .hist { color: #fff; font-size: 22px; width: 40px; }
#top .hist:disabled { opacity: .35; }

/* The chat panel (homelists#56): its own section between the lists and the box. */
#chat { display: flex; flex-direction: column; background: #fbfaf7; border-top: 2px solid var(--green); flex: none; min-height: 40px; }
#chathandle { display: flex; align-items: center; gap: 8px; padding: 0 4px 0 12px; height: 40px; touch-action: none; cursor: ns-resize; flex: none; }
#chathandle .grip { width: 36px; height: 4px; border-radius: 2px; background: #c9c3b6; position: absolute; left: 50%; transform: translateX(-50%); }
#chathandle .title { font-size: 13px; color: var(--muted); flex: 1; }
#chathandle .icon { width: 36px; height: 36px; font-size: 16px; color: var(--muted); }
#chat { position: relative; }
#chatlog { flex: 1; overflow-y: auto; padding: 0 10px 8px; }
#chatlog .msg { padding: 8px 10px; border-radius: 12px; margin: 6px 0; max-width: 92%; font-size: 15px; }
#chatlog .msg.user { background: #e7f5ef; margin-inline-start: auto; width: fit-content; }
#chatlog .msg.assistant { background: #fff; border: 1px solid var(--line); }
#chatlog .line { min-height: 1.2em; }
#chatlog .line.bullet { padding-inline-start: 14px; position: relative; }
#chatlog .line.bullet::before { content: "•"; position: absolute; inset-inline-start: 2px; color: var(--muted); }
#chatbar { width: 100%; text-align: center; font-size: 13px; color: var(--green); padding: 4px 0 6px; }
li.item.flash { background: #fef3c7; transition: background .6s; }

#cancelrec { color: var(--red); font-size: 18px; }

/* Rows are dragged like cards (homelists#71): no text selection under a long press, vertical scrolling kept. */
li.item { -webkit-user-select: none; user-select: none; touch-action: pan-y; background: var(--card); }
li.item.dragging { position: relative; z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
