:root {
  color-scheme: dark;
  --bg: #14151c;
  --bg2: #1c1e28;
  --card: #222532;
  --card2: #2a2e3d;
  --line: #343949;
  --text: #eceef4;
  --muted: #9aa1b5;
  --accent: #4f8ff7;
  --accent-text: #ffffff;
  --live: #3ccf7a;
  --warn: #f2b84b;
  --shop: #f5c542;
  --shop-text: #2a2100;
  --c-raids: #ef5b5b;
  --c-max: #e6489d;
  --c-costumes: #f28c28;
  --c-community: #39b96a;
  --c-inperson: #e3a33a;
  --c-events: #4f8ff7;
  --c-gbl: #8c93a8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f4f8;
    --bg2: #ffffff;
    --card: #ffffff;
    --card2: #f1f3f8;
    --line: #dde1ea;
    --text: #1b1e27;
    --muted: #5d6578;
    --accent: #2f6fe0;
    --live: #1f9d55;
    --warn: #b7791f;
    --c-raids: #d63b3b;
    --c-max: #c42a80;
    --c-costumes: #d4700c;
    --c-community: #1f9653;
    --c-inperson: #b97c12;
    --c-events: #2f6fe0;
    --c-gbl: #66708a;
    --shadow: 0 1px 3px rgba(20, 30, 60, .08);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* --- En-tête */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 18px; }
.brand p { margin: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35); padding: 6px;
}
.menu a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; }
.menu a:hover, .menu a:focus-visible { background: var(--card2); }
.menu-note { margin: 4px 12px 6px; font-size: 12px; color: var(--muted); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--card2); }
.btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-shop { background: var(--shop); color: var(--shop-text); border-color: transparent; }
.btn-shop:hover { background: var(--shop); filter: brightness(1.06); }
.btn-ghost { background: transparent; }

