/* ==========================================================================
   KDigit — système de design
   Tout le thème découle de --accent (réglable par utilisateur) : les teintes
   douces, survols et halos sont dérivés par color-mix(). Le serveur injecte
   aussi --on-accent (texte sur l'accent) et --accent-text (accent utilisé comme
   texte, un jeton par thème) corrigés pour le contraste AA : voir ThemeTokens.
   ========================================================================== */
:root {
    --radius-sm: 9px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 1px rgba(16, 24, 40, 0.03);
    --shadow: 0 8px 24px -6px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 28px 70px -14px rgba(16, 24, 40, 0.35);
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --accent: #5b8cff;
    --accent-contrast: #ffffff;
    --on-accent: #ffffff;
    --accent-text: var(--accent);

    /* Zoom d'interface (préférence utilisateur, 1 = 100 %) : le texte, les icônes et la barre latérale suivent. */
    --ui-scale: 1;
    --sidebar-w: calc(256px * (1 + (var(--ui-scale) - 1) * 0.5));
    --sidebar-w-collapsed: calc(78px * var(--ui-scale));
    --topbar-h: calc(64px * var(--ui-scale));
    --danger-solid: #b4232a;

    /* Palette claire */
    --bg: #f4f6fb;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-hover: #f2f4fa;
    --border: #e4e8f0;
    --text: #0f1729;
    --text-muted: #5a647d;
    --danger: #b4232a;
    --danger-bg: rgba(217, 54, 62, 0.1);
    --success: #087048;
    --success-bg: rgba(18, 160, 107, 0.12);
    --warning: #855500;
    --warning-bg: rgba(185, 119, 14, 0.12);

    /* Dérivés de l'accent */
    --accent-dim: color-mix(in srgb, var(--accent) 14%, var(--surface));
    --accent-soft: color-mix(in srgb, var(--accent) 9%, transparent);
    --accent-strong: color-mix(in srgb, var(--accent) 80%, #000);
    --accent-glow: color-mix(in srgb, var(--accent) 32%, transparent);
    --text-dim: var(--text-muted);

    font-size: calc(15px * var(--ui-scale));
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #090b11;
        --bg-elevated: #0f121a;
        --surface: #141823;
        --surface-hover: #1a1f2c;
        --border: #232a3a;
        --text: #eef1f8;
        --text-muted: #94a0b8;
        --danger: #ff6b70;
        --danger-bg: rgba(240, 87, 92, 0.14);
        --success: #3fd29a;
        --success-bg: rgba(63, 210, 154, 0.14);
        --warning: #eab04d;
        --warning-bg: rgba(234, 176, 77, 0.14);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.55);
        --shadow-lg: 0 30px 80px -14px rgba(0, 0, 0, 0.7);
    }
}

:root[data-theme="dark"] {
    --bg: #090b11;
    --bg-elevated: #0f121a;
    --surface: #141823;
    --surface-hover: #1a1f2c;
    --border: #232a3a;
    --text: #eef1f8;
    --text-muted: #94a0b8;
    --danger: #ff6b70;
    --danger-bg: rgba(240, 87, 92, 0.14);
    --success: #3fd29a;
    --success-bg: rgba(63, 210, 154, 0.14);
    --warning: #eab04d;
    --warning-bg: rgba(234, 176, 77, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 30px 80px -14px rgba(0, 0, 0, 0.7);
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body {
    margin: 0;
    background:
        radial-gradient(1100px 480px at 88% -12%, var(--accent-soft), transparent 70%),
        radial-gradient(800px 420px at -8% 105%, var(--accent-soft), transparent 70%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.65rem; margin: 0 0 20px; font-weight: 750; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0 0 14px; font-weight: 650; letter-spacing: -0.01em; }

::selection { background: var(--accent-glow); }

/* ---------- Shell : barre latérale + zone de contenu ---------- */
.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: var(--sidebar-w);
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 40;
    transition: width 0.2s ease, transform 0.22s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    height: var(--topbar-h); padding: 0 20px; flex-shrink: 0;
    color: var(--text); font-weight: 750; font-size: 1.12rem; letter-spacing: -0.02em;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent-strong));
    color: var(--accent-contrast);
    box-shadow: 0 6px 16px -4px var(--accent-glow);
}
.brand-name span { color: var(--accent-text); }
.brand-logo { max-height: 30px; max-width: 150px; display: block; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-section {
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-muted); padding: 16px 12px 6px;
}
.nav-link {
    display: flex; align-items: center; gap: 12px; position: relative;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 0.9rem; font-weight: 550; white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-dim); color: var(--accent-text); }
.nav-link.active::before {
    content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--accent);
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.user-card {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); background: var(--surface-hover); min-width: 0;
}
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent); color: var(--accent-contrast); font-weight: 700; font-size: 0.9rem;
}
.user-meta { min-width: 0; flex: 1; line-height: 1.25; }
.user-meta .user-name { font-size: 0.82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta .user-role { font-size: 0.8rem; color: var(--text-muted); }
.user-card form { margin: 0; }
.user-card .icon-btn { width: 32px; height: 32px; }

/* Menu utilisateur (sous-menu du pied de la barre latérale) */
.user-card { position: relative; padding: 0; background: transparent; }
.user-card .user-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: var(--surface-hover);
    color: inherit; font: inherit; text-align: left; cursor: pointer; min-width: 0; }
.user-card .user-link:hover { background: color-mix(in srgb, var(--surface-hover) 70%, var(--accent-dim)); }
.user-chevron { color: var(--text-muted); transition: transform .15s; display: flex; }
.user-link[aria-expanded="true"] .user-chevron { transform: rotate(180deg); }
.user-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 60; padding: 6px; border-radius: var(--radius-sm); background: var(--bg-elevated);
    border: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 2px; min-width: 230px; }
.user-menu[hidden] { display: none; }
.user-menu a, .user-menu button { display: grid; grid-template-columns: 20px 1fr; align-items: center; column-gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none;
    color: var(--text); font: inherit; font-size: 0.88rem; text-align: left; cursor: pointer; text-decoration: none; }
.user-menu a:hover, .user-menu button:hover { background: var(--surface-hover); text-decoration: none; }
.user-menu .user-menu-sub { grid-column: 2; color: var(--text-muted); font-size: 0.75rem; }
.user-menu .user-menu-danger { color: var(--danger); }
.user-menu form { margin: 0; }
body.sidebar-collapsed .user-menu { left: 0; right: auto; }
body.sidebar-collapsed .user-card .user-meta, body.sidebar-collapsed .user-chevron { display: none; }
body.sidebar-collapsed .user-card .user-link { justify-content: center; padding: 8px 0; background: transparent; }

/* Pastille de comptage dans le menu et cloche de notifications */
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: 0.72rem; font-weight: 700; text-align: center; }
body.sidebar-collapsed .nav-badge { position: absolute; top: 4px; right: 8px; margin: 0; }
.notif { position: relative; }
.notif-btn { position: relative; }
.notif-count { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--danger-solid); color: #fff;
    font-size: 0.68rem; font-weight: 700; line-height: 17px; text-align: center; }
.notif-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 70; width: min(360px, calc(100vw - 24px)); border-radius: var(--radius-sm); background: var(--bg-elevated);
    border: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: hidden; }
.notif-panel[hidden] { display: none; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.notif-head a { font-size: 0.78rem; color: var(--text-muted); }
.notif-empty { display: flex; align-items: center; gap: 8px; margin: 0; padding: 18px 14px; color: var(--text-muted); font-size: 0.88rem; }
.notif-item { display: flex; gap: 12px; padding: 12px 14px; color: var(--text); border-bottom: 1px solid var(--border); text-decoration: none; }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-hover); text-decoration: none; }
.notif-item small { display: block; color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.notif-icon { flex: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--accent-dim); color: var(--accent-text); }
.notif-warn .notif-icon { background: var(--warning-bg); color: var(--warning); }
.notif-error .notif-icon { background: var(--danger-bg); color: var(--danger); }

.app-body {
    animation: kd-arrive 0.28s ease backwards;
    margin-left: var(--sidebar-w); min-height: 100vh;
    display: flex; flex-direction: column; min-width: 0;
    transition: margin-left 0.2s ease;
}
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px; padding: 0 32px;
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar-spacer { flex: 1; }
.sidebar-toggle {
    background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
    width: 38px; height: 38px; padding: 0; border-radius: var(--radius-sm); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; box-shadow: none;
}
.sidebar-toggle:hover { color: var(--text); background: var(--surface-hover); filter: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(8, 10, 16, 0.5); z-index: 35; backdrop-filter: blur(2px); }

