:root {
  --bg: #07070a;
  --panel: rgba(18, 18, 24, 0.62);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --ink: #f2eee6;
  --ink-2: rgba(242, 238, 230, 0.64);
  --ink-3: rgba(242, 238, 230, 0.38);
  --accent: #c9a36b;
  --ok: #7fd1a8;
  --warn: #f0b85a;
  --bad: #ef6f6f;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; }
.muted { color: var(--ink-3); }

#viz { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; }

/* ── cabecera ─────────────────────────────────────────── */
.top {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 16px 24px 8px;
}
.brandmark { display: flex; align-items: baseline; gap: 12px; }
.logo { font-family: var(--serif); font-size: 34px; letter-spacing: 0.18em; color: var(--accent); line-height: 1; }
.by { color: var(--ink-3); font-size: 12px; }
.by b { color: var(--ink); font-weight: 600; letter-spacing: 0.08em; }
.by em { font-family: var(--serif); font-size: 15px; color: var(--ink-2); }
.venue { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.venue input {
  background: none; border: 0; text-align: center; font-family: var(--serif); font-size: 20px;
  color: var(--ink); width: 440px; max-width: 40vw; outline: none;
}
.venue input:focus { border-bottom: 1px solid var(--line-2); }
.status { display: flex; gap: 8px; justify-content: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font-size: 11px;
  backdrop-filter: blur(10px);
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.pill.ok i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.warn i { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: pulse 1.2s infinite; }
.pill.bad i { background: var(--bad); }
.pill.gear { text-decoration: none; color: var(--ink); cursor: pointer; }
.pill.gear:hover { border-color: var(--accent); }
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 170px; display: flex; flex-direction: column;
  background: #121217; border: 1px solid var(--line-2); border-radius: 12px; padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.user-pop a, .user-pop button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; cursor: pointer; font-size: 12.5px; }
.user-pop a:hover, .user-pop button:hover { background: var(--line); color: var(--ink); }
[hidden] { display: none !important; }

.cam { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 12px; background: #000; aspect-ratio: 4 / 3; }
.cam video, .cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam video.blur { filter: blur(14px) saturate(0.6) brightness(0.8); }
.cam-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: var(--ink-2); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ── rejilla ──────────────────────────────────────────── */
.grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 330px 1fr 340px; gap: 20px;
  padding: 8px 24px 0; height: calc(100vh - 64px - 38px);
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; overflow-y: auto; backdrop-filter: blur(18px) saturate(1.2);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 22px; letter-spacing: 0.01em; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 4px 10px; font-size: 11px; color: var(--ink-3); cursor: pointer; }
.seg button.on { background: var(--line-2); color: var(--ink); }

.scenes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.scenes button {
  border: 1px solid var(--line); background: rgba(255,255,255,0.03); border-radius: 10px;
  padding: 5px 9px; font-size: 11.5px; cursor: pointer; color: var(--ink-2); transition: all .2s;
}
.scenes button:hover { border-color: var(--line-2); color: var(--ink); }
.scenes button.on { border-color: var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 14%, transparent); }

.sensors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sensor {
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px 6px;
  background: rgba(255,255,255,0.02); position: relative; overflow: hidden;
}
.sensor .lbl { color: var(--ink-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.sensor .val { font-family: var(--serif); font-size: 26px; line-height: 1.1; }
.sensor .val small { font-family: var(--sans); font-size: 11px; color: var(--ink-3); margin-left: 3px; }
.sensor svg { display: block; width: 100%; height: 22px; margin-top: 2px; }
.sensor svg path { fill: none; stroke: var(--accent); stroke-width: 1.4; opacity: .8; }
.sensor input[type=range] { position: absolute; inset: auto 0 0 0; opacity: 0; height: 100%; cursor: ew-resize; }
.sensor:hover { border-color: var(--line-2); }

.emotion { margin-top: 14px; }
.emotion-head { display: flex; justify-content: space-between; color: var(--ink-2); margin-bottom: 6px; font-size: 12px; }
.emo-map {
  position: relative; height: 120px; border-radius: 12px; border: 1px solid var(--line);
  background:
    radial-gradient(circle at 100% 0%, rgba(240,184,90,.18), transparent 55%),
    radial-gradient(circle at 0% 0%, rgba(239,111,111,.14), transparent 55%),
    radial-gradient(circle at 0% 100%, rgba(122,162,214,.14), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(127,209,168,.16), transparent 55%);
}
.emo-map::before, .emo-map::after { content: ""; position: absolute; background: var(--line); }
.emo-map::before { left: 50%; top: 8px; bottom: 8px; width: 1px; }
.emo-map::after { top: 50%; left: 8px; right: 8px; height: 1px; }
.ax { position: absolute; font-size: 10px; color: var(--ink-3); }
.ax-y { left: 8px; top: 6px; }
.ax-x { right: 8px; bottom: 6px; }
.emo-dot {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent), 0 0 24px var(--accent);
  transition: left 1s ease, top 1s ease;
}

.outside { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
.outside select {
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px;
}
.outside select option { background: #15151b; }
.weather { color: var(--ink-2); font-size: 12px; }

/* ── centro ───────────────────────────────────────────── */
.center { display: flex; flex-direction: column; min-height: 0; }
.now { text-align: center; padding: 6vh 20px 0; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.24em; font-size: 11px; color: var(--accent); }
.now h1 {
  font-family: var(--serif); font-weight: 400; font-size: clamp(36px, 4.6vw, 68px); line-height: 1.02;
  margin: 10px 0 12px; text-shadow: 0 2px 40px rgba(0,0,0,.6); max-width: 18ch;
}
.caption { color: var(--ink-2); max-width: 60ch; margin: 0 auto; font-size: 13px; min-height: 2.9em; text-shadow: 0 1px 12px #000; }
.meta { color: var(--ink-3); margin-top: 10px; display: flex; gap: 14px; justify-content: center; }
.progress { width: min(460px, 80%); height: 2px; background: var(--line); margin: 16px auto 0; border-radius: 2px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .5s linear; }
.transport { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 18px; }
.primary {
  background: var(--accent); color: #140f07; border: 0; border-radius: 99px; padding: 11px 22px;
  font-weight: 600; cursor: pointer; box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 50%, transparent);
}
.ghost { background: rgba(255,255,255,0.04); border: 1px solid var(--line-2); border-radius: 99px; padding: 8px 16px; cursor: pointer; }
.ghost:disabled { opacity: .35; cursor: default; }
.auto { color: var(--ink-2); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.auto input { accent-color: var(--accent); }

.dials { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 18px 0 14px; }
.dial {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px;
  text-align: center; backdrop-filter: blur(14px);
}
.dial svg { width: 64px; height: 64px; display: block; margin: 0 auto; }
.dial .n { font-family: var(--serif); font-size: 20px; margin-top: -42px; height: 38px; }
.dial .l { color: var(--ink-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 6px; }
.dial circle.track { stroke: var(--line); }
.dial circle.bar { stroke: var(--accent); transition: stroke-dashoffset .8s ease; }

.brain {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px;
  backdrop-filter: blur(18px); margin-bottom: 10px;
}
.reasons { margin: 0; padding-left: 18px; color: var(--ink-2); min-height: 84px; }
.reasons li { margin: 3px 0; animation: fadein .5s both; }
.reasons li::marker { color: var(--accent); font-family: var(--mono); font-size: 10px; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
.decide-row { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.decide-row .muted { font-size: 11.5px; }

/* ── derecha ──────────────────────────────────────────── */
.brands { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.brands button {
  border: 1px solid var(--line); background: rgba(255,255,255,0.03); border-radius: 12px;
  padding: 10px; cursor: pointer; font-family: var(--serif); font-size: 17px; text-align: left; transition: all .2s;
}
.brands button.on { border-color: var(--bc); background: color-mix(in srgb, var(--bc) 16%, transparent); }
.brand-card { margin: 12px 0; padding: 12px; border-radius: 12px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); }
.brand-card .tag { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink); margin-bottom: 8px; }
.brand-card dl { margin: 0; display: grid; grid-template-columns: 74px 1fr; gap: 4px 8px; font-size: 11.5px; }
.brand-card dt { color: var(--ink-3); }
.brand-card dd { margin: 0; color: var(--ink-2); }
.brand-card dd.no { color: #e9a0a0; }

.insitu { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.insitu label { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; display: flex; justify-content: space-between; }
.insitu input:not([type]) {
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; outline: none;
}
.insitu input[type=range] { accent-color: var(--accent); }
.insitu textarea {
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  outline: none; resize: vertical; font: inherit; color: inherit; min-height: 52px;
}
.insitu textarea:focus { border-color: var(--accent); }
.insitu .panel-head { margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button { border: 1px solid var(--line); background: rgba(255,255,255,0.03); border-radius: 99px; padding: 3px 9px; font-size: 11.5px; color: var(--ink-2); cursor: pointer; }
.chips button.on { border-color: var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.insitu-actions { display: flex; gap: 8px; margin-top: 4px; }
.primary.small, .ghost.small { padding: 7px 14px; font-size: 12px; }
#insitu-state.on { color: var(--accent); }

.spool { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.spool li {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.02);
  cursor: pointer; transition: border-color .2s;
}
.spool li:hover { border-color: var(--line-2); }
.spool li .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: var(--line); }
.spool li.playing { border-color: var(--accent); }
.spool li.playing .ico { background: var(--accent); color: #140f07; }
.spool li.gen .ico { background: none; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.spool li.err .ico { background: var(--bad); }
.spool li .t { font-family: var(--serif); font-size: 15px; line-height: 1.15; }
.spool li .s { color: var(--ink-3); font-size: 10.5px; font-family: var(--mono); }
.spool li .r { color: var(--ink-3); font-size: 10.5px; text-align: right; font-family: var(--mono); }
.spool .sep { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; margin: 8px 2px 0; border: 0; background: none; padding: 0; cursor: default; display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── feed ─────────────────────────────────────────────── */
.feed {
  position: fixed; left: 0; right: 0; bottom: 0; height: 38px; z-index: 2;
  display: flex; align-items: center; gap: 28px; padding: 0 24px; overflow: hidden; white-space: nowrap;
  border-top: 1px solid var(--line); background: rgba(7,7,10,.7); backdrop-filter: blur(10px);
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.feed span b { color: var(--accent); font-weight: 500; margin-right: 6px; }
.feed span:first-child { color: var(--ink-2); }

@media (max-width: 1100px) {
  body { overflow: auto; }
  .grid { grid-template-columns: 1fr; height: auto; padding-bottom: 60px; }
  .top { grid-template-columns: 1fr; gap: 8px; }
  .status { justify-content: flex-start; }
  .venue { align-items: flex-start; }
  .venue input { text-align: left; max-width: 100%; }
  .dials { grid-template-columns: repeat(3, 1fr); }
}

/* Valoraciones, detalle del spool, petición con duración, barra de mensajes deslizable */
.now-rate { display: inline-flex; gap: 6px; }
.now-rate button, .detail-actions button { padding: 6px 10px; filter: grayscale(.6); opacity: .75; }
.now-rate button.on, .detail-actions button.on { filter: none; opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.spool li { flex-wrap: wrap; }
.spool li .detail { grid-column: 1 / -1; padding: 6px 2px 2px; cursor: default; }
.spool li .detail p { margin: 0 0 6px; color: var(--ink-2); font-size: 11.5px; line-height: 1.4; }
.spool li .detail pre { margin: 0 0 8px; white-space: pre-wrap; font: 11.5px/1.45 var(--sans); color: var(--ink); max-height: 180px; overflow: auto; }
.spool li.open { border-color: var(--line-2); background: rgba(255,255,255,.04); }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.insitu select { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.insitu select option { background: #15151b; }
.feed { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; cursor: grab; user-select: none; }
.feed.dragging { cursor: grabbing; }
.feed span { flex: none; }

/* Reproductor: el navegador pide un toque antes de sonar */
.unlock { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(7, 7, 10, 0.82); border: 0; color: var(--ink); cursor: pointer; backdrop-filter: blur(8px); }
.unlock b { font-family: var(--serif); font-size: clamp(32px, 6vw, 56px); font-weight: 400; color: var(--accent); }
.unlock span { color: var(--ink-3); font-size: 12.5px; max-width: 520px; text-align: center; padding: 0 16px; }
