* { box-sizing: border-box; }
body { margin: 0; font-family: "Helvetica Neue", Arial, sans-serif; background: #12141a; color: #e8eaf0; }
h1, h2 { font-weight: 500; }
a { color: #7db4ff; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: #8b93a7; font-size: .9rem; }
.err { color: #ff6b6b; margin-top: 10px; min-height: 1em; }
.msg { color: #6fd08c; margin-left: 10px; font-size: .85rem; }
hr { border: none; border-top: 1px solid #2a2e3a; margin: 14px 0; }

/* Login */
.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { background: #1b1e27; padding: 36px; border-radius: 14px; width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.login-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-card input, .login-card button { width: 100%; padding: 12px; margin-top: 14px; border-radius: 8px; border: 1px solid #2a2e3a; background: #12141a; color: #fff; font-size: 1rem; }
.login-card button { background: #3a6df0; border: none; cursor: pointer; font-weight: 600; }

/* Layout */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background: #171a22; border-bottom: 1px solid #262a35; }
.brand { font-weight: 600; letter-spacing: .02em; }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.link { background: none; border: none; color: #7db4ff; cursor: pointer; font-size: .95rem; padding: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 24px; max-width: 1200px; margin: 0 auto; }
.panel { background: #1b1e27; border: 1px solid #262a35; border-radius: 12px; padding: 20px; }
.panel.wide { grid-column: 1 / -1; }
.panel h2 { margin: 0 0 8px; font-size: 1.1rem; }

/* Formulaire réglages */
#settings label { display: block; margin: 12px 0; font-size: .92rem; color: #c7ccda; }
#settings input[type=number] { width: 90px; margin-left: 8px; padding: 6px 8px; background: #12141a; border: 1px solid #2a2e3a; border-radius: 6px; color: #fff; }
#settings .switch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#settings .switch .hint { flex-basis: 100%; margin-left: 26px; color: #8b93a7; font-size: .76rem; line-height: 1.35; }
#settings button { margin-top: 14px; padding: 10px 18px; background: #3a6df0; border: none; border-radius: 8px; color: #fff; font-weight: 600; cursor: pointer; }

/* Programme */
.prog-list { display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow: auto; }
.prog-item { display: flex; align-items: center; gap: 12px; padding: 8px; background: #141721; border-radius: 8px; }
.prog-item img { width: 46px; height: 64px; object-fit: cover; border-radius: 4px; background: #333; }
.prog-item .info { flex: 1; min-width: 0; }
.prog-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog-item .sub { font-size: .8rem; color: #8b93a7; }
.fill-bar { height: 6px; background: #2a2e3a; border-radius: 3px; margin-top: 5px; overflow: hidden; }
.fill-bar > span { display: block; height: 100%; background: linear-gradient(90deg,#4caf50,#ffb300,#f44336); }
.prog-item .ctrl { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: .78rem; }
.prog-item .refresh-video { min-height: auto; flex: none; padding: 4px 8px; font-size: .74rem; margin-top: 2px; }
.prog-item input[type=range] { width: 90px; }
.excluded { opacity: .45; }
/* Auto plage horaire jeune public */
.aud-banner { padding: 8px 12px; border-radius: 8px; font-size: .82rem; font-weight: 600; margin-bottom: 10px; }
.aud-banner.aud-child { background: #23331f; border: 1px solid #4f8a3a; color: #b9e3a0; }
.aud-banner.aud-adult { background: #1c2436; border: 1px solid #3a5a8a; color: #a9c4ea; }
.prog-item.aud-muted { opacity: .5; filter: grayscale(.7); }
.aud-tag { font-size: .68rem; font-weight: 600; color: #f0b64c; background: rgba(240,182,76,.14); border-radius: 99px; padding: 1px 7px; margin-left: 6px; }
.prog-item.no-video, .prog-item.no-vertical { opacity: .55; filter: grayscale(.85); }
.prog-item.no-video .ctrl, .prog-item.no-vertical .ctrl { opacity: .65; }
.prog-item.no-video img, .prog-item.no-vertical img { filter: grayscale(1); }
.warn-video,
.warn-vert { color: #ffb066; font-weight: 600; }

/* Cartons */
#cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.card-tile { background: #141721; border: 1px solid #262a35; border-radius: 10px; padding: 14px; min-width: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-tile img { width: 100%; height: 136px; object-fit: contain; background: #0a0c11; border-radius: 8px; }
.card-tile label { display: block; font-size: .82rem; margin: 10px 0 4px; color: #c7ccda; font-weight: 600; }
.card-tile input, .card-tile select { width: 100%; max-width: 100%; min-height: 36px; padding: 7px 9px; background: #0f1218; border: 1px solid #2a2e3a; border-radius: 7px; color: #fff; font-size: .9rem; }
.card-tile .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; align-items: end; }
.card-tile .row > div { flex: 1 1 0; min-width: 0; }              /* laisse rétrécir les champs date/couleur */
.card-tile input[type=date] { font-size: .88rem; padding: 7px 9px; }
.card-tile .del { color: #ff8a8a; cursor: pointer; border: 0; background: transparent; padding: 4px 0 4px 8px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.card-tile .del:hover { color: #ffb3b3; }
.kind-badge { display: inline-flex; align-items: center; min-height: 26px; font-size: .74rem; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: #22262f; color: #9fb3d9; letter-spacing: .02em; }
.kind-badge.kind-text { color: #c9a8ff; }
.kind-badge.kind-video { color: #6fd0c8; }
.kind-badge.kind-image { color: #9fd06f; }
.tile-sep { border: none; border-top: 1px solid #262a35; margin: 12px 0 10px; }
.inline-check { margin-top: 8px !important; }
.card-tile .hint { margin: 6px 0 2px; }
.card-actions { display: flex; gap: 8px; margin: 10px 0 4px; }
.card-actions .btn-mini { flex: 1; min-height: 36px; padding: 7px 10px; border: 1px solid #2a2e3a; background: #22262f; color: #cfe0ff; border-radius: 7px; cursor: pointer; font-size: .86rem; font-weight: 700; }
.video-thumb { position: relative; width: 100%; height: 136px; border-radius: 8px; overflow: hidden; background: #0a0c11; }
.video-thumb video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

/* Deux emplacements (horizontal / vertical) côte à côte dans une tuile carton. */
.card-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card-slot { display: flex; flex-direction: column; gap: 6px; }
.card-slot label:first-child { margin: 0 0 2px; font-size: .72rem; color: #8b93a7; font-weight: 600; }
.card-slot img { width: 100%; height: 100px; object-fit: contain; background: #0a0c11; border-radius: 8px; }
.card-slot .video-thumb { height: 100px; }
.slot-empty { height: 100px; border-radius: 8px; border: 1px dashed #2a2e3a; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; font-size: .68rem; color: #565d6e; }
.slot-upload { width: 100%; justify-content: center; min-height: 32px !important; padding: 6px 8px !important; font-size: .76rem !important; }
@media (max-width: 420px) { .card-slots { grid-template-columns: 1fr; } }
.swatches { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.swatch { width: 26px; height: 22px; border-radius: 5px; border: 1px solid #333; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; }

/* Prévisualisation en modal */
.card-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.card-modal[hidden] { display: none; }
.cm-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 10, .78); backdrop-filter: blur(3px); }
.cm-frame { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.cm-stage { position: relative; width: min(88vw, 900px); aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.65); container-type: size; display: flex; align-items: center; justify-content: center; background: #000; }
.cm-frame.portrait .cm-stage { width: auto; height: min(80vh, 720px); aspect-ratio: 9 / 16; }
.cm-stage img, .cm-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.cm-stage.cover img, .cm-stage.cover video { object-fit: cover; }
.cm-buttons { display: flex; gap: 10px; }
.cm-buttons button { padding: 10px 18px; border-radius: 8px; border: none; cursor: pointer; font-size: .9rem; }
.cm-replay { background: #22262f; color: #cfe0ff; }
.cm-close { background: #3a6df0; color: #fff; }

/* Rendu du carton texte dans le modal (miroir de l'écran, en unités container) */
.cm-text { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3cqh; text-align: center; padding: 9cqmin; width: 100%; height: 100%; }
.cm-text .ct-title { font-size: 9cqmin; font-weight: 800; line-height: 1.06; }
.cm-text .ct-line { width: 14cqmin; height: 1.1cqmin; min-height: 3px; border-radius: 99px; background: currentColor; opacity: .8; transform-origin: center; }
.cm-text .ct-sub { font-size: 4cqmin; font-weight: 300; line-height: 1.4; opacity: .95; max-width: 78%; }
.cm-text .ct-sub:empty { display: none; }
.cm-text.anim-slide .ct-title { animation: ctUp .7s cubic-bezier(.2,.7,.2,1) .05s both; }
.cm-text.anim-slide .ct-line  { animation: ctLine .55s ease .40s both; }
.cm-text.anim-slide .ct-sub   { animation: ctUp .7s cubic-bezier(.2,.7,.2,1) .52s both; }
.cm-text.anim-fade .ct-title  { animation: ctFade .8s ease .05s both; }
.cm-text.anim-fade .ct-line   { animation: ctLine .55s ease .42s both; }
.cm-text.anim-fade .ct-sub    { animation: ctFade .8s ease .52s both; }
.cm-text.anim-zoom .ct-title  { animation: ctZoom .7s cubic-bezier(.2,.8,.2,1) .05s both; }
.cm-text.anim-zoom .ct-line   { animation: ctLine .55s ease .42s both; }
.cm-text.anim-zoom .ct-sub    { animation: ctZoom .7s cubic-bezier(.2,.8,.2,1) .52s both; }
@keyframes ctUp   { from { opacity: 0; transform: translateY(4cqh); } to { opacity: 1; transform: none; } }
@keyframes ctFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ctZoom { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: none; } }
@keyframes ctLine { from { opacity: 0; transform: scaleX(0); } to { opacity: .8; transform: none; } }
.card-add { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.card-add button, .card-add .file-btn { min-height: 40px; padding: 9px 16px; background: #3a6df0; border: none; border-radius: 8px; color: #fff; cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; }
.card-add .sep { color: #6b7386; font-size: .85rem; }
.text-preview { width: 100%; height: 136px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 12px; overflow: hidden; }
.text-preview .tp-title { font-weight: 700; font-size: .95rem; line-height: 1.1; }
.text-preview .tp-sub { font-size: .72rem; opacity: .9; margin-top: 4px; }
.card-tile input[type=color] { height: 34px; padding: 2px; }

/* Barre d'écrans */
.screens { border-color: #3a6df0; }
.backstage { border-color: #2c8a55; }
.backstage h2 span { font-size: .8rem; margin-left: 8px; }
.screens-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.screens-bar select { padding: 9px 12px; background: #0f1218; border: 1px solid #2a2e3a; border-radius: 8px; color: #fff; font-size: .95rem; min-width: 200px; }
.btn-sm { padding: 8px 12px; border: 1px solid #2a2e3a; background: #22262f; color: #cfe0ff; border-radius: 8px; cursor: pointer; font-size: .85rem; }
.btn-sm.danger { color: #ffb3b3; border-color: #5a2a2a; }
#settings select { margin-left: 8px; padding: 6px 8px; background: #12141a; border: 1px solid #2a2e3a; border-radius: 6px; color: #fff; }
.dlink-label { color: #9aa; font-size: .85rem; width: 100%; }
.screen-actions { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.card-screens { margin: 12px 0 8px; padding: 10px; border: 1px solid #262a35; border-radius: 8px; font-size: .8rem; color: #aeb6c6; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 10px; align-items: center; background: #11141c; }
.card-screens span { color: #c7ccda; font-weight: 700; }
.card-screens em { color: #6b7386; font-style: normal; font-size: .74rem; }
.card-screens label { display: inline-flex; align-items: center; gap: 7px; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-screens input { width: auto; min-height: auto; flex: 0 0 auto; }

/* Lien de diffusion */
.diffusion { border-color: #3a6df0; }
.dlink-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.dlink-row input { flex: 1; min-width: 240px; padding: 10px 12px; background: #0f1218; border: 1px solid #2a2e3a; border-radius: 8px; color: #fff; font-size: .95rem; font-family: monospace; }
.dlink-row button, .dlink-row a { padding: 10px 16px; border-radius: 8px; border: none; cursor: pointer; font-size: .9rem; text-decoration: none; }
.dlink-row button { background: #3a6df0; color: #fff; }
.dlink-row a { background: #2a2e3a; color: #cfe0ff; }

/* Diffusion en direct */
.nowplaying { padding: 12px 14px; background: #0f1218; border: 1px solid #262a35; border-radius: 8px; font-size: 1rem; }
.np-on { color: #6fd08c; font-weight: 600; }
.np-off { color: #ff9b6b; font-weight: 600; }

/* Aperçu */
.preview { display: flex; flex-wrap: wrap; gap: 8px; }
.pv { padding: 6px 10px; border-radius: 6px; font-size: .82rem; background: #141721; border: 1px solid #262a35; }
.pv.card { background: #2a2140; border-color: #453569; }

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; padding: 14px; }
  .panel { padding: 16px; }
  .card-add { grid-template-columns: 1fr; align-items: stretch; }
  .card-add .sep { text-align: center; }
}

@media (max-width: 420px) {
  .card-head { align-items: flex-start; flex-direction: column; }
  .card-tile .del { padding-left: 0; }
  .card-screens { grid-template-columns: 1fr; }
}
