/* ------------------------------------------------------------ the app frame
   Owner decision 2026-11-06, "A + Home page": a rail of places on the left (a bottom tab bar
   on phones). Every area is a full page in the same frame. Tools on the thing you're looking
   at slide in from the right. Pop-ups are only for quick questions.
   Pattern sources: Material 3 navigation rail / bar, Apple HIG tab bars and sidebars. */
:root { --rail-w: 92px; --bar-h: 0px; --page-h: 64px; --lime: #7ff21a; --lime-ink: #0b1220; --lime-text: #2f7d0b; --lime-soft: #effbe4; --ease: cubic-bezier(.2, .8, .2, 1); }
body { display: block; overflow: hidden; }
:root { --nav-h: 0px; --dlg-h: calc(100vh - 48px); }
@supports (height: 100dvh) { :root { --dlg-h: calc(100dvh - 48px); } }

.shell { height: 100vh; display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); }
@supports (height: 100dvh) { .shell { height: 100dvh; } }

/* ---------- rail ---------- */
.rail { position: relative; z-index: 15; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0 16px; background: var(--ink); color: #c4ccd5; }
.rail-mark { display: grid; place-items: center; width: 64px; height: 56px; margin-bottom: 18px; }
.rail-mark img { height: 46px; width: auto; display: block; }
.rail-sp { flex: 1; }
.nav-item { display: grid; justify-items: center; gap: 5px; width: 80px; padding: 4px 0; color: inherit; text-decoration: none; font: 700 12px/1 var(--ui); letter-spacing: 0; -webkit-tap-highlight-color: transparent; }
.nav-item .pill { display: grid; place-items: center; width: 56px; height: 34px; border-radius: 999px; transition: background .2s var(--ease), transform .2s var(--ease); }
.nav-item svg { width: 22px; height: 22px; fill: currentColor; transition: transform .25s var(--ease); }
.nav-item:hover { color: #fff; }
.nav-item:hover .pill { background: #243040; }
.nav-item[aria-current=page] { color: #fff; }
.nav-item[aria-current=page] .pill { background: var(--lime); color: var(--lime-ink); }
.nav-item[aria-current=page] svg { transform: scale(1.06); }
.nav-item:active .pill { transform: scale(.94); }
.nav-item:focus-visible { outline: none; }
.nav-item:focus-visible .pill { outline: 3px solid var(--lime); outline-offset: 2px; }
body.plan-free #coordOpen .pill { position: relative; }
body.plan-free #coordOpen .pill::after { content: "Paid"; position: absolute; top: -6px; right: -8px; padding: 2px 5px; border-radius: 999px; background: var(--lime); color: var(--lime-ink); font: 800 9px/1 var(--ui); text-transform: uppercase; letter-spacing: .04em; }
body.plan-free #coordOpen::after, body.plan-free #coachesOpen::after { content: none; }
/* The Team icon is the team's own badge. */
.nav-item .pill .team-dot { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font: 800 12px/1 var(--display); font-style: normal; letter-spacing: .02em; box-shadow: 0 0 0 2px rgba(255,255,255,.18); }
.nav-item[aria-current=page] .pill .team-dot { box-shadow: 0 0 0 2px var(--lime-ink); }
/* The coach icon: you. Opens the account menu. */
/* The coach icon: your team's badge. Opens the coach panel (team, players, coaches, account). */
.coach-btn { display: grid; justify-items: center; gap: 5px; width: 80px; margin-top: 10px; padding: 4px 0; border: 0; background: none; color: inherit; font: 700 12px/1 var(--ui); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.coach-btn .team-dot { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font: 800 16px/1 var(--display); font-style: normal; letter-spacing: .02em; box-shadow: 0 0 0 3px #243040; transition: box-shadow .2s var(--ease), transform .2s var(--ease); }
.coach-btn:hover { color: #fff; }
.coach-btn:hover .team-dot, .coach-btn:focus-visible .team-dot { box-shadow: 0 0 0 3px var(--lime); }
.coach-btn:active .team-dot { transform: scale(.94); }
.coach-btn:focus-visible { outline: none; }
.phone-only { display: none; }
.page-head .coach-btn, .hello .coach-btn { width: auto; margin: 0 0 0 auto; padding: 0; }
.page-head .coach-btn .team-dot, .hello .coach-btn .team-dot { width: 38px; height: 38px; font-size: 15px; box-shadow: 0 0 0 2px var(--line); }

/* ---------- places ---------- */
.places { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
.place { position: absolute; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.place[hidden] { display: none; }
.place.entering { animation: place-in .32s var(--ease); }
@keyframes place-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: center; gap: 10px 16px; min-height: var(--page-h); padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.page-head h1 { margin: 0; font: 800 28px/1 var(--display); letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.page-sub { color: var(--muted); font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-sp { flex: 1; }
.page-head .nav-link { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); font: 700 14px/1 var(--ui); text-decoration: none; white-space: nowrap; transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); }
.page-head .nav-link:hover { background: var(--panel); border-color: #b8c2cc; box-shadow: 0 4px 12px rgba(24,33,43,.08); color: var(--ink); }
.page-head .nav-link:active { transform: translateY(1px); }
.page-head .nav-link svg { width: 17px; height: 17px; fill: currentColor; }
.page-head .nav-link .short { display: none; }
.page-head .ai-btn { background: var(--ink); border-color: var(--ink); color: #fff; }
.page-head .ai-btn:hover { background: #243040; border-color: #243040; color: #fff; }
.page-head .ai-btn svg { fill: var(--lime); }
.page-head .print-btn b { background: var(--ink); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.page-head .lib-toggle { border-color: var(--line); color: var(--ink); background: var(--panel); }

/* Playbook: the play maker fills the page under its header. */
.place-playbook .layout { min-height: 0; }
/* Browse is the playbook's "All cards" view, shown in place over the play maker. */
dialog.browse:not(:modal) { position: fixed; z-index: 14; inset: 0 0 var(--bar-h) var(--rail-w); width: auto; max-width: none; height: auto; max-height: none; margin: 0; border-radius: 0; box-shadow: none; animation: place-in .28s var(--ease); }

/* Practice: the Coordinator, as a page. */
.coord { display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--panel); }
.coord > .coord-plans, .coord > .coord-edit { flex: 1; }

/* Team and Settings: scrolling pages of cards. */
.place-settings { overflow: auto; overscroll-behavior: contain; grid-template-rows: auto auto; align-content: start; }
.settings-page { display: grid; gap: 18px; padding: 24px; max-width: 760px; width: 100%; margin: 0 auto; align-items: start; }
.team-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(18,26,35,.05), 0 8px 24px rgba(18,26,35,.06); overflow: hidden; }
.settings-wrap.team-card { max-height: none; padding-bottom: 6px; }
.settings-wrap .hint, .settings-body .hint { text-align: left; }

/* ---------- the coach panel: slides in from the right ---------- */
dialog.coach-panel[open] { position: fixed; z-index: 60; inset: 0 0 0 auto; margin: 0; padding: 0; border: 0; width: min(640px, 100vw); max-width: none; height: 100vh; max-height: 100vh; border-radius: 20px 0 0 20px; overflow: hidden; box-shadow: -24px 0 60px rgba(18,26,35,.28); animation: tool-in .32s var(--ease); }
body.cp-open .places::after { content: ""; position: absolute; inset: 0; z-index: 13; background: rgba(18,26,35,.45); animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; } }
@supports (height: 100dvh) { dialog.coach-panel[open] { height: 100dvh; max-height: 100dvh; } }
.cp-wrap { display: flex; flex-direction: column; height: 100%; background: var(--bg); }
.cp-head { display: flex; align-items: center; gap: 16px; padding: 22px 22px 20px; background: var(--ink); color: #fff; }
.cp-badge { display: grid; place-items: center; flex: none; width: 60px; height: 60px; border-radius: 50%; font: 800 24px/1 var(--display); font-style: normal; box-shadow: 0 0 0 3px #243040; }
.cp-who { min-width: 0; flex: 1; display: grid; gap: 4px; }
.cp-who h2 { margin: 0; font: 800 28px/1 var(--display); letter-spacing: .02em; text-transform: uppercase; overflow-wrap: anywhere; }
.cp-who .menu-who { margin: 0; padding: 0; border: 0; color: #aab6c2; font: 600 14px/1.3 var(--ui); white-space: normal; overflow-wrap: anywhere; }
.cp-who .menu-plan { margin: 0; padding: 0; border: 0; color: var(--lime); font: 700 12px/1.3 var(--ui); letter-spacing: .06em; text-transform: uppercase; }
.cp-head .icon-close { align-self: flex-start; background: #243040; border-color: #3a4b5c; color: #fff; }
.cp-head .icon-close:hover { background: #2f3d4e; }
.cp-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; padding: 16px; }
.cp-billing:has(#billingOpen[hidden]) { display: none; }
.cp-billing #billingOpen { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--lime); color: var(--lime-ink); font: 700 15px/1 var(--ui); cursor: pointer; }
.cp-billing #billingOpen svg { width: 18px; height: 18px; fill: currentColor; }
.cp-billing #billingOpen small { margin-left: auto; font-size: 12px; font-weight: 700; color: inherit; opacity: .75; }
.cp-sec { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(18,26,35,.05); overflow: hidden; }
.cp-sec > h3, .cp-sec .roster-intro h3 { margin: 0; padding: 18px 20px 0; font: 800 20px/1 var(--display); letter-spacing: .03em; text-transform: uppercase; color: var(--ink); }
.cp-sec.settings-wrap { max-height: none; padding-bottom: 6px; }
.team-id .row2 { padding-top: 14px; }
.coord-roster.cp-sec { overflow: visible; max-width: none; margin: 0; padding: 0 0 18px; gap: 12px; flex: none; min-height: auto; }
.cp-body > * { min-height: auto; }
.cp-sec, .cp-sec.settings-body { overflow: clip; }
.coord-roster.cp-sec > * { margin-left: 20px; margin-right: 20px; }
.coord-roster.cp-sec .roster-intro { margin: 0; }
.coord-roster.cp-sec .roster-intro > :not(h3) { margin: 0 20px; }
/* Players as compact cards: name, number and remove on one line; spots and note under. */
.cp-sec .roster-headrow { display: none; }
.cp-sec .roster-row { grid-template-columns: 1fr 1fr 64px 40px; padding: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.cp-sec .roster-row input[data-k=name] { grid-column: 1 / 3; grid-row: 1; }
.cp-sec .roster-row input[data-k=number] { grid-column: 3; grid-row: 1; }
.cp-sec .roster-row input[data-k=offense] { grid-column: 1; grid-row: 2; }
.cp-sec .roster-row input[data-k=defense] { grid-column: 2 / -1; grid-row: 2; }
.cp-sec .roster-row input[data-k=note] { grid-column: 1 / -1; grid-row: 3; }
.cp-sec .roster-row .roster-del, .cp-sec .roster-row > span:last-child { grid-column: 4; grid-row: 1; }
.coaches-card { padding-bottom: 18px; }
.coaches-card .coach-add, .coaches-card .coach-list { margin-left: 20px; margin-right: 20px; }
.coaches-card > .muted { margin: 10px 20px 0; }
.cp-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 6px 4px 18px; }
.cp-foot .menu-legal { flex: 1; margin: 0; padding: 0; border: 0; }
.cp-foot #signOut { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font: 700 14px/1 var(--ui); color: var(--ink); cursor: pointer; }
.cp-foot #signOut svg { width: 17px; height: 17px; fill: currentColor; }
.team-id .row2 { padding-top: 14px; }
.settings-wrap .hint, .settings-body .hint { text-align: left; }

/* ---------- Home ---------- */
.place-home { overflow: auto; overscroll-behavior: contain; grid-template-rows: auto; align-content: start; }
.home { display: grid; gap: 22px; align-content: start; max-width: 1320px; width: 100%; margin: 0 auto; padding: 32px 40px 48px; }
.hello { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.hello h1 { margin: 0; font: 800 46px/1 var(--display); text-transform: uppercase; letter-spacing: .01em; }
.hello p { margin: 0; color: var(--muted); font-weight: 600; font-size: 16px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); border-radius: 24px; overflow: hidden; background: var(--ink); color: #fff; box-shadow: 0 24px 50px rgba(18,26,35,.22); }
.hero-l { display: grid; gap: 14px; align-content: center; padding: 34px 36px; background: radial-gradient(640px 320px at 0% 0%, #22313f 0%, var(--ink) 70%); min-width: 0; }
.kicker { font: 700 13px/1.2 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--lime); }
.hero h2 { margin: 0; font: 800 44px/1 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.hero-m { margin: 0; color: #aab6c2; font-weight: 600; font-size: 15px; line-height: 1.45; max-width: 52ch; }
.hero-go { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.go-btn, .ghost-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 12px; font: 700 15px/1 var(--ui); text-decoration: none; cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s; }
.go-btn { border: 0; background: var(--lime); color: var(--lime-ink); box-shadow: 0 8px 20px rgba(127,242,26,.3); }
.go-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(127,242,26,.4); }
.ghost-btn { border: 1px solid #3a4b5c; background: transparent; color: #fff; }
.ghost-btn:hover { border-color: #5b6f87; }
.go-btn svg, .ghost-btn svg { width: 18px; height: 18px; fill: currentColor; }
.hero-r { display: grid; place-items: center; padding: 26px; background: #0d141c; min-width: 0; }
.hero-card { display: block; width: 100%; max-width: 520px; padding: 0; border: 0; background: none; cursor: pointer; transform: rotate(-2.5deg); transition: transform .35s var(--ease); }
.hero-card:hover { transform: rotate(0) scale(1.02); }
.hero-card svg { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: 0 20px 40px rgba(0,0,0,.45); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tile { position: relative; display: grid; gap: 10px; align-content: start; min-height: 220px; padding: 20px; border-radius: 18px; background: var(--panel); color: var(--ink); text-decoration: none; border: 1px solid transparent; box-shadow: 0 1px 2px rgba(18,26,35,.06), 0 8px 24px rgba(18,26,35,.08); overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(18,26,35,.06), 0 18px 36px rgba(18,26,35,.14); border-color: #cfd8e0; }
.tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tile h3 { margin: 0; display: flex; align-items: center; gap: 9px; font: 800 24px/1 var(--display); text-transform: uppercase; }
.tile h3 svg { width: 22px; height: 22px; fill: var(--lime-text); }
.tile p { margin: 0; color: var(--muted); font-weight: 600; font-size: 14px; }
.tile .tag { margin-left: auto; padding: 3px 9px; border-radius: 999px; background: var(--ink); color: var(--lime); font: 800 11px/1.3 var(--ui); letter-spacing: .08em; text-transform: uppercase; }
.fan { position: relative; height: 128px; margin-top: 4px; }
.fan div { position: absolute; top: 10px; width: 170px; border-radius: 5px; overflow: hidden; box-shadow: 0 8px 18px rgba(18,26,35,.2); transition: transform .3s var(--ease); left: calc(var(--i) * 46px); transform: rotate(calc(-7deg + var(--i) * 7deg)); }
.tile:hover .fan div { transform: rotate(calc(-10deg + var(--i) * 10deg)) translateY(-4px); }
.fan svg { display: block; width: 100%; height: auto; }
.mini { display: grid; gap: 6px; }
.mini span { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; background: var(--bg); font-size: 13px; }
.mini b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini i { flex: none; font-style: normal; color: var(--muted); font-weight: 600; }
.kids { display: flex; flex-wrap: wrap; gap: 6px; }
.kids b { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--lime-soft); color: var(--lime-text); font: 800 15px/1 var(--display); }
.kids b.more { background: var(--bg); color: var(--muted); font-size: 13px; }
.tile-hint { font-weight: 500 !important; }

/* ---------- tools slide in from the right; quick questions stay small and centred ---------- */
dialog { margin: auto; }
dialog::backdrop { top: 0; }
dialog.ai-dialog[open] { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(1240px, calc(100vw - var(--rail-w))); border-radius: 20px 0 0 20px; animation: tool-in .32s var(--ease); }
@supports (height: 100dvh) { dialog.ai-dialog[open] { height: 100dvh; max-height: 100dvh; } }
dialog.ai-dialog .ai-wrap { max-height: none; height: 100%; }
dialog.ai-dialog .ai-body { flex: 1; }
@keyframes tool-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
#newDialog[open] { animation: ask-in .22s var(--ease); }
@keyframes ask-in { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.notice { top: 16px; left: calc(50% + var(--rail-w) / 2); }

/* ---------- tablets ---------- */
@media (max-width: 1100px) {
  .library { left: var(--rail-w); bottom: var(--bar-h); transform: translateX(calc(-100% - var(--rail-w) - 16px)); }
  body.lib-open .library { transform: none; }
  .page-head { padding: 0 14px; }
  .page-head .nav-link { padding: 0 11px; }
  .page-head .nav-link .long { display: none; }
  .page-head .nav-link .short { display: inline; }
  .home { padding: 24px 22px 40px; }
  .hero { grid-template-columns: 1fr; }
  .hero-r { padding: 22px 22px 26px; }
  .hero-card { max-width: 440px; }
}
@media (max-width: 900px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- phones: the rail becomes a bottom tab bar ---------- */
@media (max-width: 760px) {
  :root { --rail-w: 0px; --bar-h: calc(66px + env(safe-area-inset-bottom)); --page-h: 56px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) var(--bar-h); }
  .places { grid-row: 1; }
  .rail { grid-row: 2; flex-direction: row; justify-content: space-around; align-items: stretch; gap: 0; padding: 6px 4px env(safe-area-inset-bottom); border-top: 1px solid #243040; }
  .rail-mark, .rail-sp, .rail .coach-btn { display: none; }
  .phone-only { display: grid; }
  dialog.coach-panel[open] { border-radius: 0; }
  .nav-item { width: auto; flex: 1; align-content: center; font-size: 11.5px; }
  .nav-item .pill { width: 52px; height: 30px; }
  .page-head { gap: 6px; padding: 0 10px; }
  .place-playbook .page-head h1 { display: none; }
  .page-head h1 { font-size: 23px; }
  .page-sub { display: none; }
  .page-head .nav-link { padding: 0 10px; }
  .home { padding: 18px 14px 32px; gap: 16px; }
  .hello h1 { font-size: 36px; }
  .hero { border-radius: 20px; }
  .hero-l { padding: 24px 22px; }
  .hero h2 { font-size: 34px; }
  .hero-r { display: none; }
  .tiles { gap: 10px; }
  .tile { min-height: 150px; padding: 16px; border-radius: 16px; }
  .tile h3 { font-size: 20px; }
  .fan { height: 92px; }
  .fan div { width: 118px; left: calc(var(--i) * 26px); }
  .settings-page { padding: 14px; gap: 14px; }
  .cp-body { padding: 12px; }
  .cp-head { padding: 16px 14px; }
  dialog.ai-dialog[open] { width: 100vw; border-radius: 0; }
  .notice { top: 10px; left: 50%; }
}
@media (max-width: 560px) {
  .page-head .nav-link > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .page-head .nav-link svg { width: 20px; height: 20px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tiles .tile:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) { .place.entering, dialog[open], dialog.browse:not(:modal) { animation: none !important; } }
