/* Phone first: one column, big touch targets, bottom navigation. Wider screens just get more room. */
:root {
  --bg: #f4f6fa; --card: #fff; --ink: #1d2433; --muted: #667085; --line: #dde2ea;
  --accent: #1f5fbf; --accent-ink: #fff; --ok: #12805c; --ok-bg: #e3f6ee; --wait: #8a5a00; --wait-bg: #fff3d6;
  --bad: #b42318; --beau: #2f6fdf; --belle: #d6457a; --both: #7a4fd0;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c; --card: #1c212b; --ink: #e8ecf3; --muted: #9aa4b5; --line: #2d3442;
    --accent: #5b8ff0; --ok-bg: #133a2c; --ok: #5fd3a3; --wait-bg: #3a2e12; --wait: #f2c46b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #12151c; --card: #1c212b; --ink: #e8ecf3; --muted: #9aa4b5; --line: #2d3442;
    --accent: #5b8ff0; --ok-bg: #133a2c; --ok: #5fd3a3; --wait-bg: #3a2e12; --wait: #f2c46b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
a.plain, a.grow { color: inherit; text-decoration: none; }
h2 { font-size: 1.3rem; margin: .4em 0 .5em; }
h3 { font-size: 1.05rem; margin: .2em 0 .5em; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.push { margin-left: auto; }
.warn { color: var(--bad); }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--accent); color: var(--accent-ink);
}
.brand { color: inherit; font-weight: 700; text-decoration: none; }
.badge { font-size: .7rem; background: rgba(255,255,255,.2); padding: 2px 6px; border-radius: 6px; }
.who { margin-left: auto; color: inherit; text-decoration: none; font-size: .9rem; opacity: .9; }
.lang-picker { position: relative; }
.top .lang-picker { margin-left: auto; }
.who + .lang-picker { margin-left: 0; }
.lang-btn { background: rgba(255,255,255,.15); color: inherit; border: 0; padding: 4px 8px; min-height: 0; }
.flag { display: inline-block; width: 22px; height: 15px; vertical-align: -2px; border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.flag svg { width: 100%; height: 100%; display: block; }
.lang-menu { position: absolute; right: 0; top: 110%; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 20; min-width: 170px; }
.lang-menu button { display: flex; width: 100%; gap: 8px; align-items: center; border: 0; background: none; text-align: left; }
.lang-menu button.on { background: var(--bg); }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }

/* bottom navigation */
nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom:empty { display: none; }
nav.bottom a { flex: 1; text-align: center; padding: 8px 0 6px; font-size: .75rem; color: var(--muted); text-decoration: none; }
nav.bottom a .ico { display: block; font-size: 1.3rem; line-height: 1.2; }
nav.bottom a.on { color: var(--accent); font-weight: 600; }

