:root {
    --bg: #f5f5f7;
    --panel: #ffffff;
    --panel-2: #f0f0f4;
    --text: #1b1b22;
    --muted: #6b6b78;
    --line: #e3e3ea;
    --accent: #6b4fe0;
    --accent-soft: #ece8fd;
    --accent-text: #ffffff;
    --ok: #1d8a4a;
    --ok-soft: #e3f5ea;
    --bad: #c8312f;
    --bad-soft: #fbe7e6;
    --nav: #15131d;
    --nav-text: #c8c6d4;
    --shadow: 0 1px 2px rgba(20, 16, 40, .06), 0 4px 16px rgba(20, 16, 40, .06);
    --radius: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f0e14;
        --panel: #18171f;
        --panel-2: #211f2a;
        --text: #ecebf2;
        --muted: #9a98a8;
        --line: #2c2a36;
        --accent: #9580ff;
        --accent-soft: #2a2443;
        --accent-text: #120f1f;
        --ok: #4cc47c;
        --ok-soft: #173123;
        --bad: #ff6b66;
        --bad-soft: #3a1c1c;
        --nav: #0a090e;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.2; margin: 4px 0 8px; letter-spacing: -.3px; }
h1:focus { outline: none; }
h2 { font-size: 17px; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
code { font-size: 13px; }
img { display: block; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-line; }
.grow { flex: 1; }
.count { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--panel-2); padding: 1px 8px; border-radius: 99px; }

/* ---- Forms and buttons */

input, select, textarea, button, .button {
    font: inherit;
    color: inherit;
    border-radius: 8px;
}

input:not([type=checkbox]), select, textarea {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 8px 11px;
    min-width: 0;
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

button, .button {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 8px 14px;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

button:hover:not(:disabled), .button:hover { background: var(--panel-2); text-decoration: none; }
button:disabled { opacity: .45; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger.ghost { background: transparent; color: var(--bad); border-color: var(--line); }
button.danger.ghost:hover:not(:disabled) { background: var(--bad-soft); }
button.small, .button.small { padding: 4px 10px; font-size: 13px; }
button.link { background: none; border: none; padding: 0; color: inherit; font: inherit; }
button.link:hover:not(:disabled) { background: none; }

button.icon {
    width: 30px;
    height: 30px;
    padding: 0;
    justify-content: center;
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    /* (the arrows as signs, not as colored emoji) */
    font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", system-ui, sans-serif;
    font-variant-emoji: text;
}

button.icon:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
button.icon.ok:hover:not(:disabled) { background: var(--ok-soft); color: var(--ok); }
button.icon.danger:hover:not(:disabled) { background: var(--bad-soft); color: var(--bad); }

label.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; user-select: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; }

.chip {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    padding: 2px 9px;
    border-radius: 99px;
    background: var(--panel-2);
    color: var(--muted);
    white-space: nowrap;
}

.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.notice { padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* ---- The public site */

.site { max-width: 1180px; margin: 0 auto; padding: 0 24px; min-height: 100vh; display: flex; flex-direction: column; }
.site-main { flex: 1; padding-bottom: 48px; }

.site-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 0 18px; }
.site-head nav { display: flex; gap: 4px; align-items: center; }
.site-head nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.site-head nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.site-head nav a.active { color: var(--text); background: var(--panel-2); }
.site-head nav a.admin-link { color: var(--accent); }

.brand { font-weight: 800; font-size: 19px; letter-spacing: -.4px; color: var(--text); }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }

.site-foot { display: flex; justify-content: space-between; padding: 20px 0 28px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.site-foot a { color: var(--muted); }

.hero { padding: 36px 0 12px; }
.hero h1 { font-size: 38px; letter-spacing: -.8px; }
.hero p { font-size: 17px; margin: 0; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 8px 0 8px; }
.page-head p { margin: 4px 0 0; max-width: 70ch; }
.back { font-size: 13px; color: var(--muted); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 80px 0; }

/* The cards of the lists */

.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

.list-card {
    display: block;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    transition: transform .15s, box-shadow .15s;
}

.list-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.list-card-body { padding: 12px 14px 14px; }
.list-card-title { display: flex; align-items: center; gap: 8px; }

.mosaic { display: grid; aspect-ratio: 16 / 10; background: var(--panel-2); overflow: hidden; }
.mosaic img { width: 100%; height: 100%; object-fit: cover; }
.mosaic.n2 { grid-template-columns: 1fr 1fr; }
.mosaic.n3 { grid-template-columns: 1fr 1fr 1fr; }
.mosaic.n4 { grid-template-columns: repeat(4, 1fr); }
.mosaic-icon { display: grid; place-items: center; font-size: 42px; opacity: .6; }

/* The posters of a list */

.poster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px 16px; }
.poster-grid.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px 12px; }

.poster-img {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    border-radius: 10px;
    overflow: hidden;
    background: var(--panel-2);
    box-shadow: var(--shadow);
}

.shape-square .poster-img { aspect-ratio: 1; }
.poster-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
a.poster-img:hover img { transform: scale(1.04); }
.poster-placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-size: 40px; opacity: .5; }

