/* Simple setup, Functional requirements: tree | scenarios | Programme and Brief panel.
   Only the columns scroll; the wizard header, the actions and the panel totals stay put. */
#setup-shell:has(#setup-panel-new:not([hidden]) .pf) {
    height: calc(100vh - var(--sticky-header-offset));
    min-height: 560px;
}
.setup-shell:has(#setup-panel-new:not([hidden]) .pf) {
    height: 100%;
    min-height: 0;
}
.setup-shell #setup-panel-new:not([hidden]):has(.pf) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.setup-shell #setup-step:has(.pf) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding-bottom: 12px;
}
.setup-shell #setup-step:has(.pf) > .setup-question {
    margin-bottom: 12px;
}
.pf {
    position: relative;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) var(--brief-rail-w, 400px);
    grid-template-areas: "tree main panel";
    flex: 1;
    min-height: 0;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    overflow: hidden;
}
.pf-tree {
    overflow-y: auto;
    overscroll-behavior: contain;
    grid-area: tree;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 0;
    padding: 10px 8px;
    border-right: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.pf-tree-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.pf-tree-node {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 32px;
    padding: 5px 8px;
    border: none;
    border-radius: var(--radius);
    background: none;
    font: inherit;
    font-size: 14px;
    color: var(--gray-800);
    text-align: left;
    cursor: pointer;
}
.pf-tree-node:hover,
.pf-tree-add:hover {
    background: var(--gray-100);
}
.pf-tree-node:focus-visible,
.pf-tree-add:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.pf-tree-node.is-active {
    background: var(--white);
    box-shadow: inset 0 0 0 1px var(--gray-300);
    font-weight: 600;
}
.pf-tree-node.is-linked {
    background: var(--accent-bg);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.pf-tree-item {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}
.pf-tree-item.pf-depth-1 {
    padding-left: 14px;
}
.pf-tree-item.pf-depth-2 {
    padding-left: 28px;
}
.pf-tree-item.pf-depth-3 {
    padding-left: 42px;
}
.pf-tree-item > .pf-tree-node,
.pf-tree-item > .pf-tree-add {
    flex: 1;
    min-width: 0;
    padding-left: 4px;
}
.pf-tree-item > .pf-tree-remove {
    flex: 0 0 auto;
    opacity: 0.35;
}
.pf-tree-item:hover > .pf-tree-remove,
.pf-tree-item:focus-within > .pf-tree-remove {
    opacity: 1;
}
.pf-tree-arrow {
    flex: 0 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: none;
    color: var(--gray-500);
    cursor: pointer;
}
.pf-tree-arrow::before {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateX(-1px) rotate(-45deg);
    transition: transform 0.12s;
}
.pf-tree-arrow[aria-expanded="true"]::before {
    transform: translateY(-2px) rotate(45deg);
}
.pf-tree-arrow:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}
.pf-tree-arrow:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.pf-tree-arrow.is-leaf {
    visibility: hidden;
    cursor: default;
}
.pf-tree-node.pf-tree-room {
    min-height: 26px;
    padding-top: 3px;
    padding-bottom: 3px;
    font-size: 13px;
    color: var(--gray-600);
}
.pf-tree-rename {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
}
.pf-tree-rename:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.pf.is-rail .pf-tree-room-item {
    display: none;
}
.pf.is-rail .pf-tree-item {
    padding-left: 0;
}
.pf.is-rail .pf-tree .pf-tree-arrow {
    padding-left: 0;
    display: none;
}
.pf-room-rules {
    margin: 0 0 12px;
    padding-left: 18px;
    font-size: 13px;
    color: var(--gray-600);
}
.pf-preset.is-changed .pf-preset-name {
    font-weight: 600;
}
.pf-tree-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pf-tree-abbr {
    display: none;
}
.pf-tree-count {
    font-size: 12px;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
}
.pf-tree-node.is-open .pf-tree-count {
    color: var(--warning);
    font-weight: 600;
}
.pf-tree-node.is-done .pf-tree-count {
    color: var(--success);
}
.pf-tree-add {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 32px;
    padding: 5px 8px;
    border: none;
    border-radius: var(--radius);
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-600);
}
.pf-tree-add > span[aria-hidden] {
    width: 8px;
    font-weight: 600;
    text-align: center;
}
.pf-menu {
    display: flex;
    flex-direction: column;
    margin: 4px 0;
    padding: 4px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: 0 6px 18px rgba(var(--black-rgb), 0.08);
}
.pf-menu-item {
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: none;
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.pf-menu-item:hover {
    background: var(--gray-100);
}
.pf-crumbs {
    display: none;
    grid-area: crumbs;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.pf-crumb-path {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 14px;
}
.pf-crumb {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: var(--gray-600);
    cursor: pointer;
}
.pf-crumb:last-child {
    font-weight: 600;
    color: var(--gray-900);
}
.pf-crumb-sep {
    color: var(--gray-400);
}
.pf-crumbs-add {
    position: relative;
    flex-shrink: 0;
}
.pf-crumb-add {
    padding: 4px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    font: inherit;
    font-size: 13px;
    color: var(--gray-800);
    cursor: pointer;
    white-space: nowrap;
}
.pf-crumb-add:hover {
    background: var(--gray-100);
}
.pf-crumb-add:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.pf-crumbs-add .pf-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 50;
    min-width: 200px;
}
.pf-crumb-select {
    max-width: 45%;
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    font: inherit;
    font-size: 13px;
}
.pf-main {
    overflow-y: auto;
    overscroll-behavior: contain;
    grid-area: main;
    min-width: 0;
    min-height: 0;
    padding: 0 24px 40px;
}
.pf-main > .prog-empty {
    margin-top: 16px;
}
.pf-scope + .pf-scope {
    margin-top: 20px;
}
.pf-scope-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 14px 0 8px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
}
.pf-scope-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}
.pf-scope-kind {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-500);
}
.pf-scn {
    margin: 0 -10px;
    padding: 0 10px;
    border-radius: var(--radius);
}
.pf-scn.is-linked {
    background: var(--accent-bg);
}
.pf-scn.is-flash,
.pf-row.is-flash,
.pf-row.is-changed {
    animation: pf-flash 1.8s ease-out;
}
@keyframes pf-flash {
    from {
        background: var(--accent-bg);
        box-shadow: inset 3px 0 0 var(--accent);
    }
    to {
        background: transparent;
        box-shadow: inset 3px 0 0 transparent;
    }
}
.pf-scn-rooms {
    margin: -8px 0 12px;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 12px;
    color: var(--gray-500);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.pf-scn-rooms:hover {
    color: var(--gray-900);
}
.pf-panel {
    grid-area: panel;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-left: 1px solid var(--gray-200);
    background: var(--white);
}
.pf-totals {
    position: relative;
    flex: 0 0 auto;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.pf-totals dl {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 8px;
    margin: 0;
}
.pf-totals dt {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-500);
}
.pf-totals dd {
    margin: 2px 0 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.pf-sheet-toggle,
.pf-close,
.pf-expand,
.pf-edge-tab {
    display: none;
}
.pf-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 8px 0 16px;
    border-bottom: 1px solid var(--gray-200);
}
.pf-tabs {
    display: flex;
    gap: 20px;
}
.pf-tab {
    padding: 10px 0 8px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font: inherit;
    font-size: 14px;
    color: var(--gray-500);
    cursor: pointer;
}
.pf-tab.is-active {
    border-bottom-color: var(--accent);
    font-weight: 600;
    color: var(--gray-900);
}
.pf-badge {
    display: inline-block;
    min-width: 18px;
    margin-left: 4px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--white);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}
