:root {
  --bg: #1e2024;
  --panel: #2b2f34;
  --panel-2: #33383e;
  --panel-3: #3c424a;
  --line: #14161a;
  --line-soft: #454c54;
  --accent: #1fb6ad;      /* teal accent */
  --accent-2: #2aa9e0;
  --warn: #f0a500;
  --text: #d8dde2;
  --muted: #8b939c;
  --key: #1fb6ad;
  --key-bone: #2aa9e0;
  --tween: #1fb6ad44;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif; font-size: 13px;
  background: var(--bg); color: var(--text); user-select: none;
}

button {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 8px; cursor: pointer; font-size: 12px;
}
button:hover { background: var(--panel-3); }
button:active { transform: translateY(1px); }
input[type="text"], input[type="number"], select {
  background: #15171a; color: var(--text);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 3px 6px; width: 100%; font-size: 12px;
}
input[type="number"] { width: 60px; }
.muted { color: var(--muted); font-size: 12px; }

body { display: flex; flex-direction: column; }

/* ===== Barre de menus ===== */
#topmenu {
  flex: 0 0 auto; display: flex; align-items: center; gap: 14px;
  background: linear-gradient(#34393f, #2a2e33);
  border-bottom: 1px solid var(--line); padding: 0 12px; height: 30px;
}
.brand { font-weight: 700; letter-spacing: .4px; font-size: 13px; color: #eef1f3; display: flex; align-items: baseline; gap: 7px; }
.tagline { font-weight: 400; font-size: 10px; letter-spacing: .3px; color: var(--muted); text-transform: lowercase; }
#menus { display: flex; height: 100%; }
.menu {
  position: relative; display: flex; align-items: center;
  padding: 0 10px; height: 100%; cursor: default; color: var(--text); font-size: 12.5px;
}
.menu:hover, .menu.open { background: var(--panel-3); }
.dropdown {
  display: none; position: absolute; top: 100%; left: 0; z-index: 40;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 0 0 6px 6px; min-width: 200px; padding: 4px;
  box-shadow: 0 8px 24px #0009;
}
.menu.open .dropdown { display: block; }
.mi {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  width: 100%; text-align: left; background: none;
  border: none; padding: 6px 10px; border-radius: 4px; font-size: 12.5px;
}
.mi:hover { background: var(--accent); color: #06201e; }
.mi-key { color: var(--muted); font-size: 11px; }
.mi:hover .mi-key { color: #06201e; }
.mi-sep { height: 1px; background: var(--line-soft); margin: 4px 6px; }

/* ===== Barre d'options d'outil ===== */
#tool-options {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  height: 30px; padding: 0 12px; font-size: 12.5px;
}
#tool-name { font-weight: 600; color: var(--accent); }
.to-sep { width: 1px; height: 18px; background: var(--line-soft); }
#tool-opts { display: flex; align-items: center; gap: 8px; }
#tool-opts .to-label { color: var(--muted); font-size: 11.5px; }
#tool-opts .to-range { width: 90px; }
#tool-opts .to-num { width: 48px; }
#tool-opts .to-check { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text); }
#tool-opts:empty + #tool-hint { margin-left: 0; }
#tool-opts:not(:empty) + #tool-hint { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line-soft); }

#app { flex: 1 1 auto; display: flex; min-height: 0; }

/* ===== Séparateurs redimensionnables ===== */
.splitter { background: var(--line); flex: 0 0 5px; z-index: 5; }
.splitter:hover, .splitter.dragging { background: var(--accent); }
.splitter-v { cursor: col-resize; align-self: stretch; }
.splitter-h { cursor: row-resize; }

/* ===== Boîte à outils (2 colonnes) ===== */
#toolbar {
  flex: 0 0 auto; background: var(--panel);
  border-right: 1px solid var(--line); padding: 8px 6px;
}
.tool-grid {
  display: grid; grid-template-columns: repeat(2, 32px); gap: 4px;
}
.tool {
  width: 32px; height: 32px; font-size: 15px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2);
}
.tool.active { outline: 2px solid var(--accent); background: #16403d; }

/* ===== Scène ===== */
#stage-wrap { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
#stage-scroll {
  flex: 1 1 auto; overflow: auto; display: flex;
  align-items: center; justify-content: center;
  background:
    linear-gradient(45deg, #191b1e 25%, transparent 25%) 0 0/22px 22px,
    linear-gradient(-45deg, #191b1e 25%, transparent 25%) 0 0/22px 22px,
    linear-gradient(45deg, transparent 75%, #191b1e 75%) 0 0/22px 22px,
    linear-gradient(-45deg, transparent 75%, #191b1e 75%) 0 0/22px 22px,
    #232629;
}
#stage { background: #fff; box-shadow: 0 0 0 1px #000, 0 10px 34px #000a; cursor: crosshair; touch-action: none; }
#stage-info {
  flex: 0 0 auto; display: flex; justify-content: space-between;
  padding: 4px 12px; font-size: 12px; color: var(--muted);
  background: var(--panel); border-top: 1px solid var(--line);
}

/* ===== Panneau de droite ===== */
#right-panel {
  flex: 0 0 256px; background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; font-weight: 600; font-size: 12.5px; color: #cfd6dc;
  background: linear-gradient(#363b41, #2d3137); border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line);
}
.panel-head button { padding: 1px 7px; font-size: 12px; }

/* Style panel */
#style-panel { padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.swatches { display: flex; gap: 8px; width: 100%; }
.target-swatch {
  flex: 1; display: flex; align-items: center; gap: 6px; justify-content: center;
  padding: 5px; background: var(--panel-2); border: 1px solid var(--line);
}
.target-swatch.active { outline: 2px solid var(--accent); }
.sw-label { font-size: 11px; color: var(--muted); }
.sw-color { width: 18px; height: 18px; border-radius: 3px; border: 1px solid #000; display: inline-block; }
#color-wheel { cursor: crosshair; touch-action: none; }
.color-fields { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.hex-field { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.hex-field input { flex: 1; text-transform: uppercase; }
.rgb-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.rgb-row label { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.rgb-row input { width: 100%; padding: 2px 4px; }
#swatch-row { width: 100%; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
#swatch-row .sw {
  width: 100%; aspect-ratio: 1; border-radius: 3px; cursor: pointer;
  border: 1px solid #0006;
}
#swatch-row .sw:hover { outline: 2px solid var(--accent); }
.width-row { width: 100%; display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.width-row input { flex: 1; }
#brush-size-val { width: 18px; text-align: right; color: var(--text); }

/* Calques */
#layers-list { list-style: none; margin: 0; padding: 4px; overflow: auto; flex: 1 1 auto; min-height: 60px; }
.layer-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 4px; cursor: pointer; font-size: 12.5px;
}
.layer-item:hover { background: var(--panel-2); }
.layer-item.selected { background: #16403d; outline: 1px solid var(--accent); }
.layer-item .tri { width: 12px; text-align: center; font-size: 9px; color: var(--muted); cursor: pointer; }
.layer-item .tri:hover { color: var(--text); }
.layer-item .tri-spacer { width: 12px; display: inline-block; }
.layer-item .vis { cursor: pointer; width: 16px; text-align: center; }
.layer-item .lock { cursor: pointer; width: 16px; text-align: center; font-size: 11px; opacity: .85; }
.layer-item .lock:hover { opacity: 1; }
.rename-input { flex: 1 1 auto; font-size: 12.5px; padding: 1px 4px; }
.op-row { flex-direction: row !important; align-items: center; gap: 6px !important; }
.op-row input { flex: 1; }
#prop-opacity-val { width: 38px; text-align: right; color: var(--text); }
.layer-item .type-badge { font-size: 11px; }
.layer-item .lname { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#layer-props { padding: 10px; display: flex; flex-direction: column; gap: 7px; font-size: 11.5px; }
#layer-props label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); }
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.prop-grid input { width: 100%; }
.check { flex-direction: row !important; align-items: center; gap: 6px !important; }

/* ===== Dopesheet / Timeline ===== */
#timeline {
  flex: 0 0 210px; background: var(--panel);
  border-top: 1px solid var(--line-soft); display: flex; flex-direction: column;
}
#transport {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
  background: linear-gradient(#33383e, #2c3036);
}
#transport button { min-width: 26px; }
#transport .fps { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.sep { width: 1px; height: 20px; background: var(--line-soft); margin: 0 3px; }
#track-area { flex: 1 1 auto; display: flex; min-height: 0; }
#track-labels { flex: 0 0 150px; border-right: 1px solid var(--line); overflow: hidden; background: var(--panel-2); }
.track-label {
  height: 26px; display: flex; align-items: center; padding: 0 10px;
  font-size: 12px; border-bottom: 1px solid var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.track-label.selected { background: #16403d; color: #eafffd; }
#track-grid-wrap { flex: 1 1 auto; position: relative; overflow: auto; }
#ruler {
  height: 22px; position: sticky; top: 0; z-index: 3;
  background: var(--panel-2); border-bottom: 1px solid var(--line); display: flex;
}
.ruler-cell {
  flex: 0 0 var(--cw,18px); text-align: center; font-size: 9px; color: var(--muted);
  border-right: 1px solid #00000030; line-height: 22px;
}
.ruler-cell.tens { color: var(--text); border-right-color: var(--line-soft); }
#tracks { position: relative; }
.track-row { height: 26px; display: flex; border-bottom: 1px solid var(--line); position: relative; }
.track-row.selected { background: #1fb6ad12; }
.track-cell { flex: 0 0 var(--cw,18px); border-right: 1px solid #00000020; cursor: pointer; position: relative; }
.track-cell:hover { background: #ffffff10; }
.keyframe {
  position: absolute; top: 50%; left: 50%;
  width: 10px; height: 10px; transform: translate(-50%,-50%) rotate(45deg);
  background: var(--key); border: 1px solid #06201e;
}
.keyframe { cursor: grab; }
.keyframe.cur { box-shadow: 0 0 0 2px #ffffff66; }
.keyframe.sel { background: #ffffff; border-color: var(--accent); box-shadow: 0 0 7px var(--accent); }
.keyframe.bone { width: 8px; height: 8px; top: 72%; background: var(--key-bone); }
.keyframe.point { width: 8px; height: 8px; top: 28%; background: #ffb020; border-color: #5a3a00; }
.tween-bar { position: absolute; top: 50%; height: 4px; transform: translateY(-50%); background: var(--tween); }
.cell-span { position: absolute; top: 3px; height: 6px; background: #2aa9e033; border-left: 2px solid var(--accent-2); border-radius: 2px; }
.cell-marker { position: absolute; top: 2px; width: 8px; height: 8px; background: var(--accent-2); border: 1px solid #06283a; border-radius: 2px; }
#playhead {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--warn); z-index: 4; pointer-events: none; box-shadow: 0 0 6px var(--warn);
}

/* ===== Overlays / modales ===== */
#export-overlay, #help-modal, #about-modal {
  position: fixed; inset: 0; background: #000a; z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
#export-overlay[hidden], #help-modal[hidden], #about-modal[hidden] { display: none; }
.export-card, .help-card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 22px 26px;
}
.export-card { min-width: 280px; text-align: center; }
.export-card .bar { margin-top: 12px; height: 8px; background: #15171a; border-radius: 5px; overflow: hidden; }
#export-bar { height: 100%; width: 0%; background: var(--accent); transition: width .1s; }
.help-card { max-width: 480px; }
.help-card h2 { margin-top: 0; }
.help-card ul { line-height: 1.7; }
