/* BuyNative MyCard — shares the BuyNative.biz palette and type */
:root {
  --brick: #AF2A1F;
  --brick-dark: #8C2118;
  --ink: #1E1C1A;
  --ink-soft: #4A4642;
  --cream: #FFFAF5;
  --cream-2: #F6EEE4;
  --gold: #FFCF4A;
  --line: #E6DCD0;
  --ok: #2E7D4F;
  --err: #B3261E;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30,28,26,.06), 0 6px 20px rgba(30,28,26,.06);
  --head: "League Spartan", "Spartan", system-ui, sans-serif;
  --body: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); font-size: 17px; line-height: 1.55; color: var(--ink); background: var(--cream); }
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); font-weight: 700; }
h2 { font-size: 1.45rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
a { color: var(--brick); }
a:hover { color: var(--brick-dark); }
img { max-width: 100%; }
.muted { color: var(--ink-soft); }
.small { font-size: .9rem; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 460px; }

/* header */
.site-header { background: #fff; border-bottom: 3px solid var(--brick); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand img { height: 44px; width: auto; }
.brand span { font-family: var(--head); font-weight: 700; font-size: 1.15rem; }
.brand span b { color: var(--brick); }
.nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nav a, .nav button.linklike { text-decoration: none; color: var(--ink); padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: .98rem; }
.nav a:hover, .nav a.active { background: var(--cream-2); color: var(--brick); }
.nav form { display: inline; margin: 0; }
button.linklike { background: none; border: 0; cursor: pointer; font: inherit; }

.site-footer { margin-top: 64px; padding: 28px 0; background: var(--ink); color: #D8D0C6; font-size: .92rem; }
.site-footer a { color: var(--gold); }

main { padding: 32px 0 16px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 8px; border: 2px solid var(--brick); background: var(--brick); color: #fff; font-family: var(--head); font-weight: 600; font-size: 1rem; text-decoration: none; cursor: pointer; line-height: 1.1; }
.btn:hover { background: var(--brick-dark); border-color: var(--brick-dark); color: #fff; }
.btn.secondary { background: #fff; color: var(--brick); }
.btn.secondary:hover { background: var(--cream-2); color: var(--brick-dark); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger { background: #fff; border-color: var(--err); color: var(--err); }
.btn.danger:hover { background: var(--err); color: #fff; }
.btn.sm { padding: 7px 12px; font-size: .9rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* forms */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel .lede { margin-top: -6px; color: var(--ink-soft); }
label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.hint { font-weight: 400; color: var(--ink-soft); font-size: .86rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #CFC4B6; border-radius: 8px; font: inherit; font-size: 1rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(175,42,31,.18); border-color: var(--brick); }
textarea { min-height: 110px; resize: vertical; }
input[type=color] { width: 54px; height: 40px; padding: 2px; border: 1px solid #CFC4B6; border-radius: 8px; background: #fff; cursor: pointer; }
.field { margin-bottom: 16px; }
.grid { display: grid; gap: 0 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 5px; }
.inline-color { display: flex; align-items: center; gap: 10px; }
.inline-color code { font-size: .9rem; }
.prefix-input { display: flex; align-items: stretch; }
.prefix-input span { padding: 10px 10px; background: var(--cream-2); border: 1px solid #CFC4B6; border-right: 0; border-radius: 8px 0 0 8px; color: var(--ink-soft); font-size: .92rem; white-space: nowrap; }
.prefix-input input { border-radius: 0 8px 8px 0; }

.upload { display: flex; gap: 14px; align-items: center; }
.upload .thumb { width: 72px; height: 72px; border-radius: 10px; border: 1px dashed #CFC4B6; background: var(--cream) center/cover no-repeat; flex: 0 0 72px; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: .75rem; text-align: center; }
.upload .thumb.round { border-radius: 50%; }
.upload .thumb.contain { background-size: contain; }

details.section { border-top: 1px solid var(--line); padding: 14px 0 2px; }
details.section summary { cursor: pointer; font-family: var(--head); font-weight: 600; font-size: 1.05rem; list-style: none; display: flex; justify-content: space-between; }
details.section summary::after { content: "+"; color: var(--brick); font-size: 1.3rem; line-height: 1; }
details.section[open] summary::after { content: "–"; }
details.section > div { padding-top: 14px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; border-left: 4px solid; background: #fff; }
.alert.ok { border-color: var(--ok); background: #EEF7F1; }
.alert.error { border-color: var(--err); background: #FCEDEC; }
.alert.warn { border-color: #C58A00; background: #FFF6DC; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

/* landing */
.hero { background: var(--ink); color: var(--cream); padding: 52px 0 46px; margin-top: -32px; margin-bottom: 32px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 6px; background: repeating-linear-gradient(90deg, var(--brick) 0 28px, var(--gold) 28px 40px, var(--cream) 40px 46px, var(--gold) 46px 58px); }
.hero h1 { color: #fff; max-width: 760px; }
.hero h1 em { font-style: normal; color: var(--gold); }
.hero p { max-width: 640px; font-size: 1.12rem; color: #E8DFD4; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 26px; max-width: 820px; }
.steps div { border-left: 3px solid var(--gold); padding: 2px 0 2px 14px; color: #E8DFD4; font-size: .98rem; }
.steps b { display: block; color: #fff; font-family: var(--head); }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }

.builder { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.preview-col { position: sticky; top: 20px; }

/* Show/hide toggle for the live preview: high contrast, thumb-reachable, always on top */
.pv-toggle {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 20px;
  background: var(--ink); color: var(--gold); border: 2px solid var(--gold); border-radius: 999px;
  font-family: var(--head); font-weight: 700; font-size: 1rem; letter-spacing: .01em; cursor: pointer;
  box-shadow: 0 6px 20px rgba(30,28,26,.35), 0 0 0 3px rgba(255,250,245,.9);
}
.pv-toggle:hover { background: #000; }
.pv-toggle { transition: opacity .15s, transform .15s; }
/* While typing on a phone the button shrinks to an icon so it covers less of the form */
body.pv-typing .pv-toggle { padding: 0; width: 48px; justify-content: center; }
body.pv-typing .pv-toggle .pv-label { display: none; }
.pv-toggle:focus-visible { outline: 3px solid var(--brick); outline-offset: 3px; }
.pv-toggle[aria-expanded="true"] { background: var(--gold); color: var(--ink); border-color: var(--ink); }

/* Wide screens: preview sits beside the form; hiding it gives the form the full width */
body.pv-hidden .builder { grid-template-columns: minmax(0, 1fr); }
body.pv-hidden .builder .preview-col { display: none; }

/* Phones and small tablets: preview is hidden by default and opens as an overlay */
@media (max-width: 960px) {
  .builder { grid-template-columns: minmax(0, 1fr); }
  .builder .preview-col { display: none; }
  .panel { padding: 18px 16px; }
  body.pv-open { overflow: hidden; }
  body.pv-open .builder .preview-col {
    display: block; position: fixed; inset: 0; z-index: 50; overflow-y: auto;
    background: rgba(30,28,26,.82); padding: 24px 16px calc(96px + env(safe-area-inset-bottom, 0px));
  }
  body.pv-open .pv-sheet { max-width: 340px; margin: 0 auto; }
  body.pv-open .preview-col .phone { width: min(300px, 86vw); }
  body.pv-open .preview-col p.muted { color: #E8DFD4; }
  /* keep the floating button clear of the last form buttons */
  .builder { padding-bottom: 72px; }
}

/* phone preview */
.phone { width: 300px; margin: 0 auto; border: 10px solid var(--ink); border-radius: 34px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.phone .pv-head { padding: 26px 18px 18px; text-align: center; color: #fff; }
.phone .pv-photo { width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 10px; background: rgba(255,255,255,.25) center/cover no-repeat; border: 3px solid #fff; }
.phone .pv-name { font-family: var(--head); font-weight: 700; font-size: 1.2rem; }
.phone .pv-title { font-size: .9rem; opacity: .9; }
.phone .pv-body { padding: 14px 16px 20px; font-size: .88rem; }
.phone .pv-btn { display: block; text-align: center; padding: 9px; border-radius: 8px; font-weight: 700; margin-bottom: 10px; }
.phone .pv-row { padding: 7px 0; border-bottom: 1px solid #eee; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone .pv-logo { max-height: 34px; display: block; margin: 12px auto 0; }

/* tables / cards */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--head); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--cream-2); color: var(--ink-soft); }
.badge.on { background: #E1F2E7; color: var(--ok); }
.badge.off { background: #F3E3E1; color: var(--err); }
.badge.admin { background: var(--gold); color: var(--ink); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }

.card-tile { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 22px; }
@media (max-width: 640px) { .card-tile { grid-template-columns: 1fr; } }
.card-tile .qr img { width: 150px; height: 150px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.linkbox { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.linkbox code { flex: 1; background: var(--cream); border: 1px solid var(--line); padding: 7px 10px; border-radius: 6px; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbox .lbl { width: 92px; font-size: .82rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .v { font-family: var(--head); font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--ink-soft); font-size: .88rem; }
.stat.accent { border-top: 4px solid var(--brick); }
.mini-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; color: var(--ink-soft); margin-top: 8px; }
.mini-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }

.chart-box { position: relative; height: 280px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.bar-list { list-style: none; padding: 0; margin: 0; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 1fr) 54px; gap: 8px; padding: 6px 0; font-size: .94rem; position: relative; }
.bar-list li .bar { position: absolute; left: 0; bottom: 2px; height: 3px; background: var(--brick); border-radius: 2px; opacity: .65; }
.bar-list li span:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { margin: 0; }
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.subnav a { padding: 10px 14px; text-decoration: none; color: var(--ink-soft); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subnav a.active, .subnav a:hover { color: var(--brick); border-color: var(--brick); }
pre.transcript { background: var(--ink); color: #E8DFD4; padding: 14px; border-radius: 8px; font-size: .88rem; white-space: pre-wrap; }
.danger-zone { border-color: #E9C2BE; }
.copy-ok { color: var(--ok); font-size: .82rem; font-weight: 700; }

/* Let form content shrink to the screen instead of widening the page */
.builder > *, .grid > *, .field { min-width: 0; }
.upload .thumb { flex-shrink: 0; }
.upload > div { min-width: 0; }
input[type=file] { max-width: 100%; font-size: .9rem; }
.prefix-input input { min-width: 0; }
@media (max-width: 480px) {
  .prefix-input { flex-direction: column; }
  .prefix-input span { border-right: 1px solid #CFC4B6; border-bottom: 0; border-radius: 8px 8px 0 0; white-space: normal; }
  .prefix-input input { border-radius: 0 0 8px 8px; }
}

/* ---------- Image crop / zoom editor ---------- */
body.crop-open { overflow: hidden; }
.crop-modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(30,28,26,.86);
  display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}
.crop-modal[hidden] { display: none; }
.crop-box {
  width: 100%; max-width: 560px; max-height: 100%; overflow-y: auto;
  background: #fff; border-radius: 16px; padding: 18px 18px 16px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.crop-box h2 { margin: 0 0 2px; font-size: 1.25rem; }
.crop-help { margin: 0 0 12px; color: var(--ink-soft); font-size: .92rem; }
.crop-stage { height: min(56vh, 420px); background: #2b2826; border-radius: 10px; overflow: hidden; }
.crop-stage img { display: block; max-width: 100%; }
.crop-zoom { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; }
.crop-zoom input[type=range] { flex: 1; accent-color: var(--brick); height: 28px; }
.crop-icon {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; border: 2px solid var(--line);
  background: #fff; color: var(--ink); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.crop-icon:hover { border-color: var(--brick); color: var(--brick); }
.crop-tools { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.crop-actions { display: flex; gap: 10px; justify-content: flex-end; }
.crop-actions .btn { min-width: 110px; }
@media (max-width: 480px) {
  .crop-box { padding: 14px 12px 12px; border-radius: 14px; }
  .crop-actions .btn { flex: 1; }
}
/* Photos show a round frame, matching how they appear on the card */
.crop-round .cropper-view-box, .crop-round .cropper-face { border-radius: 50%; }
.crop-round .cropper-view-box { outline: 0; box-shadow: 0 0 0 3px var(--gold); }
.crop-round .cropper-modal { opacity: .6; }
.adjust-btn { margin: 6px 0 2px; max-width: 100%; white-space: normal; }