.pf-panel-actions {
    display: flex;
    gap: 2px;
}
.pf-icon {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius);
    background: none;
    font: inherit;
    font-size: 16px;
    line-height: 1;
    color: var(--gray-500);
    cursor: pointer;
}
.pf-icon:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}
.pf-panel-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1;
    min-height: 0;
    padding: 12px 16px 24px;
}
.pf-pgroup {
    margin-bottom: 12px;
    border-radius: var(--radius);
}
.pf-pgroup.pf-depth-2 {
    margin: 6px 0 8px 10px;
}
.pf-pgroup.is-linked {
    background: var(--accent-bg);
}
.pf-pgroup-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
}
.pf-pgroup.pf-depth-0 > .pf-pgroup-head,
.pf-pgroup.pf-depth-1 > .pf-pgroup-head {
    border-bottom: 1px solid var(--gray-200);
    font-size: 12px;
    color: var(--gray-500);
}
.pf-pgroup.pf-depth-0 > .pf-pgroup-head .pf-pgroup-name,
.pf-pgroup.pf-depth-1 > .pf-pgroup-head .pf-pgroup-name {
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.pf-pgroup-name {
    flex: 1;
    min-width: 0;
}
/* Same columns as .pf-row, so the unit count lines up with the room counts. */
.pf-pgroup-head.is-unit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto 76px;
    align-items: center;
    gap: 4px 10px;
}
.pf-pgroup-head.is-unit .pf-pgroup-name {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: -20px;
}
.pf-pgroup-head.is-unit .pf-row-count {
    color: var(--gray-900);
}
.pf-pgroup-head.is-unit .pf-pgroup-total {
    text-align: right;
}
.pf-pgroup-total {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.pf-unit-count {
    font-size: 12px;
    font-weight: normal;
    color: var(--gray-600);
}
.pf-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto 76px;
    align-items: baseline;
    gap: 4px 10px;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.pf-row:hover {
    background: var(--gray-50);
}
.pf-row.is-linked {
    background: var(--accent-bg);
}
.pf-row-name {
    min-width: 0;
    overflow-wrap: anywhere;
}
.pf-row-count,
.pf-row-area {
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}
.pf-row-delta:not(:empty) {
    padding: 0 6px;
    border-radius: 9px;
    background: var(--accent-bg);
    color: var(--accent-hover);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    animation: pf-delta 4s ease-in forwards;
}
@keyframes pf-delta {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}
.pf-cell {
    width: 4ch;
    margin: -2px 0;
    padding: 1px 3px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    font: inherit;
    color: inherit;
    text-align: right;
    font-variant-numeric: tabular-nums;
    cursor: text;
}
.pf-row-area .pf-cell {
    width: 5ch;
}
.pf-cell:hover {
    border-color: var(--gray-300);
    background: var(--white);
}
.pf-cell:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 2px var(--primary-ring);
}
.pf-pgroup-head.is-unit .pf-cell {
    font-weight: 600;
}
.pf-types {
    margin: 12px 0 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}
