/* Base colors. A person's theme (Me → Colors & theme) overrides these from an inline <style>.
   Everything else is mixed from them, so any color combination stays readable. */
:root {
  --bg: #f6f5f1; --card: #fff; --text: #1f2421; --accent: #2f6f4f; --accent-ink: #fff;
  --warn: #b5541c; --out: #2b5c8a; --danger: #b0413e;
  --radius: 12px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151816; --card: #1f2321; --text: #e8ebe9; --accent: #5fb88a; --accent-ink: #0d1a13;
    --warn: #f0a26b; --out: #7fb0e0; --danger: #e57773; }
}
:root {
  --muted: color-mix(in srgb, var(--text) 62%, var(--card));
  --line: color-mix(in srgb, var(--text) 14%, var(--card));
  --warn-bg: color-mix(in srgb, var(--warn) 16%, var(--card));
  --out-bg: color-mix(in srgb, var(--out) 14%, var(--card));
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; margin: .4rem 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.hidden { display: none !important; }
.center { text-align: center; }

/* header */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .6rem; padding: .55rem 16px; background: var(--accent); color: var(--accent-ink); }
.top a { color: var(--accent-ink); }
.brand { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: 1.1rem; }
.back { font-size: 1.9rem; line-height: 1; padding: 0 .3rem 0 0; margin-top: -4px; }
.topsearch { flex: 1; min-width: 0; }
.topsearch input { width: 100%; border: 0; border-radius: 999px; padding: .45rem .9rem; background: rgba(255,255,255,.18); color: inherit; font-size: 15px; }
.topsearch input::placeholder { color: currentColor; opacity: .75; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; }

/* bottom nav */
.bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-around; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.bottom a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .72rem; min-width: 56px; padding: 2px 6px; }
.bottom a.scanbtn { color: var(--accent-ink); background: var(--accent); border-radius: 14px; padding: 6px 14px; margin-top: -14px; box-shadow: var(--shadow); }
.dot { display: inline-block; min-width: 1.2em; padding: 0 .3em; border-radius: 999px; background: var(--warn); color: #fff; font-size: .7rem; text-align: center; }

/* blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
.narrow { max-width: 420px; margin: 24px auto; }
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 12px; background: color-mix(in srgb, var(--accent) 16%, var(--card)); border-left: 4px solid var(--accent); font-weight: 600; }
.flash.err { background: color-mix(in srgb, var(--danger) 16%, var(--card)); border-left-color: var(--danger); }
.alert { display: block; padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 10px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.empty { padding: 1rem 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: calc(var(--radius) * .8); padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: currentColor; background: transparent; }
.btn.small { min-height: 34px; padding: .3rem .6rem; font-size: .85rem; }
.btn.round { width: 48px; height: 48px; border-radius: 50%; font-size: 1.5rem; padding: 0; }
.btn.wide { width: 100%; margin-top: 12px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0 .3rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions form { display: contents; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 4px; }
.quick .btn { padding: .6rem .4rem; font-size: .9rem; }

/* forms */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; }
.form small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: calc(var(--radius) * .8); padding: .6rem .7rem; width: 100%; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input.short { max-width: 6rem; text-transform: uppercase; }
.form.inline { grid-template-columns: 1fr; }
@media (min-width: 560px) { .form.inline { grid-template-columns: 1fr 1fr auto; align-items: end; } }
form.inline:not(.form) { display: inline; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
details > label, details > .row2 { margin-top: 10px; }
.colors { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.colors legend { font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
.swatch input[type=radio] { position: absolute; opacity: 0; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 3px solid transparent; cursor: pointer; }
.swatch input:checked + span { border-color: var(--text); }
.check { display: flex !important; align-items: center; gap: .5rem; font-weight: 400 !important; padding: .35rem 0; }
.check input { width: 22px; min-height: 22px; height: 22px; }
fieldset.card legend { font-weight: 700; padding: 0 .3rem; }

/* spaces */
.sectionhead { display: flex; align-items: baseline; justify-content: space-between; }
.spaces { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.space { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius); background: var(--c); color: var(--c-ink, #fff); min-height: 86px; box-shadow: var(--shadow); }
.space b { font-size: 1.1rem; }
.space small { opacity: .9; }
.space .owner { margin-top: auto; font-style: italic; }
.spacehead, .boxhead { background: var(--c); color: var(--c-ink, #fff); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.spacehead h1, .boxhead h1 { margin: 0; }
.spacehead p { margin: .2rem 0 0; opacity: .9; }
.boxhead { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.boxhead a, .boxhead .muted { color: inherit; opacity: .9; }
.boxname { font-size: 1.1rem; margin: .2rem 0; font-weight: 600; }
.boxhead .qr { flex: 0 0 96px; background: #fff; border-radius: 8px; padding: 4px; }
.boxhead .qr svg { display: block; width: 100%; height: auto; }
.code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-weight: 700; }
.code.big { font-size: 2rem; letter-spacing: .02em; }

/* tabs, chips */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0 10px; }
.tabs a { padding: .55rem 1rem; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; scrollbar-width: thin; }
.chips a { flex: 0 0 auto; padding: .35rem .8rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: .9rem; white-space: nowrap; }
.chips a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips a small { opacity: .7; }

/* lists */
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.items li + li { border-top: 1px solid var(--line); }
.items a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: var(--text); }
.items .grow { flex: 1; min-width: 0; display: grid; }
.items .grow b, .items .grow small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qty { text-align: right; font-weight: 600; white-space: nowrap; display: grid; justify-items: end; gap: 2px; }
.thumb { width: 48px; height: 48px; border-radius: calc(var(--radius) * .65); object-fit: cover; flex: 0 0 48px; background: var(--line); }
.thumb.none { display: block; background: repeating-linear-gradient(45deg, var(--line), var(--line) 6px, transparent 6px, transparent 12px); }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--line); color: var(--text); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.out { background: var(--out-bg); color: var(--out); }
.list { display: grid; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 12px 0; }
.list > a, .list > details > summary { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; color: var(--text); }
.list > * + * { border-top: 1px solid var(--line); }
.row-detail form { padding: 0 16px 16px; }
.plain { padding-left: 1.1rem; }
.cats { list-style: none; padding: 0; margin: 0; }
.cats li { margin: 6px 0; }
.cats .d1 { margin-left: 1.2rem; } .cats .d2 { margin-left: 2.4rem; } .cats .d3 { margin-left: 3.6rem; }
.catrow { display: flex; gap: 6px; align-items: center; }
.catrow input { flex: 1; min-width: 0; }
.shares { list-style: none; padding: 0; margin: 0 0 12px; }
.shares li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; }
.shares select { width: auto; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

/* item page */
.where { font-size: 1.05rem; }
.qtyrow { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 14px 0 6px; }
.qtyrow form { display: inline; }
.bigqty { font-size: 2.2rem; font-weight: 700; min-width: 4ch; text-align: center; }
.bigqty small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.outcard { border-color: var(--out); background: var(--out-bg); }
.gallery { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 10px; }
.gallery figure { position: relative; margin: 0; flex: 0 0 auto; }
.gallery img { height: 180px; max-width: 80vw; border-radius: var(--radius); object-fit: cover; display: block; }
.gallery .x { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; }
.photoform { display: inline; }
.photo-pick { justify-self: start; }

/* scanner */
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 1 / 1; max-height: 60vh; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .scanmsg { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 10px; background: rgba(0,0,0,.55); color: #fff; text-align: center; }

/* labels */
.sheet { display: grid; grid-template-columns: repeat(auto-fill, 2.5in); gap: .15in; justify-content: center; }
.label { width: 2.5in; border: 1px dashed #bbb; border-radius: 8px; padding: .12in; display: grid; justify-items: center; gap: 2px; background: #fff; color: #000; break-inside: avoid; }
.label svg { width: 1.9in; height: 1.9in; }
.label b { font: 700 24pt/1 ui-monospace, Consolas, monospace; }
.label small { font-size: 9pt; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media print {
  .top, .bottom, .noprint, .flash { display: none !important; }
  body { background: #fff; padding: 0; }
  main { max-width: none; padding: 0; }
  .label { border-color: #ddd; }
}

/* theme picker */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-opt { position: relative; cursor: pointer; }
.theme-opt input { position: absolute; opacity: 0; }
.theme-opt .mini { display: block; border-radius: 12px; overflow: hidden; border: 3px solid transparent; background: var(--t-bg); box-shadow: var(--shadow); }
.theme-opt input:checked + .mini { border-color: var(--accent); outline: 2px solid var(--card); outline-offset: -5px; }
.theme-opt input:focus-visible + .mini { outline: 2px solid var(--text); }
.mini .bar { display: block; height: 22px; background: var(--t-accent); }
.mini .body { display: grid; gap: 5px; padding: 8px; }
.mini .tile { display: block; height: 16px; border-radius: 4px; background: var(--t-card); }
.mini .tile.short { width: 60%; }
.mini .name { color: var(--t-text); font-size: .85rem; font-weight: 700; }
.colorrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.colorrow label { display: flex !important; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: calc(var(--radius) * .8); padding: 6px 6px 6px 12px; }
.colorrow input[type=color] { width: 48px; min-height: 36px; height: 36px; padding: 2px; flex: 0 0 48px; cursor: pointer; }
.save-bar { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.save-bar .btn { flex: 1; }
.swatch.custom { position: relative; }
.swatch.custom input[type=color] { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; border: 3px dashed var(--line); background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); cursor: pointer; }
.swatch.custom input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.swatch.custom input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.swatch.custom:has(input[type=radio]:checked) input[type=color] { border: 3px solid var(--text); }

/* shown only when a phone renders the site in "Desktop site" mode (see app.js) */
.desktop-mode { position: relative; z-index: 50; padding: 3vw; font-size: 3.4vw; line-height: 1.4; background: var(--warn-bg); color: var(--text); border-bottom: 4px solid var(--warn); }
.desktop-mode button { margin-top: 1.5vw; font-size: 3.2vw; padding: 1vw 3vw; border-radius: 1vw; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.swatch.theme span { box-shadow: inset 0 0 0 3px var(--card); outline: 2px dashed var(--c); outline-offset: -1px; }

/* storage types */
.thumb.kind, .thumb.part { display: grid; place-items: center; font-size: 1.5rem; background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.thumb.part { font: 700 .95rem/1 ui-monospace, Consolas, monospace; color: var(--accent); }
.crumbs { margin: 0 0 .2rem; font-size: .9rem; opacity: .9; }
.crumbs a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.code.big.long { font-size: 1.45rem; }
.label b.long { font-size: 16pt; }
.check.sub { padding-left: 1.6rem; }
.addparts { margin-top: 10px; }
.addparts input[type=number] { display: inline-block; width: 4.5rem; margin: 0 .3rem; }
.addparts label { display: block !important; }

/* locations */
.newloc { display: grid; gap: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: calc(var(--radius) * .8); }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.locs .d1 a { padding-left: 2rem; } .locs .d2 a { padding-left: 3.5rem; } .locs .d3 a { padding-left: 5rem; }
