/* Kairos Canvas — marca AEON en oscuro.
   Paleta oficial («Performance Creatives Guidelines 2627»): #2C2C2C #F0EEF0 #FFFFFF · #502440 #C47AA2 #F0D7E0 #273A32 #690126.
   Los grises de superficie (--panel, --card, --line) son matices derivados del carbón #2C2C2C. */
@font-face { font-family: "Montserrat"; src: url(/static/fonts/Montserrat-Regular.ttf); font-weight: 400; }
@font-face { font-family: "Montserrat"; src: url(/static/fonts/Montserrat-SemiBold.ttf); font-weight: 600; }
@font-face { font-family: "Montserrat"; src: url(/static/fonts/Montserrat-Bold.ttf); font-weight: 700; }
@font-face { font-family: "Gilda Display"; src: url(/static/fonts/GildaDisplay-Regular.ttf); }
@font-face { font-family: "WindSong"; src: url(/static/fonts/WindSong-Regular.ttf); }

:root {
  --charcoal: #2C2C2C; --mist: #F0EEF0; --white: #FFFFFF;
  --plum: #502440; --mauve: #C47AA2; --blush: #F0D7E0; --forest: #273A32; --burgundy: #690126;
  --bg: #2C2C2C; --panel: #232323; --card: #1B1B1B; --line: #3D3D3D; --muted: #9A979A;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--mist); overflow: hidden;
  font-family: "Montserrat", sans-serif; font-size: 13px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- barra superior ---------- */
.top { position: fixed; inset: 0 0 auto 0; height: 58px; display: flex; align-items: center; gap: 14px;
  padding: 0 16px; background: rgba(35,35,35,.92); border-bottom: 1px solid var(--line); z-index: 20;
  backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand img { height: 22px; filter: invert(1); }
.brand img.wordmark { height: 20px; padding-right: 12px; border-right: 1px solid var(--line); }
.brand .name { font-family: "Gilda Display", serif; font-size: 21px; color: var(--white); }
.brand .script { font-family: "WindSong", cursive; font-size: 20px; color: var(--mauve); margin-left: -4px; }
.templates { display: flex; gap: 4px; margin-left: 10px; overflow-x: auto; }
.tpl { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 13px;
  font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap; }
.tpl.on { background: var(--mist); color: var(--charcoal); border-color: var(--mist); }
.spacer { flex: 1; }
.pill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.pill b { color: var(--white); font-family: "Gilda Display", serif; font-size: 18px; font-weight: 400; }
.ghost { border: 1px solid var(--line); background: transparent; border-radius: 9px; padding: 7px 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.ghost:hover { border-color: var(--mauve); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); cursor: pointer;
  white-space: nowrap; }
.switch input { appearance: none; width: 30px; height: 17px; border-radius: 9px; background: var(--line);
  position: relative; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--mist); transition: left .15s; }
.switch input:checked { background: var(--mauve); }
.switch input:checked::after { left: 15px; }

/* ---------- lienzo ---------- */
.stage { position: fixed; inset: 58px 0 0 0; overflow: hidden; cursor: grab; touch-action: none;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(240,238,240,.09) 1px, transparent 1px); background-size: 22px 22px; }
.stage.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.wires path { fill: none; stroke: rgba(196,122,162,.55); stroke-width: 2; }
.wires path.live { stroke: var(--mauve); }
.zoombar { position: fixed; right: 16px; bottom: 16px; display: flex; gap: 6px; z-index: 15; }
.zoombar button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); font-size: 15px; }
.hint { position: fixed; left: 16px; bottom: 16px; z-index: 15; font-size: 11px; color: var(--muted);
  background: rgba(35,35,35,.85); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; max-width: 380px; }

/* ---------- nodos ---------- */
.node { position: absolute; width: 230px; user-select: none; }
.node.gen { width: 300px; }
.node .label { display: flex; justify-content: space-between; align-items: center; height: 22px;
  font-size: 10px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  cursor: move; padding: 0 4px; }
