:root {
  --bg: #faf7f0;
  --surface: #ffffff;
  --text: #221c10;
  --muted: #6e6656;
  --line: #e7e0d0;
  --gold: #7a5a12;
  --gold-soft: #f4ead2;
  --red: #b3261e;
  --red-soft: #fbe3e1;
  --amber: #8a5a00;
  --amber-soft: #fdf0d2;
  --green: #1f6b3a;
  --green-soft: #def2e4;
  --blue: #1e4f8a;
  --blue-soft: #e1ebf8;
  --grey-soft: #eeeae2;
  --radius: 0.75rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120c;
    --surface: #211d15;
    --text: #f2ecdf;
    --muted: #a99f8b;
    --line: #3a3326;
    --gold: #e0b955;
    --gold-soft: #3a2f16;
    --red: #ff8a80;
    --red-soft: #3d1c1a;
    --amber: #f3c35b;
    --amber-soft: #3a2c10;
    --green: #7fd69b;
    --green-soft: #17311f;
    --blue: #93b9ee;
    --blue-soft: #18263a;
    --grey-soft: #2d281e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
/* Settings → Language & text size. Sizes are in rem, so text, buttons and spacing all grow together. */
html[data-text="medium"] { font-size: 115%; }
html[data-text="large"] { font-size: 130%; }
@media (max-width: 490px) { html[data-text="medium"] .grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) { html[data-text="large"] .grid { grid-template-columns: 1fr; } }
.text-preview { margin: 4px 0 0; padding: 0.75rem; border-radius: 0.625rem; background: var(--grey-soft); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--gold); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.loading { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Header ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 0.5rem;
  padding: calc(0.625rem + env(safe-area-inset-top)) 1rem 0.625rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 1.125rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.5rem; height: 2.5rem; padding: 0 0.625rem;
  border-radius: 0.625rem; border: 0; background: transparent;
  color: var(--text); font-size: 0.9375rem; text-decoration: none; cursor: pointer;
}
.icon-btn:hover { background: var(--grey-soft); }
.icon-btn.gear { min-width: 2.875rem; height: 2.875rem; padding: 0 0.5rem; line-height: 1; }
/* Line icons (app.js icon()). */
.ico { width: 1.25em; height: 1.25em; flex: 0 0 auto; vertical-align: -0.25em; }
.icon-btn .ico { width: 1.375rem; height: 1.375rem; }
.icon-btn.gear .ico { width: 1.625rem; height: 1.625rem; }
.h-ico { width: 1.1em; height: 1.1em; vertical-align: -0.18em; margin-right: 0.15em; color: var(--gold); }
.pick-photo .ico { margin-right: 0.25rem; }
.back { font-size: 1.75rem; line-height: 1; padding-bottom: 4px; }

main { max-width: 47.5rem; margin: 0 auto; padding: 1rem 1rem 7.5rem; }

/* ---------- Buttons & form ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  min-height: 2.75rem; padding: 0 1rem;
  border-radius: 0.625rem; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #1b1408; } }
.btn.whatsapp { background: #1f8f4e; border-color: #1f8f4e; color: #fff; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn.small { min-height: 2.125rem; padding: 0 0.75rem; font-size: 0.875rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn-row .btn { flex: 1 1 auto; }

.fab {
  position: fixed; right: 1rem; bottom: calc(1.25rem + env(safe-area-inset-bottom)); z-index: 6;
  min-height: 3.25rem; padding: 0 1.375rem; border-radius: 1.625rem;
  box-shadow: 0 0.375rem 1.125rem rgba(0,0,0,.18);
}

label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: 2.75rem; padding: 0.625rem 0.75rem;
  border: 1px solid var(--line); border-radius: 0.625rem;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
.phone-row { display: flex; gap: 0.5rem; }
.unit-row { display: flex; gap: 0.5rem; }
.unit-toggle { display: flex; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 0.625rem; overflow: hidden; }
.unit-toggle button {
  min-width: 2.75rem; border: 0; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer;
}
.unit-toggle button.on { background: var(--gold); color: #fff; }
@media (prefers-color-scheme: dark) { .unit-toggle button.on { color: #1b1408; } }
.phone-row .cc { flex: 0 0 5.25rem; text-align: center; }
.check { display: flex; align-items: center; gap: 0.625rem; font-weight: 500; min-height: 2.75rem; }
.check input { width: 1.375rem; min-height: 1.375rem; height: 1.375rem; accent-color: var(--gold); }

.section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 0.875rem;
}
.section > h2 { font-size: 0.9375rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 0.75rem; }
.grid { display: grid; gap: 0.75rem; grid-template-columns: 1fr 1fr; }
.grid .full { grid-column: 1 / -1; }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }
.hint { font-size: 0.8125rem; color: var(--muted); margin-top: 4px; }

/* ---------- Orders / Credit log switch ---------- */
.nav-tabs {
  position: relative; display: flex; gap: 4px; padding: 4px; margin-bottom: 14px;
  background: var(--grey-soft); border-radius: 12px;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.nav-tabs a {
  position: relative; z-index: 1;
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; border-radius: 9px;
  color: var(--muted); font-weight: 600; text-decoration: none; transition: color .2s ease;
}
.nav-tabs a.on { color: var(--text); }
/* The sliding bubble behind the open tab (two equal tabs: half the bar minus padding and gap). */
.nav-bubble {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 6px);
  border-radius: 9px; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.05);
  transition: box-shadow .2s ease; will-change: transform;
}
.nav-bubble.at-1 { transform: translateX(calc(100% + 4px)); }
.nav-tabs.dragging .nav-bubble { box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.nav-tabs.dragging a { transform: none !important; cursor: grabbing; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.25rem; height: 1.25rem; padding: 0 0.375rem; border-radius: 0.625rem;
  background: var(--red); color: #fff; font-size: 0.75rem; font-weight: 700;
}
@media (prefers-color-scheme: dark) { .badge { color: #1b1408; } }

/* ---------- Credit log ---------- */
.total-box { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.total-amount { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.progress { height: 0.375rem; border-radius: 3px; background: var(--grey-soft); overflow: hidden; margin: 0.5rem 0; }
.progress span { display: block; height: 100%; background: var(--green); }
.lock-box { max-width: 26.25rem; margin: 1.5rem auto; }
.lock-box h2 { font-size: 1.125rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.lock-box form > * + *, #change-pin > * + *, #reset-form > * + * { margin-top: 0.625rem; }
.pin-input { font-size: 1.5rem; letter-spacing: .5em; text-align: center; }
.link-btn {
  display: block; margin: 0.75rem auto 0; padding: 0.5rem; border: 0; background: none;
  color: var(--gold); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer;
}
.link-btn:disabled { opacity: .6; }
.del-pay { min-width: 2rem; height: 2rem; padding: 0; color: var(--muted); font-size: 0.875rem; }

/* ---------- Products inside an order ---------- */
.product-head { margin-bottom: 4px; }
.product-head h2 { font-size: 1.125rem; }
.product-head h3 { font-size: 1rem; }
.product-block {
  border: 1px dashed var(--line); border-radius: 0.625rem;
  padding: 0.75rem; margin-bottom: 0.75rem;
}
.product-block .product-head { margin-bottom: 0.625rem; }

/* ---------- List ---------- */
.search { margin-bottom: 0.75rem; }
.tabs { display: flex; gap: 0.375rem; overflow-x: auto; margin-bottom: 0.875rem; padding-bottom: 2px; }
.tab {
  flex: 0 0 auto; min-height: 2.25rem; padding: 0 0.875rem; border-radius: 1.125rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.875rem; cursor: pointer;
}
.tab.on { background: var(--gold); border-color: var(--gold); color: #fff; }
@media (prefers-color-scheme: dark) { .tab.on { color: #1b1408; } }

.alert { padding: 0.75rem 0.875rem; border-radius: var(--radius); margin-bottom: 0.875rem; font-weight: 600; background: var(--red-soft); color: var(--red); }
.group-title { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.125rem 0 0.5rem; }
.group-title:first-child { margin-top: 0; }
.card {
  display: block; padding: 0.875rem; margin-bottom: 0.5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; text-decoration: none;
}
.card:hover { border-color: var(--gold); }
.card.overdue { border-left: 4px solid var(--red); }
.card.soon { border-left: 4px solid var(--amber); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 0.625rem; }
.card .meta { font-size: 0.875rem; color: var(--muted); margin: 2px 0 0.375rem; }
.card .bottom { font-size: 0.875rem; }
.empty { text-align: center; padding: 2.5rem 0.625rem; color: var(--muted); }

.chip { display: inline-block; padding: 2px 0.625rem; border-radius: 0.75rem; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.st-Pending { background: var(--grey-soft); color: var(--text); }
.st-With-Karigar { background: var(--blue-soft); color: var(--blue); }
.st-Ready { background: var(--green-soft); color: var(--green); }
.st-Delivered { background: var(--gold-soft); color: var(--gold); }
.st-Cancelled { background: var(--grey-soft); color: var(--muted); text-decoration: line-through; }
.due-overdue { color: var(--red); font-weight: 700; }
.due-soon { color: var(--amber); font-weight: 700; }

/* ---------- Detail ---------- */
.big-name { font-size: 1.375rem; font-weight: 700; }
.kv { display: grid; grid-template-columns: 8.75rem 1fr; gap: 0.375rem 0.75rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.status-pick { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.status-pick .tab { min-height: 2.5rem; }
.photo { width: 100%; max-height: 26.25rem; object-fit: contain; border-radius: 0.625rem; background: var(--grey-soft); display: block; }
.pick-photo { margin: 0.75rem 0 0; font-size: 1rem; }
.photo-thumb { max-width: 10rem; max-height: 10rem; border-radius: 0.5rem; display: block; margin-bottom: 0.5rem; }

.calc { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.calc td { padding: 0.375rem 0; vertical-align: top; }
.calc td:last-child { text-align: right; white-space: nowrap; padding-left: 0.75rem; font-variant-numeric: tabular-nums; }
.calc .how { display: block; font-size: 0.75rem; color: var(--muted); }
.calc .minus td:last-child { color: var(--green); }
.calc .total td { border-top: 1px solid var(--line); font-weight: 700; }
.calc .balance td { border-top: 2px solid var(--text); font-weight: 800; font-size: 1.125rem; padding-top: 0.625rem; }

/* ---------- Login ---------- */
.login { max-width: 23.75rem; margin: 0 auto; padding: 4rem 1rem; }
.login .logo { width: 4.5rem; height: 4.5rem; display: block; margin: 0 auto 0.75rem; border-radius: 1rem; }
.login h1 { text-align: center; font-size: 1.625rem; margin-bottom: 4px; }
.login p { text-align: center; margin: 0 0 1.5rem; }
.login form > * + * { margin-top: 0.75rem; }
.login .tabs { justify-content: center; }
.login .auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 0.5rem 0 1rem; }
.login .auth-tabs .tab { min-height: 2.75rem; font-size: 1rem; font-weight: 600; }
.login .auth-title { font-size: 1.25rem; text-align: center; margin: 0.5rem 0 0.375rem; }
.login p.muted { margin-bottom: 1rem; }
.login > form > * + * , .login #step2 > * + * { margin-top: 0.75rem; }
.login #step2 { margin-top: 0.75rem; }
.google-btn { gap: 0.625rem; }
.or { display: flex; align-items: center; gap: 0.625rem; margin: 1rem 0; color: var(--muted); font-size: 0.875rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

#toast {
  position: fixed; left: 50%; bottom: calc(5.625rem + env(safe-area-inset-bottom)); z-index: 20;
  transform: translateX(-50%) translateY(1.25rem); opacity: 0; pointer-events: none;
  max-width: calc(100% - 2rem); padding: 0.75rem 1.125rem; border-radius: 0.625rem;
  background: var(--text); color: var(--bg); font-weight: 600; transition: .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- Subscription ---------- */
.notice { padding: 0.625rem 0.875rem; border-radius: var(--radius); margin-bottom: 0.875rem; background: var(--amber-soft); color: var(--amber); font-weight: 600; }
.notice a { color: inherit; }
.plan-alert .btn { margin-top: 0.625rem; }
.plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
.plan-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 1.125rem 0.5rem 0.875rem; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.plan-card.on { border-color: var(--gold); background: var(--gold-soft); }
.plan-name { font-weight: 700; }
.plan-price { font-size: 1.375rem; font-weight: 800; }
.plan-price s { font-size: 0.9375rem; font-weight: 500; }
.plan-tag {
  position: absolute; top: -0.6875rem; padding: 1px 0.625rem; border-radius: 0.625rem;
  background: var(--green); color: var(--surface); font-size: 0.75rem; font-weight: 700; white-space: nowrap;
}
.qr { width: 13.75rem; max-width: 100%; margin: 1rem auto 4px; padding: 0.5rem; background: #fff; border-radius: 0.625rem; }
.qr svg { display: block; width: 100%; height: auto; }
.pay-row { display: flex; justify-content: space-between; align-items: center; gap: 0.625rem; padding: 0.625rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pay-row:last-child { border-bottom: 0; }
.pay-row > div:first-child { flex: 1 1 12.5rem; min-width: 0; overflow-wrap: anywhere; }
.pay-pending { background: var(--amber-soft); color: var(--amber); }
.pay-approved { background: var(--green-soft); color: var(--green); }
.pay-rejected { background: var(--red-soft); color: var(--red); }

/* ---------- Settings menu ---------- */
.shop-card, .set-row { display: flex; align-items: center; gap: 0.75rem; color: var(--text); text-decoration: none; }
.shop-card {
  padding: 0.875rem; margin-bottom: 0.5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.shop-avatar {
  flex: 0 0 auto; width: 3rem; height: 3rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold); font-size: 1.375rem; font-weight: 800;
}
.shop-card-name { display: block; font-size: 1.125rem; font-weight: 700; overflow-wrap: anywhere; }
.set-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.set-row { min-height: 3.75rem; padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row:active, .shop-card:active { background: var(--grey-soft); }
.set-icon { flex: 0 0 auto; width: 1.75rem; display: flex; justify-content: center; color: var(--gold); }
.set-icon .ico { width: 1.375rem; height: 1.375rem; }
.set-icon.danger-text { color: var(--red); }
.set-text { flex: 1 1 auto; min-width: 0; }
.set-title { display: block; font-weight: 600; }
.set-sub { display: block; font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.set-sub:empty { display: none; }
.set-arrow { flex: 0 0 auto; display: flex; color: var(--muted); }
.set-arrow .ico { width: 1.125rem; height: 1.125rem; }

/* ---------- Delete account ---------- */
.danger-text { color: var(--red); }
.btn.danger-fill { background: var(--red); border-color: var(--red); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.danger-fill { color: #1b0d0c; } }
.delete-list { margin: 0.5rem 0 0.75rem; padding-left: 1.25rem; }
.delete-list li { margin: 4px 0; }

/* ---------- Today's gold rates ---------- */
.rates-card {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0.875rem; margin-bottom: 0.875rem;
  background: var(--gold-soft); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.rates-card.due { background: var(--amber-soft); border-color: var(--amber); }
.rates-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 0.9375rem; overflow-wrap: anywhere; }
.rates-title { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--gold); }
.rates-card.due .rates-title { color: var(--amber); font-size: 0.9375rem; text-transform: none; letter-spacing: 0; }
.rates-edit { flex: 0 0 auto; font-weight: 700; color: var(--gold); }
.rates-card.due .rates-edit { color: var(--amber); }
.rates-card.centred { justify-content: center; text-align: center; }
.rates-card.centred .rates-text { align-items: center; }

/* ---------- Shop switcher (up to 3 shops per login) ---------- */
.shop-switch {
  display: inline-flex; align-items: center; gap: 0.375rem; max-width: 100%;
  padding: 4px 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.shop-switch span { font-size: .7em; color: var(--muted); }
.menu-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .25); }
.shop-menu {
  position: absolute; top: calc(env(safe-area-inset-top) + 3.5rem); left: 0.75rem; right: 0.75rem; max-width: 26.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0.625rem 1.875rem rgba(0, 0, 0, .25); overflow: hidden;
}
.shop-menu-item {
  display: flex; align-items: center; gap: 0.625rem; width: 100%; min-height: 3.25rem; padding: 0.625rem 0.875rem;
  border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text);
  font: inherit; text-align: left; text-decoration: none; cursor: pointer; overflow-wrap: anywhere;
}
.shop-menu-item:last-child { border-bottom: 0; }
.shop-menu-item.on { font-weight: 700; }
.shop-menu-item.add { color: var(--gold); font-weight: 600; }
.shop-menu-item .check { flex: 0 0 1.125rem; color: var(--gold); font-weight: 800; text-align: center; }
.shop-menu-note { padding: 0.75rem 0.875rem; font-size: 0.875rem; }

/* ---------- UPI QR pop-up ---------- */
.pay-backdrop { display: grid; place-items: center; padding: 1rem; background: rgba(0, 0, 0, .55); overflow-y: auto; }
.pay-popup {
  position: relative; width: 100%; max-width: 23.75rem; padding: 1.5rem 1.25rem 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; text-align: center;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, .35);
}
.pay-close { position: absolute; top: 0.5rem; right: 0.5rem; }
.pay-plan { font-size: 0.875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pay-amount { font-size: 2.125rem; font-weight: 800; margin: 2px 0 0.5rem; }
.qr.big { width: 17.5rem; margin: 0.5rem auto 4px; padding: 0.75rem; }

/* ---------- Reminder days ---------- */
.day-row { display: flex; align-items: center; gap: 0.625rem; margin: 0.5rem 0; flex-wrap: wrap; }
.day-row .day-input { width: 4.75rem; flex: 0 0 auto; text-align: center; margin: 0; }
.net-line { margin: 0.5rem 0 0; font-weight: 700; }
.net-line:empty { display: none; }

/* ---------- Contact and reviews ---------- */
.contact-line { text-align: center; margin: 0.375rem 0 1rem; overflow-wrap: anywhere; }
.stars { display: flex; gap: 4px; margin-bottom: 4px; }
.star { font-size: 2.5rem; line-height: 1; padding: 2px 4px; border: 0; background: none; color: var(--line); cursor: pointer; }
.star.on, .stars-text { color: #e8a317; }
.star-word { min-height: 1.4em; margin: 0 0 0.75rem; }
.review-avg { display: flex; align-items: baseline; gap: 0.625rem; flex-wrap: wrap; }
.review-avg-num { font-size: 1.625rem; font-weight: 700; }
.review-text { margin: 4px 0; white-space: pre-wrap; }

/* ---------- Page transitions ---------- */
/* The top bar stays in place and just crossfades its title; the page below it slides. */
.bar { view-transition-name: topbar; }
::view-transition-group(*) { animation-duration: .25s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: .25s; animation-timing-function: cubic-bezier(.2, .8, .2, 1);
}
html[data-nav="forward"]::view-transition-old(root) { animation-name: vt-out-left; mix-blend-mode: normal; }
html[data-nav="forward"]::view-transition-new(root) { animation-name: vt-in-right; mix-blend-mode: normal; box-shadow: -0.5rem 0 1.5rem rgba(0,0,0,.12); }
html[data-nav="back"]::view-transition-old(root) { animation-name: vt-out-right; mix-blend-mode: normal; z-index: 1; box-shadow: -0.5rem 0 1.5rem rgba(0,0,0,.12); }
html[data-nav="back"]::view-transition-new(root) { animation-name: vt-in-left; mix-blend-mode: normal; }
html[data-nav="fade"]::view-transition-old(root), html[data-nav="fade"]::view-transition-new(root) { animation-duration: .18s; }
@keyframes vt-in-right { from { transform: translateX(100%); } }
@keyframes vt-out-left { to { transform: translateX(-25%); opacity: .7; } }
@keyframes vt-out-right { to { transform: translateX(100%); } }
@keyframes vt-in-left { from { transform: translateX(-25%); opacity: .7; } }

/* Switching tabs: the tab bar is not faded, so the bubble can be seen sliding across. */
html[data-nav="fade"] .nav-tabs { view-transition-name: navtabs; }
html[data-nav="fade"]::view-transition-old(navtabs) { animation: none; opacity: 0; }
html[data-nav="fade"]::view-transition-new(navtabs) { animation: none; }

/* Fallback for phones without view transitions: only the new page moves. */
.enter-forward { animation: page-in-right .25s cubic-bezier(.2, .8, .2, 1); }
.enter-back { animation: page-in-left .25s cubic-bezier(.2, .8, .2, 1); }
.enter-fade { animation: page-fade .18s ease; }
@keyframes page-in-right { from { transform: translateX(40%); opacity: 0; } }
@keyframes page-in-left { from { transform: translateX(-40%); opacity: 0; } }
@keyframes page-fade { from { opacity: 0; } }

/* ---------- Pop-ups ---------- */
.menu-backdrop { animation: backdrop-in .2s ease; }
.menu-backdrop.closing { animation: backdrop-out .2s ease forwards; pointer-events: none; }
.shop-menu { transform-origin: top left; animation: menu-drop .2s cubic-bezier(.2, .8, .2, 1); }
.closing .shop-menu { animation: menu-lift .2s ease forwards; }
.pay-popup { animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
.closing .pay-popup { animation: sheet-down .2s ease forwards; }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }
@keyframes menu-drop { from { opacity: 0; transform: translateY(-0.5rem) scale(.97); } }
@keyframes menu-lift { to { opacity: 0; transform: translateY(-0.5rem) scale(.97); } }
@keyframes sheet-up { from { opacity: 0; transform: translateY(3.75rem); } }
@keyframes sheet-down { to { opacity: 0; transform: translateY(3.75rem); } }

/* ---------- Pressed look ---------- */
.btn, .icon-btn, .card, .set-row, .shop-card, .rates-card, .nav-tabs a, .shop-menu-item, .star {
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease;
}
.btn:active:not(:disabled), .icon-btn:active, .nav-tabs a:active, .star:active { transform: scale(.95); }
.card:active, .set-row:active, .shop-card:active, .rates-card:active, .shop-menu-item:active { transform: scale(.985); }

@media (prefers-reduced-motion: reduce) {
  .bar { view-transition-name: none; }
  .enter-forward, .enter-back, .enter-fade, .menu-backdrop, .shop-menu, .pay-popup { animation: none !important; }
  .btn, .icon-btn, .card, .set-row, .shop-card, .rates-card, .nav-tabs a, .shop-menu-item, .star { transition: none; }
  .btn:active, .icon-btn:active, .nav-tabs a:active, .card:active, .set-row:active, .shop-card:active, .rates-card:active, .shop-menu-item:active { transform: none; }
}

/* ---------- Export to Excel ---------- */
.export-list { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.export-list li { padding: 0.375rem 0; border-bottom: 1px solid var(--line); }
.export-list li:last-child { border-bottom: 0; }
.export-done { text-align: center; padding: 0.75rem; margin-bottom: 0.75rem; border-radius: var(--radius); background: var(--green-soft); overflow-wrap: anywhere; }
.export-done b { color: var(--green); }

.older-btn { margin-top: 0.75rem; }

/* ---------- No internet ---------- */
#offline-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 0.625rem 1rem calc(0.625rem + env(safe-area-inset-bottom));
  background: var(--amber-soft); color: var(--amber); border-top: 1px solid var(--line);
  font-size: 0.875rem; font-weight: 600; text-align: center;
}
body.offline .fab { bottom: calc(4.75rem + env(safe-area-inset-bottom)); }
body.offline #toast { bottom: calc(9.125rem + env(safe-area-inset-bottom)); }
.draft-note { display: flex; align-items: center; justify-content: space-between; gap: 0.625rem; flex-wrap: wrap; }

/* ---------- Admin: errors ---------- */
.err-row { padding: 0.625rem 0; border-bottom: 1px solid var(--line); }
.err-row:last-child { border-bottom: 0; }
.err-row summary { cursor: pointer; list-style: none; overflow-wrap: anywhere; }
.err-row summary::-webkit-details-marker { display: none; }
.err-row.new summary b { color: var(--red); }
.err-detail { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.75rem; background: var(--grey-soft); padding: 0.5rem; border-radius: 0.5rem; max-height: 15rem; overflow: auto; }

/* Gold / Silver switch at the top of each product */
.metal-toggle { display: inline-flex; margin: 4px 0 0.75rem; }
.metal-toggle button { min-width: 5.5rem; min-height: 2.5rem; }
.purity-field[hidden] { display: none; }

/* Store version: after a plan ends the + button is just a label */
.fab.fab-off { background: var(--grey-soft); color: var(--muted); border-color: var(--line); cursor: default; }

/* Send work to a karigar (order page) */
.karigar-send { display: grid; gap: 0.375rem; margin-top: 0.75rem; }

/* ---------- Pull down to refresh ---------- */
html, body { overscroll-behavior-y: contain; }   /* our own pull-to-refresh instead of the browser's reload */
#pull {
  position: fixed; left: 50%; z-index: 4; pointer-events: none; opacity: 0;
  transform: translate(-50%, -48px);
}
#pull.leaving { transition: transform .25s ease, opacity .25s ease; }
.pull-circle {
  width: 2.5rem; height: 2.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--muted); box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
#pull.ready .pull-circle, #pull.spinning .pull-circle { color: var(--gold); }
.pull-circle .ico { width: 1.375rem; height: 1.375rem; }
#pull.spinning .ico { animation: pull-spin .8s linear infinite; }
@keyframes pull-spin { to { transform: rotate(360deg); } }
/* Touch screens refresh by pulling down, so the button (easy to hit instead of Settings) is only on computers. */
/* Phones pull down to refresh. Some Samsung phones claim to have a mouse, so "has a touch screen at all"
   (any-pointer: coarse) and the Play Store app (html.store-app) both count as a phone. */
@media (any-pointer: coarse) { .refresh-btn { display: none; } }
html.store-app .refresh-btn { display: none; }
.refresh-btn { margin-right: 0.5rem; }

/* Stop iPhone's long-press link preview on in-app links (order/credit cards, settings rows) */
a, .set-row, .shop-card { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ---------- Long-press quick menu on order / credit cards ---------- */
.card { -webkit-user-select: none; user-select: none; }   /* holding a card doesn't select its text */
.quick-backdrop { background: rgba(0, 0, 0, .45); }
.quick-sheet {
  position: absolute; top: auto; left: 0.75rem; right: 0.75rem; margin: 0 auto;
  bottom: calc(env(safe-area-inset-bottom) + 0.75rem); max-width: 26.25rem; max-height: 80vh; overflow-y: auto;
  transform-origin: bottom center; animation: sheet-up .25s cubic-bezier(.2, .8, .2, 1);
}
.closing .quick-sheet { animation: sheet-down .2s ease forwards; }
.quick-head { display: flex; flex-direction: column; gap: 0.125rem; padding: 0.875rem; border-bottom: 1px solid var(--line); }
.quick-head strong { font-size: 1.0625rem; }
.quick-head .muted { font-size: 0.875rem; }
.quick-label { padding: 0.625rem 0.875rem 0.25rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.quick-grow { flex: 1; }
.quick-sheet .shop-menu-item .ico { width: 1.125rem; height: 1.125rem; color: var(--muted); }
.quick-sheet .shop-menu-item.wa { color: #1f8f4e; font-weight: 600; }
@media (prefers-color-scheme: dark) { .quick-sheet .shop-menu-item.wa { color: #3ccf78; } }
.quick-sheet .quick-close { justify-content: center; color: var(--muted); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .quick-sheet { animation: none !important; } }

/* Orders and Credit log pages: holding a finger never selects or copies text (search box still works) */
main[data-pull], main[data-pull] *, .quick-backdrop, .quick-backdrop * {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
main[data-pull] input, main[data-pull] textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