/* --- Onglets */
.tabs {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 4px; padding: 6px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.tabs button {
  flex: 1 0 auto; appearance: none; border: 0; background: transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 10px; font: inherit; font-weight: 650; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

main { max-width: 980px; margin: 0 auto; padding: 14px 16px 24px; }
.foot { max-width: 980px; margin: 0 auto; padding: 0 16px 28px; }

/* --- Barre d'outils du calendrier */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input[type="search"] { flex: 1 1 180px; min-width: 0; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

input, select {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0;
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.panel p { margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 6px 11px 6px 9px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); opacity: .35; }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--c); }
.chip[aria-pressed="true"]::before { opacity: 1; }

.cat-raids { --c: var(--c-raids); }
.cat-max { --c: var(--c-max); }
.cat-costumes { --c: var(--c-costumes); }
.cat-community { --c: var(--c-community); }
.cat-inperson { --c: var(--c-inperson); }
.cat-events { --c: var(--c-events); }
.cat-gbl { --c: var(--c-gbl); }

/* --- Liste */
.day-head { display: flex; align-items: baseline; gap: 8px; margin: 18px 2px 8px; font-size: 15px; }
.day-head:first-child { margin-top: 4px; }
.day-head .tag { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.day-head .count { font-size: 12px; color: var(--muted); }
.empty { padding: 24px; text-align: center; color: var(--muted); background: var(--card); border-radius: var(--radius); }

.ev {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c);
  border-radius: var(--radius); margin-bottom: 8px; box-shadow: var(--shadow); overflow: hidden;
}
.ev > summary { list-style: none; cursor: pointer; display: flex; gap: 12px; padding: 10px 12px; align-items: flex-start; }
.ev > summary::-webkit-details-marker { display: none; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; background: var(--card2); }
.ev-main { min-width: 0; flex: 1; }
.ev-top { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-bottom: 3px; }
.pill {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--muted)) 18%, transparent); color: var(--c, var(--muted));
}
.badge { font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.live { color: var(--live); border-color: color-mix(in srgb, var(--live) 50%, transparent); }
.ev h3 { font-size: 15.5px; font-weight: 700; overflow-wrap: anywhere; }
.when, .where { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.when strong { color: var(--text); font-weight: 600; }
.countdown { color: var(--warn); font-weight: 600; }
.countdown.live { color: var(--live); }
.mons { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 6px; }
.mons img { width: 34px; height: 34px; object-fit: contain; }
.ev-body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.ev-body p { margin: 10px 0; }
.ev-body h4 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ev-body ul { margin: 4px 0; padding-left: 20px; }
.ev-body li { margin: 2px 0; }
.ev-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ev-actions a { text-decoration: none; }

.grid-mons { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.mon {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  background: var(--card2); border-radius: 10px; padding: 6px 4px; font-size: 12px; line-height: 1.25;
}
.mon img { width: 56px; height: 56px; object-fit: contain; }
.mon .fl { font-size: 11px; color: var(--muted); }
.mon.costume { outline: 1px solid color-mix(in srgb, var(--c-costumes) 60%, transparent); }

/* --- Mois */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.month-nav h2 { font-size: 17px; text-transform: capitalize; }
.month-nav .navs { display: flex; gap: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal .dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cell {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit;
  min-height: 92px; border-radius: 8px; padding: 4px; text-align: left; display: flex; flex-direction: column; gap: 2px;
  cursor: pointer; overflow: hidden;
}
.cell.out { opacity: .45; }
.cell.today { border-color: var(--accent); }
.cell[aria-pressed="true"] { background: var(--card2); box-shadow: inset 0 0 0 2px var(--accent); }
.cell .num { font-size: 12px; font-weight: 700; }
.cell.today .num { color: var(--accent); }
.bar {
  display: block; width: 100%; font-size: 11px; line-height: 1.3; padding: 1px 4px; border-radius: 4px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--c) 25%, transparent);
  border-left: 3px solid var(--c);
}
.more { font-size: 11px; color: var(--muted); }
details.past > summary { cursor: pointer; list-style: none; }
details.past > summary::-webkit-details-marker { display: none; }
details.past > summary::before { content: "▸"; color: var(--muted); }
details.past[open] > summary::before { content: "▾"; }
@media (max-width: 640px) {
  .cell { min-height: 58px; padding: 3px; }
  .bar { font-size: 0; height: 7px; padding: 0; border-left-width: 0; background: var(--c); }
  .thumb { width: 52px; height: 52px; }
}

/* --- Raids */
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 22px 2px 10px; }
.section-title:first-child { margin-top: 4px; }
.section-title h2 { font-size: 17px; }
.tier { margin: 14px 2px 8px; font-size: 14px; color: var(--muted); font-weight: 700; }
.bosses { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.boss {
  display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.boss img { width: 64px; height: 64px; object-fit: contain; flex: none; }
.boss h3 { font-size: 15px; }
.boss .en { font-size: 12px; color: var(--muted); }
.boss .cp { font-size: 13px; margin-top: 3px; }
.boss .types { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.boss .types span { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--card2); }
.linkish { appearance: none; border: 0; background: none; padding: 0; margin-top: 4px; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.rows .row {
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 8px;
}
.rows .row .who { display: flex; gap: 4px; flex-wrap: wrap; }
.chipmon { display: inline-flex; align-items: center; gap: 4px; background: var(--card2); border-radius: 999px; padding: 2px 9px 2px 2px; font-size: 13px; }
.chipmon img { width: 28px; height: 28px; object-fit: contain; }

/* --- Calculateur */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form > * + * { margin-top: 10px; }
.poke-row { display: flex; gap: 10px; align-items: flex-end; }
.grow { flex: 1; }
.sprite { width: 56px; height: 56px; object-fit: contain; }
.row2, .row3 { display: grid; gap: 8px; }
.row2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.appraisal { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; margin: 10px 0 0; }
.appraisal legend { font-size: 13px; font-weight: 700; padding: 0 4px; }
.appraisal > * + * { margin-top: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-weight: 500; }
#iv-manual .row3 label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }

.summary { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; margin-bottom: 8px; }
.summary .big { font-size: 22px; font-weight: 800; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 9px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--card2); position: sticky; top: 0; }
th:first-child, td:first-child { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--card2); }
tbody tr[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); }
tr:last-child td { border-bottom: 0; }
.pct-hi { color: var(--live); font-weight: 700; }
.pct-mid { color: var(--warn); font-weight: 700; }
.leagues { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin: 10px 0; }
.league { background: var(--card2); border-radius: 10px; padding: 10px 12px; }
.league .rank { font-size: 20px; font-weight: 800; }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.warn { color: var(--warn); }

@media (max-width: 520px) {
  main { padding: 12px 12px 20px; }
  .brand h1 { font-size: 16px; }
  .btn-shop { padding: 8px 11px; }
  .row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  th, td { padding: 6px 6px; }
}