/* Barre latérale réduite (icônes seules) */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .app-body { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .user-meta { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 12px 0; }
body.sidebar-collapsed .nav-link.active::before { left: -12px; }
body.sidebar-collapsed .user-card { justify-content: center; padding: 8px 0; background: transparent; }

.version-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.8rem; color: var(--text-muted); font-weight: 550;
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface);
}
.version-pill:hover { text-decoration: none; border-color: var(--accent); color: var(--text); }
.version-pill .update-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }

.theme-toggle {
    background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
    width: 38px; height: 38px; padding: 0; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.95rem;
    display: inline-flex; align-items: center; justify-content: center; box-shadow: none;
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); filter: none; }

.app-main { flex: 1; }
.container { max-width: 1400px; margin: 0 auto; padding: 28px 32px 40px; }

.app-footer {
    padding: 18px 32px 26px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.app-footer a { color: var(--text-muted); }
.app-footer a:hover { color: var(--text); }

/* ---------- Cartes / primitives ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 0.88rem; vertical-align: middle; }
th { color: var(--text-muted); font-weight: 650; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.06em; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-hover) 70%, transparent); }
tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 650;
    letter-spacing: 0.01em;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-disabled { background: var(--border); color: var(--text-muted); }
.badge-suspended { background: var(--warning-bg); color: var(--warning); }
.badge-expired { background: var(--danger-bg); color: var(--danger); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot-online { background: var(--success); }
.dot-offline { background: var(--text-muted); }

form.inline { display: inline; }

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-text);
    box-shadow: 0 0 0 4px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--text-muted) 70%, transparent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }

label { display: block; margin-bottom: 6px; font-size: 0.82rem; color: var(--text-muted); font-weight: 550; }
.field { margin-bottom: 16px; }

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px;
    background: var(--accent);
    color: var(--accent-contrast);
    border: 1px solid color-mix(in srgb, var(--accent) 78%, #000);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 650;
    font-family: inherit;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.14), 0 6px 14px -8px var(--accent-glow);
    transition: filter 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
button:hover, .btn:hover { filter: brightness(1.07); text-decoration: none; }
button:active, .btn:active { filter: brightness(0.96); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
#main:focus-visible { outline: none; }
.btn-danger { background: var(--danger-solid); color: #fff; border-color: color-mix(in srgb, var(--danger-solid) 78%, #000); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.14); }
.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px;
    border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 650; line-height: 1.2; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { filter: none; border-color: var(--accent); color: var(--accent-text); background: var(--surface); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.flash {
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.9rem;
    border: 1px solid transparent; border-left-width: 4px;
}
.flash-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); border-left-color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); border-left-color: var(--danger); }

.license-banner { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.88rem; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.license-banner.ok { background: var(--success-bg); color: var(--success); }
.license-banner.warn { background: var(--warning-bg); color: var(--warning); }
.license-banner.error { background: var(--danger-bg); color: var(--danger); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 14px;
}
.stat-card .stat-icon {
    width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-dim); color: var(--accent-text);
}
.stat-card .stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-card .stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-card .value { font-size: 1.75rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.stat-card .label { color: var(--text-muted); font-size: 0.8rem; margin-top: 3px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.text-dim { color: var(--text-muted); }
.text-warn { color: var(--warning); }
.text-danger { color: var(--danger); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 28px 16px; }
.login-card { width: 100%; max-width: 420px; border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 30px; }

.agent-choice { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-top: 14px; background: var(--bg-elevated); }
.agent-choice-detected { border-color: var(--accent); }
.agent-choice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.agent-choice-head strong { font-size: 1rem; }

/* Studio visuel (glisser-déposer) des gabarits RSS/API, voir rss-studio.js */
.kstudio-canvas {
    position: relative;
    flex: 1;
    min-width: 0;
    aspect-ratio: 16 / 9;
    background: #0f1115;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background-image:
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 10% 10%;
}
.kstudio-panel {
    width: 250px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    max-height: 480px;
    overflow-y: auto;
}
.kstudio-panel .field { margin-bottom: 10px; }
.kstudio-panel .field label { font-size: 0.8rem; }
.kstudio-block {
    position: absolute;
    border: 1px dashed rgba(255,255,255,0.35);
    color: #e6e8ec;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
}
.kstudio-block.selected { border: 1px solid var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.kstudio-block-badge {
    position: absolute; top: -1px; left: -1px;
    background: var(--accent); color: var(--accent-contrast);
    font-size: 0.8rem; padding: 1px 5px; border-radius: 0 0 4px 0;
    opacity: 0; pointer-events: none; transition: opacity 0.1s ease;
}
.kstudio-block:hover .kstudio-block-badge, .kstudio-block.selected .kstudio-block-badge { opacity: 1; }
.kstudio-resize-handle {
    position: absolute; right: -4px; bottom: -4px; width: 12px; height: 12px;
    background: var(--accent); border-radius: 50%; cursor: nwse-resize;
}

/* Studio de composition des zones (playlists multi-écrans), voir zone-studio.js */
.kzone-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.kzone-template {
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: 6px; cursor: pointer; aspect-ratio: 16/9; position: relative;
}
.kzone-template:hover { border-color: var(--accent); }
.kzone-template-mini { position: relative; width: 100%; height: 100%; }
.kzone-template-mini.portrait { aspect-ratio: 9/16; margin: 0 auto; }
.kzone-template-mini span {
    position: absolute; background: var(--accent); opacity: 0.75;
    border: 1px solid var(--surface);
}
.kzone-canvas {
    position: relative;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 16 / 9;
    background: #0f1115;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin: 0 auto;
}
.kzone-canvas.portrait { aspect-ratio: 9 / 16; max-width: 220px; }
.kzone-rect {
    position: absolute; box-sizing: border-box;
    border: 1px dashed rgba(255,255,255,0.4);
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: #e6e8ec; display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; cursor: move; user-select: none;
}
.kzone-rect.selected { border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 34%, transparent); }
.kzone-resize-handle {
    position: absolute; right: -4px; bottom: -4px; width: 12px; height: 12px;
    background: var(--accent); border-radius: 50%; cursor: nwse-resize;
}

/* ---------- Médiathèque ---------- */
.media-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.media-tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow-sm); position: sticky; top: 84px; }
.media-tree a { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 0.86rem; }
.media-tree a:hover { background: var(--surface-hover); text-decoration: none; color: var(--text); }
.media-tree a.active { background: var(--accent-dim); color: var(--text); font-weight: 600; }
.media-tree ul { list-style: none; margin: 0; padding-left: 16px; }
.media-tree > ul { padding-left: 0; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.media-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.media-item .thumb { width: 100%; height: 100px; object-fit: cover; display: block; background: #000; cursor: pointer; }
.media-item .thumb-widget { display: flex; align-items: center; justify-content: center; font-size: 2.4rem; background: var(--surface-hover); }
.media-item .info { padding: 8px; font-size: 0.8rem; }
.media-item .info .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.media-item .actions { display: flex; flex-wrap: wrap; gap: 4px; }
.media-item .actions form { flex: 1; min-width: 0; }
.media-item .actions button, .media-item .actions .btn { width: 100%; padding: 4px 6px; font-size: 0.8rem; }
.media-item .actions select { padding: 4px 6px; font-size: 0.8rem; }

.breadcrumb { margin-bottom: 14px; font-size: 0.88rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { margin: 0 6px; }
.breadcrumb .current { color: var(--text); }

.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.folder-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.folder-card a { color: var(--text); display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.folder-card a:hover { text-decoration: none; color: var(--accent-text); }
.folder-card .icon { font-size: 1.3rem; }
.folder-card .count { color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; }
.folder-card .folder-actions { margin-top: 8px; display: flex; gap: 4px; }
.folder-card .folder-actions form { flex: 1; }
.folder-card .folder-actions button { width: 100%; padding: 3px 6px; font-size: 0.8rem; }

/* ---------- Bibliothèque de widgets ---------- */
/* Assistant « Service connecté » : tuiles de services, puis galerie de mises en page */
.service-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.service-tile {
    background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
    padding: 16px; text-align: left; cursor: pointer; font-size: 0.9rem;
    display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 6px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.service-tile:hover, .service-tile:focus-visible { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.tile-icon { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; margin-bottom: 4px; border-radius: 12px; background: var(--accent-dim); color: var(--accent-text); }
.tile-blurb { color: var(--text-muted); font-size: 0.82rem; line-height: 1.35; font-weight: 400; }
.wz-head { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; padding-right: 36px; }
.wz-head h2 { margin: 0; }
.layout-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 6px; }
.layout-card {
    background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
    padding: 8px; cursor: pointer; text-align: center; font-size: 0.8rem; font-weight: 600;
    display: flex; flex-direction: column; align-items: stretch; gap: 8px;
}
.layout-card:hover { border-color: var(--accent); }
.layout-card.selected { border-color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-dim); }
.layout-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden; background: var(--surface-hover); color: var(--accent-text); }
.layout-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.layout-name { line-height: 1.25; }
.layout-picker { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 6px; }
.layout-picker .layout-gallery { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); margin-top: 0; }
.layout-preview-box { order: 2; position: sticky; top: 0; }
.layout-preview { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px; border: 1px solid var(--border); background: #0b1020; }
.layout-preview iframe { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; }
@media (max-width: 760px) { .layout-picker { grid-template-columns: 1fr; } .layout-preview-box { order: 0; position: static; } }
.wall-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 8px; align-items: center; }
@media (max-width: 520px) { .wall-row { grid-template-columns: 1fr auto; } .wall-row select { grid-column: 1 / -1; } }

.region-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.region-gallery-item {
    background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
    padding: 8px; text-align: center; cursor: pointer; font-size: 0.8rem; font-weight: 500;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.region-gallery-item:hover { border-color: var(--accent); }
.region-gallery-item.selected { border-color: var(--accent); background: var(--accent-dim); }
.region-thumb { display: flex; align-items: center; justify-content: center; width: 100%; height: 84px; padding: 6px; box-sizing: border-box; border-radius: 10px; overflow: hidden; background: var(--surface-hover); color: var(--accent-text); }
.fm-thumb { height: 100%; width: auto; max-width: 100%; fill: currentColor; fill-opacity: 0.75; stroke: var(--surface); stroke-width: 3; stroke-linejoin: round; }

.tabs {
    display: flex; gap: 4px; margin-bottom: 22px; padding: 4px; width: fit-content; max-width: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: 13px; overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
.tabs a { padding: 8px 15px; color: var(--text-muted); font-size: 0.88rem; font-weight: 550; border-radius: 9px; white-space: nowrap; }
.tabs a.active { background: var(--accent-dim); color: var(--accent-text); font-weight: 650; }
.tabs a:hover { text-decoration: none; color: var(--text); background: var(--surface-hover); }
.tabs a.active:hover { background: var(--accent-dim); color: var(--accent-text); }

.expiry-badge { font-size: 0.8rem; padding: 2px 7px; border-radius: 999px; background: var(--warning-bg); color: var(--warning); }
.expiry-badge.expired { background: var(--danger-bg); color: var(--danger); }

.picker-panel { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.picker-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; }
.picker-list .picker-folder, .picker-list .picker-media { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); font-size: 0.85rem; }
.picker-list .picker-folder:hover, .picker-list .picker-media:hover { background: var(--surface-hover); }
.picker-list .picker-media .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* Paramètres d'affichage repliables (page playlist) */
.settings-collapsible > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-collapsible > summary::-webkit-details-marker { display: none; }
.settings-collapsible[open] > summary { margin-bottom: 14px; }
.settings-collapsible-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.settings-collapsible-recap { font-size: 0.82rem; }
.settings-collapsible-toggle { display: inline-flex; align-items: center; gap: 6px; }
.settings-collapsible[open] .settings-collapsible-toggle { display: none; }

/* Sélecteur de médias en tuiles (page playlist) */
.media-add-tabs { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-hover); border-radius: var(--radius-sm); }
.media-add-tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: none; background: transparent; color: var(--text-dim); border-radius: var(--radius-sm); font-size: 0.85rem; cursor: pointer; }
.media-add-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.media-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; max-height: 420px; overflow-y: auto; padding: 2px; }
.media-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-decoration: none; transition: border-color 0.12s ease, background 0.12s ease; }
.media-tile:hover { border-color: var(--accent, var(--border)); background: var(--surface-hover); }
.media-tile-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-hover); color: var(--text-dim); }
.media-tile-folder .media-tile-icon { color: var(--accent, var(--text-dim)); }
.media-tile-name { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.media-tile-add { display: flex; gap: 4px; align-items: center; margin-top: auto; }
.media-tile-add select { font-size: 0.8rem; padding: 2px 4px; }
.media-webpage-form { max-width: 520px; }

.kiosk-downloads { display: flex; gap: 10px; flex-wrap: wrap; }

.color-swatch { width: 42px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); }

