/* Reusable pieces: buttons, chips, segmented controls, cards, forms, toast, sheet, overlays. */

/* ---- buttons ---- */
.btn-primary {
  font-weight: 600; background: var(--primary); color: var(--primary-ink); border: none;
  border-radius: var(--r-pill); padding: 12px 22px; min-height: 48px; cursor: pointer;
  transition: transform .12s, background .15s, box-shadow .15s; box-shadow: 0 2px 0 rgba(0,0,0,.08);
}
.btn-primary:hover { background: var(--primary-deep); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-big { padding: 14px 26px; font-size: 1.02rem; }
.btn-ghost {
  font-weight: 500; font-size: .92rem; background: none; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 10px 18px; min-height: 44px;
  cursor: pointer; margin-top: 20px;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn-ghost.no-mt { margin-top: 0; }
.back-btn { background: none; border: none; color: var(--muted); font-weight: 500; padding: 12px 0; cursor: pointer; }
.back-btn:hover { color: var(--ink); }
.row-btn {
  font-size: .82rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill);
  color: var(--muted); padding: 6px 12px; min-height: 34px; cursor: pointer;
}
.row-btn:hover { color: var(--ink); border-color: var(--muted); }
.row-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.row-btn.suggested { border-color: var(--success); color: var(--success); font-weight: 600; }

/* ---- chips and segmented controls ---- */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 7px 14px; font-size: .88rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip-btn.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.seg { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: var(--r-pill); padding: 3px; }
.seg-btn { background: none; border: none; border-radius: var(--r-pill); padding: 6px 16px; font-size: .88rem; font-weight: 500; color: var(--muted); cursor: pointer; }
.seg-btn.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }
.grade {
  position: absolute; top: 8px; right: 8px; min-width: 26px; height: 26px; border-radius: 13px; display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1);
}
.grade-A { color: var(--success); } .grade-B { color: #5A8F2E; } .grade-C { color: var(--warn); } .grade-D { color: var(--danger); }

/* ---- cards and forms ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; box-shadow: var(--shadow-1); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
.field input, .field select, .search, .chips-input input {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; width: 100%; outline: none; min-height: 44px;
}
.field input:focus, .search:focus, .field select:focus { border-color: var(--primary); }
.search { margin-bottom: 12px; border-radius: var(--r-pill); padding-left: 18px; }
.money-input { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px; color: var(--muted); min-height: 44px; }
.money-input input { border: none; padding: 8px 0; width: 5.5em; min-height: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.form-row { max-width: 460px; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: calc(var(--tabbar-h) + 16px); left: 0; right: 0; margin: 0 auto; width: max-content;
  max-width: calc(100vw - 32px); background: var(--ink); color: var(--bg); border-radius: var(--r-pill);
  padding: 10px 20px; font-size: .9rem; box-shadow: var(--shadow-2); z-index: 80; animation: fade .25s ease both;
}
.toast b { color: var(--accent); }
body.in-trip .toast { bottom: 128px; }

/* ---- recipe sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 90; background: rgba(43, 33, 24, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease both; }
.sheet-inner {
  position: relative; background: var(--bg); width: min(640px, 100%); max-height: 92vh; overflow-y: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 0 var(--gutter) 32px; animation: rise .25s ease both;
}
.sheet-close { position: sticky; top: 10px; float: right; width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--surface); box-shadow: var(--shadow-1); font-size: 1.5rem; line-height: 1; cursor: pointer; z-index: 2; margin-top: 10px; }
body.sheet-open { overflow: hidden; }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet-inner { border-radius: var(--r-lg); } }

/* ---- overlays (receipt preview, quick check) ---- */
.overlay { position: fixed; inset: 0; z-index: 95; background: rgba(251, 246, 238, .96); display: flex; align-items: center; justify-content: center; animation: fade .2s ease both; padding: var(--gutter); }
.overlay-inner { width: min(520px, 100%); max-height: 90vh; overflow-y: auto; }
.overlay-title { font-family: var(--display); font-size: 1.6rem; font-weight: 600; margin-bottom: 12px; }
.check-inner { text-align: center; }
.check-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px 20px; margin-bottom: 12px; box-shadow: var(--shadow-1); animation: rise .25s ease both; }
.check-card .q-text { font-family: var(--display); font-size: 1.5rem; font-weight: 600; }
.check-card .q-hint { color: var(--muted); margin: 6px 0 16px; }
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.q-btn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 10px 18px; min-height: 44px; cursor: pointer; font-weight: 500; }
.q-btn.yes { border-color: var(--success); color: var(--success); }
.q-btn:hover { background: var(--surface-2); }
.receipt-lines { max-height: 50vh; overflow-y: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.receipt-line { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); font-size: .9rem; }
.receipt-line:last-child { border-bottom: none; }
.receipt-line .rl-name { flex: 1; min-width: 0; }
.receipt-line .rl-name small { display: block; color: var(--muted); font-size: .75rem; }
.receipt-line .rl-price { font-variant-numeric: tabular-nums; font-weight: 600; }
.receipt-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.link-btn { background: none; border: none; color: var(--primary); font-weight: 600; padding: 10px 0; cursor: pointer; }