.node .label .opt { letter-spacing: .06em; text-transform: none; font-weight: 400; }
.frame { position: relative; background: var(--card); border: 5px solid #121212; border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line), 0 18px 40px rgba(0,0,0,.35); aspect-ratio: 3 / 4; overflow: hidden; }
.node.gen .frame { aspect-ratio: var(--ar, 3 / 4); }
.node.small .frame { aspect-ratio: 4 / 3; }
.frame img, .frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame .empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; color: var(--muted); font-size: 11px; text-align: center; padding: 14px; }
.frame .empty svg { width: 30px; height: 30px; opacity: .6; }
.frame .corner { position: absolute; top: 8px; display: flex; gap: 6px; }
.frame .corner.l { left: 8px; } .frame .corner.r { right: 8px; }
.icon { width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(18,18,18,.72); color: var(--white);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; text-decoration: none; }
.frame .counter { position: absolute; right: 8px; bottom: 8px; font-size: 10px; background: rgba(18,18,18,.72);
  padding: 3px 7px; border-radius: 6px; }
.frame .tag { position: absolute; left: 8px; bottom: 8px; font-size: 10px; background: rgba(18,18,18,.72);
  padding: 3px 7px; border-radius: 6px; max-width: 80%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame .busy { position: absolute; inset: 0; background: rgba(18,18,18,.78); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; font-size: 11px; text-align: center; padding: 16px; }
.spin { width: 26px; height: 26px; border: 2px solid var(--line); border-top-color: var(--mauve); border-radius: 50%;
  animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.below { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.btn { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 8px 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.btn:hover { border-color: var(--mauve); }
.btn.primary { background: var(--mist); color: var(--charcoal); border-color: var(--mist); }
.btn.primary:hover { background: var(--white); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 6px; }
.row > * { flex: 1; min-width: 0; }
.sel { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  font-size: 11px; }
.txt { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  font-size: 11px; resize: vertical; min-height: 54px; }
.txt::placeholder { color: #6E6B6E; }
.note { font-size: 10px; color: var(--muted); line-height: 1.4; }
.port { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--panel);
  border: 2px solid var(--mauve); }
.port.in { left: -6px; } .port.out { right: -6px; }
.portlbl { position: absolute; left: 10px; font-size: 9px; color: var(--muted); letter-spacing: .06em;
  transform: translateY(-2px); pointer-events: none; }
.node.text .frame { aspect-ratio: auto; padding: 10px; }

/* ---------- modales ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(10,10,10,.7); display: flex;
  align-items: center; justify-content: center; padding: 20px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; width: min(980px, 100%);
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.sheet header { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.sheet header h3 { margin: 0; font-family: "Gilda Display", serif; font-weight: 400; font-size: 22px; flex: 1; }
.sheet .tabs { display: flex; gap: 6px; padding: 12px 18px 0; flex-wrap: wrap; }
.sheet .search { margin: 12px 18px 0; width: auto; }
.sheet .grid { padding: 16px 18px 18px; overflow-y: auto; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid transparent; background: var(--card);
  aspect-ratio: 3 / 4; padding: 0; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 9px 8px; font-size: 11px; font-weight: 600;
  text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.82)); color: var(--white); }
.tile.on { border-color: var(--mauve); }
.tile:hover { border-color: var(--line); }
.tile.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 1px dashed var(--line); color: var(--muted); font-size: 12px; }
.tile .x { position: absolute; top: 6px; right: 6px; }
.form { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.empty-msg { padding: 30px 18px; color: var(--muted); text-align: center; }

/* ---------- acceso ---------- */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0; font-family: "Gilda Display", serif; font-weight: 400; font-size: 34px; color: var(--white); }
.login .eyebrow { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.login input[type=password] { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 11px; }
.err { color: var(--blush); font-size: 12px; min-height: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--mist);
  color: var(--charcoal); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 12px; max-width: 90vw; }
.toast.bad { background: var(--blush); color: var(--burgundy); }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 86vh; border-radius: 12px; display: block; }

@media (max-width: 720px) {
  .top { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .templates { order: 3; width: 100%; margin: 0; }
  .stage { top: 104px; }
  .hint { display: none; }
  .pill span { display: none; }
}
