:root {
  --navy: #0d2b52; --navy-2: #163d6f; --ink: #13233a; --soft: #5a6b80; --line: #dfe5ec;
  --bg: #f2f5f8; --paper: #fff; --red: #d0233f; --green: #1f8a5b; --amber: #c27a00;
  --r: 10px; --display: "Barlow Condensed", "Arial Narrow", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 Barlow, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--navy-2); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: .01em; margin: 0; line-height: 1.1; }
h1 { font-size: 32px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
.muted { color: var(--soft); }
.small { font-size: 13px; }

/* Layout */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand img { width: 42px; height: 42px; border-radius: 10px; }
.brand b { font-family: var(--display); font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: .02em; }
.brand small { display: block; font-size: 12px; color: rgba(255,255,255,.65); }
.side select { width: 100%; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: #fff; border-radius: 8px; padding: 8px; }
.side select option { color: var(--ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: rgba(255,255,255,.8); text-decoration: none; padding: 9px 10px; border-radius: 8px; font-weight: 500; display: flex; align-items: center; gap: 11px; }
.nav a .ic { flex: none; opacity: .85; width: 20px; text-align: center; font-size: 16px; }
.nav a.on .ic { opacity: 1; color: var(--red); }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: #fff; color: var(--navy); font-weight: 600; }
.side .me { margin-top: auto; font-size: 13px; color: rgba(255,255,255,.7); padding: 0 6px; }
.side .me b { color: #fff; display: block; }
.side .me button { background: none; border: 0; color: rgba(255,255,255,.75); padding: 0; cursor: pointer; text-decoration: underline; }
main { padding: 26px 30px 60px; max-width: 1180px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head p { margin: 4px 0 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* Dashboard banner: race-day photo with a navy fade behind the words */
.hero { border-radius: 14px; margin-bottom: 18px; min-height: 210px; display: flex; align-items: flex-end; padding: 26px 28px; color: #fff;
  background: linear-gradient(90deg, rgba(13,43,82,.95) 0%, rgba(13,43,82,.7) 38%, rgba(13,43,82,.05) 75%), url(/hero.jpg) center 58% / cover no-repeat, var(--navy); }
.hero h1 { font-size: 40px; }
.hero-kicker { margin: 0 0 4px; font-weight: 600; color: rgba(255,255,255,.8); }
.hero-sub { margin: 6px 0 14px; color: rgba(255,255,255,.85); }
.hero .hero-btn { background: #fff; color: var(--navy); border-color: #fff; }
.hero .hero-btn:hover { background: #e8eef5; }
@media (max-width: 820px) { .hero { min-height: 180px; padding: 20px; background-position: 70% 55%; } .hero h1 { font-size: 30px; } }

/* Surfaces */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid2 > .card + .card { margin-top: 0; }
.grid2 + .card, .card + .grid2 { margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat b { font-family: var(--display); font-size: 30px; font-weight: 800; color: var(--navy); display: block; line-height: 1; }
.stat span { color: var(--soft); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--soft); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.link { cursor: pointer; }
tr.link:hover td { background: #f6f9fc; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tablewrap { overflow-x: auto; }
.empty { padding: 26px; text-align: center; color: var(--soft); }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 8px 13px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: #b9c4d0; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid #c9d2dc; border-radius: 8px; padding: 8px 10px; background: #fff; }
textarea { min-height: 70px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
label.f { display: block; }
label.f > span { display: block; font-size: 13px; font-weight: 600; color: var(--soft); margin-bottom: 4px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 17px; height: 17px; accent-color: var(--navy); }
.search { max-width: 280px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #e8eef5; color: var(--navy); }
.pill.green { background: #dff3ea; color: var(--green); }
.pill.amber { background: #fbefd9; color: var(--amber); }
.pill.red { background: #fbe3e7; color: var(--red); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--soft); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--navy); border-color: var(--red); }

/* Silks + drivers */
.silk { width: 26px; height: 26px; flex: none; vertical-align: middle; }
.driver { display: inline-flex; align-items: center; gap: 7px; }

/* Race card */
.race { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); overflow: hidden; }
.race + .race { margin-top: 16px; }
.race-h { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #f6f9fc; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.race-no { font-family: var(--display); font-weight: 800; font-size: 26px; color: #fff; background: var(--navy); border-radius: 8px; min-width: 42px; text-align: center; padding: 2px 8px; }
.place { font-family: var(--display); font-weight: 800; font-size: 20px; }
.place.p1 { color: var(--red); }
td input.mini { width: 74px; padding: 5px 7px; }
.map { height: 320px; border-radius: var(--r); border: 1px solid var(--line); }
.map.tall { height: 460px; }
.mk { background: var(--navy); color: #fff; border: 2px solid #fff; border-radius: 99px; font-weight: 700; font-size: 12px; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.mk.finish { background: var(--red); }

/* Handicap log */
.log li { margin: 0 0 6px; }
.hc-big { font-family: var(--display); font-size: 44px; font-weight: 800; color: var(--navy); line-height: 1; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; overflow: hidden; background: #081a33; }
/* Blurred race-night photo behind the sign in card, darkened so the card stays the focus. */
.login::before { content: ""; position: absolute; inset: -40px; background: url(/login-bg.jpg) center / cover no-repeat; filter: blur(14px); transform: scale(1.05); }
.login::after { content: ""; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(13,43,82,.55) 0%, rgba(8,26,51,.78) 100%); }
.login > * { position: relative; z-index: 1; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { color: var(--navy); margin-bottom: 18px; padding: 0; }
.login .brand small { color: var(--soft); }
.err { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* Modal + toast */
.modal { position: fixed; inset: 0; background: rgba(8,20,40,.5); display: grid; place-items: center; padding: 16px; z-index: 2000; }
.modal[hidden] { display: none; }
.modal .box { background: #fff; border-radius: 14px; width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; padding: 22px; }
.modal .box.wide { max-width: 860px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 3000; }
.toast.on { opacity: 1; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 18px; background: #f2f5f8; padding: 10px 12px; border-radius: 8px; user-select: all; }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; }
  .side .club { flex: 1; min-width: 150px; }
  .nav { display: none; }
  .side .me { display: none; }
  main { padding: 18px 16px 50px; }
  .form { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
}

/* Page changes: the old page stays (slightly dimmed) until the new one is ready, then fades in. */
main.busy { opacity: .6; transition: opacity .12s .08s; pointer-events: none; }
main.enter > * { animation: rise .2s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Modals and the confirm box */
.modal { animation: fade .14s ease-out; }
.modal .box { animation: pop .16s cubic-bezier(.2,.9,.3,1.2); }
.modal.closing { animation: fade .14s ease-in reverse forwards; }
.modal.closing .box { animation: pop .14s ease-in reverse forwards; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.modal.confirm { z-index: 2500; }
.modal.confirm .box { max-width: 420px; }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-solid:hover { background: #b51d36; }
.btn { transition: background .12s, border-color .12s, transform .08s; }
.btn:active { transform: scale(.97); }

/* HTML dropdowns */
.dd { position: relative; }
.dd-native { position: absolute !important; opacity: 0; pointer-events: none; width: 1px !important; height: 1px; }
.dd-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left;
  border: 1px solid #c9d2dc; border-radius: 8px; padding: 8px 10px; background: #fff; cursor: pointer; min-height: 38px; }
.dd-btn:hover { border-color: #9fb0c2; }
.dd.open .dd-btn { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(22,61,111,.12); }
.dd-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chev { flex: none; color: var(--soft); transition: transform .15s; }
.dd.open .dd-chev { transform: rotate(180deg); }
.dd.dark .dd-btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.22); color: #fff; }
.dd.dark .dd-chev { color: rgba(255,255,255,.8); }
.dd-list { position: fixed; z-index: 3000; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(8,26,51,.18); padding: 5px; max-height: 320px; display: flex; flex-direction: column;
  opacity: 0; transform: translateY(-4px); transition: opacity .12s, transform .12s; outline: none; }
.dd-list.on { opacity: 1; transform: none; }
.dd-search { margin: 2px 2px 6px; width: auto !important; }
.dd-opts { overflow-y: auto; }
.dd-opt { padding: 8px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-opt.active { background: #eef3f9; }
.dd-opt.sel { font-weight: 600; color: var(--navy); }
.dd-opt.sel::after { content: "\2713"; float: right; margin-left: 12px; color: var(--red); }
.dd-none { padding: 10px; color: var(--soft); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  main.enter > *, .modal, .modal .box, .modal.closing, .modal.closing .box { animation: none !important; }
  .dd-list, main.busy, .btn { transition: none; }
}

/* Members filters */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--soft); }
.chip b { color: var(--ink); margin-left: 3px; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.on b { color: #fff; }
.th-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.th-sort:hover { color: var(--navy); }

/* Colour swatches in dropdowns */
.dd-sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 8px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }

/* Activity log */
.a-day { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--navy); padding: 14px 4px 6px; border-bottom: 1px solid var(--line); }
.a-day:first-child { padding-top: 0; }
.a-row { display: flex; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.a-ic { flex: none; width: 26px; height: 26px; border-radius: 99px; background: #e8eef5; color: var(--navy); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.a-ic.del { background: #fbe3e7; color: var(--red); }
.a-ic.bad { background: var(--red); color: #fff; }
.a-ch summary { cursor: pointer; color: var(--navy-2); font-size: 13px; margin-top: 4px; }
.a-ch table { margin-top: 6px; font-size: 13px; width: auto; }
.a-ch td { padding: 3px 10px 3px 0; border: 0; }
.arrow { color: #ffd23f; font-size: 14px; line-height: 16px; text-align: center; text-shadow: 0 0 3px rgba(0,0,0,.8); }

/* Unplaced run: three dots, filled per start without placing */
.run { display: inline-flex; gap: 4px; vertical-align: middle; }
.run i { width: 11px; height: 11px; border-radius: 99px; border: 2px solid #b9c4d0; }
.run i.on { background: var(--amber); border-color: var(--amber); }
.run-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.run.full i.on { background: var(--red); border-color: var(--red); }
.warn-t { color: var(--red); }
/* Start number, like a saddlecloth */
.no { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 5px; border-radius: 6px; background: var(--navy); color: #fff; font-family: var(--display); font-weight: 800; font-size: 16px; }

/* Distance change badge + "i" explainer */
td.dist { white-space: nowrap; }
.delta { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 99px; margin-right: 6px; vertical-align: 1px; }
.delta.neg { background: #fbe3e7; color: var(--red); }
.delta.pos { background: #dff3ea; color: var(--green); }
.info { width: 20px; height: 20px; margin-left: 6px; border-radius: 99px; border: 1.5px solid #9fb0c2; background: #fff; color: var(--navy-2);
  font: italic 700 12px/1 Georgia, serif; cursor: pointer; vertical-align: 1px; padding: 0; }
.info:hover, .info:focus-visible { border-color: var(--navy); background: var(--navy); color: #fff; }
.why { position: fixed; z-index: 3500; width: min(380px, calc(100vw - 16px)); background: #0f2238; color: #fff; border-radius: 10px; padding: 12px 14px;
  font-size: 13.5px; line-height: 1.45; box-shadow: 0 12px 30px rgba(8,26,51,.35); opacity: 0; transform: translateY(-3px); transition: opacity .12s, transform .12s; }
.why.on { opacity: 1; transform: none; }
.why-h { font-family: var(--display); font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.why table { width: 100%; }
.why td { border: 0; padding: 3px 0; vertical-align: top; color: rgba(255,255,255,.88); }
.why td.n { padding-right: 12px; color: #fff; text-align: right; }
.why p { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.15); color: rgba(255,255,255,.75); }
.why .neg { color: #ff8a9b; font-weight: 700; }
.why .pos { color: #7be0b5; font-weight: 700; }

/* Gap arrows: a curved bracket from the middle of the row above to the middle of this row */
table.field tbody tr { height: 50px; }
th.gap-h { width: 92px; }
td.gapc { position: relative; padding: 0; width: 92px; }
.gap { position: absolute; left: 2px; right: 0; top: -50%; height: 100%; pointer-events: auto; }
.gap-arc { position: absolute; left: 0; top: 8px; bottom: 8px; width: 16px; border: 2px solid #7f95ad; border-left: 0; border-radius: 0 14px 14px 0; }
.gap-arc::after { content: ""; position: absolute; left: -2px; bottom: -6px; border: 5px solid transparent; border-right: 7px solid #7f95ad; border-left: 0; }
.gap-t { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); font-size: 12.5px; font-weight: 700; color: var(--navy-2); background: #eef3f9; border-radius: 99px; padding: 1px 7px; white-space: nowrap; }
.dd-ic { display: inline-flex; margin-right: 8px; vertical-align: -6px; }
.dd-ic .silk { width: 22px; height: 22px; }

/* Phones: bottom tab bar + "More" sheet */
.tabbar, .sheet, .sheet-bg { display: none; }
@media (max-width: 820px) {
  main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500; background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border: 0; background: none;
    color: var(--soft); text-decoration: none; font-size: 11.5px; font-weight: 600; cursor: pointer; border-radius: 10px; -webkit-tap-highlight-color: transparent; }
  .tabbar .ic { font-size: 19px; height: 23px; line-height: 23px; }
  .tabbar a.on, .tabbar button.on, .tabbar button[aria-expanded="true"] { color: var(--navy); }
  .tabbar a.on .ic, .tabbar button.on .ic { color: var(--red); }
  .tabbar a:active, .tabbar button:active { background: #eef3f9; }
  .sheet-bg { display: block; position: fixed; inset: 0; z-index: 1600; background: rgba(8,20,40,.4); animation: fade .15s; }
  .sheet-bg[hidden] { display: none; }
  .sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1700; background: #fff; border-radius: 18px 18px 0 0;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .22s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 -10px 30px rgba(8,26,51,.2); }
  .sheet.open { transform: none; }
  .sheet-grab { width: 40px; height: 5px; border-radius: 99px; background: #d5dde6; margin: 2px auto 10px; }
  .sheet-me { padding: 4px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; }
  .sheet a, .sheet button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 10px; border: 0; background: none; border-radius: 10px;
    color: var(--ink); text-decoration: none; font-size: 16px; font-weight: 600; cursor: pointer; text-align: left; }
  .sheet a .ic, .sheet button .ic { color: var(--navy-2); width: 22px; text-align: center; font-size: 18px; }
  .sheet a.on { background: #eef3f9; }
  .sheet a.on .ic { color: var(--red); }
  .sheet #out2 { color: var(--red); }
  .sheet #out2 .ic { color: var(--red); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }

/* Track editor */
.hint { font-size: 13.5px; color: var(--soft); margin: 10px 0; min-height: 20px; display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.hint b { color: var(--ink); }
.hint.busy { color: var(--navy-2); }
.spin { width: 15px; height: 15px; border-radius: 99px; border: 2px solid #c9d6e6; border-top-color: var(--navy-2); animation: sp .8s linear infinite; flex: none; margin-top: 2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.res { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 10px; cursor: pointer; }
.res i { color: var(--navy-2); width: 18px; text-align: center; }
.res span { display: flex; flex-direction: column; min-width: 0; }
.res b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res small { color: var(--soft); font-size: 12px; }
.res.on { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(13,43,82,.15); }
.hdl { width: 22px; height: 22px; border-radius: 99px; border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.5); cursor: grab; }
.hdl.hdl-move { background: var(--navy); }
.hdl.hdl-end { background: var(--red); }
.hdl.hdl-width { background: #f59e0b; }
.hdl.in { display: inline-block; width: 13px; height: 13px; border-width: 2px; vertical-align: -2px; cursor: default; }

/* Made by Lewin Digital */
.made { display: block; margin-top: 14px; font-size: 12px; color: rgba(255,255,255,.5); text-decoration: none; }
.made b { font-weight: 600; color: rgba(255,255,255,.75); }
.made:hover b { color: #fff; }
.sheet .made { color: var(--soft); text-align: center; margin: 10px 0 0; padding: 0; justify-content: center; font-size: 12.5px; font-weight: 400; }
.sheet .made b { color: var(--navy-2); }
.login .made.login-made { position: relative; z-index: 1; text-align: center; margin-top: 16px; color: rgba(255,255,255,.65); }
.login { grid-auto-flow: row; align-content: center; }

/* Phones: table rows become cards */
@media (max-width: 820px) {
  .tablewrap { overflow: visible; }
  .card.tablewrap { padding: 0; background: none; border: 0; }
  table.cards, table.cards tbody { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
  .race table.cards tr, .modal table.cards tr, .card table.cards tr { box-shadow: none; }
  table.cards tr.wide { padding: 0; }
  table.cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 5px 0; text-align: right; min-height: 0; }
  table.cards td::before { content: attr(data-label); color: var(--soft); font-size: 13px; font-weight: 500; text-align: left; flex: none; }
  table.cards td:not([data-label])::before, table.cards td[data-label=""]::before { content: none; }
  table.cards td:not([data-label]) { justify-content: flex-end; }
  table.cards td:first-child { justify-content: flex-start; text-align: left; font-size: 16px; padding-top: 2px; }
  table.cards td:first-child::before { content: none; }
  table.cards td:empty { display: none; }
  table.cards tr.wide td { display: block; text-align: center; }
  tr.link:hover td { background: none; }
  tr.link:active { background: #f6f9fc; }

  /* Race field: number + horse on one line, the rest under it */
  .race table.cards { padding: 10px 10px 2px; }
  table.field tr { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; }
  table.field td { grid-column: 1 / -1; }
  table.field td:first-child { grid-column: 1; padding: 0; }
  table.field td:nth-child(2) { grid-column: 2; justify-content: flex-start; font-size: 17px; padding: 2px 0 6px; }
  table.field td:nth-child(2)::before { content: none; }
  td.gapc { position: static; width: auto; }
  td.gapc:not(:has(.gap)) { display: none; }
  .gap { position: static; display: inline-flex; }
  .gap-arc { display: none; }
  .gap-t { position: static; transform: none; }
  td input.mini { width: 110px; }
}
@media (max-width: 820px) {
  table.field tbody tr { height: auto; }
  .sheet:not(.open) { visibility: hidden; transition: transform .22s cubic-bezier(.2,.8,.2,1), visibility 0s .22s; }
}
@media (max-width: 820px) {
  table.cards td { justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
  table.cards td::before { margin-right: auto; }
  table.cards td:first-child { justify-content: flex-start; }
  table.cards td > div { width: auto; }
  .search { max-width: none; width: 100%; }
}

/* Download menu */
.menu-pop { position: fixed; z-index: 3200; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 34px rgba(8,26,51,.2);
  padding: 6px; min-width: 260px; opacity: 0; transform: translateY(-4px); transition: opacity .12s, transform .12s; }
.menu-pop.on { opacity: 1; transform: none; }
.menu-pop button { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 8px; text-align: left; cursor: pointer; }
.menu-pop button:hover, .menu-pop button:focus-visible { background: #eef3f9; outline: none; }
.menu-pop i { width: 20px; text-align: center; color: var(--navy-2); font-size: 17px; }
.menu-pop span { display: flex; flex-direction: column; }
.menu-pop small { color: var(--soft); font-size: 12px; }
.btn .spin { display: inline-block; vertical-align: -2px; }

/* Pony next to horse names */
.hname { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.pony-ic { width: 28px; height: 28px; object-fit: contain; flex: none; }
.pony-box { display: inline-flex; align-items: flex-end; justify-content: center; flex: none; }
.dd-own { width: 22px; text-align: center; color: var(--navy-2); margin-right: 6px; }

/* ===================== Phone polish ===================== */
@media (max-width: 820px) {
  /* iPhone zooms into inputs under 16px */
  input, select, textarea, .dd-btn { font-size: 16px; }
  /* installed app: keep clear of the notch */
  .side { padding-top: calc(12px + env(safe-area-inset-top)); }

  /* Page heading: title, then one tidy row of actions that scrolls sideways if needed */
  .head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 14px; }
  .head > .row:last-child:not(:first-child), .head > div:last-child:not(:first-child) { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
  .head > .row:last-child::-webkit-scrollbar { display: none; }
  .head .btn { flex: none; padding: 9px 13px; }
  .head .search { flex: 1 0 100%; }
  .head h1 { font-size: 28px; }
  /* horse/member heading: picture beside the name */
  .head > .row:first-child { flex-wrap: nowrap; align-items: center; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }

  /* Race header: number + name + status on one line, actions in a scrolling row underneath */
  .race-h { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 12px; }
  .race-h > .btn { display: none; }
  .race-h .race-actions { grid-column: 1 / -1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .race-h .race-actions::-webkit-scrollbar { display: none; }
  .race-h .race-actions .btn { display: inline-flex; flex: none; }

  /* Race field: compact runner cards */
  table.field tr { grid-template-columns: auto 1fr auto; column-gap: 10px; row-gap: 2px; padding: 10px 12px; align-items: center; }
  table.field td { grid-column: 2; padding: 0; justify-content: flex-start; text-align: left; font-size: 14px; }
  table.field td::before { content: none !important; }
  table.field td:first-child { grid-column: 1; grid-row: 1 / span 3; align-self: start; padding-top: 4px; }
  table.field td:nth-child(2) { grid-column: 2; grid-row: 1; font-size: 16px; padding: 0; }
  table.field td[data-label="Driver"] { grid-row: 2; color: var(--soft); }
  table.field td[data-label="Distance"] { grid-row: 3; font-weight: 700; color: var(--ink); }
  table.field td.gapc { grid-row: 3; grid-column: 2; justify-content: flex-end; }
  table.field td[data-label="Place"] { grid-column: 3; grid-row: 1; justify-content: flex-end; }
  table.field td[data-label="Place"] .place { font-size: 24px; }
  table.field td[data-label="Time"] { grid-column: 3; grid-row: 2; justify-content: flex-end; color: var(--soft); }
  table.field td:last-child:not([data-label]) { grid-column: 3; grid-row: 2 / span 2; justify-content: flex-end; }
  table.field .driver .silk { width: 20px; height: 20px; }

  /* Popups become bottom sheets with the buttons always in reach */
  .modal { place-items: end stretch; padding: 0; }
  .modal .box { max-width: none !important; width: 100%; border-radius: 18px 18px 0 0; max-height: 92vh; padding: 18px 16px 0;
    display: flex; flex-direction: column; animation: sheetUp .22s cubic-bezier(.2,.8,.2,1); }
  .modal .box > h2 { position: sticky; top: 0; }
  .modal .box::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: #d5dde6; margin: -8px auto 10px; flex: none; }
  .modal .foot { position: sticky; bottom: 0; background: #fff; margin: 14px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .modal .foot .btn { flex: 1; justify-content: center; padding: 12px; }
  .modal.confirm { place-items: center; padding: 16px; }
  .modal.confirm .box { border-radius: 14px; animation: pop .16s; padding: 20px; }
  .modal.confirm .box::before { content: none; }
  .modal.confirm .foot { position: static; margin: 16px 0 0; padding: 0; border: 0; }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
  .modal.closing .box { animation: sheetUp .16s ease-in reverse forwards; }
  .modal .box { overflow-y: auto; }

  /* Cards a touch tighter */
  .card { padding: 14px; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat b { font-size: 26px; }
}
@media (max-width: 820px) and (prefers-reduced-motion: reduce) { .modal .box { animation: none; } }
.race-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 820px) { .head > .btn { align-self: flex-start; } }

/* Horse photos */
.horse-photo { border-radius: 99px; object-fit: cover; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #c9d6e6; background: #e8eef5; }
.photo-wrap { position: relative; display: inline-flex; flex: none; }
.photo-btn { position: absolute; right: -4px; bottom: -2px; width: 30px; height: 30px; border-radius: 99px; border: 2px solid #fff; background: var(--navy); color: #fff; cursor: pointer; display: grid; place-items: center; font-size: 13px; box-shadow: 0 2px 6px rgba(8,26,51,.3); }
.photo-btn:hover { background: var(--navy-2); }

/* add to home screen guide */
.seg { display: inline-flex; background: #e8eef5; border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--navy); cursor: pointer; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(13, 43, 82, .15); }
.steps { list-style: none; margin: 12px 0 0; padding: 0; counter-reset: st; display: grid; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.45; }
.step-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 16px; position: relative; }
.steps li { counter-increment: st; }
.step-ic::after { content: counter(st); position: absolute; top: -6px; left: -6px; width: 17px; height: 17px; border-radius: 99px; background: var(--red); color: #fff; font: 700 10.5px/17px sans-serif; text-align: center; }
.install-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.install-banner > i { font-size: 26px; color: var(--navy); }
.install-banner .grow { flex: 1; min-width: 160px; }

/* register filters and sorting */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters .chips + .chips, #typec + .chips { padding-left: 10px; border-left: 1px solid var(--line); }
.filters .search { min-width: 200px; }
.th-sort { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.th-sort i { font-size: 10px; opacity: .35; }
.th-sort.on { color: var(--navy); }
.th-sort.on i { opacity: 1; color: var(--red); }
th.n .th-sort { justify-content: flex-end; }
#sortm { display: none; }
.type-pill { background: #eef2ff; color: #3730a3; }
@media (max-width: 760px) {
  #sortm { display: block; flex: 1 1 100%; }
  .filters .search, .filters .dd, .filters > div:has(> .club-f) { flex: 1 1 100%; min-width: 0; }
  .filters .chips + .chips, #typec + .chips { padding-left: 16px; border-left: 0; }
  .filters .chips { padding-bottom: 2px; }
  .filters .chip { flex: none; }
  .filters > * { flex: 1 1 100%; min-width: 0; }
  .filters > .chips, #typec { flex-basis: calc(100% + 32px); }
  .filters .grow { display: none; }
}
.pill.hist { background: #eef1f5; color: #5a6b80; }

/* racing colours editor */
.silk-ed { display: flex; gap: 16px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }
.silk-ed-prev { flex: none; width: 84px; display: grid; place-items: center; padding-top: 4px; }
.silk-ed-main { flex: 1; min-width: 0; display: grid; gap: 10px; }
.silk-ed-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sc-row { display: flex; align-items: center; gap: 8px; }
.sc-lab { width: 58px; flex: none; font-size: 13px; color: var(--soft); font-weight: 600; }
.sc-row .dd { flex: 1; min-width: 0; }
.sc-fine { flex: none; width: 42px; height: 40px; border-radius: 10px; border: 1px solid var(--line); position: relative; cursor: pointer; display: grid; place-items: center; box-shadow: inset 0 0 0 3px #fff; }
.sc-fine input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.sc-fine i { font-size: 12px; color: #fff; mix-blend-mode: difference; pointer-events: none; }
#silkStyle label { margin: 0; }
@media (max-width: 600px) { .silk-ed { flex-direction: column; align-items: stretch; } .silk-ed-prev { width: auto; } }
.silk-ed-prev .silk { width: 76px; height: 76px; }
