:root {
  /* Brand colours: Linen, White, Bark, Umber, Linen Border, Deep Brick */
  --bg: #FAF5EC;
  --panel: #ffffff;
  --ink: #2A1C15;
  --muted: #6B5A4E;
  --line: #EADFCF;
  --field: #ffffff;
  --accent: #A33A1A;
  --accent-ink: #ffffff;
  --danger: #c92a2a;
  --good: #2b8a3e;
  --warn-bg: #fff4e0;
  --warn-ink: #8a5300;
  --err-bg: #ffe8e8;
  --err-ink: #a51111;
  --bar: #E0A12E;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d130e;
    --panel: #2A1C15;
    --ink: #FAF5EC;
    --muted: #D9CBB8;
    --line: #4A372B;
    --field: #33241B;
    --accent: #F2B33D;
    --accent-ink: #2A1C15;
    --danger: #ff6b6b;
    --good: #69db7c;
    --warn-bg: #3a2a0c;
    --warn-ink: #ffd8a8;
    --err-bg: #3d1515;
    --err-ink: #ffc9c9;
    --bar: #F2B33D;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 14px/1.45 "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 4px; overflow-x: auto; }
.top nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.top nav a.on { background: var(--bg); color: var(--ink); }
.top nav .sep { flex: none; width: 1px; margin: 6px 6px; background: var(--line); }
.top nav a.site { color: #b4530a; }
.top nav a.site.on { background: #fdf0e3; color: #8a3c00; }

main { max-width: 1240px; margin: 0 auto; padding: 24px 20px 80px; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 4px 0 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 32px; min-height: 32px; padding: 0; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

label.field { display: grid; gap: 5px; grid-template-columns: minmax(0, 1fr); }
label.field > span { font-weight: 500; }
.hint { color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=url], input[type=email], input:not([type]), select, textarea {
  width: 100%; min-height: 38px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--field);
}
textarea { min-height: 70px; resize: vertical; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); cursor: pointer; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check b { display: block; font-weight: 500; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.stack { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 640px) { .two { grid-template-columns: minmax(0, 1fr); } main { padding: 16px 16px 80px; } .top { padding: 0 16px; gap: 12px; } }

.msg { padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }
.msg.err { background: var(--err-bg); color: var(--err-ink); }
.msg.warn { background: var(--warn-bg); color: var(--warn-ink); }
.msg ul { margin: 4px 0 0; padding-left: 18px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* Creator list */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.creator { display: grid; gap: 14px; }
.creator .who { display: flex; gap: 12px; align-items: center; }
.avatar { width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden; color: #fff; font-weight: 700; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.creator .meta { color: var(--muted); font-size: 13px; }

/* Editor: form on the left, phone preview on the right */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.preview-col { position: sticky; top: 76px; display: grid; gap: 10px; justify-items: center; }
@media (max-width: 980px) { .editor { grid-template-columns: minmax(0, 1fr); } .preview-col { position: static; } }
.phone { width: 360px; height: 720px; border-radius: 36px; border: 10px solid #000; overflow: hidden; background: #000; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
@media (max-width: 420px) { .phone { width: 300px; height: 620px; } }
.phone iframe { width: 100%; height: 100%; border: 0; display: block; background: #0b0b0d; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.savebar { position: sticky; top: 56px; z-index: 10; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 0; margin: -12px 0 12px; background: var(--bg); }
.status { color: var(--muted); font-size: 13px; }
.status.dirty { color: var(--warn-ink); }

.list { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.list-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
@media (max-width: 520px) { .list-row { grid-template-columns: 1fr; } }
.moves { display: flex; gap: 4px; }

.link-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); background: var(--field); }
.link-card .bar { display: flex; align-items: center; gap: 8px; }
.link-card .bar b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details summary { cursor: pointer; font-weight: 500; }
details[open] summary { margin-bottom: 10px; }

.photo { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.thumb { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); background: var(--bg); }
.thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 11px; padding: 0; }

.share { display: grid; gap: 6px; }
.share-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.share-row code { font-size: 12.5px; padding: 7px 9px; border-radius: 8px; background: var(--bg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Analytics */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filters select { width: auto; min-width: 200px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.tile .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .note { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart rect.bar { fill: var(--bar); }
.chart rect.hit { fill: transparent; cursor: default; }
.chart rect.hit:hover + rect.bar, .chart g.day:hover rect.bar { opacity: .75; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.tip b { display: block; margin-bottom: 2px; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; transition: .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%); }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 20px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }

/* Header extras */
.top .grow { flex: 1; }
.top .switch { width: auto; max-width: 180px; padding: 6px 8px; }
.top .me { color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.top .me.on { color: var(--ink); }
@media (max-width: 640px) { .top .brand { display: none; } .top .switch { max-width: 110px; } .top .me { max-width: 80px; } }

/* Sign-in, set-up, invite and reset screens */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth h1 { font-size: 22px; }
.notice { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--bg); display: grid; gap: 8px; }
.notice .share-row { grid-template-columns: minmax(0, 1fr) auto; }
.member .meta, .muted { color: var(--muted); font-size: 12.5px; }
.roles { margin: 0; padding-left: 18px; color: var(--muted); }
.roles b { color: var(--ink); font-weight: 500; }

/* Billing */
#banner:empty { display: none; }
#banner { padding: 10px 20px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 500; font-size: 13.5px; }
#banner a { color: inherit; }
.plan { display: grid; gap: 6px; }
.plan .big { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }

/* ---------- Beta tag ---------- */
.beta {
  display: inline-block; vertical-align: 2px; margin-left: 4px; padding: 1px 7px; border-radius: 999px;
  background: #F6E3D8; color: #A33A1A; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
@media (prefers-color-scheme: dark) { .beta { background: #4A372B; color: #F6E3D8; } }
h3 { font-size: 14px; margin: 0; }
div.field { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); justify-items: start; }
div.field > .hint { justify-self: stretch; }
.lbl { font-weight: 500; }
.count { color: var(--muted); font-weight: 400; }
.seg.choice { flex-wrap: wrap; }

/* ---------- Profile: main link and secondary handles ---------- */
.biolinks { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.bl-head { display: grid; gap: 2px; }
.bl-head + .linkline { margin-bottom: 6px; }
.linkline { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.linkline code { font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.handle-card { display: grid; gap: 8px; padding: 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.handle-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.at-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--field); padding-left: 10px; }
.at-input .at { color: var(--muted); }
.at-input input { border: 0; background: none; min-height: 36px; padding-left: 2px; }
.at-input input:focus-visible { outline: none; }
.at-input:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.address { display: flex; align-items: center; min-width: 0; border-radius: 8px; background: var(--bg); padding-left: 10px; font: 12.5px ui-monospace, Menlo, monospace; color: var(--muted); }
.address input.path { border: 0; background: none; min-height: 32px; padding: 4px 8px 4px 0; font: inherit; color: var(--ink); min-width: 0; }
.address input.path:focus-visible { outline: none; }
.address:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 560px) {
  .handle-row { grid-template-columns: minmax(0, 1fr) auto; }
  .handle-row select { grid-column: 1 / -1; }
}

/* ---------- Links: tracking boxes and extras ---------- */
details.tracking, details.extras { border-top: 1px solid var(--line); padding-top: 12px; }
.track-list { display: grid; gap: 8px; }
.track-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.track-name { display: grid; line-height: 1.25; min-width: 0; }
.track-name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-name small { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.more { margin-top: 8px; }
details.more summary { font-size: 13px; color: var(--muted); }
@media (max-width: 560px) { .track-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; } .track-row .track-name { grid-column: 1 / -1; } }
.track-tools { margin-top: 10px; }
.add-track { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.add-track-form { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 8px; }
.add-track-form input:not([type=url]) { grid-column: 2 / -1; }
.add-track-form input[type=url] { grid-column: 1 / 3; }
.csv-example { width: 100%; border-collapse: collapse; font-size: 13px; }
.csv-example th, .csv-example td { text-align: left; padding: 5px 8px; border: 1px solid var(--line); overflow-wrap: anywhere; }
.csv-example th { color: var(--muted); font-weight: 600; background: var(--bg); }
.csv-actions { margin-top: 4px; }
input[type=datetime-local] { width: 100%; min-height: 38px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--field); }
.check input:disabled + span { opacity: .55; }

/* ---------- Page settings ---------- */
.beta-zone { padding: 14px; border-radius: 12px; border: 1px dashed #E3B9A5; background: color-mix(in srgb, #F6E3D8 35%, var(--panel)); }
@media (prefers-color-scheme: dark) { .beta-zone { border-color: #6B5A4E; background: #33241B; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 999px; }
.chip button:hover { color: var(--danger); }
div.field > select { width: auto; min-width: 220px; max-width: 100%; }

/* ---------- Colours ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.swatch:hover { transform: translateY(-1px); }

/* ---------- Settings: escape animation ---------- */
.opt-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.opt-card { display: grid; gap: 10px; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--field); }
.opt-card.on { border-color: var(--accent); }
.opt-card label { display: grid; gap: 4px; cursor: pointer; }
.opt-card .pick { display: flex; align-items: center; gap: 8px; }
.opt-card input[type=checkbox] { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.opt-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt-card .btn { justify-self: start; }
.guide-art { position: relative; height: 96px; margin-bottom: 6px; border-radius: 10px; overflow: hidden; background: radial-gradient(circle at 92% 8%, #4A372B, #2A1C15 70%); }
.guide-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.guide-art path { fill: none; stroke: #F2B33D; stroke-width: 3; stroke-linecap: round; }
.guide-art.leaves path { stroke: none; } /* each leaf has its own fill */
.guide-art .dot, .guide-art span.dot { fill: #fff; }
.guide-art .chev { fill: none; stroke: #F2B33D; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.guide-art span.dot { position: absolute; top: 4px; right: 10px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.25); }
.guide-art.hand img { position: absolute; width: 34px; right: 22px; top: 12px; transform-origin: 50% 0; transform: rotate(40deg) scaleX(-1); }

/* ---------- Dialogs ---------- */
dialog.qr { width: min(380px, calc(100% - 32px)); }
dialog.qr img { width: 100%; image-rendering: pixelated; border-radius: 10px; border: 1px solid var(--line); }
dialog.qr code { font-size: 12.5px; padding: 7px 9px; border-radius: 8px; background: var(--bg); overflow-wrap: anywhere; }
dialog.csv { width: min(560px, calc(100% - 32px)); }
.csv-plan { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.csv-plan li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; overflow-wrap: anywhere; }
.csv-plan li.bad { border-color: var(--danger, #c0392b); color: var(--danger, #c0392b); }
.csv-plan small { color: var(--muted); }
dialog.preview-dlg { width: auto; max-width: calc(100% - 32px); }
dialog.preview-dlg .phone { margin: 0 auto; height: min(720px, calc(100vh - 140px)); width: calc(min(720px, calc(100vh - 140px)) / 2); }
.top .help { color: var(--muted); text-decoration: none; font-weight: 500; }
.address input.path { flex: 1; width: 100%; }
@media (max-width: 560px) {
  .linkline { grid-template-columns: minmax(0, 1fr) auto auto; }
  .linkline > code, .linkline > .address { grid-column: 1 / -1; }
}

/* Brand: Fraunces headings, leaf-cornered primary buttons, the Leaf V in the top bar */
h1, .brand, .panel h2 { font-family: "Fraunces", Georgia, serif; font-weight: 800; letter-spacing: -.01em; }
.btn.primary { border-radius: 12px 4px 12px 4px; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand svg { width: 24px; height: 24px; flex: none; }
.seg button.on { background: var(--ink); color: var(--bg); }

/* Guide page */
.guide { display: grid; gap: 16px; max-width: 820px; }
.guide .panel + .panel { margin-top: 0; }
.guide-list { margin: 0; padding-left: 20px; display: grid; gap: 10px; line-height: 1.55; }

/* Bubbles are leaf-shaped (round-sharp-round-sharp corners), like the Leavr mark */
.beta { border-radius: 9px 2px 9px 2px; }
.chip { border-radius: 14px 4px 14px 4px; }
.chip button { border-radius: 10px 3px 10px 3px; }
