:root {
    --bg: #f4f6f3;
    --surface: #ffffff;
    --text: #18211e;
    --muted: #65716d;
    --line: #d9dfdb;
    --primary: #285f4e;
    --primary-dark: #1f4a3d;
    --primary-soft: #e4eee9;
    --danger: #a5352d;
    --danger-soft: #fae8e6;
    --success: #246b4b;
    --success-soft: #e5f3eb;
    --info-soft: #e9f0f8;
    --shadow: 0 20px 55px rgba(24, 33, 30, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1; letter-spacing: -.035em; font-weight: 650; }
h2 { margin-bottom: 8px; font-size: 1.15rem; line-height: 1.25; }
p { color: var(--muted); }
code { padding: 2px 6px; border-radius: 6px; background: var(--primary-soft); }

.container { width: min(1080px, calc(100% - 32px)); margin-inline: auto; }
.topbar { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); background: rgba(244, 246, 243, .92); backdrop-filter: blur(12px); }
.nav { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--primary); color: #fff; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-actions form { margin: 0; }
.user-name { color: var(--muted); }

.page { padding-block: 62px 80px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 32px; }
.page-heading p { margin-bottom: 0; }
.eyebrow { display: inline-block; margin-bottom: 14px; color: var(--primary); font-size: .82rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.summary { padding: 12px 16px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-dark); white-space: nowrap; }

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-weight: 650;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover { transform: translateY(-1px); border-color: #aab7b0; }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(40, 95, 78, .24); outline-offset: 2px; }
.button.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: transparent; }
.button.danger { border-color: #edc5c1; color: var(--danger); }
.button.danger:hover { background: var(--danger-soft); }
.button.full { width: 100%; }
.button:disabled { cursor: default; transform: none; }
.voted-button { border-color: #b9d9c6; background: var(--success-soft); color: var(--success); }

.topic-list { display: grid; gap: 12px; }
.topic-card { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 25px rgba(24, 33, 30, .035); }
.topic-card.voted { border-color: #b9d9c6; }
.rank { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 750; }
.topic-content h2 { margin-bottom: 5px; font-size: 1.12rem; }
.topic-content p { margin-bottom: 8px; }
.vote-count { color: var(--muted); font-size: .9rem; white-space: nowrap; }

.alert { margin-bottom: 22px; padding: 13px 15px; border: 1px solid transparent; border-radius: 11px; }
.alert.success { border-color: #b9d9c6; background: var(--success-soft); color: var(--success); }
.alert.error { border-color: #edc5c1; background: var(--danger-soft); color: var(--danger); }
.alert.info { border-color: #c7d9eb; background: var(--info-soft); color: #325b7e; }
.empty-state { padding: 50px 24px; border: 1px dashed #b7c1bb; border-radius: 18px; text-align: center; background: rgba(255, 255, 255, .55); }
.empty-state p { margin-bottom: 0; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(430px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 34px; }
.auth-card h1 { font-size: 2.3rem; }

.stack { display: grid; gap: 16px; }
.stack.compact { gap: 10px; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 650; }
input, textarea, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #bac4be; border-radius: 9px; background: #fff; color: var(--text); }
textarea { resize: vertical; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.section-block { margin-top: 48px; }
.section-title { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 16px; }
.section-title p { margin-bottom: 0; }
.admin-list { display: grid; gap: 12px; }
.admin-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.topic-edit-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 18px; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; }
.check { display: flex; align-items: center; gap: 7px; }
.check input { width: 18px; min-height: 18px; }
.user-table { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 18px; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-row strong, .user-row span { display: block; }
.user-row div span { color: var(--muted); font-size: .9rem; }
.badge { padding: 5px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: .82rem; }

@media (max-width: 760px) {
    .page { padding-top: 38px; }
    .page-heading, .nav { align-items: flex-start; }
    .page-heading { flex-direction: column; }
    .nav { padding-block: 14px; }
    .nav-actions { flex-wrap: wrap; justify-content: flex-end; }
    .user-name { display: none; }
    .topic-card { grid-template-columns: 40px minmax(0, 1fr); }
    .topic-card form, .topic-card > .button { grid-column: 2; justify-self: start; }
    .topic-card-expanded .score-popover { grid-column: 1; grid-row: 2; }
    .topic-card-expanded .comments-panel { grid-column: 2; width: 100%; }
    .admin-grid { grid-template-columns: 1fr; }
    .admin-item, .topic-edit-form { grid-template-columns: 1fr; }
    .item-actions { justify-content: flex-start; }
}

@media (max-width: 470px) {
    .container { width: min(100% - 20px, 1080px); }
    .nav .button { padding-inline: 10px; }
    .nav-actions .ghost { display: none; }
    .topic-card { padding: 15px; gap: 12px; }
    .auth-card { padding: 24px; }
}

/* Direction visuelle BAI — chaleureuse, moderne et adaptée à un outil interne */
body {
    background:
        radial-gradient(circle at 8% 4%, rgba(214, 126, 67, .14), transparent 28rem),
        radial-gradient(circle at 92% 18%, rgba(40, 95, 78, .14), transparent 34rem),
        var(--bg);
    background-attachment: fixed;
}

.topbar {
    background: rgba(250, 251, 248, .86);
    box-shadow: 0 8px 28px rgba(24, 33, 30, .045);
}

.brand-mark {
    background: linear-gradient(145deg, #2d6d58, #173e32);
    box-shadow: 0 7px 16px rgba(40, 95, 78, .24);
}

.page-heading {
    position: relative;
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, .9), rgba(236, 243, 239, .82));
    box-shadow: 0 18px 55px rgba(24, 33, 30, .07);
    overflow: hidden;
}

.page-heading::after {
    content: "";
    position: absolute;
    width: 170px;
    height: 170px;
    right: -65px;
    top: -90px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(214, 126, 67, .22), rgba(40, 95, 78, .08));
    pointer-events: none;
}

.eyebrow { color: #bd6228; }

.summary {
    position: relative;
    z-index: 1;
    border: 1px solid rgba(40, 95, 78, .12);
    background: rgba(255, 255, 255, .76);
    box-shadow: 0 8px 18px rgba(24, 33, 30, .05);
}

.button.primary {
    background: linear-gradient(135deg, #32745f, #214d40);
    box-shadow: 0 8px 18px rgba(40, 95, 78, .18);
}

.button.primary:hover {
    background: linear-gradient(135deg, #285f4e, #173d32);
    box-shadow: 0 10px 22px rgba(40, 95, 78, .24);
}

.topic-card {
    border-color: rgba(40, 95, 78, .12);
    box-shadow: 0 12px 32px rgba(24, 33, 30, .055);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.topic-card:hover {
    transform: translateY(-2px);
    border-color: rgba(40, 95, 78, .28);
    box-shadow: 0 18px 42px rgba(24, 33, 30, .085);
}

.rank {
    background: linear-gradient(145deg, #eef5f1, #dbeae2);
    box-shadow: inset 0 0 0 1px rgba(40, 95, 78, .07);
}

.topic-card:first-child .rank {
    background: linear-gradient(145deg, #f9e9dc, #f3d4bd);
    color: #9c4d1c;
}

.auth-page { position: relative; overflow: hidden; }
.auth-page::before,
.auth-page::after {
    content: "";
    position: fixed;
    border-radius: 50%;
    filter: blur(2px);
    pointer-events: none;
}
.auth-page::before { width: 340px; height: 340px; left: -130px; top: -120px; background: rgba(214, 126, 67, .15); }
.auth-page::after { width: 420px; height: 420px; right: -170px; bottom: -180px; background: rgba(40, 95, 78, .14); }

.auth-card {
    position: relative;
    z-index: 1;
    border-color: rgba(255, 255, 255, .8);
    box-shadow: 0 28px 80px rgba(24, 33, 30, .14);
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    border-radius: 22px 22px 0 0;
    background: linear-gradient(90deg, #d67e43, #285f4e);
}

.panel,
.admin-item,
.user-table {
    border-color: rgba(40, 95, 78, .12);
    box-shadow: 0 12px 34px rgba(24, 33, 30, .055);
}

.panel h2,
.section-title h2 { color: var(--primary-dark); }

input,
textarea,
select {
    transition: border-color .15s ease, box-shadow .15s ease;
}

input:hover,
textarea:hover,
select:hover { border-color: #8fa399; }

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(40, 95, 78, .1);
}

/* Votes +1 / -1, détail des votants et commentaires */
.topic-card-expanded { align-items: start; }

.score-popover {
    position: relative;
    min-width: 76px;
    padding: 9px 12px;
    border: 1px solid rgba(40, 95, 78, .14);
    border-radius: 13px;
    background: linear-gradient(145deg, #f5f9f7, #e7f0eb);
    text-align: center;
    cursor: help;
}

.score-popover > span { display: block; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
.score-value { display: block; color: var(--primary-dark); font-size: 1.45rem; line-height: 1.1; }

.vote-tooltip {
    position: absolute;
    z-index: 30;
    right: 0;
    top: calc(100% + 9px);
    width: 245px;
    padding: 13px;
    border: 1px solid rgba(40, 95, 78, .16);
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 20px 50px rgba(24, 33, 30, .18);
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
    pointer-events: none;
}

.score-popover:hover .vote-tooltip,
.score-popover:focus .vote-tooltip,
.score-popover:focus-within .vote-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }
.vote-tooltip > strong { display: block; margin-bottom: 8px; }
.tooltip-voter { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: var(--text); }
.tooltip-empty { color: var(--muted); }
.vote-sign { min-width: 30px; font-size: .78rem; }
.positive { color: #1f7650; }
.negative { color: #b0443a; }

.topic-card .vote-form {
    grid-column: 2 / -1;
    width: 100%;
    justify-self: stretch;
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) auto;
    align-items: end;
    gap: 14px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.vote-choice { display: flex; gap: 8px; }
.vote-button {
    min-width: 74px;
    min-height: 56px;
    display: grid;
    place-items: center;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 750;
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.vote-button span { font-size: .72rem; font-weight: 650; color: var(--muted); }
.vote-button:hover { transform: translateY(-1px); }
.vote-button.up:hover,
.vote-button.up.selected { border-color: #76b596; background: #e6f4ec; color: #1d6847; box-shadow: 0 7px 16px rgba(31, 118, 80, .11); }
.vote-button.down:hover,
.vote-button.down.selected { border-color: #d69b95; background: #faebe9; color: #a33c34; box-shadow: 0 7px 16px rgba(176, 68, 58, .1); }
.vote-button.up.selected span { color: #1d6847; }
.vote-button.down.selected span { color: #a33c34; }

.reason-field { gap: 5px; }
.reason-field > span { color: var(--muted); font-weight: 500; }
.reason-field textarea { min-height: 56px; }
.saved-vote { align-self: center; color: var(--success); font-size: .86rem; white-space: nowrap; }
.comment-actions { display: grid; gap: 7px; align-self: end; }
.save-comment { white-space: nowrap; }
.comment-hint { max-width: 210px; color: var(--muted); font-size: .82rem; line-height: 1.35; }

.topic-card .comments-panel { grid-column: 2 / -1; border-top: 1px solid var(--line); padding-top: 13px; }
.comments-panel summary { display: inline-flex; align-items: center; gap: 8px; color: var(--primary-dark); font-weight: 700; cursor: pointer; list-style-position: outside; }
.comments-panel summary span { min-width: 25px; padding: 2px 7px; border-radius: 999px; background: var(--primary-soft); text-align: center; font-size: .78rem; }
.comments-list { display: grid; gap: 9px; margin-top: 13px; }
.comments-list > p { margin-bottom: 0; }
.comment-item { padding: 13px 15px; border-left: 3px solid #b9d9c6; border-radius: 0 11px 11px 0; background: #f7faf8; }
.comment-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.comment-vote { font-weight: 800; }
.comment-item p { margin-bottom: 0; color: var(--text); }

@media (max-width: 820px) {
    .topic-card .vote-form { grid-template-columns: 1fr; }
    .saved-vote { justify-self: start; }
    .comment-actions { justify-items: start; }
}

@media (max-width: 470px) {
    .score-popover { min-width: 65px; }
    .vote-tooltip { right: -4px; width: min(245px, calc(100vw - 40px)); }
    .topic-card .vote-form, .topic-card .comments-panel { grid-column: 1 / -1; }
    .vote-choice { width: 100%; }
    .vote-button { flex: 1; }
}

/* BAI v6 — radar, duels, maturation et journal de décision */
.radar-board {
    margin-bottom: 24px;
    padding: 24px;
    border: 1px solid rgba(40, 95, 78, .13);
    border-radius: 20px;
    background: rgba(255, 255, 255, .82);
    box-shadow: 0 15px 42px rgba(24, 33, 30, .055);
}
.radar-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 18px; }
.radar-heading h2, .radar-heading p { margin-bottom: 0; }
.radar-heading p { max-width: 430px; }
.radar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.radar-stat { padding: 14px; border-radius: 13px; background: var(--primary-soft); }
.radar-stat strong { display: block; font-size: 1.45rem; }
.radar-stat span { color: var(--muted); font-size: .82rem; }
.radar-stat.consensus { background: #e4f3e9; color: #1c7049; }
.radar-stat.divisive { background: #f8e9dc; color: #9a4d1e; }
.radar-stat.promising { background: #e5eef8; color: #315f87; }
.radar-stat.rework { background: #f7e7e5; color: #a13e36; }
.radar-stat.emerging { background: #eeece7; color: #665f54; }

.duel-card {
    display: grid;
    grid-template-columns: minmax(220px, .65fr) minmax(0, 1.35fr);
    gap: 26px;
    align-items: center;
    margin-bottom: 28px;
    padding: 24px;
    border-radius: 20px;
    background: linear-gradient(135deg, #173f34, #285f4e);
    color: #fff;
    box-shadow: 0 18px 45px rgba(24, 68, 55, .2);
}
.duel-intro .eyebrow { color: #f3be96; }
.duel-intro h2 { margin-bottom: 7px; }
.duel-intro p { margin-bottom: 0; color: rgba(255, 255, 255, .7); }
.duel-form { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 10px; }
.duel-form button { min-height: 100px; padding: 16px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 14px; background: rgba(255, 255, 255, .1); color: #fff; text-align: left; cursor: pointer; transition: background .16s ease, transform .16s ease; }
.duel-form button:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .18); }
.duel-form button span { display: block; margin-bottom: 8px; color: #f3be96; font-size: .75rem; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.duel-form button strong { display: block; line-height: 1.3; }
.duel-or { align-self: center; color: rgba(255, 255, 255, .55); font-size: .8rem; }

.topic-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.radar-badge, .status-badge, .version-badge, .objection-label { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: .73rem; font-weight: 750; }
.radar-badge.consensus { background: #e4f3e9; color: #1c7049; }
.radar-badge.divisive { background: #f8e9dc; color: #9a4d1e; }
.radar-badge.promising { background: #e5eef8; color: #315f87; }
.radar-badge.rework { background: #f7e7e5; color: #a13e36; }
.radar-badge.emerging { background: #eeece7; color: #665f54; }
.status-badge { background: #eef1ef; color: #54635d; }
.status-experiment { background: #e8e7f8; color: #574fa0; }
.status-accepted { background: #dff2e7; color: #176845; }
.status-rejected { background: #f3e5e3; color: #963d35; }
.version-badge { background: #f5ede6; color: #8d542e; }
.duel-score { color: var(--muted); font-size: .82rem; }

.outcome-panel, .review-notice {
    grid-column: 2 / -1;
    padding: 13px 15px;
    border-radius: 12px;
}
.outcome-panel { display: grid; gap: 3px; }
.outcome-panel span, .outcome-panel p { margin: 0; }
.outcome-panel.experiment { border: 1px solid #cbc7ef; background: #f0effa; color: #4e478f; }
.outcome-panel.experiment p { color: #625ba0; }
.outcome-panel.decision { border: 1px solid #bcdcc9; background: #e8f4ed; color: #1d6847; }
.outcome-panel.decision p { color: #315f4a; }
.review-notice { border: 1px dashed #d49a6f; background: #fcf1e8; color: #935124; }

.argument-panel { min-width: 0; }
.argument-panel > summary { margin-bottom: 8px; color: var(--primary-dark); font-weight: 700; cursor: pointer; }
.argument-grid { display: grid; gap: 10px; }
.argument-grid label > span { color: var(--muted); font-weight: 500; }
.argument-grid textarea { min-height: 58px; }
.objection-label { margin-bottom: 7px; background: #f8e9dc; color: #9a4d1e; }
.comment-item .improvement { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #cdd8d1; color: #315f4a; }
.tooltip-voter { flex-wrap: wrap; }
.tooltip-voter small { width: 100%; padding-left: 38px; color: var(--muted); }

.topic-card .versions-panel { grid-column: 2 / -1; border-top: 1px solid var(--line); padding-top: 12px; }
.versions-panel summary { color: var(--primary-dark); font-weight: 700; cursor: pointer; }
.versions-panel summary span { display: inline-flex; min-width: 24px; justify-content: center; padding: 2px 7px; border-radius: 999px; background: var(--primary-soft); font-size: .78rem; }
.versions-list { display: grid; gap: 9px; margin-top: 12px; }
.versions-list article { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #f8faf8; }
.versions-list article > strong, .versions-list article > span { display: block; }
.versions-list article > span { margin-top: 3px; color: var(--muted); font-size: .8rem; }
.versions-list article p { margin: 8px 0 0; }

.inline-version { display: inline-flex; margin-left: 6px; padding: 2px 7px; border-radius: 999px; background: #f5ede6; color: #8d542e; font-size: .72rem; }
.decision-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

@media (max-width: 860px) {
    .radar-grid { grid-template-columns: repeat(3, 1fr); }
    .duel-card { grid-template-columns: 1fr; }
    .decision-fields { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .radar-heading { align-items: start; flex-direction: column; }
    .radar-grid { grid-template-columns: repeat(2, 1fr); }
    .duel-form { grid-template-columns: 1fr; }
    .duel-or { justify-self: center; }
    .outcome-panel, .review-notice, .topic-card .versions-panel { grid-column: 1 / -1; }
}
