:root {
  --bg: #0f1115;
  --bg-2: #161922;
  --bg-3: #1d212c;
  --bg-4: #262b38;
  --line: #2c3240;
  --text: #e8eaf0;
  --muted: #8a92a6;
  --accent: #ff6b35;
  --accent-2: #ff8c5a;
  --blue: #4dabf7;
  --green: #51cf66;
  --clip: #3b5bdb;
  --clip-video: #1c7ed6;
  --text-clip: #ae3ec9;
  --audio-clip: #2f9e44;
  --radius: 8px;
  font-family: "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 13px; overflow: hidden; }
body { display: grid; grid-template-rows: 52px 1fr auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--bg-3); border-radius: 6px; padding: 6px 12px; transition: background .12s, border-color .12s; }
button:hover { background: var(--bg-4); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--bg-3); }
button.icon { width: 34px; height: 32px; padding: 0; font-size: 16px; }
button.small { padding: 4px 10px; font-size: 12px; }
button.danger { color: #ff8787; }
input[type=text], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.35; }
input[type=color] { width: 40px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); padding: 2px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
select:focus, input:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Barre du haut */
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 15px; letter-spacing: .2px; white-space: nowrap; }
.brand-mark { color: var(--accent); }
.project-name { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; width: 240px; font-weight: 600; }
.project-name:hover { border-color: var(--line); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-actions select { width: auto; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* Espace de travail */
.workspace { display: grid; grid-template-columns: 300px 1fr 300px; min-height: 0; }
.left, .right { background: var(--bg-2); min-height: 0; display: flex; flex-direction: column; }
.left { border-right: 1px solid var(--line); }
.right { border-left: 1px solid var(--line); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; border: none; padding: 7px 4px; color: var(--muted); font-weight: 600; }
.tabs button.active { background: var(--bg-4); color: var(--text); }
.panel, .inspector { overflow-y: auto; padding: 12px; flex: 1; }
.inspector-title { padding: 12px 14px; font-weight: 700; border-bottom: 1px solid var(--line); }

.panel h3, .inspector h3 { margin: 14px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.panel h3:first-child, .inspector h3:first-child { margin-top: 0; }
.field { margin-bottom: 10px; }
.field > label { display: block; color: var(--muted); margin-bottom: 4px; font-size: 12px; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row > * { flex: 1; }
.field-row > input[type=color] { flex: 0 0 40px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.range-val { min-width: 42px; text-align: right; color: var(--muted); flex: 0 0 auto !important; font-variant-numeric: tabular-nums; }

.media-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.media-item { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line); cursor: pointer; }
.media-item:hover { border-color: var(--accent); }
.media-item .badge { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.65); padding: 1px 6px; border-radius: 4px; font-size: 11px; }
.media-item .name { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px; font-size: 11px; background: linear-gradient(transparent, rgba(0,0,0,.8)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item .add { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; padding: 0; border-radius: 50%; background: var(--accent); border: none; color: #fff; font-weight: 700; opacity: 0; }
.media-item:hover .add { opacity: 1; }
.media-item video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.btn-block { width: 100%; margin-bottom: 10px; }

.cards { display: grid; gap: 8px; }
.card { text-align: left; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-3); border: 1px solid var(--line); }
.card:hover { border-color: var(--accent); }
.card strong { display: block; margin-bottom: 2px; }
.card span { color: var(--muted); font-size: 12px; }
.card.active { border-color: var(--accent); background: #2a1d17; }
.text-preset { font-size: 14px; }

.hint { background: var(--bg-3); border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px; color: var(--muted); line-height: 1.45; }

/* Scène d'aperçu */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #0a0b0e; }
.preview-wrap { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 16px; }
.preview-wrap.drop { outline: 2px dashed var(--accent); outline-offset: -10px; }
#preview { background: #000; box-shadow: 0 10px 40px rgba(0,0,0,.6); border-radius: 4px; }
.empty-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; gap: 6px; background: #0a0b0e; }
.empty-hint h2 { margin: 6px 0 2px; }
.empty-hint p { max-width: 420px; line-height: 1.5; margin: 4px 0; }
.empty-icon { font-size: 44px; }
.transport { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); background: var(--bg-2); }
.transport .play { background: var(--accent); border-color: var(--accent); color: #fff; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); }
.time #time-cur { color: var(--text); }
.format-label { margin-left: auto; color: var(--muted); }

/* Timeline */
.timeline-area { background: var(--bg-2); border-top: 1px solid var(--line); }
.timeline-toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.zoom { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.zoom input { width: 140px; }
.timeline { display: grid; grid-template-columns: 90px 1fr; height: 230px; }
.track-labels { border-right: 1px solid var(--line); }
.ruler-label { height: 24px; border-bottom: 1px solid var(--line); }
.track-label { height: 62px; display: flex; align-items: center; padding: 0 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
.tracks-scroll { overflow-x: auto; overflow-y: hidden; position: relative; }
.tracks { position: relative; min-width: 100%; }
.ruler { height: 24px; border-bottom: 1px solid var(--line); position: relative; cursor: pointer; background: var(--bg-2); }
.ruler .tick { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line); padding-left: 4px; font-size: 10px; color: var(--muted); line-height: 24px; }
.ruler .tick.minor { height: 30%; top: 70%; }
.track { height: 62px; position: relative; border-bottom: 1px solid var(--line); }
.block { position: absolute; top: 6px; height: 50px; border-radius: 6px; overflow: hidden; cursor: grab; border: 2px solid transparent; user-select: none; }
.block.selected { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,107,53,.6); }
.block.dragging { opacity: .75; cursor: grabbing; z-index: 5; }
.block .label { position: absolute; left: 6px; right: 10px; bottom: 3px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.block .handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; background: rgba(255,255,255,.12); }
.block .handle.r { right: 0; }
.block .handle.l { left: 0; }
.block.clip { background: var(--clip) center/cover; }
.block.clip.video { background-color: var(--clip-video); }
.block.clip::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(0,0,0,.65)); pointer-events: none; }
.block.clip .label { z-index: 1; }
.block.text { background: var(--text-clip); height: 22px; top: 4px; }
.block.text .label { bottom: 3px; }
.block.audio { background: repeating-linear-gradient(90deg, #2b8a3e 0 3px, #37b24d 3px 6px); }
.transition-dot { position: absolute; top: 22px; width: 18px; height: 18px; margin-left: -9px; transform: rotate(45deg); background: #fff; border: 2px solid var(--accent); border-radius: 3px; z-index: 4; cursor: pointer; }
.transition-dot.none { background: var(--bg-4); border-color: var(--muted); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; z-index: 10; }
.playhead span { position: absolute; top: 0; left: -6px; width: 14px; height: 14px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.drop-marker { position: absolute; top: 2px; bottom: 2px; width: 3px; background: var(--accent); z-index: 6; }
.track-empty { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }

/* Fenêtre d'export */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { width: 460px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-card h2 { margin: 0 0 16px; }
.modal-card .row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.progress { height: 10px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffd43b); transition: width .15s; }

.toast { position: fixed; bottom: 260px; left: 50%; transform: translateX(-50%); background: var(--bg-4); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.5); }

/* Calques */
.layer-list { display: grid; gap: 4px; margin: 6px 0; }
.layer-row { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 6px; background: var(--bg-3); border: 1px solid var(--line); cursor: pointer; }
.layer-row:hover { border-color: var(--accent); }
.layer-row.active { border-color: var(--accent); background: #2a1d17; }
.layer-ico { width: 20px; text-align: center; color: var(--accent); font-weight: 700; }
.layer-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.icon.mini { width: 22px; height: 22px; font-size: 10px; padding: 0; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter.ttf') format('truetype'); font-weight: 100 900; }
@font-face { font-family: 'Montserrat'; src: url('../fonts/Montserrat.ttf') format('truetype'); font-weight: 100 900; }
.media-item.picked { border: 2px solid var(--accent); box-shadow: 0 0 0 2px rgba(255,107,53,.35); }
.pick-grid { grid-template-columns: repeat(3, 1fr); }

/* En-tête et pied de page TAKE-TECH */
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 26px; height: 26px; }
body { grid-template-rows: 52px 1fr auto 34px; }
.app-footer { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 14px;
  background: linear-gradient(90deg, #12141a, #1a1d26 50%, #12141a); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.app-footer strong { color: var(--text); }
.app-footer .f-left { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; }
.app-footer .f-left img { width: 20px; height: 20px; }
.app-footer .f-sep { width: 1px; height: 14px; background: var(--line); }
.app-footer .f-center { text-align: center; white-space: nowrap; }
.app-footer .f-center strong { color: var(--accent); letter-spacing: .4px; }
.app-footer .f-right { justify-self: end; }
.f-link { background: transparent; border: 1px solid transparent; color: var(--accent); padding: 3px 10px; font-weight: 600; }
.f-link:hover { border-color: var(--accent); background: rgba(255,107,53,.08); }
#app-version { color: var(--muted); font-weight: 400; }

/* Bibliothèque de polices */
.font-btn { width: 100%; text-align: left; font-size: 16px; padding: 7px 10px; background: var(--bg); }
.font-pop { position: fixed; z-index: 70; width: 330px; display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 50px rgba(0,0,0,.6); }
.font-cats { display: flex; flex-wrap: wrap; gap: 4px; }
.font-cats button { padding: 3px 8px; font-size: 11px; background: var(--bg-3); }
.font-cats button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.font-list { overflow-y: auto; flex: 1; display: grid; gap: 4px; align-content: start; }
.font-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 8px 10px; background: var(--bg-3); }
.font-item.active { border-color: var(--accent); background: #2a1d17; }
.font-prev { font-size: 20px; line-height: 1.2; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.font-name { font-size: 11px; color: var(--muted); }

/* Piste des calques */
.block.layer { height: 20px; top: 4px; background: linear-gradient(90deg, #e8590c, #ff8c5a); }
.block.layer .label { bottom: 2px; font-size: 10.5px; }
.block.layer.muted-layer { opacity: .4; }
.block.audio .handle { z-index: 2; }
.layer-zone { position: absolute; top: 0; bottom: 0; background: rgba(255,107,53,.06); border-left: 1px dashed rgba(255,107,53,.4); border-right: 1px dashed rgba(255,107,53,.4); }

/* Fenêtre de fermeture (charte Gesti-Motion : fond sombre, accent orange, logo TT) */
.modal { animation: modal-fade .18s ease-out; backdrop-filter: blur(3px); }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes card-pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.close-card { width: 500px; padding: 0; overflow: hidden; border-top: 3px solid var(--accent); animation: card-pop .22s cubic-bezier(.2,.9,.3,1.2); }
.close-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px 14px; background: linear-gradient(180deg, #1d212c, var(--bg-2)); border-bottom: 1px solid var(--line); }
.close-head img { width: 42px; height: 42px; }
.close-head h2 { margin: 0; font-size: 18px; }
.close-sub { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.close-body { display: flex; gap: 14px; align-items: flex-start; padding: 18px 22px 4px; }
.close-body p { margin: 0; line-height: 1.55; color: var(--text); }
.close-icon { flex: 0 0 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  color: var(--accent); background: rgba(255,107,53,.12); border: 1px solid rgba(255,107,53,.45); }
.close-warn { margin: 10px 22px 0 68px; padding: 8px 10px; border-radius: 6px; background: rgba(255,212,59,.1); border: 1px solid rgba(255,212,59,.35); color: #ffd43b; font-size: 12px; }
.close-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; }
button.danger-outline { background: transparent; border-color: rgba(255,135,135,.6); color: #ff8787; }
button.danger-outline:hover { background: rgba(255,135,135,.1); }

/* ===== Charte DesiDecor (surcharge de la charte Gesti-Motion) ===== */
:root {
  --bg: #07080f; --bg-2: #0e0f1b; --bg-3: #161829; --bg-4: #1f2238; --line: #262a44;
  --text: #f1f1f8; --muted: #9a9cb8; --accent: #ff4f7b; --accent-2: #ff7a3d;
  --grad: linear-gradient(100deg, #ff9a52, #ff7a3d 25%, #ff3d7f 60%, #a24dff);
  font-family: 'Manrope', 'Inter', 'Segoe UI', system-ui, sans-serif;
}
button.primary, a.primary { background: var(--grad); border: 0; color: #fff; font-weight: 700; box-shadow: 0 8px 24px rgba(255, 61, 127, .3); }
button.primary:hover, a.primary:hover { filter: brightness(1.08); background: var(--grad); }
.btn-link { display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 6px; text-decoration: none; }
.topbar { background: rgba(14, 15, 27, .92); }
.brand { text-decoration: none; color: var(--text); }
.brand span b { background: linear-gradient(90deg, #ff4f8b, #a24dff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand em { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 2px 7px; border-radius: 999px; }
.brand-logo { width: 32px !important; height: 28px !important; }
.token-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--text);
  background: linear-gradient(135deg, rgba(255,122,61,.18), rgba(162,77,255,.18)); border: 1px solid rgba(255,79,123,.45); font-size: 12.5px; white-space: nowrap; }
.token-pill b { font-size: 15px; }
.token-pill.empty { border-color: #ff8787; color: #ffb3b3; }
.account-link { color: var(--text); text-decoration: none; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.account-link:hover { background: var(--bg-3); }
.tabs button.active { background: var(--grad); color: #fff; }
.card.active, .layer-row.active { border-color: var(--accent); background: rgba(255, 61, 127, .1); }
.empty-logo { width: 84px; margin-bottom: 6px; }
.exp-cost { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.exp-cost b { color: #ffd0bd; }
.close-card { border-top-color: var(--accent); }
.proj-list { max-height: 50vh; overflow-y: auto; padding: 8px 14px; }
.proj-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.proj-row b { display: block; }
.proj-row span { font-size: 12px; }
.app-footer .f-center strong { color: #ff7a9b; }
.small-screen { display: none; }
@media (max-width: 1100px) {
  .small-screen { display: flex; position: fixed; inset: 0; z-index: 100; background: var(--bg); flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; gap: 8px; }
  .small-screen img { width: 90px; }
  .small-screen a { padding: 12px 22px; border-radius: 999px; text-decoration: none; margin-top: 10px; }
}
