/* Snekkjó innkaup — phone first. Thumb-reachable actions, big tap targets,
   nothing that needs precision. Light and dark both come from one set of
   tokens so the only per-theme decisions are the two blocks below. */

:root {
  --bg:        #f6f5f2;
  --surface:   #ffffff;
  --surface-2: #efede8;
  --line:      #e2dfd8;
  --ink:       #1c1b18;
  --ink-2:     #6b675e;
  --ink-3:     #9a958a;
  --accent:    #2f6f4e;
  --accent-ink:#ffffff;
  --accent-sw: #eaf2ed;
  --warn:      #9a5b12;
  --warn-sw:   #fbf0e0;
  --bad:       #a3342c;
  --bad-sw:    #fbeae8;
  --radius:    14px;
  --tap:       44px;
  --pad:       16px;
  --shadow:    0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #16171a;
    --surface:   #1f2125;
    --surface-2: #272a2f;
    --line:      #33373d;
    --ink:       #ecebe8;
    --ink-2:     #a7a49d;
    --ink-3:     #76736d;
    --accent:    #6bbd8e;
    --accent-ink:#10231a;
    --accent-sw: #1d2e25;
    --warn:      #e0a862;
    --warn-sw:   #2e2619;
    --bad:       #e88f86;
    --bad-sw:    #2f1f1d;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { padding-bottom: env(safe-area-inset-bottom); }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); }

/* ------------------------------------------------------------------ layout */

#app { max-width: 620px; margin: 0 auto; padding: 0 var(--pad) 140px; }
#app.loading::after {
  content: ""; display: block; width: 26px; height: 26px; margin: 25vh auto 0;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 0 10px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
header.top h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: -.01em; }
header.top .sub { display: block; font-size: 12px; font-weight: 400; color: var(--ink-2); }

.iconbtn {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  display: grid; place-items: center; font-size: 19px; color: var(--ink-2);
  flex: 0 0 auto;
}
.iconbtn:active { background: var(--surface-2); }

/* --------------------------------------------------------------------- tabs */

nav.tabs {
  display: flex; gap: 4px; margin: 0 0 14px;
  background: var(--surface-2); padding: 4px; border-radius: 12px;
}
nav.tabs button {
  flex: 1; padding: 9px 4px; border-radius: 9px; font-size: 14px;
  color: var(--ink-2); font-weight: 500;
}
nav.tabs button[aria-current="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}

/* -------------------------------------------------------------------- cards */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--pad); margin-bottom: 10px;
}
.card.tap { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.card.tap:active { background: var(--surface-2); }
.card h2 { margin: 0; font-size: 17px; }
.card .meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

.empty { text-align: center; color: var(--ink-2); padding: 48px 20px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; }

/* -------------------------------------------------------------------- items */

ul.items { list-style: none; margin: 0; padding: 0; }

li.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px 8px 8px; margin-bottom: 8px;
}
li.item.gone { opacity: .45; }

.thumb {
  width: 54px; height: 54px; flex: 0 0 auto; border-radius: 10px; overflow: hidden;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--ink-3);
}
/* height:100% would resolve against a content-sized track, i.e. not at all,
   leaving the photo at its natural aspect and spilling into the next row. */
.thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; }

.name { flex: 1; min-width: 0; }
.name b { display: block; font-weight: 550; font-size: 15px; line-height: 1.25; }
/* block, or text-overflow has nothing to clip and the email runs under the
   badges beside it */
.name small { display: block; color: var(--ink-2); font-size: 12.5px; }

/* The quantity stepper is the main control, so it gets real tap targets. */
.stepper { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.stepper button {
  width: 34px; height: 34px; border-radius: 9px; font-size: 18px; line-height: 1;
  background: var(--surface-2); color: var(--ink);
}
.stepper button:active { background: var(--line); }
.stepper .n { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ------------------------------------------------------------------ pickers */

.search {
  width: 100%; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.search::placeholder { color: var(--ink-3); }

.badge {
  display: inline-block; flex: 0 0 auto; font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  vertical-align: 1px;
}
.badge.due  { background: var(--warn-sw); color: var(--warn); }
.badge.bad  { background: var(--bad-sw);  color: var(--bad); }
.badge.ok   { background: var(--accent-sw); color: var(--accent); }

/* Accordion. `name` on <details> makes the browser close the others, so there
   is no open/close bookkeeping in the client. */
details.group { margin-bottom: 8px; }
details.group summary {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 0 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-weight: 550; font-size: 15px; list-style: none;
}
details.group summary::-webkit-details-marker { display: none; }
details.group summary::after {
  content: "›"; color: var(--ink-3); font-size: 19px; transition: transform .15s;
}
details.group[open] summary { border-radius: var(--radius) var(--radius) 0 0; }
details.group[open] summary::after { transform: rotate(90deg); }
details.group summary:active { background: var(--surface-2); }
details.group ul.items {
  border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius); padding: 6px;
}
details.group ul.items li.item { border: 0; background: none; margin: 0; }
details.group ul.items li.item + li.item { border-top: 1px solid var(--line); }

.addbtn {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  background: var(--accent-sw); color: var(--accent); font-size: 20px; font-weight: 600;
}
.addbtn:active { transform: scale(.94); }
.addbtn[disabled] { background: var(--surface-2); color: var(--ink-3); }
/* Explicit, because a `display` here would outrank the UA's [hidden] rule and
   leave the minus clickable while invisible — the backdrop bug in miniature. */
.addbtn[hidden] { display: none; }

.stepper[hidden] { display: none; }

/* ------------------------------------------------------------- bottom bar */

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 35%);
  display: flex; gap: 10px; justify-content: center;
}
.bottom > * { max-width: 620px; flex: 1; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; border-radius: 13px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
  padding: 0 18px; width: 100%; text-decoration: none;
}
.btn:active { filter: brightness(.94); }
.btn[disabled] { background: var(--surface-2); color: var(--ink-3); box-shadow: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
/* Menu rows read as a list, not as a stack of call-to-action buttons. */
.menurow { justify-content: flex-start; margin-bottom: 8px; font-weight: 500; }

/* -------------------------------------------------------------------- sheet */

/* :not([hidden]) is load-bearing. A bare `display: flex` here outranks the UA's
   `[hidden] { display: none }`, which leaves this full-viewport overlay painted
   and hit-testable at all times: the page dims slightly and every tap lands on
   the backdrop instead of the control underneath. */
#sheet:not([hidden]) {
  display: flex; align-items: flex-end; justify-content: center;
}
#sheet {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35);
}
#sheet .panel {
  background: var(--bg); width: 100%; max-width: 620px;
  border-radius: 18px 18px 0 0; padding: 10px var(--pad) calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: rise .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translateY(14px); opacity: .5; } }
#sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
#sheet h2 { margin: 0 0 12px; font-size: 18px; }

/* -------------------------------------------------------------------- toast */

#toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px;
  border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
}

/* ------------------------------------------------------------------ history */

ol.log { list-style: none; margin: 0; padding: 0; }
ol.log li {
  display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line);
  font-size: 14px; align-items: baseline;
}
ol.log li:last-child { border-bottom: 0; }
ol.log time { flex: 0 0 76px; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
ol.log .who { color: var(--ink-2); }

.sectionhead {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); margin: 20px 0 8px; font-weight: 600;
}

.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); font-size: 13px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
