* { box-sizing: border-box; }
/* Theme: every app color lives in these variables. To change the look (e.g. back to a brand color), edit only here. */
:root {
  /* Chain picker "sticker wall" (same in light and dark mode) */
  --wall: #000000; --wall-text: #ffffff; --wall-muted: #9a9a9a; --wall-line: #262626;
  --sticker-edge: #ffffff; --wall-button: #ffffff; --wall-button-text: #000000;
  --bg: #ffffff; --card: #ffffff; --text: #000000; --muted: #6e6e6e; --line: #e6e6e6;
  --accent: #000000; --accent-text: #ffffff; --border: #e6e6e6; --badge: #f2f2f2; --soft: #f5f5f5;
  --price: #000000; --urgent: #000000; --urgent-bg: #ececec; --on: #000000; --initials-bg: #2b2b2b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #111111; --text: #ffffff; --muted: #9a9a9a; --line: #262626;
    --accent: #ffffff; --accent-text: #000000; --border: #262626; --badge: #1f1f1f; --soft: #161616;
    --price: #ffffff; --urgent: #ffffff; --urgent-bg: #2a2a2a; --on: #ffffff; --initials-bg: #2b2b2b;
  }
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto; max-width: 560px; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.fine { font-size: 12px; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 6px 0; }
.primary {
  border: 0; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 17px;
  padding: 15px 20px; border-radius: 14px; width: 100%;
}
.primary:disabled { opacity: .45; }
.primary.small { width: auto; font-size: 15px; padding: 10px 16px; }

/* ---- Top bar ---- */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 0 10px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar h1 { margin: 0; font-size: 30px; letter-spacing: -.02em; }
#subtitle { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; color: var(--text);
}
.icon-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.icon-btn.on svg { fill: currentColor; }

/* ---- Chain chips ---- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 12px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chipf {
  flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 6px 12px 6px 8px; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chipf:first-child { padding-left: 14px; }
.chipf.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---- Avatar ---- */
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--brand, var(--initials-bg)); color: var(--brand-text, #fff); font-weight: 800; font-size: 16px; letter-spacing: -.02em;
}
.avatar { position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 12%; opacity: 0; transition: opacity .2s; }
.avatar.has-logo img { opacity: 1; }
.avatar.has-logo b { visibility: hidden; }
.avatar.has-logo { box-shadow: inset 0 0 0 1px var(--line); }
.avatar.xs img { padding: 6%; }
.avatar.sm { width: 40px; height: 40px; border-radius: 12px; font-size: 14px; }
.avatar.xs { width: 22px; height: 22px; border-radius: 7px; font-size: 10px; }

/* ---- Feed ---- */
.group h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 2px 8px; }
.deals { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.deal {
  display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 18px; background: var(--card);
  border: 1px solid var(--line); color: inherit; text-decoration: none;
}
.deal:active { transform: scale(.985); }
.deal.later { opacity: .6; }
.deal .body { flex: 1; min-width: 0; }
.deal .chain { font-size: 13px; color: var(--muted); font-weight: 600; }
.deal .title { font-size: 15px; font-weight: 600; line-height: 1.3; margin-top: 1px; }
.reqs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.req { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--soft); border-radius: 6px; padding: 2px 6px; }
.req.unconfirmed { background: none; border: 1px dashed var(--line); padding: 1px 5px; }
.side { text-align: right; flex: none; max-width: 38%; }
.price { font-size: 24px; font-weight: 800; color: var(--price); letter-spacing: -.02em; line-height: 1.05; }
.ends { font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.ends.urgent { color: var(--urgent); background: var(--urgent-bg); border-radius: 6px; padding: 2px 6px; display: inline-block; }
.empty { text-align: center; padding: 48px 12px; color: var(--muted); }
.empty .big { font-size: 18px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.foot { text-align: center; padding: 24px 0 32px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  max-width: calc(100% - 32px); z-index: 20;
}

/* ---- Chain picker ---- */
.picker { position: fixed; inset: 0; background: var(--bg); z-index: 10; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 0; }
.picker[hidden] { display: none; }
.picker-head { padding: 22px 16px 8px; max-width: 560px; width: 100%; margin: 0 auto; }
.picker-head h2 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.picker-head p { margin: 4px 0 14px; color: var(--muted); }
.picker-head input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: inherit;
}
.picker-list { list-style: none; margin: 0 auto; padding: 4px 16px 16px; overflow-y: auto; flex: 1; display: grid; gap: 8px; align-content: start; max-width: 560px; width: 100%; }
.pick {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--card); text-align: left;
}
.pick-name { flex: 1; font-weight: 600; display: flex; flex-direction: column; }
.pick-name small { font-size: 12px; color: var(--price); font-weight: 600; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.pick.on { border-color: var(--accent); }
.pick.on .check { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center/16px no-repeat; border-color: var(--accent); }
.picker-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); max-width: 560px; width: 100%; margin: 0 auto; }