/* ---------- Fenêtres modales ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(8, 10, 16, 0.55);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
    animation: kd-fade 0.15s ease;
}
.modal-box {
    background: var(--bg-elevated); border-radius: var(--radius-lg); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg); max-width: 900px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 26px;
    animation: kd-pop 0.18s ease;
}
@keyframes kd-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kd-arrive { from { opacity: 0.4; } to { opacity: 1; } }
@keyframes kd-pop { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-close { float: right; background: var(--surface-hover); border: none; color: var(--text-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; width: 32px; height: 32px; padding: 0; border-radius: 50%; box-shadow: none; }
.modal-close:hover { color: var(--text); filter: none; background: var(--border); }

/* ---------- En-tête de page (fil d'ariane + icône) ---------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head-icon {
    display: flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
    background: linear-gradient(145deg, var(--accent-dim), color-mix(in srgb, var(--accent) 24%, var(--surface)));
    color: var(--accent-text);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}
.page-head h1 { margin: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.page-head .ph-section { text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; }
.page-head .ph-sep { color: var(--text-muted); font-weight: 400; }
.page-head .ph-current { color: var(--text); }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search-field { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.toolbar .search-field .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.toolbar .search-field input { padding-left: 34px; }
.toolbar-spacer { flex: 1; }

.btn-dashed {
    display: inline-flex; align-items: center; gap: 8px;
    background: transparent; border: 1.5px dashed var(--border); color: var(--text-muted);
    padding: 10px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; cursor: pointer; box-shadow: none;
}
.btn-dashed:hover { border-color: var(--accent); color: var(--accent-text); text-decoration: none; background: var(--accent-soft); filter: none; }

/* ---------- Arbre générique (sites, dossiers, utilisateurs...) ---------- */
.tree-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
.tree-panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); position: sticky; top: 84px; overflow: hidden;
}
.tree-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tree-panel-head h2 { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.tree-panel-search { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tree-panel-body { padding: 8px; max-height: 60vh; overflow-y: auto; }

.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-left: 18px; }
.tree-row {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 8px; border-radius: var(--radius-sm); font-size: 0.86rem; color: var(--text);
    cursor: pointer;
}
.tree-row:hover { background: var(--surface-hover); }
.tree-row.active { background: var(--accent-dim); font-weight: 600; }

.kdigit-drop-target.kdigit-drag-over { background: var(--accent-dim); outline: 2px dashed var(--accent); outline-offset: -2px; }
.data-table tbody tr[draggable="true"] { cursor: grab; }
.data-table tbody tr.kdigit-dragging { opacity: 0.4; }
.tree-row a { color: inherit; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row a:hover { text-decoration: none; }
.tree-toggle { background: none; border: none; color: var(--text-muted); padding: 2px; cursor: pointer; display: flex; flex-shrink: 0; }
.tree-toggle.leaf { visibility: hidden; }
.tree-toggle svg { transition: transform 0.12s ease; }
.tree-toggle.collapsed svg { transform: rotate(-90deg); }
.tree-row .icon { color: var(--text-muted); flex-shrink: 0; }
.tree-row .tree-badge { font-size: 0.8rem; color: var(--text-muted); background: var(--surface-hover); padding: 1px 7px; border-radius: 999px; flex-shrink: 0; }
.tree-children.collapsed { display: none; }
.tree details > summary { list-style: none; cursor: pointer; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary .tree-toggle { visibility: visible; }
.tree details > summary .tree-toggle svg { transition: transform 0.12s ease; }
.tree details:not([open]) > summary .tree-toggle svg { transform: rotate(-90deg); }
.tree li { list-style: none; }
.tree-panel-foot { display: flex; gap: 4px; padding: 8px; border-top: 1px solid var(--border); }
.tree-panel-foot button { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 7px; border-radius: var(--radius-sm); cursor: pointer; display: flex; }
.tree-panel-foot button:hover { color: var(--text); background: var(--surface-hover); }

.content-pane { min-width: 0; }

/* ---------- Tableau de données (statut, miniature, rail d'actions) ---------- */
.data-table thead th { white-space: nowrap; }
.data-table .dt-thumb { width: 52px; height: 52px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-hover); display: block; }
.data-table .dt-thumb-fallback {
    width: 52px; height: 52px; border-radius: var(--radius-sm); background: var(--surface-hover);
    display: flex; align-items: center; justify-content: center; color: var(--text-muted);
}
.data-table .dt-name { font-weight: 600; }

/* KDigit Studio : miniature vivante d'un visuel, choix d'orientation et fenêtre plein écran de l'éditeur (media.js) */
.data-table .studio-thumb { overflow: hidden; position: relative; background: #e2e8f0; }
.studio-thumb iframe { width: 100%; height: 100%; border: 0; pointer-events: none; display: block; }
.studio-orient-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.studio-orient { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 12px; border-radius: var(--radius-md, 12px); border: 1px solid var(--border, #d6dbe6);
    background: var(--surface-hover, #f4f6fa); color: inherit; cursor: pointer; text-align: center; }
.studio-orient:hover, .studio-orient:focus-visible { border-color: var(--accent); background: var(--accent-dim); }
.studio-orient-shape { display: block; border-radius: 6px; border: 3px solid var(--accent); background: var(--surface, #fff); margin-bottom: 6px; }
.studio-orient-shape.land { width: 128px; height: 72px; }
.studio-orient-shape.port { width: 72px; height: 128px; }
.studio-dialog { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0d1017; overflow: hidden; }
.studio-dialog::backdrop { background: #000; }
.studio-dialog iframe { width: 100%; height: 100%; border: 0; display: block; }
.data-table .dt-sub { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }
.data-table tr.dt-group-row td { background: var(--accent-dim); font-weight: 700; padding: 9px 8px; }
.data-table tr.dt-group-row .tree-row { background: transparent; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted); }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.status-dot.pending { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.status-pill .ts { color: var(--text-muted); font-size: 0.8rem; }

.action-rail { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    background: transparent; border: none; color: var(--text-muted); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn.accent:hover { background: var(--accent-dim); color: var(--accent-text); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn:disabled:hover { background: transparent; color: var(--text-muted); }

/* ---------- Galerie de widgets (dans une modale) ---------- */
.gallery-section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; margin: 18px 0 10px; }
.gallery-section-title:first-child { margin-top: 0; }

/* ---------- Segmented control (orientation, mode écran...) ---------- */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.segmented { position: relative; }
.segmented input:focus-visible + label { outline: 3px solid var(--accent-text); outline-offset: -3px; }
.segmented label {
    margin: 0; padding: 8px 14px; font-size: 0.85rem; font-weight: 500; color: var(--text-muted);
    cursor: pointer; display: flex; align-items: center; gap: 6px; background: var(--bg-elevated);
    border-right: 1px solid var(--border);
}
.segmented label:last-child { border-right: none; }
.segmented input:checked + label { background: var(--accent); color: var(--accent-contrast); }

.perm-grid { display: grid; grid-template-columns: 1fr repeat(3, 90px); gap: 4px 12px; align-items: center; }
.perm-grid .perm-head { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); text-align: center; }
.perm-grid .perm-section { font-size: 0.88rem; padding: 6px 0; }
.perm-grid label { display: flex; justify-content: center; margin: 0; }
.perm-grid input[type="radio"] { width: auto; }

/* Pastilles de couleurs d'accent proposées */
.accent-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.accent-chip { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.accent-chip:hover { transform: scale(1.12); filter: none; box-shadow: 0 0 0 2px var(--text-muted); }

input[type="file"] { padding: 7px 10px; }
input[type="file"]::file-selector-button {
    margin-right: 12px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface-hover); color: var(--text); font-weight: 600; font-family: inherit; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--accent-text); }

/* Boutons « discrets » : pas d'ombre/halo du bouton principal. */
.icon-btn, .tree-toggle, .tree-panel-foot button, .media-add-tab, .pw-toggle { box-shadow: none; }
.icon-btn:hover, .tree-toggle:hover, .tree-panel-foot button:hover, .media-add-tab:hover { filter: none; }
.tree-badge { font-size: 0.8rem; color: var(--text-muted); background: var(--surface-hover); padding: 2px 8px; border-radius: 999px; flex-shrink: 0; white-space: nowrap; }

/* ---------- Tableau de bord modulaire ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.dash-module { grid-column: span 12; min-width: 0; display: flex; flex-direction: column; position: relative; }
.dash-module[data-span="2"] { grid-column: span 2; }
.dash-module[data-span="3"] { grid-column: span 3; }
.dash-module[data-span="4"] { grid-column: span 4; }
.dash-module[data-span="5"] { grid-column: span 5; }
.dash-module[data-span="6"] { grid-column: span 6; }
.dash-module[data-span="7"] { grid-column: span 7; }
.dash-module[data-span="8"] { grid-column: span 8; }
.dash-module[data-span="9"] { grid-column: span 9; }
.dash-module[data-span="10"] { grid-column: span 10; }
/* Hauteur en lignes : un module haut occupe la place de plusieurs modules empilés à côté de lui ; « dense » comble les trous. */
.dash-grid { grid-auto-flow: row dense; }
.dash-module[data-rows="2"] { grid-row: span 2; }
.dash-module[data-rows="3"] { grid-row: span 3; }
/* Logo du système d'un player, menu d'aperçu, groupes par site, aperçu distant */
.os-logo { display: inline-flex; vertical-align: middle; color: var(--text-muted); }
.os-logo.os-android { color: #2f9e5f; }
.os-logo.os-raspberry { color: #c51a4a; }
.os-logo.os-windows { color: #1f7ae0; }
.modal-os { float: right; display: flex; align-items: center; height: 32px; margin-right: 12px; }
.site-row { display: inline-flex; align-items: center; gap: 8px; }
.menu-pop { position: relative; display: inline-flex; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 250px; padding: 6px; border-radius: var(--radius-sm); background: var(--bg-elevated);
    border: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 2px; text-align: left; }
.menu-list[hidden] { display: none; }
.menu-list a, .menu-list .menu-off { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 0.86rem; font-weight: 600; text-decoration: none; }
.menu-list a:hover { background: var(--surface-hover); text-decoration: none; }
.menu-list small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.76rem; }
.menu-list .menu-off { opacity: .5; cursor: not-allowed; }
.remote-cmd { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.remote-cmd code { flex: 1; min-width: 0; overflow-x: auto; padding: 5px 8px; border-radius: 7px; background: var(--surface-hover); border: 1px solid var(--border); font-size: 0.8rem; }
.watch-card { max-width: 980px; }
.watch-status { padding: 8px 12px; border-radius: 8px; background: var(--surface-hover); font-weight: 600; margin-bottom: 12px; }
.watch-status.on { background: var(--success-bg); color: var(--success); }
.watch-status.off { background: var(--danger-bg); color: var(--danger); }
.watch-frame { display: grid; place-items: center; min-height: 200px; border-radius: var(--radius-sm); background: #05070c; overflow: hidden; }
.watch-frame img { display: block; max-width: 100%; max-height: 70vh; }
.watch-empty { color: #94a0b8; padding: 40px 16px; text-align: center; }
.watch-now { margin: 12px 0; padding-left: 20px; }
.dash-rows-label { font-size: 0.72rem; color: var(--text-muted); min-width: 44px; text-align: center; }
.dash-module[data-hidden="1"] { display: none; }
.dash-module-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dash-module-body > * { flex: 1; min-width: 0; }
.dash-module .card, .dash-module .stat-card { margin-bottom: 0; }
.dash-module-body > .card, .dash-module-body > .stat-card, #pending-section > .card { height: 100%; }
.dash-module-body > #pending-section { display: flex; flex-direction: column; }
.dash-module-bar { display: none; }

.dash-editbar {
    display: flex; align-items: center; gap: 14px 22px; flex-wrap: wrap;
    padding: 14px 18px; margin-bottom: 20px; border-radius: var(--radius);
    background: linear-gradient(120deg, var(--accent-dim), color-mix(in srgb, var(--accent) 6%, var(--surface)));
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    animation: kd-fade 0.2s ease;
}
.dash-editbar[hidden] { display: none; }
.dash-editbar-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 320px; font-size: 0.84rem; color: var(--text-muted); }
.dash-editbar-text strong { color: var(--text); font-size: 0.92rem; }
.dash-editbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-hidden-tray { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
.dash-hidden-tray:empty { display: none; }
.dash-tray-label { font-size: 0.8rem; color: var(--text-muted); }

body.dash-editing .dash-module { outline: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 6px; border-radius: var(--radius); }
body.dash-editing .dash-module-bar {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 4px 6px 4px 4px;
    background: var(--accent-dim); border-radius: var(--radius-sm); color: var(--accent-text); font-size: 0.8rem; font-weight: 650;
}
body.dash-editing .dash-module-body { pointer-events: none; user-select: none; opacity: 0.8; }
body.dash-editing .dash-module.dragging { opacity: 0.35; }
.dash-grip { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 7px; cursor: grab; color: var(--accent-text); }
.dash-grip:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.dash-grip:active { cursor: grabbing; }
.dash-module-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-tools { display: inline-flex; align-items: center; gap: 1px; }
.dash-tools .icon-btn { width: 26px; height: 26px; color: var(--accent-text); }
.dash-tools .icon-btn:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-text); }
.dash-tools .icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.dash-tools .icon-btn[data-act="narrow"], .dash-tools .icon-btn[data-act="widen"] { font-size: 1.15rem; font-weight: 700; line-height: 1; padding: 0 0 2px; }
.dash-span-label { min-width: 34px; text-align: center; font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.dash-card h2 { margin-bottom: 12px; }
.dash-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dash-card-head h2 { margin: 0; }
.dash-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.dash-meter { height: 8px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; margin-bottom: 10px; }
.dash-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #fff)); }
.dash-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dash-list a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); color: var(--text); }
.dash-list a:hover { background: var(--surface-hover); text-decoration: none; }
.dash-list-icon { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--accent-dim); color: var(--accent-text); }
.dash-list-main { flex: 1; min-width: 0; font-size: 0.88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-list-main small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dash-shortcuts a {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); color: var(--text); font-size: 0.86rem; font-weight: 600;
}
.dash-shortcuts a .icon { color: var(--accent-text); }
.dash-shortcuts a:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.dash-empty { display: flex; align-items: center; gap: 14px; color: var(--success); }
.dash-empty > div { display: flex; flex-direction: column; color: var(--text-muted); font-size: 0.84rem; }
.dash-empty strong { color: var(--text); font-size: 0.95rem; }

@media (max-width: 1100px) {
    .dash-module[data-span="2"], .dash-module[data-span="3"], .dash-module[data-span="4"], .dash-module[data-span="5"] { grid-column: span 6; }
    .dash-module[data-span="7"], .dash-module[data-span="8"], .dash-module[data-span="9"], .dash-module[data-span="10"] { grid-column: span 12; }
    .dash-module[data-rows] { grid-row: auto; }
}
@media (max-width: 720px) {
    .dash-grid { gap: 14px; }
    .dash-module[data-span="4"], .dash-module[data-span="5"], .dash-module[data-span="6"] { grid-column: span 12; }
}
@media (max-width: 480px) {
    .dash-module[data-span="2"], .dash-module[data-span="3"] { grid-column: span 6; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .media-layout, .tree-layout { grid-template-columns: 1fr; }
    .media-tree, .tree-panel { position: static; }
    .picker-panel { grid-template-columns: 1fr; }

    /* La barre latérale devient un tiroir. */
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
    body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .app-body, body.sidebar-collapsed .app-body { margin-left: 0; }
    body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
    body.sidebar-collapsed .brand-name, body.sidebar-collapsed .nav-label, body.sidebar-collapsed .nav-section,
    body.sidebar-collapsed .user-meta { display: revert; }
    body.sidebar-collapsed .nav-link { justify-content: flex-start; padding: 10px 12px; }
    body.sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 0 20px; }
    .topbar { padding: 0 16px; }
}

@media (max-width: 720px) {
    .topbar-right .version-pill { display: none; }
    .grid-2 { grid-template-columns: 1fr; }
    .container { padding: 18px 16px 32px; }
    h1 { font-size: 1.35rem; }
    .card { padding: 16px; }
    .page-head-icon { width: 38px; height: 38px; }
    .perm-grid { grid-template-columns: 1fr repeat(3, 70px); font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
}
[data-studio-canvas-settings] label { margin: 0; white-space: nowrap; }

/* ==========================================================================
   Accessibilité, ergonomie tactile, préférences utilisateur (v1.5.0)
   ========================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link {
    position: absolute; left: 12px; top: -64px; z-index: 400; padding: 10px 16px;
    background: var(--accent); color: var(--on-accent); border-radius: var(--radius-sm); font-weight: 650;
}
.skip-link:focus { top: 12px; text-decoration: none; }

/* Carte utilisateur : l'avatar et le nom mènent à « Mes préférences » */
.user-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; border-radius: var(--radius-sm); }
.user-link:hover { text-decoration: none; }
.user-meta .user-name, .user-meta .user-role { display: block; }
a.theme-toggle { text-decoration: none; }
a.theme-toggle:hover { text-decoration: none; }
.nav-link .nav-label, .user-meta { overflow: hidden; text-overflow: ellipsis; }

/* Utilitaires (remplacent les styles en ligne les plus répétés) */
.text-sm { font-size: 0.85rem; }
.hint { font-size: 0.8rem; margin-top: 4px; }
.break-all { word-break: break-all; }
.mt-sm { margin-top: 10px; }
.mb-md { margin-bottom: 14px; }
.justify-end { justify-content: flex-end; }
.text-right { text-align: right; }
.pair-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pair-form input, .pair-form select { width: auto; min-width: 130px; flex: 1 1 130px; }
.pair-code { font-size: 1.1rem; }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 640px; }

/* Toasts et confirmation (ui.js) */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
    pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
    background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 0.9rem; animation: kd-pop 0.18s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast-close { margin-left: auto; background: none; border: none; box-shadow: none; color: var(--text-muted); padding: 0 4px; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.toast-close:hover { filter: none; color: var(--text); }
.confirm-box { max-width: 460px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* Page « Mes préférences » */
.pref-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.pref-fieldset { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.pref-fieldset > legend { font-size: 0.95rem; font-weight: 650; padding: 0; margin-bottom: 4px; }
.pref-fieldset > .text-dim { margin: 0 0 12px; font-size: 0.85rem; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.swatch { position: relative; display: block; margin: 0; }
.swatch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.swatch-face {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px;
    border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
    color: var(--text); font-size: 0.85rem; font-weight: 600;
}
.swatch-dot { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.swatch input:checked + .swatch-face { border-color: var(--accent-text); background: var(--accent-dim); }
.swatch input:focus-visible + .swatch-face { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.swatch:hover .swatch-face { border-color: var(--accent-text); }
.custom-color { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.custom-color input[type="color"] { width: 54px; height: 44px; padding: 3px; cursor: pointer; }
.custom-color input[type="text"] { width: 120px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.inherit-line { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 0.9rem; color: var(--text); }
.inherit-line input { width: 20px; height: 20px; }
.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.pref-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pref-preview { position: sticky; top: 84px; }
.pref-preview-body { display: flex; flex-direction: column; gap: 12px; }
.pref-preview-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.preset-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.preset-card h3 { margin: 0; font-size: 1rem; }
.preset-card p { margin: 0; font-size: 0.85rem; color: var(--text-muted); flex: 1; }
.preset-map { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-hover); }
.preset-map i { display: block; height: 16px; border-radius: 3px; background: var(--accent); opacity: 0.8; }
.preset-map i.more { opacity: 0.35; }
.pref-layout-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.pref-layout-list li { font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; background: var(--accent-dim); color: var(--accent-text); font-weight: 600; }
.pref-layout-list li.off { background: var(--surface-hover); color: var(--text-muted); text-decoration: line-through; }

/* Densité compacte : marges réduites (les zones de toucher de 44 px des écrans tactiles ne changent pas) */
html[data-density="compact"] .card { padding: 16px; margin-bottom: 14px; }
html[data-density="compact"] th, html[data-density="compact"] td { padding: 7px 8px; }
html[data-density="compact"] .container { padding: 18px 24px 28px; }
html[data-density="compact"] .nav-link { padding: 7px 12px; }
html[data-density="compact"] .dash-grid { gap: 14px; }
html[data-density="compact"] .stat-card { padding: 12px 14px; }
html[data-density="compact"] .field { margin-bottom: 12px; }
html[data-density="compact"] .page-head { margin-bottom: 16px; }
html[data-density="compact"] .app-footer { padding-top: 8px; }

/* Zoom d'interface : texte (unités rem), icônes et barre latérale suivent l'échelle choisie */
html[data-zoom="125"] { --ui-scale: 1.25; }
html[data-zoom="150"] { --ui-scale: 1.5; }
html[data-zoom="175"] { --ui-scale: 1.75; }
html[data-zoom] svg.icon { zoom: var(--ui-scale); }
html[data-zoom] .container { max-width: none; }
html[data-zoom] .sidebar-brand .brand-mark, html[data-zoom] .user-avatar { zoom: var(--ui-scale); }

/* Texte en gras : tout le texte de l'interface passe en gras (hiérarchie conservée par les tailles) */
html[data-weight="bold"] body, html[data-weight="bold"] body * { font-weight: 700 !important; }
html[data-weight="bold"] .text-dim, html[data-weight="bold"] .dt-sub { color: var(--text); }
html[data-weight="bold"] { --text-muted: var(--text); }

/* Mode daltonien : l'information ne repose jamais sur la couleur seule (forme + symbole en plus) */
html[data-cvd] .status-dot, html[data-cvd] .dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: none; }
html[data-cvd] .status-dot.online, html[data-cvd] .dot-online { background: var(--success); }
html[data-cvd] .status-dot.offline, html[data-cvd] .dot-offline { background: transparent; box-shadow: inset 0 0 0 2.5px var(--text-muted); }
html[data-cvd] .status-dot.pending { background: var(--warning); border-radius: 2px; transform: rotate(45deg); width: 9px; height: 9px; }
html[data-cvd] .status-dot.error { background: var(--danger); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
html[data-cvd] .badge::before, html[data-cvd] .expiry-badge::before { margin-right: 4px; font-weight: 800; }
html[data-cvd] .badge-active::before { content: "✓"; }
html[data-cvd] .badge-pending::before, html[data-cvd] .badge-suspended::before, html[data-cvd] .expiry-badge::before { content: "!"; }
html[data-cvd] .badge-expired::before, html[data-cvd] .expiry-badge.expired::before { content: "✕"; }
html[data-cvd] .badge-disabled::before { content: "–"; }
html[data-cvd] .flash::before, html[data-cvd] .license-banner::before { margin-right: 8px; font-weight: 800; }
html[data-cvd] .flash-success::before, html[data-cvd] .license-banner.ok::before { content: "✓"; }
html[data-cvd] .flash-error::before, html[data-cvd] .license-banner.error::before { content: "✕"; }
html[data-cvd] .license-banner.warn::before { content: "!"; }
html[data-cvd] .stat-icon.success { box-shadow: inset 0 0 0 2px var(--success); }
html[data-cvd] .stat-icon.warning { box-shadow: inset 0 0 0 2px var(--warning); border-radius: 6px; }

/* Animations réduites : préférence de l'utilisateur ou réglage du système */
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Écrans tactiles : cibles d'au moins 44 px */
@media (pointer: coarse) {
    button, .btn, .btn-secondary, .icon-btn, .sidebar-toggle, .theme-toggle, .nav-link, .tabs a, .media-add-tab, .tree-toggle, .modal-close { min-height: 44px; }
    .icon-btn, .sidebar-toggle, .theme-toggle, .tree-toggle, .modal-close { min-width: 44px; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="color"]), select { min-height: 44px; }
    input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
    .tree-row { min-height: 44px; }
    .tree-row a { align-self: stretch; display: flex; align-items: center; }
    .dash-list a, .dash-shortcuts a, .media-tile, summary, .picker-list .picker-folder, .picker-list .picker-media { min-height: 44px; }
    .tabs a { display: inline-flex; align-items: center; }
    .action-rail { flex-wrap: wrap; }
    .user-card .icon-btn { width: 44px; height: 44px; }
    .dash-module-bar { flex-wrap: wrap; }
    .accent-chip { width: 36px; height: 36px; }
}

/* Petits écrans : tableaux en cartes, fenêtres en feuille du bas, indicateurs 2 x 2 */
@media (max-width: 720px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody { display: block; }
    .data-table tr {
        display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 18px; position: relative;
        padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
    }
    .data-table td { display: block; border: 0; padding: 2px 0; background: none !important; }
    .data-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
    .data-table td[data-primary] { flex: 1 1 100%; font-weight: 600; padding-right: 28px; }
    .data-table td[data-dot] { position: absolute; right: 14px; top: 16px; padding: 0; }
    .data-table td.dt-wide { flex: 1 1 100%; }
    .data-table td[data-actions] { flex: 1 1 100%; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
    .data-table td[data-actions] .action-rail, .data-table td[data-actions] .justify-end { justify-content: flex-start; }
    .data-table tr.dt-group-row { padding: 9px 12px; }

    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-box { max-width: none !important; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
    .toasts { left: 16px; right: 16px; bottom: 12px; max-width: none; }
    .pref-layout { grid-template-columns: 1fr; }
    .pref-preview { position: static; }
}
@media (max-width: 480px) {
    .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
    .stat-card .stat-icon { width: 38px; height: 38px; }
    .stat-card .value { font-size: 1.5rem; }
    .swatches { grid-template-columns: repeat(2, 1fr); }
}

body.modal-open { overflow: hidden; }

svg.icon { flex-shrink: 0; }

@media (pointer: coarse) {
    .user-link, .tree-panel-foot button, .color-swatch { min-height: 44px; }
    .tree-panel-foot button, .color-swatch { min-width: 44px; }
    .accent-chip { width: 44px; height: 44px; }
    .app-footer a { display: inline-block; padding: 12px 8px; }
    a.text-dim, .dt-name a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ==========================================================================
   Pages Playlists, Médiathèque, Utilisateurs (v1.6.0)
   ========================================================================== */
[hidden] { display: none !important; }
.field-label { display: block; margin-bottom: 6px; font-size: 0.82rem; color: var(--text-muted); font-weight: 550; }
.page-head-flat { padding: 0; margin-bottom: 12px; border: none; }
.settings-collapsible-title h2 { display: inline; margin: 0; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.input-sm { width: 90px; }
.input-date { width: 155px; }
.input-zone { width: auto; min-width: 120px; font-size: 0.8rem; padding: 6px 8px; }
.input-filter { width: auto; min-width: 190px; }
.mt-xs { margin-top: 6px; }
.toolbar-tight { margin-bottom: 12px; }

/* Aperçus de la médiathèque : boutons (clavier) à la place des images cliquables */
.dt-thumb-btn { padding: 0; border: 0; background: transparent; box-shadow: none; border-radius: var(--radius-sm); cursor: zoom-in; display: block; }
.dt-thumb-btn:hover { filter: none; outline: 2px solid var(--accent); outline-offset: 1px; }
a.dt-thumb-fallback { color: var(--text-muted); }
a.dt-thumb-fallback:hover { color: var(--accent-text); text-decoration: none; }
.modal-preview { width: auto; max-width: 94vw; background: #000; border-color: #222; }
.modal-preview .modal-close { background: rgba(255, 255, 255, 0.14); color: #fff; }
.preview-title { color: #fff; font-weight: 600; text-align: center; margin: 0 44px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.preview-body img, .preview-body video { max-width: min(92vw, 100%); max-height: calc(100vh - 170px); object-fit: contain; display: block; }
.preview-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; }
.preview-bar .btn-sm.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }
.preview-stage { position: relative; overflow: hidden; background: #000; border-radius: var(--radius-sm); }
.preview-stage iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: #000; }

/* Galeries de services (boutons) */
button.service-tile, button.layout-card, button.region-gallery-item {
    font-family: inherit; color: var(--text); line-height: 1.3; width: 100%;
}
button.service-tile, button.layout-card { box-shadow: none; }
button.service-tile:hover, button.layout-card:hover, button.region-gallery-item:hover { filter: none; }

/* Droits des utilisateurs : une ligne par section */
.perm-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.perm-line:last-child { border-bottom: none; }
.perm-name { flex: 1 1 140px; font-weight: 600; font-size: 0.9rem; }
.perm-opt { display: inline-flex; align-items: center; gap: 7px; margin: 0; font-size: 0.85rem; color: var(--text); min-height: 32px; cursor: pointer; }
.perm-opt input { width: auto; }

/* Page d'installation du player (/agents) */
.agents-card { max-width: 700px; }
.agent-steps { margin: 8px 0 14px; padding-left: 20px; }
.agent-steps li { margin-bottom: 4px; }
.agent-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 12px; }
.agent-note { border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; padding: 8px 12px; margin: 10px 0; }
.agent-faq summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.agent-faq p { margin: 0 0 10px; }
.agents-back { margin-top: 18px; }

/* Diffuser une playlist : fenêtre d'attribution aux players */
.broadcast-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.broadcast-list li { border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 12px; }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 0; font-weight: 500; cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; }
.check-row small { display: block; font-weight: 400; font-size: 0.8rem; }
/* Fréquence de mise à jour des services (Paramètres → Intégrations) */
.freq-list { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
.freq-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 150px; gap: 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.freq-row:last-child { border-bottom: 0; }
.freq-row:hover { background: var(--surface-hover); }
.freq-label strong { display: block; font-size: 0.92rem; }
.freq-label small { display: block; color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.freq-control { display: flex; gap: 6px; align-items: center; }
.freq-control .freq-val { width: 90px; }
.freq-control .freq-unit { width: auto; min-width: 70px; }
.freq-default { color: var(--text-muted); font-size: 0.8rem; text-align: right; }
@media (max-width: 760px) { .freq-row { grid-template-columns: 1fr; gap: 8px; } .freq-default { text-align: left; } }
.module-row { align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.module-row.is-soon { opacity: .7; cursor: default; }
.module-icon { flex: none; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent-dim); color: var(--accent-text); }
.kv-list { margin: 0 0 8px; display: grid; gap: 8px; }
.kv-list > div { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv-list dt { color: var(--text-muted); font-size: 0.86rem; }
.kv-list dd { margin: 0; font-weight: 600; word-break: break-word; }
.check-group { display: flex; flex-wrap: wrap; gap: 0 22px; margin-bottom: 4px; }
.broadcast-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broadcast-note { margin: 0 0 8px 30px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Cadre Players du tableau de bord : état réel de diffusion (forme + texte, jamais la couleur seule) */
.players-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.players-head h2 { margin: 0; }
.players-count { font-size: 0.85rem; font-weight: 600; margin-left: 6px; }
.players-card .btn-sm { white-space: nowrap; }
.players-tools { display: flex; align-items: center; gap: 8px; }
.live-badge { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px; border-radius: 999px; font-size: 0.82rem; font-weight: 650; white-space: nowrap; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.live-playing { background: var(--success-bg); color: var(--success); }
.live-playing .live-dot { animation: liveRing 1.8s ease-out infinite; }
.live-standby { background: var(--warning-bg); color: var(--warning); }
.live-standby .live-dot { background: linear-gradient(90deg, currentColor 50%, transparent 50%); box-shadow: inset 0 0 0 2px currentColor; }
.live-offline, .live-disabled { background: var(--border); color: var(--text-muted); }
.live-offline .live-dot { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.live-disabled .live-dot { border-radius: 2px; }
@keyframes liveRing { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .live-playing .live-dot { animation: none; } }

/* Journal d'un player */
.logs-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.logs-box { max-height: 55vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); font-size: 0.85rem; }
.logs-box > p { padding: 14px; margin: 0; }
.log-row { display: grid; grid-template-columns: 9.5em 4.5em 4.5em 1fr; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--border); align-items: baseline; }
.log-row:last-child { border-bottom: 0; }
.log-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.log-level { font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
.log-info .log-level, .log-src { color: var(--text-muted); }
.log-src { font-size: 0.78rem; }
.log-warning .log-level { color: var(--warning); }
.log-error { background: var(--danger-bg); }
.log-error .log-level { color: var(--danger); }
.log-msg { overflow-wrap: anywhere; }
@media (max-width: 640px) { .log-row { grid-template-columns: 1fr auto; } .log-time { grid-column: 1 / -1; } .log-src { display: none; } }

/* Vue en direct d'un player */
/* Mise à jour du player : colorée quand une version plus récente est publiée, grisée sinon */
.icon-btn.update-idle { opacity: 0.45; }
.icon-btn.update-idle:hover { opacity: 1; }
.icon-btn.update-ready { position: relative; color: var(--accent-text); background: var(--accent-dim); }
.icon-btn.update-ready::after { content: ''; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px var(--surface); }

/* Les actions d'un player passent à la ligne sur un écran étroit au lieu de sortir du cadre */
.players-card .action-rail { flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; }

/* Propositions d'adresse (fiche du player) */
.addr-suggest { position: absolute; z-index: 5; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 260px; overflow: auto; }
.addr-suggest li { padding: 9px 11px; border-radius: 7px; cursor: pointer; }
.addr-suggest li:hover { background: var(--accent-dim); }
.details-grid .field, .field:has(> [data-city-suggest]), .field:has(> [data-address-pick]) { position: relative; }

/* Documentation (/wiki) */
.wiki-search { display: flex; gap: 8px; }
.wiki-search input { min-width: 220px; }
.wiki-group h2 { margin-top: 0; }
.wiki-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.wiki-list li { display: flex; flex-direction: column; gap: 2px; }
.wiki-list a { font-weight: 600; }
.wiki-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.wiki-nav { position: sticky; top: 16px; font-size: 0.9rem; }
.wiki-nav-title { margin: 14px 0 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.wiki-nav-title:first-child { margin-top: 0; }
.wiki-nav ul { list-style: none; margin: 0; padding: 0; }
.wiki-nav a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.wiki-nav a:hover { background: var(--surface-hover); }
.wiki-nav a.active { background: var(--accent-dim); color: var(--accent-text); font-weight: 600; }
.wiki-article h1 { margin-top: 0; }
.wiki-print { float: right; margin: 0 0 8px 12px; }
.print-head { display: none; }

/* Impression d'une page de la documentation : le texte seul, sur toute la largeur, avec un bandeau et des coupures de page propres (« Imprimer » ou PDF). */
@media print {
    @page { size: A4; margin: 16mm 15mm 18mm; }
    html, body { background: #fff !important; color: #111 !important; font-size: 11pt; }
    .sidebar, .sidebar-backdrop, .topbar, .app-footer, .wiki-nav, .wiki-toc, .no-print, .breadcrumb, .flash, .license-banner, .toasts { display: none !important; }
    .app-body { margin: 0 !important; animation: none !important; }
    .container, .app-main { max-width: none !important; padding: 0 !important; margin: 0 !important; }
    .wiki-layout { display: block; }
    .wiki-article.card { border: 0 !important; box-shadow: none !important; background: none !important; padding: 0 !important; }
    .print-head { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; margin-bottom: 14px; border-bottom: 2px solid #111; font-size: 9.5pt; color: #333; }
    .wiki-article h1 { font-size: 20pt; margin: 0 0 4pt; }
    .wiki-article > p.text-dim { color: #444 !important; font-size: 11pt; margin-top: 0; }
    .wiki-content { max-width: none; line-height: 1.5; }
    .wiki-content h2 { font-size: 14pt; border-top: 1px solid #999; margin-top: 16pt; break-after: avoid; page-break-after: avoid; }
    .wiki-content h3 { font-size: 12pt; break-after: avoid; page-break-after: avoid; }
    .wiki-content table, .wiki-content pre, .wiki-content blockquote, .wiki-content li { break-inside: avoid; page-break-inside: avoid; }
    .wiki-content table { width: 100%; border-collapse: collapse; font-size: 10pt; }
    .wiki-content th, .wiki-content td { border: 1px solid #888 !important; padding: 4pt 6pt; background: none !important; color: #111 !important; }
    .wiki-content pre, .wiki-content code { background: #f2f2f2 !important; color: #111 !important; border: 1px solid #ccc; font-size: 9.5pt; }
    .wiki-content pre { white-space: pre-wrap; padding: 6pt; }
    .wiki-content a { color: #111 !important; text-decoration: underline; }
    .wiki-content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #444; word-break: break-all; }
    .wiki-content a[href^="/"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #666; }
    img { max-width: 100% !important; break-inside: avoid; }
}
.wiki-toc { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 14px 0; background: var(--bg-elevated); font-size: 0.9rem; }
.wiki-toc ul { margin: 6px 0 0; padding-left: 18px; }
.wiki-content { line-height: 1.65; max-width: 78ch; }
.wiki-content h2 { margin: 1.6em 0 0.5em; padding-top: 0.4em; border-top: 1px solid var(--border); scroll-margin-top: 16px; }
.wiki-content h3 { margin: 1.3em 0 0.4em; scroll-margin-top: 16px; }
.wiki-content code { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 0.88em; }
.wiki-content pre { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; }
.wiki-content pre code { background: none; border: 0; padding: 0; }
.wiki-content blockquote { margin: 1em 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.wiki-content table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 0.92rem; display: block; overflow-x: auto; }
.wiki-content th, .wiki-content td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
@media (max-width: 860px) {
    .wiki-layout { grid-template-columns: 1fr; }
    .wiki-nav { position: static; }
    .wiki-search { width: 100%; }
    .wiki-search input { flex: 1; min-width: 0; }
}

@media (pointer: coarse) {
    a.dt-name { display: inline-flex; align-items: center; min-height: 44px; }
}

/* Paramètres → Caches et Notes de version */
.cache-bar { width: 100%; height: 10px; margin: 6px 0 14px; accent-color: var(--accent); }
.release-entry { border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 14px; margin-bottom: 10px; background: var(--bg-elevated); }
.release-entry > summary { cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.release-section { margin: 10px 0 2px; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.release-items { margin: 0 0 12px 18px; padding: 0; font-size: 0.9rem; line-height: 1.55; }

/* ---------- Programmation de diffusion ---------- */
.plan-status { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.plan-status > div { min-width: 0; }
.plan-status strong { display: block; }
.plan-default { margin-left: auto; font-size: 0.85rem; }
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.plan-side { display: grid; gap: 16px; }
.plan-cal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.plan-cal-head h2 { margin: 0; }
.plan-cal { display: grid; grid-template-columns: 48px repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; font-size: 0.78rem; user-select: none; -webkit-user-select: none; }
.plan-corner, .plan-dayhead { background: var(--surface-hover); border-bottom: 1px solid var(--border); padding: 7px 4px; text-align: center; font-weight: 650; }
.plan-dayhead { border-left: 1px solid var(--border); }
.plan-dayhead.today { color: var(--accent-text); background: var(--accent-dim); }
.plan-hours > div { height: var(--hour); border-top: 1px solid var(--border); position: relative; }
.plan-hours > div:first-child { border-top: 0; }
.plan-hours span { position: absolute; top: -0.6em; right: 6px; color: var(--text-muted); font-variant-numeric: tabular-nums; background: var(--surface); padding: 0 2px; }
.plan-hours > div:first-child span { display: none; }
.plan-col { position: relative; height: calc(24 * var(--hour)); border-left: 1px solid var(--border); touch-action: pan-y; cursor: crosshair;
    background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), var(--border) calc(var(--hour) - 1px), var(--border) var(--hour)); }
.plan-col.today { background-color: var(--accent-soft); }
.plan-block { position: absolute; display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; overflow: hidden; padding: 2px 5px;
    background: color-mix(in srgb, var(--c) 82%, #000 0%); color: #fff; border: 0; border-left: 3px solid color-mix(in srgb, var(--c) 55%, #000); border-radius: 5px;
    font: inherit; font-size: 0.74rem; line-height: 1.25; cursor: pointer; box-shadow: var(--shadow-sm); }
.plan-block strong { font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-block span { opacity: 0.9; font-variant-numeric: tabular-nums; }
.plan-block:hover { filter: brightness(1.08); }
.plan-block:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 1px; }
.plan-ghost { position: absolute; left: 2px; right: 2px; background: var(--accent-glow); border: 2px dashed var(--accent); border-radius: 5px; pointer-events: none; }
.plan-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); pointer-events: none; z-index: 2; }
.plan-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.plan-days { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.plan-day { margin: 0; }
.plan-day input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.plan-day span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 38px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 600; font-size: 0.85rem; cursor: pointer; background: var(--surface); color: var(--text); }
.plan-day input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.plan-day input:focus-visible + span { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.plan-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.plan-allday { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-weight: 500; cursor: pointer; }
.plan-allday input { width: 18px; height: 18px; margin: 0; }
.plan-adv { margin: 4px 0 14px; }
.plan-adv summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; padding: 4px 0; }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#plan-delete { margin-top: 12px; }
.plan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.plan-list li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.plan-list li:last-child { border-bottom: 0; }
.plan-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.plan-list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 0.85rem; }
.plan-list-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) { .plan-layout { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .plan-cal { grid-template-columns: 38px repeat(7, minmax(0, 1fr)); font-size: 0.7rem; } .plan-block span { display: none; } .plan-default { margin-left: 0; } }
@media (prefers-reduced-motion: reduce) { .plan-block { transition: none; } }

/* ---------- Tableau de bord : détails d'un player, choix redémarrer / éteindre ---------- */
.link-btn { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; box-shadow: none; min-height: 0; border-radius: 4px; }
.link-btn:hover { color: var(--accent-text); text-decoration: underline; filter: none; background: none; }
.link-btn:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.modal-lg { max-width: 980px; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 28px; margin-top: 14px; }
.details-grid section { min-width: 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.details-grid h3 { margin: 0 0 10px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr); gap: 7px 12px; margin: 0 0 8px; font-size: 0.86rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.meter { height: 6px; margin-top: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.copy-id { font-size: 1rem; font-weight: 700; letter-spacing: 0.04em; margin-right: 8px; }
.power-choices { display: grid; gap: 12px; margin-top: 14px; }
.power-choices form { margin: 0; }
.power-choice { display: grid; grid-template-columns: 28px 1fr; column-gap: 12px; align-items: center; width: 100%; text-align: left; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: none; cursor: pointer; }
.power-choice svg { grid-row: span 2; }
.power-choice strong { font-size: 0.98rem; }
.power-choice span { color: var(--text-muted); font-size: 0.82rem; font-weight: 400; }
.power-choice:hover { border-color: var(--accent); background: var(--accent-soft); filter: none; }
.power-choice.danger:hover { border-color: var(--danger); background: var(--danger-bg); }
@media (max-width: 800px) { .details-grid { grid-template-columns: 1fr; } .kv { grid-template-columns: minmax(0, 9em) minmax(0, 1fr); } }

/* Avancement de la mise à jour du logiciel d'un player */
.upd { margin-top: 6px; font-size: 0.78rem; color: var(--text-muted); max-width: 320px; }
.upd-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; color: var(--text); font-weight: 600; }
.upd-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.upd-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.4s ease; }
.upd-bar.upd-wait > span { background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: upd-slide 1.2s linear infinite; }
@keyframes upd-slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.upd-done { color: var(--success, #1f8a4c); }
.upd-error { color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .upd-bar.upd-wait > span { animation: none; background: var(--accent); opacity: 0.5; } .upd-bar > span { transition: none; } }

/* Alerte de stockage (tableau de bord) */
.storage-alert { display: flex; gap: 16px; align-items: flex-start; padding: 16px 20px; border-radius: var(--radius); border: 2px solid var(--danger); background: var(--danger-bg); color: var(--danger); }
.storage-alert strong { display: block; font-size: 1.1rem; font-weight: 800; }
.storage-alert p { margin: 4px 0 0; font-weight: 700; color: var(--danger); }
.storage-alert a { color: inherit; text-decoration: underline; }
.storage-alert-icon { flex-shrink: 0; margin-top: 2px; }
.storage-low { color: var(--danger); font-weight: 700; }
body:not(.dash-editing) .dash-module.is-calm { display: none; }

/* Sélecteurs de couleur des services connectés : une pastille cliquable de la hauteur des autres champs */
#widget-form .field input[type="color"] { width: 100%; height: 2.6rem; padding: 0.25rem; cursor: pointer; background: var(--surface-2, transparent); border: 1px solid var(--border); border-radius: var(--radius-sm); }
#widget-form .field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
#widget-form .field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: calc(var(--radius-sm) - 2px); }

/* Formulaire des horaires d'ouverture : un jour par ligne, trois plages */
#widget-form .oh-form { display: grid; gap: 0.4rem; }
#widget-form .oh-form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; }
#widget-form .oh-form-day { flex: 0 0 6rem; font-weight: 600; }
#widget-form .oh-form-range { display: inline-flex; align-items: center; gap: 0.3rem; }
#widget-form .oh-form-range input[type="time"] { width: 7.4rem; }

/* Mode intégré au Studio (/media?embed=studio) : seul l'assistant de service reste visible, sur fond transparent. */
html.kd-embed, html.kd-embed body { background: transparent !important; overflow: hidden; }
html.kd-embed body * { visibility: hidden; }
html.kd-embed #widget-modal, html.kd-embed #widget-modal *, html.kd-embed .flash { visibility: visible; }
html.kd-embed .flash { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 9999; max-width: 90vw; }
.watch-age { margin: 8px 0 0; }
.watch-age.stale { color: var(--danger); font-weight: 600; }

/* Droits d'accès (1.26.0) : éditeur de périmètre et page « Droits ». */
.scope-editor { display: grid; gap: 14px; margin-top: 8px; }
.scope-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; min-width: 0; }
.scope-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.scope-list { margin-top: 10px; max-height: 240px; overflow-y: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.scope-row { display: flex; align-items: center; gap: 8px; padding-top: 4px; padding-bottom: 4px; padding-right: 4px; font-size: 0.9rem; cursor: pointer; }
.scope-row input { margin: 0; }
.scope-sub { margin: 10px 0 2px; font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.perm-title { margin: 18px 0 4px; font-size: 0.95rem; }
.rights-intro { margin-bottom: 16px; }
.rights-intro p { margin: 0 0 6px; }

/* Mises en page : catalogue des modèles proposés (1.27.0). */
.tpl-catalog-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; }
.tpl-catalog-head > div:first-child { flex: 1 1 320px; min-width: 0; }
.tpl-search { flex: 0 1 260px; margin: 0; }
.tpl-group { margin-top: 22px; }
.tpl-group h3 { margin: 0 0 10px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0; color: var(--text-muted); }
.tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tpl-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); min-width: 0; }
.tpl-card[hidden], .tpl-group[hidden] { display: none; }
.tpl-card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tpl-card select { max-width: 100%; }
.tpl-presets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tpl-presets li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 0.88rem; }
.tpl-presets li:first-child { border-top: none; }
.tpl-presets li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tpl-presets img { border-radius: 4px; object-fit: cover; flex: none; }
.tpl-none { margin: 18px 0 0; }
