/* We are Wii – feuille de style. Les couleurs viennent des variables définies dans les réglages. */
:root {
  --radius: 10px;
  --gap: 1rem;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: .4rem 0 .8rem; }
small { font-size: .82em; }
code, kbd, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface2); padding: .1em .35em; border-radius: 4px; }
kbd { background: var(--surface2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; }
pre { overflow: auto; background: var(--surface2); padding: .6rem; border-radius: 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }
.inline { display: inline; margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); }

/* Icônes monochromes */
.i { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; flex: none; }
.i.big { width: 2.6rem; height: 2.6rem; opacity: .55; }

/* En-tête */
.topbar { background: var(--header-bg); color: var(--header-text); display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { color: var(--header-text); display: inline-flex; align-items: baseline; gap: .5rem; font-weight: 700; font-size: 1.15rem; }
.brand .i { align-self: center; width: 1.5em; height: 1.5em; }
.brand:hover { text-decoration: none; }
.ver { font-weight: 400; opacity: .7; font-size: .7rem; letter-spacing: .02em; }
.mainnav { display: flex; align-items: center; gap: .15rem; margin-left: auto; flex-wrap: wrap; }
.mainnav a, .navbtn { color: var(--header-text); opacity: .8; display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .65rem; border-radius: 8px; background: none; border: 0; font: inherit; cursor: pointer; }
.mainnav a:hover, .navbtn:hover { opacity: 1; background: rgba(255, 255, 255, .1); text-decoration: none; }
.mainnav a.active { opacity: 1; background: rgba(255, 255, 255, .16); }
.nav-sep { width: 1px; height: 1.4rem; background: rgba(255, 255, 255, .25); margin: 0 .4rem; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: var(--header-text); padding: .3rem; cursor: pointer; }
@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .mainnav { display: none; width: 100%; flex-direction: column; align-items: stretch; margin: 0; }
  .mainnav.open { display: flex; }
  .nav-sep { display: none; }
}

