:root {
  --pink: #ff2aa1;
  --pink-dark: #d81b86;
  --pink-pale: #fff0f8;
  --purple: #7b3fe4;
  --gradient: linear-gradient(135deg, #ff2aa1 0%, #7b3fe4 100%);
  --ink: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --surface: #ffffff;
  --page: #f6f7fb;
  --danger: #c0262d;
  --danger-pale: #fdecec;
  --success: #15803d;
  --success-pale: #e9f7ee;
  --radius: 14px;
  --font-body: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Oswald', 'Inter Tight', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__logo { width: 40px; height: auto; }
.topbar__title { font-family: var(--font-heading); font-size: 1.25rem; letter-spacing: .02em; color: var(--ink); white-space: nowrap; }
.topbar__actions { display: flex; align-items: center; gap: 4px; }

/* ---- Layout ---- */
.app { max-width: 820px; margin: 0 auto; padding: 20px 16px 140px; }
.loading { color: var(--muted); text-align: center; padding: 48px 0; }

/* ---- Buttons ---- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 20px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.button--primary { background: var(--pink); color: #fff; }
.button--primary:hover { background: var(--pink-dark); }
.button--primary:disabled { background: #f3a6cf; cursor: wait; }
.button--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.button--ghost:hover { border-color: var(--muted); }
.button--add { background: var(--pink-pale); color: var(--pink-dark); border: 1px dashed #f5a3cf; width: 100%; margin-bottom: 12px; }
.field--group { border: 0; padding: 0; margin-inline: 0; min-width: 0; }
.field--group > legend { padding: 0; }
.button--add:hover { background: #ffe3f2; }
.button--danger { background: var(--surface); border-color: #f1b5b8; color: var(--danger); }
.button--danger:hover { background: var(--danger-pale); }
.button--small { min-height: 38px; padding: 6px 14px; font-size: .9rem; }
.link-button {
  white-space: nowrap; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: .92rem; text-decoration: none;
}
.link-button:hover { color: var(--ink); background: var(--page); }

/* ---- Login ---- */
.login {
  max-width: 400px; margin: 48px auto 0; padding: 32px 28px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(15,23,42,.08);
}
.login h1 { font-family: var(--font-heading); font-size: 1.8rem; margin: 0 0 6px; color: var(--ink); }
.login p { margin: 0 0 22px; color: var(--muted); }
.login .button { width: 100%; margin-top: 8px; }

/* ---- Tabs ---- */
.tabs {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 4px; margin-bottom: 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.tab {
  min-height: 42px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font-weight: 700; font-size: .92rem; color: var(--muted);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); color: #fff; }

/* ---- Section header ---- */
.section-head { margin-bottom: 16px; }
.section-head h1 { font-family: var(--font-heading); font-size: 1.9rem; margin: 0; color: var(--ink); }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.section-head a { color: var(--pink-dark); font-weight: 600; }

/* ---- Messages ---- */
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; margin-bottom: 16px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 500;
}
.notice--error { background: var(--danger-pale); border-color: #f1b5b8; color: #8a1c21; }
.notice--success { background: var(--success-pale); border-color: #b6e2c4; color: #14532d; }
.notice--working { background: #f3f0ff; border-color: #d8ccfb; color: #3b2a7a; }
.notice a { color: inherit; font-weight: 700; }
.notice__dot { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: currentColor; }
.notice--working .notice__dot { animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---- Item cards ---- */
.items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0 0 12px; padding: 0; list-style: none; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card--open { border-color: #f5a3cf; box-shadow: 0 6px 24px rgba(255,42,161,.08); }
.card--past { opacity: .7; }
.card__head {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; min-height: 64px;
  background: none; border: 0; text-align: left; cursor: pointer; border-radius: var(--radius);
}
.card__text { flex: 1; min-width: 0; }
.card__title { display: block; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__sub { display: block; font-size: .88rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__badge { flex: 0 0 auto; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; background: var(--page); color: var(--muted); }
.card__badge--new { background: var(--pink-pale); color: var(--pink-dark); }
.card__chevron { flex: 0 0 auto; width: 18px; height: 18px; color: var(--muted); transition: transform .2s; }
.card--open .card__chevron { transform: rotate(180deg); }
.card__body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.card__actions .spacer { flex: 1; }

/* ---- Fields ---- */
.field { margin-top: 16px; }
.field > label, .field > .field__label { display: block; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.field__required { color: var(--pink-dark); font-weight: 600; font-size: .85rem; margin-left: 4px; }
.field__help { margin: 6px 0 0; font-size: .86rem; color: var(--muted); }
.field__error { margin: 6px 0 0; font-size: .86rem; color: var(--danger); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; background: #fff;
  border: 1px solid #cbd5e1; border-radius: 10px;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255,42,161,.18); }
.input--invalid { border-color: var(--danger); }
.textarea { min-height: 170px; resize: vertical; line-height: 1.55; }
.textarea--short { min-height: 90px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row .field { margin-top: 16px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 14px;
  border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; cursor: pointer; font-weight: 600; font-size: .92rem;
}
.check input { width: 18px; height: 18px; accent-color: var(--pink); margin: 0; }
.check:has(input:checked) { border-color: var(--pink); background: var(--pink-pale); color: var(--pink-dark); }

.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 700; color: var(--ink); }
.toggle input { width: 22px; height: 22px; accent-color: var(--pink); margin: 0; }

.more { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 6px; }
.more > summary { cursor: pointer; padding: 10px 0; font-weight: 700; color: var(--pink-dark); list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: '+ '; }
.more[open] > summary::before { content: '− '; }

/* ---- Photo picker: frames match how the photo shows on the site ---- */
.photo { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.photo__preview {
  position: relative; overflow: hidden; flex: 0 0 auto;
  background: var(--gradient); display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-heading); font-size: 1.4rem;
}
.photo__preview img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; user-select: none; -webkit-user-drag: none; }
.photo__preview--circle { width: 120px; height: 120px; border-radius: 50%; }
.photo__preview--portrait { width: 144px; height: 180px; border-radius: 14px; }
.photo__preview--landscape { width: 210px; height: 140px; border-radius: 12px; }
.photo__preview--whole { background: #0f172a; }
.photo__preview--whole img { object-fit: contain; object-position: 50% 50%; }
.photo__preview--draggable { cursor: grab; touch-action: none; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #f5a3cf; }
.photo__preview--draggable:active { cursor: grabbing; }
.photo__buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.photo__file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.thumb { width: 44px !important; height: 44px !important; border-radius: 50% !important; flex: 0 0 auto; font-size: 1rem; box-shadow: none !important; }
.thumb.photo__preview--whole img { object-fit: cover; }

.crop { margin-top: 14px; padding: 14px 16px; background: var(--page); border-radius: 12px; display: grid; gap: 10px; max-width: 460px; }
.crop__row { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 12px; font-size: .9rem; font-weight: 600; color: var(--text); }
.range { width: 100%; accent-color: var(--pink); min-height: 28px; }
.crop .link-button { justify-self: start; padding-left: 0; }

/* ---- Repeating rows (roster, coaches, details) ---- */
.field--list { margin-top: 20px; }
.rows { display: grid; gap: 10px; margin: 10px 0 12px; }
.rows__empty { margin: 8px 0 12px; color: var(--muted); font-size: .9rem; }
.row { border: 1px solid var(--border); border-radius: 12px; padding: 4px 14px 10px; background: #fcfcfe; }
.row__fields { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .row__fields--2 { grid-template-columns: 1fr 1fr; }
  .row__fields--4 { grid-template-columns: 80px 1fr 1fr 120px; }
}
.field--sub { margin-top: 10px; }
.field--sub > label { font-size: .85rem; }
.field--wide { grid-column: 1 / -1; }
.field--sub .textarea { min-height: 90px; }
.row__actions { display: flex; gap: 4px; justify-content: flex-end; margin-top: 6px; }
.link-button--danger { color: var(--danger); }
.link-button:disabled { opacity: .35; cursor: default; }

/* ---- Save bar ---- */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--ink); color: #fff; box-shadow: 0 -8px 30px rgba(15,23,42,.18);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.savebar__inner { max-width: 820px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.savebar__text { font-weight: 600; }
.savebar__buttons { display: flex; gap: 8px; }
.savebar .button--ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }

@media (max-width: 560px) {
  .topbar__title { font-size: 1.1rem; }
  .topbar__site { display: none; }
  .tabs { grid-template-columns: repeat(3, 1fr); border-radius: 18px; }
  .tab { border-radius: 14px; }
  .field-row { grid-template-columns: 1fr; }
  .savebar__inner { justify-content: center; }
  .savebar__text { width: 100%; text-align: center; }
  .savebar__buttons { width: 100%; }
  .savebar__buttons .button { flex: 1; }
}

/* ---- Per-team schedules ---- */
.group-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.group-picker__item {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px;
  border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--text);
}
.group-picker__item[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.group-picker__count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--page); color: var(--muted); font-size: .75rem; text-align: center; }
.group-picker__item[aria-selected="true"] .group-picker__count { background: rgba(255,255,255,.18); color: #fff; }
.group-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.group-toolbar .button--add { width: auto; flex: 1 1 260px; margin-bottom: 0; }
.copy-chooser { margin: 12px 0; padding: 16px; border: 1px solid #f5a3cf; border-radius: 12px; background: var(--pink-pale); }
.copy-chooser__title { margin: 0 0 10px; font-weight: 700; color: var(--ink); }
.copy-chooser__actions { display: flex; gap: 8px; margin-top: 12px; }