/* building blocks */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.panel.org { border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 8px; }
button, .button {
  font: inherit; min-height: 44px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
button.small, .button.small { min-height: 34px; padding: 4px 10px; font-size: .9rem; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.big { font-size: 1.1rem; padding: 12px 20px; }
button.danger { color: var(--bad); border-color: var(--bad); background: none; }
button.on { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
input, select, textarea {
  font: inherit; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
}
input[type=checkbox] { width: 22px; min-height: 22px; height: 22px; }
.row select { width: auto; flex: 1; }
.field { display: block; margin: 0 0 10px; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 3px; }
.check-line { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 8px; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
details summary { cursor: pointer; font-weight: 600; }

/* segmented choice */
.seg { display: flex; gap: 0; margin-bottom: 10px; }
.seg button { flex: 1; border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 10px 0 0 10px; margin-left: 0; }
.seg button:last-child { border-radius: 0 10px 10px 0; }

/* chips and role letters */
.chip { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.chip.signed_up { background: var(--wait-bg); color: var(--wait); border-color: transparent; }
.chip.attended { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.cancelled { color: var(--muted); }
.chip.caller { background: #efe7ff; color: #5a32b0; border-color: transparent; }
.chip.noacc { color: var(--muted); font-style: italic; }
.ri { display: inline-flex; align-items: center; justify-content: center; width: 1.45em; height: 1.45em; border-radius: 50%; color: #fff; font-size: .72em; font-weight: 700; vertical-align: .1em; }
.ri-beau { background: var(--beau); } .ri-belle { background: var(--belle); } .ri-both { background: var(--both); }

/* dance list: filters, list or cards with pictures */
.list-head { display: flex; align-items: center; gap: 8px; }
.list-head h2 { flex: 1; }
.view-seg { margin: 0; }
.view-seg button { min-height: 38px; padding: 4px 14px; }
.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip { min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: .9rem; }
.fchip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.favs { margin-bottom: 8px; }
.filter-line { margin-bottom: 10px; }
.filters .fgroup { margin-bottom: 12px; }
.flabel { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.row.dates { align-items: flex-start; flex-wrap: nowrap; }
.row.dates > .field { flex: 1; min-width: 0; }
.row.dates select { width: 100%; }
.fav { color: #e0a100; }
.cards.as-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cards.as-cards .card { margin: 0; }
.thumb { width: 64px; height: 64px; flex: none; border-radius: 10px; overflow: hidden; background: var(--bg); align-self: center; }
.thumb img, .card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.big-card { flex-direction: column; padding: 0; overflow: hidden; gap: 0; }
.card-img { aspect-ratio: 16 / 9; background: var(--bg); }
.card-img img { object-fit: contain; background: #000; }
.card-row { display: flex; gap: 12px; padding: 12px; }
.flyer { display: block; width: 100%; max-height: 340px; object-fit: contain; background: var(--bg); border-radius: 10px; margin: 8px 0; }
.club-img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: none; }
.club-img.big { width: 72px; height: 72px; }
.club-head { display: flex; gap: 12px; align-items: center; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.actions > * { min-height: 52px; font-size: 1.05rem; width: 100%; }
.action-chip { display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 1.05rem; }

/* dance cards */
.card { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; color: inherit; text-decoration: none; }
.card-date { width: 64px; flex: none; text-align: center; display: flex; flex-direction: column; justify-content: center; background: var(--bg); border-radius: 10px; padding: 6px 2px; font-size: .85rem; }
.card-date.today { background: var(--accent); color: var(--accent-ink); }
.card-body { flex: 1; min-width: 0; }
.card-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.card-foot .muted { margin-right: auto; }
.role-links { margin-top: 10px; }

/* my place */
.place { background: var(--card); border: 4px solid var(--line); border-radius: 18px; padding: 16px; margin: 0 0 12px; text-align: center; }
.place-tip { color: var(--muted); font-weight: 600; }
.place-sq { font-size: 2.6rem; font-weight: 800; border-radius: 12px; margin: 8px auto; padding: 4px 16px; display: inline-block; color: #1d2433; }
.place.out .place-sq { background: var(--bg); color: var(--ink); }
.place-line { font-size: 1.1rem; margin: 4px 0; }
.place.waiting { border-style: dashed; }
.announce { background: var(--wait-bg); color: var(--wait); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 12px; font-weight: 600; }
.announce.big { font-size: 1.6rem; }

/* organiser and caller */
.counts { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 8px 0 12px; }
.counts div { background: var(--bg); border-radius: 10px; text-align: center; padding: 6px 2px; }
.counts strong { display: block; font-size: 1.3rem; }
.counts span { font-size: .7rem; color: var(--muted); }
.counts .hi { background: var(--accent); color: var(--accent-ink); }
.counts .hi span { color: inherit; opacity: .85; }
.tipbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tipnow { flex-basis: 100%; font-size: 1.1rem; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); }
.clist { margin-top: 8px; }
.crow { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.crow .cname { flex: 1; min-width: 0; }
.crow .tick { width: 40px; min-height: 40px; padding: 0; font-size: 1.2rem; }
.crow.here .tick { background: var(--ok); color: #fff; border-color: var(--ok); }
.crow:not(.here) .cname { color: var(--muted); }
.st-sitout { background: var(--wait-bg); color: var(--wait); border-color: transparent; }
.st-must { background: #ffe4e4; color: var(--bad); border-color: transparent; }
.approve { padding: 8px 0; border-bottom: 1px solid var(--line); }
.members .member { display: flex; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.pick button { display: flex; justify-content: space-between; width: 100%; margin: 4px 0; text-align: left; }
.pick small { color: var(--muted); }

/* squares, couple 1 at the bottom, then counter-clockwise: 2 right, 3 top, 4 left */
.sq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.box { position: relative; border: 3px solid; border-radius: 14px; padding: 8px; display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: auto auto auto; gap: 4px; min-height: 170px; font-size: .82rem; }
.box-n { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #1d2433; }
.couple { display: flex; gap: 4px; align-items: center; }
.couple .cn { font-weight: 800; color: var(--muted); }
.couple .pair { display: flex; flex-direction: column; }
.c-bottom { grid-row: 3; grid-column: 1 / 4; justify-content: center; }
.c-top { grid-row: 1; grid-column: 1 / 4; justify-content: center; }
.c-right { grid-row: 2; grid-column: 3; justify-content: flex-end; text-align: right; }
.c-left { grid-row: 2; grid-column: 1; }
.c-top .pair, .c-bottom .pair { flex-direction: row; gap: 10px; }
.outline { grid-column: 1 / -1; padding: 6px 2px; }

/* big screen: dark, everything on one screen (sizes set by the program), like the standalone program */
body.on-display { padding: 0; overflow: hidden; }
body.on-display .top { display: none; }
body.on-display main { max-width: none; padding: 0; }
.display { position: fixed; inset: 0; background: #111; color: #f4f4f4; padding: 1.2vh 1.5vw; overflow: hidden; z-index: 50; }
.display .d-head { display: flex; align-items: baseline; gap: 1.2em; margin-bottom: .3em; font-size: .6em; white-space: nowrap; }
.display .d-legend { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.display .d-title { font-weight: 700; }
.display .d-meta, .display .d-legend { color: #aaa; }
.display .d-clock .clock { font-size: 1.6em; color: #fff; font-weight: 700; }
.display .d-next { color: #f4a261; }
.display .d-btn { font: inherit; font-size: 14px; min-height: 0; padding: 4px 10px; border-radius: 8px; background: #333; color: #eee; border: 1px solid #555; text-decoration: none; cursor: pointer; }
.display .d-announce { background: #3a2e12; color: #f2c46b; border-radius: .3em; padding: .15em .5em; margin-bottom: .3em; font-weight: 600; }
.display .d-grid { column-gap: 2.2em; }
.display .d-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 1.8em; align-items: baseline;
  column-gap: .6em; break-inside: avoid; padding: .08em 0; border-bottom: 1px solid #2a2a2a; }
.display .d-name { font-weight: 600; display: flex; align-items: baseline; gap: .3em; min-width: 0; white-space: nowrap; }
.display .d-n { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.display .d-icons { flex: none; display: inline-flex; gap: .2em; align-items: center; font-size: .8em; }
.display .d-sq { font-weight: 800; text-align: center; border-radius: .3em; color: #111; }
.display .d-partner { color: #ccc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.display .d-out .d-name, .display .d-out .d-partner { color: #777; }
.display .d-out .d-sq { background: transparent; color: #777; font-weight: 400; }
.display .d-out .ri { opacity: .6; }
.display .d-empty { font-size: 2em; text-align: center; color: #888; margin-top: 20vh; }
.ri.flex { position: relative; }
.ri.flex::after { content: ''; position: absolute; top: -.15em; right: -.2em; width: .5em; height: .5em; border-radius: 50%; background: #c9a0ff; border: .08em solid #111; }
.display .d-squares { display: grid; gap: .6em; }
.display .d-box { position: relative; display: grid; border: .15em solid; border-radius: .5em; padding: .3em .4em;
  grid-template-columns: minmax(0, 1fr) 2.2em minmax(0, 1fr); column-gap: .3em; row-gap: .1em; align-items: center; }
.display .d-box-n { grid-row: 2; grid-column: 2; justify-self: center; width: 1.8em; height: 1.8em; line-height: 1.8em; border-radius: .3em;
  text-align: center; font-weight: 800; color: #111; font-size: 1.1em; }
.display .d-couple { display: flex; align-items: center; gap: .3em; min-width: 0; }
.display .d-top { grid-row: 1; grid-column: 1 / 4; justify-self: center; }
.display .d-bottom { grid-row: 3; grid-column: 1 / 4; justify-self: center; }
.display .d-left { grid-row: 2; grid-column: 1; justify-self: end; }
.display .d-right { grid-row: 2; grid-column: 3; justify-self: start; }
.display .d-cn { flex: none; font-size: .6em; color: #888; border: 1px solid #555; border-radius: 50%; width: 1.5em; height: 1.5em; line-height: 1.4em; text-align: center; }
.display .d-pair { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.display .d-outline { margin-top: .4em; font-size: .8em; color: #999; line-height: 1.5; }
.display .d-outline .d-out, .display .d-outline .d-name { display: inline-flex; color: #999; }

/* QR dialog and toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--card); border-radius: 18px; padding: 18px; max-width: 380px; width: 100%; text-align: center; }
.qr { background: #fff; border-radius: 12px; padding: 8px; margin: 0 auto; max-width: 300px; }
.qr svg { width: 100%; height: auto; display: block; }
.url { word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 10px; transition: .2s; z-index: 40; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* computers and tablets: navigation on the left, wider pages, two columns where it helps */
@media (min-width: 1000px) {
  body { padding-bottom: 0; padding-left: 200px; }
  body.on-display { padding-left: 0; }
  .top { margin-left: -200px; padding-left: 20px; }
  nav.bottom { top: 0; bottom: 0; right: auto; width: 200px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line);
    padding-top: 64px; z-index: 5; }
  nav.bottom a { flex: none; display: flex; gap: 10px; align-items: center; text-align: left; padding: 12px 20px; font-size: .95rem; }
  nav.bottom a .ico { display: inline; font-size: 1.2rem; }
  main { max-width: 1200px; padding: 16px 24px; }
  .cards:not(.as-cards) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  .two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; align-items: start; }
  .run-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 0 16px; align-items: start; }
  .toast { bottom: 24px; }
}
@media (min-width: 1500px) {
  .cards:not(.as-cards) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .counts { grid-template-columns: repeat(3, 1fr); }
  .sq-grid { grid-template-columns: 1fr; }
}