.poster-img .rank {
    position: absolute;
    top: 8px;
    left: 8px;
    min-width: 26px;
    height: 26px;
    padding: 0 7px;
    border-radius: 99px;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: grid;
    place-items: center;
    backdrop-filter: blur(4px);
}

.poster-img .done-mark {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 99px;
    background: var(--ok);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 700;
}

.poster.done .poster-img img { filter: saturate(.6); }
.poster-body { padding: 8px 2px 0; }
.poster-title { font-weight: 600; line-height: 1.3; }
.poster-sub { color: var(--muted); font-size: 13px; }
.poster-note { font-size: 13px; margin-top: 4px; white-space: pre-line; }

.done-section { margin-top: 12px; }
.done-section summary { cursor: pointer; list-style: none; }
.done-section summary::-webkit-details-marker { display: none; }
.done-section summary h2::before { content: "▸"; font-size: 13px; color: var(--muted); }
.done-section[open] summary h2::before { content: "▾"; }

/* ---- The administration */

.admin { display: flex; min-height: 100vh; }

.admin-nav {
    width: 220px;
    flex-shrink: 0;
    background: var(--nav);
    color: var(--nav-text);
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.admin-nav a.brand { display: block; color: #fff; padding: 0 10px 18px; }
.admin-nav a.brand:hover { background: none; }
.admin-nav a, .admin-nav button.link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: var(--nav-text);
    border-radius: 8px;
    text-align: left;
    width: 100%;
    font-size: 14px;
    white-space: normal;
}

.admin-nav a:hover, .admin-nav button.link:hover:not(:disabled) { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.admin-nav a.active { background: rgba(149, 128, 255, .18); color: #fff; }
.admin-nav .ico { width: 18px; text-align: center; opacity: .85; }

.admin-main { flex: 1; min-width: 0; padding: 28px 36px 60px; max-width: 1100px; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.module {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: inherit;
}

.module:hover { text-decoration: none; box-shadow: var(--shadow); }
.module-ico { font-size: 22px; color: var(--accent); }

.new-list { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.new-list input { flex: 1; min-width: 220px; }

.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; }
.table .order { width: 76px; white-space: nowrap; }
.table a { color: inherit; }
.table a.chip.ok { color: var(--ok); }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 14px 0 6px; }
.settings label:not(.check) { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.settings label input, .settings label select, .settings label textarea { color: var(--text); font-size: 15px; }
.settings .wide { grid-column: 1 / -1; }
.prefixed { display: flex; align-items: stretch; }
.prefixed > span { padding: 8px 4px 8px 11px; background: var(--panel-2); border: 1px solid var(--line); border-right: none; border-radius: 8px 0 0 8px; color: var(--muted); font-size: 15px; }
.prefixed > input { flex: 1; border-radius: 0 8px 8px 0; }

.add-item {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin: 18px 0 4px;
    padding: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.add-item input:not([type=checkbox]) { flex: 1; min-width: 200px; font-size: 16px; border: none; padding: 8px 6px; }
.add-item input:not([type=checkbox]):focus { outline: none; }
.add-item label.check { font-size: 13px; color: var(--muted); }

/* The items in the editor */

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: box-shadow .1s, opacity .1s;
}

.item:hover { box-shadow: var(--shadow); }
.item.dragging { opacity: .4; }
.item.drop-above { box-shadow: 0 -3px 0 0 var(--accent); }
.item.drop-below { box-shadow: 0 3px 0 0 var(--accent); }
.item[draggable=true] .handle { cursor: grab; }
.handle { color: var(--muted); width: 14px; text-align: center; opacity: .5; user-select: none; }
.item:hover .handle { opacity: 1; }
.rank { width: 24px; text-align: right; font-weight: 700; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.thumb {
    width: 44px;
    height: 66px;
    padding: 0;
    flex-shrink: 0;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
    background: var(--panel-2);
    border: 1px dashed var(--line);
    color: var(--muted);
    font-size: 20px;
}

.thumb.shape-square { height: 44px; }
.thumb:has(img) { border-style: solid; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { outline: 2px solid var(--accent); }

.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-title a { font-weight: 400; margin-left: 4px; font-size: 13px; }
.item-note { font-size: 13px; white-space: pre-line; margin-top: 2px; }
.item-actions { display: flex; align-items: center; gap: 1px; flex-shrink: 0; }

.items.done .item { opacity: .8; }
.items.done .thumb { width: 34px; height: 51px; }
.items.done .thumb.shape-square { height: 34px; }
.fold { gap: 8px; font-weight: 700 !important; }

.edit { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }

/* The image picker */

.modal-back {
    position: fixed;
    inset: 0;
    background: rgba(10, 8, 20, .55);
    backdrop-filter: blur(3px);
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 100;
}

.modal {
    width: min(860px, 100%);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--panel);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { overflow-y: auto; min-height: 120px; }
.modal-foot { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }

.cand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.cand {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 6px;
    white-space: normal;
    text-align: left;
    border-color: transparent;
    background: transparent;
}

.cand img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; background: var(--panel-2); }
.shape-square .cand img { aspect-ratio: 1; }
.cand:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.cand.current { border-color: var(--ok); }
.cand.saving { border-color: var(--accent); }
.cand-title { font-size: 13px; font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cand-src { font-size: 11px; color: var(--muted); }

label.file { position: relative; overflow: hidden; }
label.file input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* The login */

.login { max-width: 340px; margin: 14vh auto 0; padding: 0 20px; display: flex; flex-direction: column; gap: 16px; }
.login .brand { font-size: 24px; text-align: center; }
.login form { display: flex; flex-direction: column; gap: 10px; }

/* ---- Small screens */

@media (max-width: 760px) {
    .site { padding: 0 16px; }
    .hero h1 { font-size: 30px; }
    .poster-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px 12px; }
    .admin { flex-direction: column; }
    .admin-nav { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 10px; }
    .admin-nav .brand { padding: 6px 10px; width: 100%; }
    .admin-nav a, .admin-nav button.link { width: auto; }
    .admin-nav .grow { display: none; }
    .admin-main { padding: 18px 14px 40px; }
    .settings { grid-template-columns: 1fr; }
    .item { flex-wrap: wrap; }
    .item-actions { width: 100%; justify-content: flex-end; }
    .handle { display: none; }
}

/* ---- Blazor */

#blazor-error-ui {
    background: var(--bad-soft);
    color: var(--bad);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary { background: var(--bad); padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Une erreur est survenue." }