.pf-type {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 3px 0;
}
.pf-type-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
}
.pf-unit-count input {
    width: 76px;
    margin-left: 4px;
    padding: 3px 6px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font: inherit;
}
.pf-scn-add {
    display: block;
    margin-top: 12px;
    font-size: 13px;
}
.prog-brief-nodes {
    color: var(--gray-500);
    font-size: 0.9em;
}
.pf-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
}
.pf-form .prog-topic-title {
    margin: 0;
}
.pf-form-field {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.pf-form-field > span {
    color: var(--gray-600);
}
.pf-form-field input,
.pf-form-field select {
    width: auto;
    max-width: 320px;
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
}
.pf-form-rooms {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.pf-form-rooms input[type="number"] {
    width: 80px;
}
.pf-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    background: var(--white);
    font-size: 12px;
}
.pf-chip-remove {
    padding: 0 4px;
    border: 0;
    background: none;
    color: var(--gray-500);
    font: inherit;
    cursor: pointer;
}
.pf-form-error {
    margin: 0;
    font-size: 12px;
    color: var(--danger);
}
.pf-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.pf-scn-remove {
    display: block;
    margin-top: 4px;
    font-size: 12px;
}
.pf-form-field.pf-preset {
    grid-template-columns: minmax(160px, 260px) minmax(0, 1fr);
}
.pf-preset-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-wrap: anywhere;
}
.pf-preset-name {
    color: var(--gray-800);
}
.pf-preset-source {
    font-size: 11px;
    color: var(--gray-500);
}
.pf-preset-group {
    margin: 14px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    overflow-wrap: anywhere;
}
.pf-preset-group:first-of-type {
    margin-top: 4px;
}
.pf-room-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 12px;
}
@media (max-width: 640px) {
    .pf-form-field,
    .pf-form-field.pf-preset {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
    }
}
.pf-brief-group + .pf-brief-group {
    margin-top: 14px;
}
.pf-brief-head {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-500);
}
.pf-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    margin: 0 0 8px;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    font: inherit;
    text-align: left;
}
.pf-card.is-linked {
    border-color: var(--accent);
    background: var(--accent-bg);
}
.pf-card.is-placeholder {
    border-style: dashed;
    background: var(--gray-50);
    cursor: pointer;
}
.pf-card.is-placeholder:hover {
    border-color: var(--gray-400);
}
.pf-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}
.pf-card-open {
    font-size: 12px;
    color: var(--warning);
}
.pf-card-pictos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.pf-card-picto {
    max-width: 100%;
    margin: 0;
}
.pf-card-picto svg {
    max-width: 100%;
    height: auto;
}
.pf-card-picto figcaption {
    margin-top: 2px;
    font-size: 12px;
    color: var(--gray-600);
}
.pf-preview-link {
    margin-top: 8px;
    font-size: 13px;
}
.pf-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--gray-500);
}