#install { text-align: center; padding: 16px 0 72px; }
#install img { border-radius: 18px; }
#install h1 { margin: 10px 0 4px; font-size: 22px; line-height: 1.2; }
#install .lead { color: var(--muted); margin: 0 0 18px; font-size: 16px; }
.steps { text-align: left; list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 12px; counter-reset: step; }
.steps li {
  counter-increment: step; display: flex; gap: 14px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  font-size: 18px; line-height: 2;
}
.steps li::before {
  content: counter(step); flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-weight: 700; line-height: 32px;
  display: grid; place-items: center;
}
.chip {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px;
  border-radius: 10px; background: var(--badge); color: var(--text); font-weight: 700; font-size: 20px;
  border: 2px solid var(--accent);
  vertical-align: middle;
}
.sheet-row {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 10px;
  background: var(--badge); font-weight: 600; vertical-align: middle; line-height: 1.6;
}
.note { color: var(--muted); margin: 0; }
#install code { font-weight: 700; color: var(--text); }
button#install-btn {
  border: 0; background: var(--accent); color: var(--accent-text); font: inherit; font-size: 18px; font-weight: 700;
  padding: 16px 28px; border-radius: 14px; width: 100%;
}
.arrow { position: fixed; left: 50%; color: var(--accent); animation: bob 1.2s ease-in-out infinite; }
.arrow-bottom { bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); }
/* Safari 26 compact bar: the ≡ button sits about 29% across the screen. */
.arrow-bottom-menu { bottom: calc(12px + env(safe-area-inset-bottom)); left: 29%; transform: translateX(-50%); }
.arrow-top { top: calc(8px + env(safe-area-inset-top)); left: auto; right: 16px; }
.arrow-top svg { transform: rotate(180deg); }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 8px; } }
.arrow-top { animation-name: bob-up; }
@keyframes bob-up { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
@media (prefers-reduced-motion: reduce) { .arrow { animation: none; } }

#phone-only { text-align: center; padding: 48px 0; }
#phone-only img { border-radius: 18px; }
#phone-only h1 { margin: 14px 0 6px; font-size: 26px; }
#phone-only .lead { color: var(--muted); margin: 0 auto 24px; max-width: 420px; font-size: 17px; }
.qr { width: 220px; height: 220px; margin: 0 auto 20px; padding: 10px; background: #fff; border-radius: 16px; border: 1px solid var(--border); }
.qr svg { width: 100%; height: 100%; display: block; }

/* ---- Fake Safari tap demo ---- */
.demo {
  position: relative; width: 300px; max-width: 100%; height: 190px; margin: 0 auto 14px;
  border-radius: 22px; overflow: hidden; background: #1c1c1e; color: #f2f2f7;
  border: 1px solid var(--border); font-size: 13px; text-align: left;
}
.demo svg { width: 16px; height: 16px; flex: none; }
.d-bar { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 38px; display: flex; gap: 8px; align-items: center; }
.d-circle { width: 38px; height: 38px; border-radius: 50%; background: #3a3a3c; display: grid; place-items: center; font-size: 18px; flex: none; }
.d-pill { flex: 1; height: 38px; border-radius: 19px; background: #3a3a3c; display: flex; align-items: center; gap: 8px; padding: 0 12px; min-width: 0; }
.d-url { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; opacity: .9; }
.d-bar-old { justify-content: space-around; background: #2c2c2e; left: 0; right: 0; bottom: 0; height: 44px; font-size: 18px; color: #0a84ff; }
.d-bar-old svg { width: 20px; height: 20px; }
.d-row { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 8px; transition: background .2s; }
.d-pop {
  position: absolute; left: 50px; bottom: 54px; width: 170px; padding: 4px; border-radius: 14px; background: #2c2c2e;
  opacity: 0; transform: scale(.9) translateY(6px); transform-origin: bottom left; transition: opacity .25s, transform .25s;
}
.d-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 8px 12px; border-radius: 16px 16px 0 0; background: #2c2c2e;
  transform: translateY(105%); transition: transform .35s ease;
}
.d-confirm {
  position: absolute; inset: 0; background: #1c1c1e; transform: translateY(105%); transition: transform .35s ease; padding: 10px 12px;
}
.d-confirm-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.d-confirm-head span { color: #0a84ff; }
.d-add { font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.d-confirm-body { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 10px; border-radius: 12px; background: #2c2c2e; font-size: 15px; }
.d-confirm-body img { border-radius: 8px; }
.d-finger {
  position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  background: rgba(255,255,255,.45); border: 2px solid #fff; left: 50%; top: 120%;
  transition: left .45s ease, top .45s ease; animation: tap 1.7s ease-in-out infinite;
}
@keyframes tap { 0%, 40% { scale: 1; } 55% { scale: .7; } 70%, 100% { scale: 1; } }
/* Phases: where the finger is and which layer is open. */
.demo-ios26[data-phase="p-menu"] .d-finger { left: 77px; top: 161px; }
.demo-ios26[data-phase="p-menu"] .d-menu { color: #fff; }
.demo[data-phase="p-share"] .d-pop { opacity: 1; transform: none; }
.demo-ios26[data-phase="p-share"] .d-finger { left: 100px; top: 49px; }
.demo-ios26[data-phase="p-share"] .d-row-share { background: #48484a; }
.demo-ios[data-phase="p-share"] .d-finger { left: 138px; top: 168px; }
.demo[data-phase="p-add"] .d-sheet { transform: none; }
.demo[data-phase="p-add"] .d-finger { left: 120px; top: 128px; }
.demo[data-phase="p-add"] .d-row-add { background: #48484a; }
.demo[data-phase="p-confirm"] .d-sheet { transform: none; }
.demo[data-phase="p-confirm"] .d-confirm { transform: none; }
.demo[data-phase="p-confirm"] .d-finger { left: 271px; top: 23px; }
.demo[data-phase="p-confirm"] .d-add { background: rgba(10,132,255,.25); }
@media (prefers-reduced-motion: reduce) { .d-finger { animation: none; } }
.steps li { transition: border-color .2s, box-shadow .2s; }
.steps li.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.steps { gap: 10px; }
.steps li { padding: 12px 14px; }

/* ---- Settings sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 9; background: var(--bg); overflow-y: auto; padding-top: env(safe-area-inset-top); }
.sheet[hidden] { display: none; }
.sheet-head { position: sticky; top: 0; background: var(--bg); display: flex; flex-direction: column; align-items: flex-end; padding: 10px 16px 6px; max-width: 560px; margin: 0 auto; }
.sheet-head h2 { align-self: flex-start; margin: 0; font-size: 30px; letter-spacing: -.02em; }
.sheet-body { max-width: 560px; margin: 0 auto; padding: 8px 16px 40px; }
.set-group { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 6px 14px; margin: 14px 0; }
.set-label { display: flex; justify-content: space-between; align-items: center; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 6px 0; }
.set-label .link-btn { text-transform: none; letter-spacing: 0; font-size: 15px; }
.my-chains { list-style: none; margin: 0; padding: 0; }
.my-chains li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-weight: 600; }
.my-chains .grow { flex: 1; }
.my-chains small { color: var(--muted); font-weight: 500; font-size: 13px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; width: 100%; }
.set-row small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.set-btn { background: none; border: 0; text-align: left; font-size: 16px; }
.set-btn span { color: var(--muted); font-size: 22px; }
.switch { flex: none; width: 52px; height: 32px; border-radius: 16px; border: 0; background: var(--line); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--on); }
.switch[aria-checked="true"]::after { background: var(--bg); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.center { text-align: center; }
.picker { z-index: 11; }

/* ---- Logo-first: hide the name wherever the logo loaded ---- */
.avatar.lg { width: 100%; height: auto; aspect-ratio: 1; border-radius: 22%; font-size: 20px; }
.picker-list { grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 360px) { .picker-list { grid-template-columns: repeat(3, 1fr); } }
.tile {
  position: relative; width: 100%; padding: 0; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.tile .avatar { box-shadow: 0 0 0 1px var(--line); transition: box-shadow .15s, transform .15s; }
.tile.on .avatar { box-shadow: 0 0 0 3px var(--accent); }
.tile:active .avatar { transform: scale(.94); }
.tile-name { font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; color: var(--muted); }
.tile:has(.avatar.has-logo) .tile-name { display: none; }
.tile .check { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; border-color: var(--bg); }
.tile.on .check { opacity: 1; transform: none; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center/14px no-repeat; border: 2px solid var(--bg); }
.tile .dot { position: absolute; left: -3px; top: -3px; background: var(--price); color: #fff; border: 2px solid var(--bg); width: 12px; height: 12px; border-radius: 50%; }
.deal:has(.avatar.has-logo) .chain { display: none; }
.chipf:has(.avatar.has-logo) { padding: 4px 10px; }
.chipf:has(.avatar.has-logo) .cn { display: none; }
.chipf .avatar.xs { width: 28px; height: 28px; }
.my-chains li:has(.avatar.has-logo) .mc-name { display: none; }
.picker-legend { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.picker-legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--price); display: inline-block; }
.picker-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.picker-list { padding-top: 14px; }

/* ---- Sticker wall picker (black wall, logos bring the color) ---- */
.picker { background: var(--wall); color: var(--wall-text); }
.picker-head { position: relative; padding-bottom: 0; }
.picker-head h2 { font-size: 32px; font-weight: 800; color: var(--wall-text); }
.picker-head p { color: var(--wall-muted); margin-bottom: 6px; }
#picker-all { position: absolute; top: 30px; right: 16px; color: var(--wall-text); font-weight: 700; }
.picker-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 18px; padding: 18px 22px 28px; }
@media (max-width: 360px) { .picker-list { gap: 16px 12px; } }
/* Unpicked stickers sit tilted and faded; picked ones straighten up in full color.
   No extra rings, so a wall with everything picked still looks clean. */
.picker .tile { transform: rotate(var(--r)); transition: transform .25s cubic-bezier(.3,1.5,.6,1); -webkit-tap-highlight-color: transparent; }
.picker .tile .avatar.lg {
  border-radius: 22px; border: 4px solid var(--sticker-edge); font-size: 14px; line-height: 1.1; padding: 6px;
  box-shadow: 0 10px 22px rgba(0,0,0,.55); opacity: .4; filter: grayscale(.7); transition: opacity .2s, filter .2s;
}
.picker .tile .avatar.lg b { overflow-wrap: anywhere; }
.picker .tile .avatar.lg img { padding: 10%; }
.picker .tile .avatar.has-logo { background: var(--sticker-edge); }
.picker .tile.on { transform: rotate(calc(var(--r) * .35)); }
.picker .tile.on .avatar.lg { opacity: 1; filter: none; }
.picker .tile:active { transform: rotate(0) scale(.94); }
.picker .tile-name { display: none; }
.picker .tile .check { width: 22px; height: 22px; top: -7px; right: -7px; }
.picker .tile.on .check { background: var(--sticker-edge) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center/12px no-repeat; border: 0; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.picker-foot { background: var(--wall); border-top: 1px solid var(--wall-line); max-width: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.picker-count { color: var(--wall-text); font-weight: 700; }
.picker-foot .primary { width: auto; padding: 14px 28px; border-radius: 999px; background: var(--wall-button); color: var(--wall-button-text); font-weight: 800; }
.picker-foot .primary:disabled { opacity: .35; }

/* ---- Brand accents: kept minimal. Brand color only on the logo badge and the price (--c set inline from data/chains.json). ---- */
.branded { --ink: var(--ink-l); }
@media (prefers-color-scheme: dark) { .branded { --ink: var(--ink-d); } }
.deal.branded .price { color: var(--ink); }