main.page { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 3rem; flex: 1; }
main.bare { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.pagehead h1 { margin: 0; }
.crumbs { margin-bottom: .4rem; font-size: .9rem; }

/* Cartes et grilles */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.inactive { opacity: .6; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.cards .card { margin: 0; }
.project-card { color: var(--text); display: flex; flex-direction: column; gap: .35rem; transition: transform .1s, border-color .1s; }
.project-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.project-card h2 { margin: 0; }
.pct { font-size: 1.3rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; align-items: start; }
.grid-idea { display: grid; grid-template-columns: 1fr 160px; gap: 1rem; }
@media (max-width: 600px) { .grid-idea { grid-template-columns: 1fr; } }
.grid2 > .card { margin-bottom: 0; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

/* Mise en page utilitaire */
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.row.gap { gap: .6rem; }
.row.center-v { align-items: center; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.stack.tight { gap: .35rem; }

/* Formulaires */
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .92rem; }
label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; font-size: .95rem; cursor: pointer; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-weight: 400;
}
input[type=file] { font-size: .9rem; max-width: 100%; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
input[type=color] { width: 2.6rem; height: 2.2rem; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
textarea { resize: vertical; min-height: 2.6rem; }
textarea.mono { font-size: .85rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset[disabled] input, fieldset[disabled] select, fieldset[disabled] textarea { opacity: .75; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .5rem .9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--surface2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.big { padding: .75rem 1.3rem; font-size: 1.05rem; }
.btn.icon-only { padding: .45rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Messages */
.flash { padding: .65rem .9rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid; font-size: .95rem; }
.flash-ok { background: color-mix(in srgb, var(--success) 14%, var(--surface)); border-color: color-mix(in srgb, var(--success) 50%, var(--border)); }
.flash-err { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.flash-warn { background: color-mix(in srgb, var(--warning) 16%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 50%, var(--border)); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--surface2); border: 1px solid var(--border); color: var(--muted); }
.badge.warn { color: var(--warning); }
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .15rem .6rem; border-radius: 99px; white-space: nowrap; background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.pill.st-todo { color: var(--text); }
.pill.st-wip { background: color-mix(in srgb, var(--warning) 18%, var(--surface)); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }
.pill.st-done { background: color-mix(in srgb, var(--success) 18%, var(--surface)); color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.pill.st-idea { border-style: dashed; }

/* Progression */
.bar { height: 10px; background: var(--surface2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar.tall { height: 18px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.big-pct { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.big-pct small { font-size: 1rem; font-weight: 600; margin-left: .1rem; }
.statlist { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-direction: column; gap: .35rem; }
.statrow { margin-bottom: .9rem; }
.statrow .bar { margin: .25rem 0; }

/* En-tête de projet et onglets */
.phead { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.phead h1 { margin-bottom: .2rem; }
.phead-prog { min-width: 220px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: .4rem; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs.sub a { padding: .35rem .8rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1; min-width: 160px; width: auto !important; }
.filters select { width: auto !important; }

/* Listes */
.group { margin-bottom: 1.4rem; }
.group h2 { display: flex; align-items: center; gap: .5rem; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row-item { display: flex; align-items: center; gap: .8rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border); color: var(--text); }
.row-item:last-child { border-bottom: 0; }
a.row-item:hover { background: var(--surface2); text-decoration: none; }
.row-item .grow small { margin-top: .05rem; }
.thumb { width: 2.6rem; height: 2.6rem; flex: none; display: grid; place-items: center; background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 12px 12px; border-radius: 8px; overflow: hidden; color: var(--muted); border: 1px solid var(--border); }
.thumb.big { width: 4rem; height: 4rem; }
.thumb img { max-width: 100%; max-height: 100%; image-rendering: pixelated; object-fit: contain; }
.weight { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.table th { font-size: .82rem; color: var(--muted); font-weight: 600; }
.sprite-preview { background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 16px 16px; border: 1px solid var(--border); border-radius: 8px; padding: .5rem; overflow: auto; text-align: center; }
.pix { image-rendering: pixelated; min-width: 160px; width: min(100%, 640px); height: auto; }
.comment { border-left: 3px solid var(--border); padding: .2rem .8rem; }
.comment p { margin: .2rem 0 .4rem; }
.idea.prio-3 { border-left: 4px solid var(--accent); }
.idea h3 { margin: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.sw { width: 22px; height: 22px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .25); display: inline-block; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem 1rem; }
.colorpick { flex-direction: row; align-items: center; gap: .6rem; font-weight: 400; }

/* Modales */
dialog.modal { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 1.2rem; width: min(520px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog.modal::backdrop { background: rgba(10, 14, 22, .55); }

/* Aide */
.help summary { cursor: pointer; font-weight: 700; font-size: 1.05rem; }
.help summary .i { margin-right: .3rem; }
.help details[open] summary { margin-bottom: .6rem; }

/* Connexion */
.is-auth main { display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.6rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .8rem; }
.auth-card h2 { margin: 0; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-bottom: .4rem; }
.auth-brand .i { width: 2rem; height: 2rem; color: var(--accent); }
.auth-brand h1 { font-size: 1.5rem; margin: 0; }
.auth-card .flash { margin: 0; }

/* ======================= Éditeur de pixel art ======================= */
body.ed { height: 100vh; height: 100dvh; overflow: hidden; background: var(--canvas-bg); color: var(--text); }
.ed-app { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--bg); }
.ed-top { display: flex; align-items: center; gap: .4rem; padding: .35rem .6rem; background: var(--header-bg); color: var(--header-text); flex-wrap: wrap; }
.ed-top .title { font-weight: 700; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 40vw; }
.ed-top .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); color: var(--header-text); padding: .38rem .6rem; }
.ed-top .btn:hover { background: rgba(255, 255, 255, .2); }
.ed-top .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ed-top .dirty { color: var(--warning); font-size: .85rem; }
.ed-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 56px minmax(0, 1fr) 260px; }
.ed-tools { background: var(--surface); border-right: 1px solid var(--border); padding: .4rem; display: flex; flex-direction: column; gap: .3rem; overflow-y: auto; }
.ed-tools .tbtn { width: 100%; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); cursor: pointer; padding: 0; }
.ed-tools .tbtn:hover { background: var(--surface2); }
.ed-tools .tbtn.on { background: var(--accent); color: var(--accent-text); }
.ed-tools .tbtn .i { width: 1.35rem; height: 1.35rem; }
.ed-tools .sep { height: 1px; background: var(--border); margin: .2rem 0; }
.ed-stage { position: relative; background: var(--canvas-bg); overflow: hidden; touch-action: none; min-height: 0; }
.ed-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.ed-status { position: absolute; left: .5rem; bottom: .4rem; font: .75rem var(--mono); color: #fff; background: rgba(0, 0, 0, .55); padding: .15rem .5rem; border-radius: 6px; pointer-events: none; }
.ed-side { background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; padding: .6rem; display: flex; flex-direction: column; gap: .9rem; min-height: 0; }
.ed-side h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .35rem; display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.ed-pal { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.ed-pal button { aspect-ratio: 1; border: 1px solid rgba(0, 0, 0, .35); border-radius: 3px; padding: 0; cursor: pointer; }
.ed-pal button.sel { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 1; }
.ed-pal .add { background: var(--surface2); color: var(--text); display: grid; place-items: center; }
.ed-cur { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.ed-cur .big { width: 2.2rem; height: 2.2rem; border: 2px solid var(--border); border-radius: 6px; flex: none; }
.ed-btns { display: flex; flex-wrap: wrap; gap: .3rem; }
.ed-btns .btn { padding: .28rem .5rem; font-size: .8rem; }
.ed-btns .btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ed-layers { display: flex; flex-direction: column; gap: 3px; }
.ed-layer { display: flex; align-items: center; gap: .3rem; padding: .25rem .4rem; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: .85rem; }
.ed-layer.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.ed-layer span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-layer button { background: none; border: 0; color: inherit; cursor: pointer; padding: .1rem; }
.ed-frames { background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: stretch; gap: .5rem; padding: .4rem .6rem; overflow-x: auto; min-height: 0; }
.ed-frames .fr { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font-size: .7rem; color: var(--muted); }
.ed-frames .fr canvas { display: block; border: 2px solid var(--border); border-radius: 4px; background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 8px 8px; image-rendering: pixelated; }
.ed-frames .fr.sel canvas { border-color: var(--accent); }
.ed-frames .fr.sel { color: var(--text); font-weight: 700; }
.ed-frames .fbtns { display: flex; flex-direction: column; gap: .25rem; flex: none; justify-content: center; }
.ed-prev { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.ed-prev canvas { background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 10px 10px; border: 1px solid var(--border); border-radius: 6px; image-rendering: pixelated; max-width: 100%; }
.ed-anim { display: grid; grid-template-columns: 1fr 3.4rem 3.4rem 3.4rem; gap: 3px; align-items: center; font-size: .8rem; }
.ed-anim input { padding: .2rem .3rem !important; font-size: .8rem; }
.ed-side details { border-top: 1px solid var(--border); padding-top: .5rem; }
.ed-side summary { cursor: pointer; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ed-sheet-toggle { display: none; }
@media (max-width: 860px) {
  .ed-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .ed-tools { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--border); }
  .ed-tools .tbtn { width: 2.6rem; flex: none; }
  .ed-tools .sep { width: 1px; height: auto; margin: 0 .2rem; flex: none; }
  .ed-side { position: fixed; left: 0; right: 0; bottom: 0; max-height: 62vh; border-left: 0; border-top: 2px solid var(--border); z-index: 30; transform: translateY(100%); transition: transform .2s; box-shadow: 0 -8px 30px rgba(0, 0, 0, .35); }
  .ed-side.open { transform: none; }
  .ed-sheet-toggle { display: inline-flex; }
  .ed-top .title { max-width: 30vw; }
}
.ed-dialog label { font-size: .88rem; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.tpl-card { display: flex; flex-direction: column; gap: .5rem; margin: 0; }
.tpl-card canvas { background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 12px 12px; border: 1px solid var(--border); border-radius: 8px; image-rendering: pixelated; align-self: center; max-width: 100%; }
.tpl-card .btns { display: flex; flex-wrap: wrap; gap: .3rem; }

.ed-top .btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ed-top .btn[disabled] { opacity: .4; }
.ed-side section { position: relative; }
