/* ---------- Tema estilo Apple: claro por defecto, oscuro automático ---------- */
:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-2: #f2f2f7;
  --border: #e3e3e8;
  --border-strong: #c7c7cc;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0077ed;
  --accent-2: #0071e3;
  --accent-soft: rgba(0, 113, 227, .1);
  --own: #0071e3;
  --danger: #ff3b30;
  --f7: #8e44ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --glass: rgba(255, 255, 255, .72);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --panel: #1c1c1e;
    --panel-2: #2c2c2e;
    --border: #38383a;
    --border-strong: #48484a;
    --text: #f5f5f7;
    --muted: #98989d;
    --accent: #2997ff;
    --accent-2: #0a84ff;
    --accent-soft: rgba(10, 132, 255, .18);
    --own: #0a84ff;
    --danger: #ff453a;
    --f7: #bf5af2;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    --glass: rgba(28, 28, 30, .72);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; font-size: 14px; letter-spacing: -.01em; }

button, select, input, textarea, .btn-like {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid transparent; border-radius: 10px; padding: 7px 12px;
}
input, select, textarea { border-color: var(--border); background: var(--panel); }
button, .btn-like { cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
button:hover:not(:disabled), .btn-like:hover { border-color: var(--border-strong); }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; font-weight: 600; border-radius: 980px; padding: 8px 16px; }
button.primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
button.soft { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; border-radius: 980px; padding: 8px 16px; }
button.link { background: none; border: none; color: var(--accent-2); padding: 0; font-weight: 500; }
button.ghost, .ghost { background: transparent; border-color: var(--border); }
button.danger { color: var(--danger); border-color: transparent; background: transparent; }
button.icon { font-size: 16px; padding: 4px 10px; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--own); outline-offset: -1px; }
input[type=number] { min-width: 0; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.muted { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.spacer { flex: 1; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  background: var(--glass); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; display: flex; align-items: center; gap: 8px; cursor: pointer; letter-spacing: -.02em; }
.brand img { width: 28px; height: 28px; object-fit: contain; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; border-radius: 980px; }
.tabs button:hover:not(:disabled) { color: var(--text); border-color: transparent; }
.tabs button.active { background: var(--panel-2); color: var(--text); }
.top-actions { display: flex; gap: 6px; }
.mode-switch { background: var(--panel-2); border: none !important; border-radius: 10px !important; padding: 2px; }
.mode-switch button { font-weight: 600; padding: 5px 12px; border-radius: 8px !important; color: var(--muted); }
.mode-switch button.active { background: var(--panel) !important; color: var(--text) !important; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
body[data-mode="f7"] .mode-switch button.active { color: var(--f7) !important; }
body[data-mode="f7"] .topbar { border-bottom-color: var(--f7); }
.sync-btn { display: inline-flex; align-items: center; gap: 6px; --c: #8b98a5; }
.dot, .sync-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; }

.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; }

/* ---------- Board view ---------- */
.toolbar {
  width: 180px; padding: 12px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.tool-group { display: flex; flex-direction: column; gap: 6px; }
.tool-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toolbar button { text-align: left; }
.toolbar button.active { background: var(--own); border-color: var(--own); color: #fff; }
.dot-i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.swatches { gap: 4px; }
.swatch { width: 24px; height: 24px; padding: 0 !important; border-radius: 50%; border: 2px solid var(--border); }
.swatch.on { outline: 2px solid var(--own); outline-offset: 1px; }

.pitch-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 12px; gap: 10px; }
.board-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.title-input { flex: 1; min-width: 180px; font-size: 16px; font-weight: 600; }
.badge.kind { color: #b26a00; background: rgba(255,159,10,.14); border-color: transparent; }
.pitch-box { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#pitch { width: 100%; height: 100%; max-height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 6px; }
#pitch .token, #pitch .drawing { cursor: grab; }
#pitch .handle { cursor: move; }
#pitch.tool-erase .erasable { cursor: not-allowed; }
#pitch.tool-draw, #pitch.tool-draw .token, #pitch.tool-draw .drawing { cursor: crosshair; }

.frames { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.frame-list { display: flex; gap: 4px; flex-wrap: wrap; }
.frame-list button { min-width: 34px; }
.frame-list button.active { background: var(--own); border-color: var(--own); color: #fff; }

.side {
  width: 260px; padding: 12px; background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px; overflow-y: auto;
}
.card { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 13px; }
.card select, .card input { width: 100%; }
#selCard { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.sel-body { display: flex; flex-direction: column; gap: 8px; }
.card-flat { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Pages ---------- */
.view.page { flex-direction: column; padding: 20px 24px; overflow-y: auto; gap: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head h2 .muted { font-size: 14px; font-weight: 400; margin-left: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.tcard .thumb { background: #2d7a3a; aspect-ratio: 105/68; cursor: pointer; }
.tcard .thumb svg { width: 100%; height: 100%; display: block; }
.thumb-empty { height: 100%; display: grid; place-items: center; text-align: center; color: #d9f2dc; font-size: 13px; background: repeating-linear-gradient(90deg, #2d7a3a 0 20px, #33873f 20px 40px); }
.tcard .info { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tcard .name { font-weight: 600; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); cursor: default; }
[data-tag] { cursor: pointer; }
.empty { color: var(--muted); padding: 40px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); grid-column: 1 / -1; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text); }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; }
.seg button.active { background: var(--own); color: #fff; }

/* ---------- Squad ---------- */
.squad { display: flex; flex-direction: column; gap: 18px; }
.squad h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.pcard { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.pcard.unavailable { opacity: .7; border-style: dashed; }
.pcard .num { width: 38px; height: 38px; border-radius: 50%; background: var(--own); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.pcard .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pcard .meta > div:first-child { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .actions { display: flex; gap: 4px; }
.pcard .actions button { padding: 4px 8px; font-size: 12px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stats th, table.stats td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.stats th { background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
table.stats tr:last-child td { border-bottom: none; }
table.match input[type=number] { width: 58px; padding: 3px 6px; }
table.match tr.dim td { opacity: .5; }
table.match tr.dim td:first-child { opacity: 1; }

/* ---------- Training / matches ---------- */
.split-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.session-list { display: flex; flex-direction: column; gap: 6px; }
.session-item { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; white-space: normal; }
.session-item.active { border-color: var(--accent-2); background: var(--accent-soft); }
.res { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: var(--c); color: #fff; font-size: 11px; margin-right: 6px; }
.editor { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.editor .fields { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.editor .fields3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.score { display: flex; gap: 8px; }
.score label { flex: 1; }
.exercise { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: 1fr 90px; gap: 8px; }
.exercise .full { grid-column: 1 / -1; }
.exercise .ex-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.exercise .thumb-mini { width: 100%; max-width: 280px; background: #2d7a3a; border-radius: 6px; cursor: pointer; overflow: hidden; }
.exercise .thumb-mini svg { display: block; width: 100%; }
.att-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; font-size: 13px; }
.att-chip .att-mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--border); font-weight: 700; font-size: 12px; }
.att-chip.on { border-color: var(--c); }
.att-chip.on .att-mark { background: var(--c); color: #fff; }

/* ---------- Calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-day { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 220px; }
.cal-day.today { border-color: var(--own); }
.cal-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); text-transform: capitalize; font-size: 12px; }
.cal-head b { font-size: 18px; color: var(--text); }
.cal-items { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cal-item { text-align: left; display: flex; flex-direction: column; gap: 2px; white-space: normal; padding: 6px 8px; font-size: 12px; border-left: 3px solid var(--accent-2); }
.cal-item.match { border-left-color: var(--danger); }
.cal-item span { color: var(--muted); }
.cal-add { display: flex; gap: 4px; flex-wrap: wrap; }
.cal-add button { font-size: 11px; padding: 3px 6px; }

/* ---------- Presentation ---------- */
.present { position: fixed; inset: 0; z-index: 50; background: #0b0f13; color: #f5f5f7; display: flex; flex-direction: column; padding: 12px; gap: 10px; }
.present[hidden] { display: none; }
.pres-top { display: flex; align-items: center; gap: 12px; font-size: 18px; }
#presSvg { flex: 1; min-height: 0; width: 100%; cursor: pointer; user-select: none; }
.pres-notes { position: absolute; right: 16px; top: 60px; width: min(380px, 80vw); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; white-space: pre-wrap; font-size: 16px; line-height: 1.45; }
.pres-nav { display: flex; justify-content: center; gap: 10px; }
.pres-nav button { font-size: 16px; padding: 10px 18px; }

/* ---------- Modal / toast ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; width: min(520px, 94vw); padding: 20px; max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog h3 { margin-top: 0; }
#modalBody { display: flex; flex-direction: column; gap: 10px; }
#modalBody input, #modalBody select, #modalBody textarea { width: 100%; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; max-height: 55vh; overflow-y: auto; }
.tpl { text-align: left; display: flex; flex-direction: column; gap: 3px; white-space: normal; padding: 10px 12px; }
.tpl:hover { border-color: var(--own) !important; }
.sync-box { display: flex; flex-direction: column; gap: 10px; }
.sync-box p { margin: 0; }
.sync-box pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 11px; white-space: pre-wrap; color: var(--text); user-select: all; }
.sync-box details summary { cursor: pointer; color: var(--own); }
.sync-state { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; border-radius: 980px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .cal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-day { min-height: 0; }
}
@media (max-width: 1000px) {
  #view-board { flex-direction: column; overflow-y: auto; }
  .toolbar, .side, .pitch-wrap { width: auto; border: none; flex-shrink: 0; overflow: visible; }
  .pitch-wrap { order: -1; }
  .toolbar { flex-direction: row; flex-wrap: wrap; gap: 10px; }
  .toolbar button { padding: 5px 8px; }
  .tool-group { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .pitch-box { min-height: 58vw; }
  .split-layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .editor .fields3 { grid-template-columns: 1fr 1fr; }
  .view.page { padding: 16px; }
}
@media (max-width: 560px) {
  .cal-grid { grid-template-columns: 1fr; }
  .editor .fields, .editor .fields3 { grid-template-columns: 1fr; }
}

/* =========================================================
   Estilo Apple: superficies, sombras y bordes suaves
   ========================================================= */
.toolbar, .side { background: var(--panel); }
.card { background: var(--bg); border-color: transparent; }
.tcard, .pcard, .editor, .cal-day, .table-wrap { border-color: transparent; box-shadow: var(--shadow); }
.tcard { border-radius: 18px; }
.session-item { background: var(--panel); border-color: transparent; box-shadow: var(--shadow); border-radius: 14px; }
.exercise { background: var(--bg); border-color: transparent; border-radius: 14px; }
dialog { border: none; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.present button.ghost { color: #f5f5f7; border-color: #3a3a3c; }
.pres-notes { color: var(--text); }
.page-head h2 { font-size: 28px; letter-spacing: -.03em; }
#pitch { border-radius: 14px; }

/* =========================================================
   Inicio y Entrenador IA
   ========================================================= */
.view.page.home { gap: 22px; }
.home > * { width: 100%; max-width: 1080px; margin-left: auto; margin-right: auto; flex-shrink: 0; }
.hero { display: flex; align-items: center; gap: 20px; padding: 8px 4px 0; }
.hero-crest { width: 88px; height: 88px; border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); display: grid; place-items: center; overflow: hidden; cursor: pointer; flex-shrink: 0; text-align: center; font-size: 11px; color: var(--muted); }
.hero-crest img { width: 80%; height: 80%; object-fit: contain; }
.hero-text { flex: 1; min-width: 0; }
.hero h1 { margin: 2px 0 4px; font-size: 34px; letter-spacing: -.03em; font-weight: 700; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--accent-2); text-transform: uppercase; letter-spacing: .04em; }
body[data-mode="f7"] .eyebrow { color: var(--f7); }

.coach { background: var(--panel); border-radius: 22px; box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.coach::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, #0071e3, #8e44ec, #ff2d55, #ff9f0a); }
.coach-head { display: flex; gap: 14px; align-items: flex-start; }
.coach-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: linear-gradient(135deg, #0071e3, #8e44ec); flex-shrink: 0; }
.coach h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.coach-head .muted { font-size: 14px; margin: 0; }
.badge.demo { background: rgba(255,159,10,.15); color: #b26a00; border: none; vertical-align: middle; font-size: 11px; }
#coachInput { font-size: 16px; padding: 12px 14px; border-radius: 14px; background: var(--panel-2); border-color: transparent; resize: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel-2); border-radius: 980px; font-size: 13px; padding: 5px 12px; }
.coach-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 8px 0; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.reveal { opacity: 0; animation: rise .45s ease forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.plan { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 16px; }
.plan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.plan h3, .live h3 { margin: 4px 0; font-size: 20px; letter-spacing: -.02em; }
.plan p, .live p { margin: 4px 0; line-height: 1.45; }
.tip { background: var(--panel-2); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.block { background: var(--panel-2); border-radius: 14px; padding: 2px 14px; }
.block summary { display: flex; align-items: center; gap: 10px; padding: 11px 0; cursor: pointer; list-style: none; }
.block summary::-webkit-details-marker { display: none; }
.mins { font-weight: 700; color: var(--accent-2); min-width: 38px; }
.bname { font-weight: 600; flex: 1; }
.block-body { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 14px; padding-bottom: 12px; }
.block-body:has(> div:only-child) { grid-template-columns: 1fr; }
.block-board { border-radius: 10px; overflow: hidden; cursor: pointer; background: #2d7a3a; align-self: start; }
.block-board svg { display: block; width: 100%; }
.sub { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 8px; }
.plan ul, .live ul { margin: 4px 0; padding-left: 18px; }
.plan li, .live li { margin: 3px 0; line-height: 1.4; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.excard { background: var(--panel-2); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.excard .block-board { border-radius: 0; }
.excard-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.web { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.weblink { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--panel-2); border-radius: 12px; color: var(--text); text-decoration: none; }
.weblink:hover { background: var(--accent-soft); }

.live { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; border-top: 1px solid var(--border); padding-top: 16px; align-items: start; }
.live-board { position: relative; border-radius: 14px; overflow: hidden; background: #2d7a3a; }
.live-board svg { display: block; width: 100%; }
.live-status { position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.55); color: #fff; border-radius: 980px; padding: 0 12px; font-size: 12px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.live-status .thinking { color: #fff; padding: 5px 0; }
.live-status .dots i { background: #fff; }
.done { display: inline-block; padding: 5px 0; }
.live-text { display: flex; flex-direction: column; gap: 4px; }

.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.hcard { background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.hcard-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hcard .big { font-size: 17px; font-weight: 600; }
.hcard .link { margin-top: auto; align-self: flex-start; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quick button { text-align: left; font-size: 13px; }

.crest-edit { display: flex; align-items: center; gap: 14px; }
.crest-prev { width: 72px; height: 72px; border-radius: 18px; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 12px; }
.crest-prev img { width: 85%; height: 85%; object-fit: contain; }
fieldset.checks { border: 1px solid var(--border); border-radius: 12px; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; margin: 0; }
fieldset.checks legend { color: var(--muted); font-size: 12px; padding: 0 4px; }

@media (max-width: 760px) {
  .live, .block-body { grid-template-columns: 1fr; }
  .hero { flex-wrap: wrap; }
  .hero h1 { font-size: 26px; }
  .coach { padding: 18px; }
}

/* =========================================================
   Estilo ChatGPT: barra mínima, menú ☰ lateral y chat
   ========================================================= */
:root { --drawer: #f9f9f9; --chat-bg: #ffffff; --bubble: #f1f1f3; --send: #0d0d0d; --send-fg: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root { --drawer: #171717; --chat-bg: #212121; --bubble: #303030; --send: #f5f5f7; --send-fg: #0d0d0d; }
}
.topbar { gap: 8px; padding: 8px 10px; }
.icon-btn { background: transparent; border: none; width: 40px; height: 40px; padding: 0; border-radius: 10px; display: grid; place-items: center; color: var(--text); font-size: 18px; flex-shrink: 0; }
.icon-btn:hover:not(:disabled) { background: var(--panel-2); border: none; }
.top-title { flex: 1; font-size: 17px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 980px; background: var(--panel-2); color: var(--muted); }
body[data-mode="f7"] .mode-pill { background: rgba(142, 68, 236, .14); color: var(--f7); }
body[data-mode="f7"] .topbar { border-bottom-color: var(--border); }

/* menú lateral */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 40; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 50;
  background: var(--drawer); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
  transform: translateX(-102%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto;
}
.drawer.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.18); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer .mode-switch { display: flex; }
.drawer .mode-switch button { flex: 1; }
.new-chat { text-align: left; font-weight: 600; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.drawer-nav { display: flex; flex-direction: column; gap: 2px; }
.drawer-nav button { display: flex; align-items: center; gap: 10px; text-align: left; background: transparent; border: none; border-radius: 10px; padding: 9px 10px; font-size: 15px; color: var(--text); }
.drawer-nav button:hover:not(:disabled) { background: var(--panel-2); border: none; }
.drawer-nav button.active { background: var(--panel-2); font-weight: 600; }
.ni { width: 22px; text-align: center; font-size: 16px; }
.drawer-section { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px 0; }
.chat-history { display: flex; flex-direction: column; gap: 1px; flex: 1; min-height: 60px; }
.hist { display: flex; align-items: center; border-radius: 10px; }
.hist:hover, .hist.active { background: var(--panel-2); }
.hist-open { flex: 1; min-width: 0; text-align: left; background: transparent; border: none; padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.hist-open:hover:not(:disabled) { border: none; }
.hist-del { background: transparent; border: none; color: var(--muted); padding: 4px 8px; opacity: 0; font-size: 12px; }
.hist:hover .hist-del { opacity: 1; }
.hist-empty { padding: 4px 10px; }
.drawer-foot { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.drawer-foot > * { flex: 1; text-align: center; font-size: 13px; }

/* chat */
.view.chat { flex-direction: column; background: var(--chat-bg); min-height: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 24px 16px 8px; }
.chat-empty { max-width: 680px; margin: 8vh auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.chat-crest { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; overflow: hidden; font-size: 32px; background: var(--panel-2); }
.chat-crest img { width: 85%; height: 85%; object-fit: contain; }
.chat-empty h1 { font-size: 30px; letter-spacing: -.03em; margin: 6px 0 0; font-weight: 600; }
.chat-empty p { margin: 0 0 8px; max-width: 520px; font-size: 15px; line-height: 1.45; }
.chat-empty .chips { justify-content: center; }
.chat-empty .chip { background: transparent; border: 1px solid var(--border); padding: 8px 14px; font-size: 14px; color: var(--text); }
.chat-empty .chip:hover:not(:disabled) { background: var(--panel-2); }
.chat-thread { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--bubble); padding: 10px 16px; border-radius: 22px; max-width: 80%; font-size: 15px; line-height: 1.45; white-space: pre-wrap; }
.msg.assistant { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; background: linear-gradient(135deg, #0071e3, #8e44ec); }
.msg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.5; }
.answer-text { margin: 4px 0 0; }
.msg-body .plan, .msg-body .live { border-top: none; padding-top: 0; }
.followups { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.link-like { color: var(--accent-2); cursor: pointer; font-size: 13px; margin: 2px 0; }
.excard details > summary { list-style: none; }
.excard details > summary::-webkit-details-marker { display: none; }
.view.chat .excard, .view.chat .block, .view.chat .tip { background: var(--bubble); }

.composer-wrap { padding: 8px 16px 14px; background: var(--chat-bg); }
.composer {
  max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 28px; padding: 8px 8px 8px 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.view.chat .composer { background: var(--chat-bg); }
@media (prefers-color-scheme: dark) { .view.chat .composer { background: var(--bubble); border-color: transparent; } }
#coachInput { flex: 1; border: none; background: transparent; padding: 8px 0; font-size: 16px; resize: none; outline: none; max-height: 180px; line-height: 1.4; }
#coachInput:focus { outline: none; }
.send { width: 36px; height: 36px; border-radius: 50%; padding: 0; display: grid; place-items: center; background: var(--send); color: var(--send-fg); border: none; flex-shrink: 0; }
.send:hover:not(:disabled) { border: none; opacity: .85; }
.composer-note { text-align: center; margin-top: 6px; font-size: 11px; }

@media (max-width: 760px) {
  .chat-empty { margin-top: 4vh; }
  .chat-empty h1 { font-size: 24px; }
  .msg.assistant { gap: 8px; }
  .avatar { width: 26px; height: 26px; font-size: 13px; }
  .chat-scroll { padding: 16px 12px 8px; }
  .composer-wrap { padding: 6px 10px 10px; }
}
.excard .block-board { align-self: stretch; aspect-ratio: 105 / 68; display: grid; place-items: center; }
.excard .block-board svg { width: 100%; height: 100%; }
#coachInput { overflow-y: hidden; }
.players-pill {
  flex-shrink: 0; align-self: center; border: none; border-radius: 980px; background: var(--panel-2);
  font-size: 14px; font-weight: 600; padding: 7px 10px; cursor: pointer; color: var(--text);
  -webkit-appearance: none; appearance: none; margin-left: -8px;
}
.players-pill:focus { outline: 2px solid var(--accent-2); }

/* =========================================================
   Cuenta: iniciar sesión / registrarse
   ========================================================= */
.login-btn { background: var(--send); color: var(--send-fg); border: none; border-radius: 980px; padding: 7px 14px; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.login-btn:hover:not(:disabled) { border: none; opacity: .88; }
.avatar-btn { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: none; background: linear-gradient(135deg, #0071e3, #8e44ec); color: #fff; font-weight: 700; display: grid; place-items: center; position: relative; flex-shrink: 0; }
.avatar-btn:hover:not(:disabled) { border: none; }
.avatar-btn::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--c); border: 2px solid var(--chat-bg); }

.drawer-foot { flex-direction: column; gap: 8px; }
.drawer-foot > * { flex: none; text-align: left; }
.account-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); text-align: left; white-space: normal; }
.acc-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-weight: 700; color: #fff; background: linear-gradient(135deg, #0071e3, #8e44ec); }
.acc-avatar.empty { background: var(--panel-2); color: var(--muted); font-size: 16px; }
.acc-avatar.big { width: 52px; height: 52px; font-size: 22px; }
.acc-text { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.acc-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-state { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.acc-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.backup-row { display: flex; gap: 14px; padding: 0 4px; }
.backup-row .link { font-size: 12px; color: var(--muted); background: none; border: none; padding: 0; cursor: pointer; }

.chat-login { margin-top: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: var(--muted); background: rgba(255, 159, 10, .1); border-radius: 14px; padding: 10px 14px; }

.auth { display: flex; flex-direction: column; gap: 12px; }
.auth-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.auth-hero h3 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.02em; }
.auth-hero p { margin: 0; font-size: 14px; line-height: 1.4; }
.auth-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; background: var(--accent-soft); }
.auth-tabs { display: flex; background: var(--panel-2); border: none !important; border-radius: 10px !important; padding: 2px; }
.auth-tabs button { flex: 1; border-radius: 8px !important; color: var(--muted); font-weight: 600; }
.auth-tabs button.active { background: var(--panel) !important; color: var(--text) !important; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.auth input { font-size: 16px; padding: 10px 12px; }
.auth .wide { width: 100%; padding: 11px; font-size: 15px; }
.auth .center { text-align: center; align-self: center; }
.auth .small { font-size: 12px; margin: 0; }
.auth-msg { border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.auth-msg.error { background: rgba(255, 59, 48, .12); color: #d70015; }
.auth-msg.ok { background: rgba(52, 199, 89, .14); color: #1a7f37; }
@media (prefers-color-scheme: dark) { .auth-msg.error { color: #ff6961; } .auth-msg.ok { color: #30d158; } }
.acct { display: flex; align-items: center; gap: 12px; }
.acct b { word-break: break-all; }
#modalTitle:empty { display: none; }

/* =========================================================
   Fotos, compartir y vista pública
   ========================================================= */
.pcard .num.photo { background-size: cover; background-position: center; position: relative; }
.pcard .num.photo span { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--own); color: #fff; font-size: 10px; display: grid; place-items: center; border: 2px solid var(--panel); }
.photo-edit { display: flex; align-items: center; gap: 14px; }
.photo-prev { width: 72px; height: 72px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; font-size: 26px; flex-shrink: 0; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.pres-crest { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; margin-right: 8px; }
#presTitle { display: inline-flex; align-items: center; }

.share { display: flex; flex-direction: column; gap: 10px; }
.share .wide { width: 100%; padding: 11px; font-size: 15px; }
.share .small { font-size: 12px; margin: 0; }
.share-head { display: flex; flex-direction: column; gap: 2px; }
.share-head b { font-size: 17px; }
.share-link { display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); border-radius: 12px; padding: 10px; }
.share-link input { width: 100%; font-size: 13px; }
.share-link a { text-decoration: none; text-align: center; }
.share pre, #shareResult pre { white-space: pre-wrap; font-size: 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; user-select: all; }

body.viewing > header, body.viewing > .drawer, body.viewing > .scrim, body.viewing > .view { display: none !important; }
.viewer { flex: 1; overflow-y: auto; background: var(--chat-bg); }
.v-wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.v-head { display: flex; align-items: center; gap: 14px; }
.v-head img { width: 56px; height: 56px; object-fit: contain; }
.v-ball { font-size: 40px; }
.v-head h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: -.03em; }
.vplayer { display: flex; flex-direction: column; gap: 8px; }
.vplayer svg { width: 100%; display: block; border-radius: 14px; background: #2d7a3a; }
.vplay { align-self: flex-start; background: var(--send); color: var(--send-fg); border: none; border-radius: 980px; padding: 9px 16px; font-weight: 600; }
.v-notes { white-space: pre-wrap; line-height: 1.5; margin: 0; }
.v-ex { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.v-ex h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.v-foot { margin-top: 20px; text-align: center; color: var(--muted); font-size: 13px; }
.v-foot a { color: var(--accent-2); }
.v-empty { text-align: center; align-items: center; margin-top: 12vh; }
#modalBody input[type=checkbox] { width: auto; }
.ai-warn { background: rgba(255, 159, 10, .12); border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.pills { display: flex; flex-direction: column; gap: 4px; align-self: center; margin-left: -8px; }
.pills .players-pill { margin-left: 0; padding: 4px 9px; font-size: 13px; }
.board-info { background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 7px 10px; font-size: 13px; margin: 2px 0 6px; }

/* ---------- selector de zonas del campo ---------- */
.zone-label { font-size: 12px; color: var(--muted); }
.zone-box { display: flex; flex-direction: column; gap: 8px; }
.zone-format { display: flex; background: var(--panel-2); border: none !important; border-radius: 10px !important; padding: 2px; }
.zone-format button { flex: 1; border-radius: 8px !important; color: var(--muted); font-weight: 600; background: transparent; border: none; }
.zone-format button.active { background: var(--panel) !important; color: var(--text) !important; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.zone-svg { width: 100%; display: block; border-radius: 12px; background: #2d7a3a; touch-action: none; user-select: none; -webkit-user-select: none; }
.zcell { fill: rgba(0,0,0,.28); stroke: rgba(255,255,255,.45); stroke-width: .3; stroke-dasharray: 1.2 .8; cursor: pointer; transition: fill .12s; }
.zcell:hover { fill: rgba(0,0,0,.18); }
.zcell.on { fill: rgba(10,132,255,.32); stroke: #fff; stroke-dasharray: none; }
.zone-info { font-size: 14px; }
.zone-presets .chip { font-size: 12px; padding: 4px 10px; }

/* ---------- legal y marca ---------- */
.auth .terms { align-items: flex-start; font-size: 13px; line-height: 1.4; }
.auth .terms input { margin-top: 3px; width: auto; }
.auth a { color: var(--accent-2); }
.legal-row a { font-size: 12px; color: var(--muted); text-decoration: none; }
.legal-row a:hover { color: var(--text); }
.v-foot { line-height: 1.6; }
.v-cta { display: inline-block; margin-top: 10px; background: var(--send); color: var(--send-fg) !important; padding: 9px 18px; border-radius: 980px; text-decoration: none; font-weight: 600; }
