@font-face { font-family: 'Nunito'; src: url('../ui-fonts/nunito-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('../ui-fonts/nunito-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('../ui-fonts/nunito-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('../ui-fonts/nunito-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('../ui-fonts/fredoka-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('../ui-fonts/fredoka-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root, html[data-theme="dark"] {
  --navy: #12305a; --coral: #ff7a69; --coral-d: #f0604e; --sun: #ffc94a; --mint: #3fbf8f;
  --bg: #0e1320; --paper: #171f30; --paper2: #1e283c; --ink: #e6ebf4; --muted: #96a2b8; --line: #2b3650;
  --head: #cfe0ff; --primary: #3b6fd0; --primary-h: #4b80e0; --tint: #22345a; --hover: #232e45; --warm: #2c2616;
  --bad: #ff6b5f; --ok: #43c997; --badbg: #3a1d1d; --warnbg: #34291a; --infobg: #1d2a44;
  --stage1: #222c41; --stage2: #121828; --plate: #2b3038; --plate-line: #3d434d;
  --radius: 16px; --shadow: 0 6px 24px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #fbf6ef; --paper: #ffffff; --paper2: #f7f2ea; --ink: #1d2433; --muted: #6b7385; --line: var(--line);
  --head: #12305a; --primary: #12305a; --primary-h: #1d4580; --tint: var(--tint); --hover: var(--hover); --warm: var(--warm);
  --bad: #e0453a; --ok: #2aa876; --badbg: var(--badbg); --warnbg: var(--warnbg); --infobg: var(--tint);
  --stage1: #ffffff; --stage2: #f3ece2; --plate: #3a3f47; --plate-line: #4a5059;
  --shadow: 0 6px 24px rgba(18, 48, 90, .08), 0 1px 3px rgba(18, 48, 90, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Nunito', system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: 'Fredoka', 'Nunito', sans-serif; font-weight: 600; color: var(--head); margin: 0 0 .4em; line-height: 1.15; }
a { color: var(--head); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* ---------- en-tête */
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar img { height: 46px; width: auto; }
.topbar .brand { display: flex; flex-direction: column; text-decoration: none; }
.topbar .brand b { font-family: 'Fredoka'; font-weight: 600; color: var(--head); font-size: 1.15rem; }
.topbar .brand span { font-size: .82rem; color: var(--muted); }
.topbar .spacer { flex: 1; }
.topbar a.back { text-decoration: none; font-weight: 700; color: var(--head); font-size: .95rem; }

/* ---------- boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 11px 20px; font-weight: 800; cursor: pointer; background: var(--primary); color: #fff; text-decoration: none; transition: transform .08s, background .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: var(--primary-h); }
.btn:active { transform: scale(.97); }
.btn.coral { background: var(--coral); }
.btn.coral:hover { background: var(--coral-d); }
.btn.ghost { background: transparent; color: var(--head); box-shadow: inset 0 0 0 2px var(--line); }
.btn.ghost:hover { background: var(--paper); box-shadow: inset 0 0 0 2px var(--head); }
.btn.small { padding: 7px 13px; font-size: .88rem; }
.btn.danger { background: var(--paper); color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }
.btn.danger:hover { background: var(--badbg); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big { padding: 15px 28px; font-size: 1.08rem; }
.iconbtn { width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--paper); box-shadow: var(--shadow); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem; color: var(--head); }
.iconbtn:hover { background: var(--hover); }
.iconbtn.on { background: var(--primary); color: #fff; }

/* ---------- accueil */
.hero { max-width: 1060px; margin: 0 auto; padding: 46px 22px 18px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); }
.hero p { font-size: 1.12rem; color: var(--muted); max-width: 640px; margin: 0 auto; }
.products { max-width: 1060px; margin: 0 auto; padding: 24px 22px 60px; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
.product { background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); padding: 26px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
a.product:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(18, 48, 90, .14); }
.product .emoji { width: 64px; height: 64px; border-radius: 18px; background: var(--warm); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.product h2 { font-size: 1.45rem; margin: 6px 0 0; }
.product p { margin: 0; color: var(--muted); flex: 1; }
.product .go { font-weight: 800; color: var(--coral-d); }
.product.soon { opacity: .75; }
.product .tag { position: absolute; top: 18px; right: 18px; background: var(--sun); color: #12305a; font-weight: 800; border-radius: 999px; padding: 4px 12px; font-size: .8rem; }
.footer { text-align: center; padding: 26px; color: var(--muted); font-size: .88rem; }

/* ---------- configurateur */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 0; height: calc(100vh - 71px); }
.stage { position: relative; background: radial-gradient(circle at 50% 40%, var(--stage1) 0%, var(--stage2) 75%); overflow: hidden; touch-action: none; }
.stage canvas { display: block; width: 100%; height: 100%; outline: none; }
.stage .tools { position: absolute; top: 14px; left: 14px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 2; }
.stage .tools .group { display: flex; gap: 0; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.stage .tools .group button { border: 0; background: transparent; padding: 9px 13px; cursor: pointer; font-weight: 700; color: var(--head); }
.stage .tools .group button.on { background: var(--primary); color: #fff; }
.stage .status { position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 2; display: flex; justify-content: center; pointer-events: none; }
.stage .status > div { pointer-events: auto; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 16px; font-weight: 700; max-width: 640px; }
.stage .status .ok { color: var(--ok); }
.stage .status .bad { color: var(--bad); }
.stage .status ul { margin: 4px 0 0; padding-left: 18px; font-weight: 600; font-size: .9rem; }
.stage .hint { position: absolute; top: 14px; right: 14px; background: var(--paper); border-radius: 12px; padding: 8px 12px; font-size: .85rem; color: var(--muted); box-shadow: var(--shadow); z-index: 2; max-width: 260px; }
.stage .seltools { position: absolute; z-index: 3; display: flex; gap: 6px; transform: translate(-50%, -130%); background: var(--paper); padding: 6px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); }
.stage .seltools button { width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--paper2); cursor: pointer; font-size: 1rem; }
.stage .seltools button:hover { background: var(--line); }
.stage .loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; background: var(--bg); z-index: 5; font-weight: 700; color: var(--head); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--coral); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel { background: var(--paper); border-left: 1px solid var(--line); overflow-y: auto; padding: 20px 22px 110px; position: relative; }
.panel .step { margin-bottom: 24px; }
.panel .step h3 { font-size: 1.12rem; display: flex; align-items: center; gap: 10px; }
.panel .step h3 .n { width: 28px; height: 28px; border-radius: 50%; background: var(--sun); color: #12305a; display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label, .lbl { font-weight: 700; font-size: .92rem; color: var(--head); }
.input, input[type=text], input[type=number], input[type=url], input[type=password], input[type=email], input[type=search], select, textarea { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 10px 13px; background: var(--paper); outline: none; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--head); }
input.name-input { font-size: 1.35rem; font-weight: 800; padding: 12px 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); border-radius: 12px; background: var(--paper); padding: 6px 12px; cursor: pointer; font-size: 1.25rem; min-width: 52px; text-align: center; transition: border-color .12s, background .12s; }
.chip:hover { border-color: var(--muted); }
.chip.on { border-color: var(--head); background: var(--tint); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--paper); box-shadow: 0 0 0 2px var(--line); cursor: pointer; position: relative; padding: 0; }
.swatch.on { box-shadow: 0 0 0 3px var(--head); }
.swatch.on::after { content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff; text-shadow: 0 0 3px rgba(0, 0, 0, .6); }
.swatch-label { font-size: .85rem; color: var(--muted); margin-top: 4px; min-height: 1.2em; }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.libitem { border: 2px solid var(--line); border-radius: 14px; background: var(--paper); padding: 10px 8px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-weight: 700; font-size: .9rem; transition: border-color .12s, transform .08s; }
.libitem:hover { border-color: var(--head); }
.libitem:active { transform: scale(.97); }
.libitem svg { width: 54px; height: 54px; }
.libitem .plus { font-size: .78rem; color: var(--coral-d); }
.libitem[disabled] { opacity: .4; cursor: not-allowed; }
.placed { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.placed .row { display: flex; align-items: center; gap: 10px; border: 2px solid var(--line); border-radius: 12px; padding: 7px 10px; background: var(--paper); cursor: pointer; }
.placed .row.sel { border-color: var(--head); background: var(--tint); }
.placed .row.bad { border-color: var(--bad); }
.placed .row svg { width: 30px; height: 30px; flex: none; }
.placed .row .nm { flex: 1; font-weight: 700; font-size: .92rem; }
.placed .row .dot { width: 22px; height: 22px; border-radius: 50%; box-shadow: 0 0 0 2px var(--line); flex: none; }
.selbox { border: 2px solid var(--head); background: var(--tint); border-radius: 14px; padding: 12px; margin-top: 12px; }
.selbox h4 { margin: 0 0 8px; font-size: 1rem; }
.order-bar { position: sticky; bottom: -110px; margin: 0 -22px; padding: 14px 22px; background: linear-gradient(180deg, transparent, var(--paper) 30%); }
.order-bar .btn { width: 100%; }

/* ---------- fenêtres */
.modal-bg { position: fixed; inset: 0; background: rgba(18, 30, 50, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--paper); border-radius: 22px; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 26px; box-shadow: 0 30px 60px rgba(0, 0, 0, .25); position: relative; }
.modal.wide { width: min(1000px, 100%); }
.modal .close { position: absolute; top: 14px; right: 14px; }
.platforms { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 10px 0 16px; }
.platform { border: 2px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; background: var(--paper); text-align: left; font-weight: 800; }
.platform small { display: block; font-weight: 600; color: var(--muted); margin-top: 3px; }
.platform.on { border-color: var(--head); background: var(--tint); }
.refbox { display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--warm); border: 2px dashed var(--sun); border-radius: 18px; padding: 18px; margin: 14px 0; flex-wrap: wrap; }
.refbox code { font-family: 'Fredoka', monospace; font-size: 2rem; font-weight: 600; letter-spacing: 2px; color: var(--head); }
.notice { background: var(--tint); border-radius: 14px; padding: 12px 14px; margin: 10px 0; }
.notice.warn { background: var(--warnbg); }
.notice.bad { background: var(--badbg); color: var(--bad); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700; z-index: 200; box-shadow: var(--shadow); }

/* ---------- admin */
.admin-wrap { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 71px); }
.side { background: var(--paper); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 3px; }
.side button { text-align: left; border: 0; background: transparent; padding: 10px 14px; border-radius: 12px; cursor: pointer; font-weight: 700; color: var(--head); }
.side button:hover { background: var(--hover); }
.side button.on { background: var(--primary); color: #fff; }
.side .navlink { display: block; padding: 10px 14px; border-radius: 12px; font-weight: 700; color: var(--head); text-decoration: none; }
.side .navlink:hover { background: var(--hover); }
.side .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 1.3rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 18px; }
.field .help { font-size: .8rem; color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--hover); }
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 800; background: var(--tint); color: var(--head); white-space: nowrap; }
.badge.nouvelle { background: #fff1d6; color: #8a5a00; }
.badge.payee { background: #e0f4ec; color: #1e7a55; }
.badge.production { background: #e6eefc; color: #1d4580; }
.badge.imprimee { background: #efe6fc; color: #5b2d9e; }
.badge.livree { background: #e3e9f0; color: #3c4a5c; }
.badge.annulee { background: var(--badbg); color: var(--bad); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.editor-admin { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 0; height: calc(100vh - 71px); margin: -24px -28px -60px; }
.plates { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.plate-card { background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.plate-card svg { width: 100%; height: auto; background: var(--plate); border-radius: 10px; }
.plate-card b { font-family: 'Fredoka'; font-weight: 600; color: var(--head); }
.colorrow input[type=color] { width: 44px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; }
.switch input { width: 20px; height: 20px; accent-color: var(--head); }
.login { max-width: 420px; margin: 70px auto; }
details.adv summary { cursor: pointer; font-weight: 800; color: var(--head); margin: 6px 0 10px; }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; height: auto; }
  .stage { height: 58vh; min-height: 360px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); padding-bottom: 30px; }
  .order-bar { position: sticky; bottom: 0; }
  .admin-wrap { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .sep { display: none; }
  .editor-admin { grid-template-columns: 1fr; height: auto; }
  .topbar img { height: 38px; }
  .stage .hint { display: none; }
}
@media (max-width: 600px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar .brand span { display: none; }
  .topbar a.back { font-size: .85rem; }
}

.badge.nouvelle { background: #4a3a12; color: #ffd27a; }
html[data-theme="light"] .badge.nouvelle { background: #fff1d6; color: #8a5a00; }
.badge.attente { background: #3b2a4f; color: #d8b8ff; }
html[data-theme="light"] .badge.attente { background: #f1e6ff; color: #5b2d9e; }
html[data-theme="dark"] .badge.payee, :root:not([data-theme="light"]) .badge.payee { background: #183a2e; color: #6fe0b0; }
:root:not([data-theme="light"]) .badge.production { background: #1b2c4f; color: #9cc0ff; }
:root:not([data-theme="light"]) .badge.imprimee { background: #2e2147; color: #c9a8ff; }
:root:not([data-theme="light"]) .badge.livree { background: #263040; color: #b4c0d2; }
:root:not([data-theme="light"]) .badge.annulee { background: #3a1d1d; color: #ff9a90; }
.themebtn { border: 0; background: var(--paper2); color: var(--ink); border-radius: 999px; padding: 8px 12px; cursor: pointer; font-weight: 700; }
.account-link { text-decoration: none; font-weight: 700; color: var(--head); font-size: .92rem; background: var(--paper2); padding: 8px 12px; border-radius: 999px; white-space: nowrap; }
.guestbar { font-size: .85rem; color: var(--muted); margin: -6px 0 14px; }
.guestbar a { color: var(--head); font-weight: 700; }
input[type=color] { background: none; }

.cart-link span { background: var(--primary); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; margin-left: 2px; }
.cart-link span[hidden] { display: none; }
.price-live { background: var(--paper); border-radius: 12px; padding: 4px 0 2px; text-align: center; font-size: 26px; font-weight: 800; color: var(--head); margin-bottom: 8px; }
.price-live s { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.price-live small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }
