:root {
  --bg: #070a18;
  --panel: #0e1530;
  --panel-2: #141d40;
  --gold: #bd9a3f;
  --gold-2: #d6b768;
  --text: #f2ede1;
  --muted: rgba(242, 237, 225, 0.6);
  --line: rgba(214, 183, 104, 0.2);
  --ok: #8fd4ab;
  --err: #e0a0a0;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 'Montserrat', system-ui, sans-serif; min-height: 100vh; }
a { color: var(--gold-2); }
h1, h2, h3 { font-family: 'Oswald', sans-serif; font-weight: 600; letter-spacing: 0.02em; margin: 0 0 12px; }
h2 { font-size: 1.15rem; color: var(--gold-2); }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-family: ui-monospace, Menlo, monospace; }

/* --- Accueil : grille de boutons --- */
body.home { background: radial-gradient(120% 50% at 50% -10%, rgba(214, 183, 104, 0.16), transparent 60%), var(--bg); }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px; border-bottom: 1px solid var(--line); background: rgba(7, 10, 24, 0.9); }
.ht-brand { display: flex; align-items: center; gap: 10px; font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.95rem; }
.ht-brand img { height: 40px; width: auto; }
.ht-user { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ht-user form { margin: 0; }
.ht-name { font-weight: 600; }
.home-page { max-width: 1000px; }
.home-title { font-size: 1.8rem; margin: 6px 0 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); text-decoration: none; color: var(--text); transition: border-color .15s, transform .1s, background .15s; }
.tile:hover { border-color: var(--ac); background: var(--panel-2); }
.tile:active { transform: scale(0.98); }
.tile-icon { width: 52px; height: 52px; border-radius: 14px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; background: linear-gradient(160deg, var(--ac), color-mix(in srgb, var(--ac) 55%, #000)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2); }
.tile-txt strong { display: block; font-family: 'Oswald', sans-serif; font-size: 1.1rem; font-weight: 600; }
.tile-txt span { display: block; font-size: 0.78rem; color: var(--muted); line-height: 1.35; }
@media (max-width: 520px) { .tiles { grid-template-columns: 1fr 1fr; } .tile { flex-direction: column; text-align: center; padding: 16px 10px; } .tile-txt span { display: none; } .ht-name { display: none; } }
.empty { text-align: center; color: var(--muted); margin-top: 40px; }

/* --- Pages internes --- */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: rgba(7, 10, 24, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar-back { text-decoration: none; font-weight: 600; white-space: nowrap; }
.bar-brand { display: flex; align-items: center; gap: 8px; font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.85rem; }
.bar-brand img { height: 30px; }
.bar-title { font-family: 'Oswald', sans-serif; font-size: 1.05rem; text-align: center; flex: 1; }
.bar-spacer { width: 70px; }
.page { max-width: 760px; margin: 0 auto; padding: 18px 16px 50px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card.narrow { max-width: 420px; margin: 30px auto; }
.center { text-align: center; }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 16px; overflow-x: auto; }
.tabs a { flex: 1; text-align: center; padding: 8px 10px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.tabs a.on { background: var(--gold); color: var(--bg); }

.form label { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold-2); margin: 14px 0 6px; font-weight: 600; }
.form input[type=text], .form input[type=password], .form input[type=url], .form input[type=number], .select {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
.form input:focus, .select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }
.check { display: flex !important; gap: 10px; align-items: flex-start; text-transform: none !important; letter-spacing: 0 !important; color: var(--text) !important; font-weight: 500 !important; font-size: 0.9rem !important; margin: 10px 0 0 !important; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--gold); flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 20px; border-radius: 10px; border: 1px solid var(--gold); background: var(--gold); color: var(--bg); font: inherit; font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; text-decoration: none; cursor: pointer; }
.btn-outline { background: transparent; color: var(--gold-2); }
.btn-danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn-sm { padding: 7px 12px; font-size: 0.72rem; }
.btn-block { width: 100%; }
.form .btn { margin-top: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.actions form { margin: 0; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 0.9rem; }
.alert-success { background: rgba(90, 170, 120, 0.15); color: var(--ok); }
.alert-error { background: rgba(190, 90, 90, 0.15); color: var(--err); }
.alert-info { background: rgba(189, 154, 63, 0.14); color: var(--gold-2); }

/* Grades */
.grade { border-left: 5px solid var(--gc, var(--gold)); }
.grade-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grade-head h2 { margin: 0; color: var(--text); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: rgba(214, 183, 104, 0.15); color: var(--gold-2); }
.pill.admin { background: var(--gold); color: var(--bg); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin-top: 8px; }
.perm { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--bg); }
.perm input { width: 20px; height: 20px; accent-color: var(--gold); flex: none; }
.perm .pi { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; background: var(--ac); flex: none; }
.perm .pn { font-size: 0.85rem; font-weight: 600; line-height: 1.2; }
.perm .pd { display: block; font-size: 0.68rem; color: var(--muted); font-weight: 400; word-break: break-all; }
.perm:has(input:checked) { border-color: var(--gold); background: rgba(214, 183, 104, 0.1); }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors label { margin: 0 !important; }
.colors input { position: absolute; opacity: 0; }
.colors span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 3px solid transparent; cursor: pointer; }
.colors input:checked + span { border-color: #fff; box-shadow: 0 0 0 2px var(--c); }
details > summary { cursor: pointer; color: var(--gold-2); font-weight: 600; font-size: 0.85rem; }

/* Listes */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .li-main { flex: 1; min-width: 160px; }
.list .li-main strong { display: block; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; color: #120d02; background: var(--gc, #888); }
.off { opacity: 0.5; }
.secret { background: var(--bg); border: 1px dashed var(--gold); border-radius: 10px; padding: 14px; text-align: center; font-size: 1.4rem; letter-spacing: 0.06em; color: var(--gold-2); margin: 10px 0; user-select: all; }
.sc-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--ac); flex: none; }
.table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.table td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.form label.perm { display: flex; margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); font-size: inherit; font-weight: 500; }
.form .colors label { display: block; }
.perm-levels { grid-column: 1 / -1; cursor: default; }
.perm-levels .pn { flex: 1; }
.lvl-select { margin-top: 6px; padding: 8px 10px !important; font-size: 14px !important; }
/* Objectifs soiree */
.nights { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 12px; }
.night { flex: none; min-width: 108px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); text-decoration: none; color: var(--text); text-align: center; font-size: 0.78rem; font-weight: 600; text-transform: capitalize; }
.night small { display: block; font-size: 0.66rem; color: var(--muted); text-transform: none; min-height: 1em; }
.night.on { border-color: var(--gold); background: rgba(214, 183, 104, 0.15); }
.night.done small { color: var(--ok); }
.obj-form h2 { color: var(--text); }
.q { padding: 12px 0; border-top: 1px solid var(--line); }
.q-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.form .q-label { margin: 0; font-size: 0.92rem; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 600; }
.q-target { font-size: 0.75rem; color: var(--gold-2); font-weight: 700; white-space: nowrap; }
.q-help { margin: 4px 0 0; font-size: 0.75rem; color: var(--muted); }
.q-num { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.q-num input { max-width: 160px; font-size: 1.2rem !important; text-align: center; }
.q-num span { color: var(--muted); }
.q textarea, .form textarea { width: 100%; margin-top: 8px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; resize: vertical; }
.seg { display: flex; gap: 6px; margin-top: 8px; }
.seg label { flex: 1; margin: 0 !important; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 11px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-weight: 700; cursor: pointer; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 0.95rem; }
.seg input:checked + span { background: var(--gold); color: var(--bg); border-color: var(--gold); }
.stars span { font-size: 1rem; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .select { width: auto; flex: 1; min-width: 140px; }
.night-title { font-size: 1rem; text-transform: capitalize; margin: 16px 0 8px; color: var(--text); }
.sheet-link { text-decoration: none; color: var(--text); }
.new { display: inline-block; background: #d0202c; color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 0.62rem; font-weight: 700; vertical-align: middle; }
.score { font-family: 'Oswald', sans-serif; font-size: 1.1rem; padding: 4px 12px; border-radius: 999px; text-align: center; }
.score.ok { background: rgba(90, 170, 120, 0.18); color: var(--ok); }
.score.mid { background: rgba(214, 183, 104, 0.18); color: var(--gold-2); }
.score.ko { background: rgba(190, 90, 90, 0.18); color: var(--err); }
.score.big { font-size: 1.6rem; line-height: 1.1; padding: 8px 16px; border-radius: 14px; }
.score small { display: block; font-family: 'Montserrat', sans-serif; font-size: 0.6rem; text-transform: uppercase; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.answers .ans { font-weight: 700; font-size: 1rem; text-align: right; }
.mark { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.mark.ok { background: var(--ok); color: var(--bg); }
.mark.ko { background: var(--err); color: var(--bg); }
.comment { background: rgba(214, 183, 104, 0.08); border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; }
.qlist { padding-left: 20px; margin: 0 0 12px; }
.qlist li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.qlist li .li-main { flex: 1; }
.qlist li strong { display: block; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline .select { flex: 1; }
.tile-badge { position: absolute; top: 8px; right: 8px; background: #d0202c; color: #fff; border-radius: 999px; font-size: 0.7rem; font-weight: 700; padding: 1px 8px; }
.tile { position: relative; }
/* Feuilles : mise en page facon feuille papier */
.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.qgrid .q.full, .qgrid .full, .qgrid .q-section { grid-column: 1 / -1; }
@media (max-width: 520px) { .qgrid { grid-template-columns: 1fr; } }
.q input[type=text] { width: 100%; margin-top: 8px; }
.q-num input[type=text] { width: auto; margin-top: 0; }
.q-section { grid-column: 1 / -1; text-align: center; font-size: 1.25rem; color: var(--gold-2); margin: 18px 0 4px; padding-top: 14px; border-top: 2px solid var(--gold); }
.q-info { background: rgba(214, 183, 104, 0.08); border-radius: 10px; padding: 10px 12px !important; margin: 10px 0; border-top: 0 !important; }
.q-info p { margin: 4px 0 0; font-size: 0.85rem; white-space: pre-line; }
.q.by-manager { background: rgba(63, 174, 106, 0.08); border-radius: 10px; padding: 10px 12px; margin-top: 8px; border-top: 0; }
.q-locked { margin-top: 6px; font-weight: 700; white-space: pre-line; color: var(--ok); }
.q-com { font-size: 0.75rem; font-weight: 700; color: #f0a35a; white-space: nowrap; }
.com-out { font-style: normal; color: #f0a35a; font-weight: 700; }
.com-total { text-align: right; font-size: 0.95rem; margin: 14px 0 0; }
.com-total strong { color: #f0a35a; font-family: 'Oswald', sans-serif; font-size: 1.2rem; }
.q-detail { margin-top: 8px !important; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap label { flex: 1 1 40%; }
.q-list { display: grid; gap: 6px; margin-top: 8px; }
.ql-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.ql-row input[type=text] { margin-top: 0; padding: 9px 10px; font-size: 15px; }
.ql-head span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.ql-add { margin-top: 8px !important; }
.sheet-meta { display: flex; gap: 8px 20px; flex-wrap: wrap; font-size: 0.88rem; padding: 10px 12px; background: var(--bg); border-radius: 10px; margin-bottom: 4px; text-transform: none; }
.sheet-meta span:first-child { text-transform: capitalize; }
.preview-bar { background: rgba(58, 143, 214, 0.15); border: 1px dashed #3a8fd6; color: #a9cff5; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 0.88rem; }
.preview-bar a { color: #fff; }
.com-box { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(240, 163, 90, 0.1); font-size: 0.85rem; }
.com-sum strong { color: #f0a35a; font-size: 1.05rem; }
.ans-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ans-row.by-manager .li-main strong { color: var(--ok); }
.ans-row .li-main { flex: 1; min-width: 0; }
.ans-row .li-main strong, .ans-row .li-main span { display: block; }
.ans { text-align: right; font-weight: 700; max-width: 60%; }
.ans .pre { white-space: pre-line; font-weight: 500; }
.mini { border-collapse: collapse; font-size: 0.8rem; font-weight: 500; }
.mini th, .mini td { border: 1px solid var(--line); padding: 3px 8px; text-align: left; }
.mini th { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; }
.q-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.q-tools form { margin: 0; }
.q-tools .btn:disabled { opacity: 0.3; }
.qlist li { flex-wrap: wrap; }
.qlist li.is-section strong { color: var(--gold-2); text-transform: uppercase; letter-spacing: 0.05em; }
/* Editeur de feuille : apercu en direct a droite (ordinateur) */
body.wide .page { max-width: 760px; }
.editor-preview { display: none; }
@media (min-width: 1100px) {
  body.wide .page { max-width: 1480px; }
  .editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
  .editor-preview { display: block; position: sticky; top: 70px; }
  .editor-preview iframe { width: 100%; height: calc(100vh - 130px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
  .ep-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
}
body.embed { background: var(--bg); }
.embed-page { padding: 12px; max-width: none; }
.draft-hl { outline: 2px dashed #3a8fd6; outline-offset: 4px; border-radius: 8px; }
.why { margin-top: 8px; padding: 10px 12px; border-left: 3px solid var(--err); background: rgba(190, 90, 90, 0.08); border-radius: 0 10px 10px 0; }
.form .why-label { margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 0.85rem; }
.why .req { font-size: 0.65rem; color: var(--err); text-transform: uppercase; font-weight: 700; margin-left: 4px; }
.why textarea { margin-top: 6px; }
.why-ans { font-weight: 500; font-size: 0.82rem; color: var(--err); margin-top: 2px; }
/* Texte + nombre */
.tn-list { display: grid; gap: 6px; margin-top: 8px; }
.tn-row { display: flex; gap: 8px; align-items: center; }
.tn-row input[type=text] { margin-top: 0; }
.tn-row input:first-child { flex: 1; min-width: 0; }
.tn-row .tn-num { width: 96px !important; flex: none; text-align: center; }
.tn-unit { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.tn-out { display: block; margin-top: 6px; font-size: 0.85rem; }
.tn-ans { display: flex; justify-content: flex-end; gap: 10px; font-weight: 500; }
.tn-ans strong { min-width: 50px; }
.tt-row input { flex: 1 1 0 !important; width: auto !important; min-width: 0; }
/* Les colonnes ne doivent jamais deborder de la carte (champs cote a cote sur petit ecran). */
.qgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 520px) { .qgrid { grid-template-columns: minmax(0, 1fr); } }
.qgrid > * { min-width: 0; }
.tn-row input { min-width: 0; }
