/* Kondo x Martha: linen paper, jadeite primary, one soft wash per space. Light-only by design. */
:root {
  --paper: #fbf8f3;
  --card: #ffffff;
  --line: #ebe4d8;
  --line-2: #ddd5c7;
  --ink: #2f3a34;
  --ink-2: #56605a;
  --ink-3: #737b75;
  --primary: #2f5a45;
  --primary-ink: #fbf8f3;
  --danger: #a3392c;
  --danger-wash: #f8e1dc;

  --jade: #9cc7ad;   --jade-wash: #dcefe3;   --jade-ink: #2d5a40;
  --blush: #e8b7aa;  --blush-wash: #f7e2dc;  --blush-ink: #7a3b2e;
  --butter: #e3c873; --butter-wash: #f6edcf; --butter-ink: #6b5420;
  --sky: #a9c6db;    --sky-wash: #dfeaf2;    --sky-ink: #2e4d63;

  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --body: "Nunito Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --tabs-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font: 17px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) 32px max(18px, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 18px;
}
h1, h2, .display { font-family: var(--display); font-weight: 600; margin: 0; line-height: 1.05; text-wrap: balance; }
h1 { font-size: 40px; letter-spacing: -0.01em; }
h2 { font-size: 26px; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: 15px; }
.label {
  font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.stack { display: grid; gap: 10px; }
.row-actions { display: flex; gap: 10px; }
.row-actions > * { flex: 1; }

/* Controls */
button, .btn { font: inherit; }
.btn {
  height: 50px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px;
  font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.danger { color: var(--danger); border-color: #e6c3bc; }
.btn.danger.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--primary); }
.btn:active { transform: scale(0.98); }
.btn[aria-busy="true"] { opacity: 0.7; pointer-events: none; }
:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 700; font-size: 15px; }
input[type="text"], input[type="password"], input[type="search"], input[type="number"] {
  font: inherit; font-size: 17px; height: 50px; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); padding: 0 14px; width: 100%;
}
.search {
  display: flex; align-items: center; gap: 10px; height: 54px; border-radius: 16px; border: 1px solid var(--line-2);
  background: var(--card); padding: 0 14px;
}
.search svg { width: 22px; height: 22px; stroke: var(--ink-3); fill: none; stroke-width: 1.8; flex: none; }
.search input { border: 0; height: 100%; padding: 0; background: transparent; font-size: 18px; }
.search input:focus { outline: none; }
.search:focus-within { border-color: var(--primary); }

.chip {
  display: inline-flex; align-items: center; font-size: 14px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  white-space: nowrap; letter-spacing: 0.02em;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  font: inherit; font-size: 15px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); cursor: pointer; min-height: 40px;
}
.chip-btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

.c-jade { background: var(--jade-wash); color: var(--jade-ink); }
.c-blush { background: var(--blush-wash); color: var(--blush-ink); }
.c-butter { background: var(--butter-wash); color: var(--butter-ink); }
.c-sky { background: var(--sky-wash); color: var(--sky-ink); }
.sw { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.sw-jade { background: var(--jade); } .sw-blush { background: var(--blush); }
.sw-butter { background: var(--butter); } .sw-sky { background: var(--sky); }

/* Lists */
.list { display: grid; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; min-height: 56px;
}
.list-row:last-child { border-bottom: 0; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-weight: 700; }
.list-row .sub { font-size: 15px; color: var(--ink-3); overflow-wrap: anywhere; }
.qty { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.spaces { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.space {
  border-radius: 16px; padding: 14px; text-decoration: none; display: grid; gap: 2px; min-height: 84px; align-content: end;
}
.space .display { font-size: 26px; }
.space span { font-size: 15px; }

/* Bin page */
.bin-head { display: grid; gap: 8px; }
.bin-head .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.photo {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 18px; background: #e9e2d4; display: block;
}
.photo-empty {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 18px; border: 1.5px dashed var(--line-2); background: var(--card);
  display: grid; place-content: center; gap: 12px; text-align: center; padding: 20px; color: var(--ink-2);
}
.things { display: grid; }
.things li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.things li:last-child { border-bottom: 0; }
ul.things { list-style: none; margin: 0; padding: 0; }

/* Sheets */
.scrim { position: fixed; inset: 0; background: rgba(35, 40, 37, 0.35); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; background: var(--paper); border-radius: 22px 22px 0 0;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  display: grid; gap: 14px; max-width: 600px; margin: 0 auto;
  animation: up 0.22s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line-2); justify-self: center; }
.sheet .foot {
  position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom, 0px)); background: var(--paper);
  padding: 10px 0 calc(18px + env(safe-area-inset-bottom, 0px)); margin-bottom: calc(-18px - env(safe-area-inset-bottom, 0px));
  display: grid; gap: 8px;
}
@keyframes up { from { transform: translateY(30px); opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.edit-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); min-height: 56px; }
.edit-row input[type="text"] { border: 0; background: transparent; height: 48px; padding: 0 4px; flex: 1; min-width: 0; }
.edit-row input[type="text"]:focus { outline: none; background: var(--card); border-radius: 10px; }
.edit-row.off input[type="text"] { text-decoration: line-through; color: var(--ink-3); }
.check {
  width: 44px; height: 44px; flex: none; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.check span {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--primary); display: grid; place-items: center;
}
.check[aria-checked="true"] span { background: var(--primary); }
.check svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 3; }
.check[aria-checked="false"] svg { display: none; }
.check[aria-checked="false"] span { border-color: var(--line-2); }
.stepper { display: flex; align-items: center; flex: none; }
.stepper button {
  width: 36px; height: 44px; border: 0; background: transparent; color: var(--primary); font-size: 22px; cursor: pointer; padding: 0;
}
.stepper output { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink-3); font-size: 24px; cursor: pointer; flex: none;
}
.add-row {
  display: flex; align-items: center; gap: 10px; min-height: 52px; border: 0; background: transparent; color: var(--primary);
  font: inherit; font-weight: 700; cursor: pointer; padding: 0 8px;
}

.looking { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 8px 0 16px; }
.looking img { width: 100%; max-height: 40vh; object-fit: cover; border-radius: 16px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--jade); animation: pulse 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; } .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 50% { transform: scale(0.5); opacity: 0.4; } }

.note { background: var(--butter-wash); color: var(--butter-ink); border-radius: 14px; padding: 12px 14px; font-size: 15px; }
.error { background: var(--danger-wash); color: var(--danger); border-radius: 14px; padding: 12px 14px; font-size: 15px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; z-index: 50; font-weight: 600; font-size: 15px;
}

/* Tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: rgba(251, 248, 243, 0.96); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.tabs a, .tabs button {
  flex: 1; max-width: 180px; height: var(--tabs-h); display: grid; place-items: center; align-content: center; gap: 2px;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--ink-3); text-decoration: none; background: none; border: 0; cursor: pointer;
}
.tabs svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs [aria-current="page"] { color: var(--primary); }

/* Scanner */
.scanner { position: fixed; inset: 0; z-index: 40; background: #111; display: grid; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame {
  position: absolute; left: 50%; top: 45%; width: min(70vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, 0.9); border-radius: 24px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
}
.scanner .bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 12px; color: #fff; text-align: center;
}
.scanner .bar .btn { background: rgba(255, 255, 255, 0.95); }
