:root {
  --bg: #0d1015;
  --panel: #151a22;
  --panel-2: #1c222c;
  --line: #272f3b;
  --text: #e8edf5;
  --muted: #8b97a8;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button, input, select, textarea { font-family: inherit; font-size: 100%; color: inherit; }
button { cursor: pointer; }

/* ------------------------------------------------------------ inicio */

.home {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.home-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.brand svg { width: 26px; height: 26px; color: var(--accent); }

.home p.sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; line-height: 1.5; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 7px;
}

.input, select.input, textarea.input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--accent); }

#code {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #232b37; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #05202b; }
.btn.primary:hover { background: #5ccbfa; }
.btn.green { background: var(--accent-2); border-color: var(--accent-2); color: #052e14; }
.btn.ghost { background: transparent; }
.btn.danger { color: #fca5a5; border-color: #4b2226; background: #2a1618; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 11px; font-size: 13px; font-weight: 500; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.hint { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin-top: 18px; }
.hint code {
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12px;
}

.divider { height: 1px; background: var(--line); margin: 22px 0; }

/* ------------------------------------------------------- controlador */

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.pill b { color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.dot.on { background: var(--accent-2); box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.spacer { flex: 1; }

.main {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  min-height: 0;
}

.col {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  border-right: 1px solid var(--line);
}
.col:last-child { border-right: none; }

.col h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.col h3 .spacer { flex: 1; }
.col h3 + .sect { margin-top: 0; }
.sect { margin-top: 24px; }

.list { display: flex; flex-direction: column; gap: 6px; }

.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.item:hover { border-color: #37475c; }
.item.active { border-color: var(--accent); background: #10222c; }
.item .t { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .m { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.item .x { opacity: .5; padding: 2px 5px; border-radius: 6px; background: transparent; border: none; color: var(--muted); }
.item .x:hover { opacity: 1; color: #fca5a5; background: #2a1618; }

.empty { color: var(--muted); font-size: 13px; padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }

/* controles */

.ctl { margin-bottom: 14px; }
.ctl label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.ctl label b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
}
input[type=range]::-webkit-slider-runnable-track { height: 5px; background: var(--line); border-radius: 4px; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
input[type=range]::-moz-range-track { height: 5px; background: var(--line); border-radius: 4px; }
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--panel);
}

input[type=color] {
  width: 100%;
  height: 40px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}
.toggle.on { background: #10222c; border-color: var(--accent); color: var(--accent); }

.transport { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.transport .btn { padding: 14px 6px; font-size: 13px; flex-direction: column; gap: 4px; }
.transport .btn svg { width: 20px; height: 20px; }
#play { grid-column: span 3; background: var(--accent-2); border-color: var(--accent-2); color: #052e14; font-size: 15px; }
#play.playing { background: #f59e0b; border-color: #f59e0b; color: #2b1a00; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 6px; text-align: center; }
.stat .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

#seek { margin-bottom: 6px; }

/* lista de párrafos para saltar */
.para-list { display: flex; flex-direction: column; gap: 4px; }
.para {
  text-align: left;
  background: var(--panel);
  border: 1px solid transparent;
  border-left: 3px solid var(--line);
  border-radius: 0 8px 8px 0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.4;
  display: block;
  width: 100%;
}
.para:hover { color: var(--text); border-left-color: #4b5b70; }
.para.current { color: var(--text); border-left-color: var(--accent); background: #101c25; }

.editor { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
.editor textarea {
  flex: 1;
  min-height: 260px;
  resize: vertical;
  line-height: 1.6;
  font-size: 14px;
}

.mini {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  height: 200px;
  position: relative;
  background: #000;
}
.mini-screen { position: absolute; top: 0; left: 0; overflow: hidden; transform-origin: top left; }
#miniContent { position: absolute; top: 0; left: 0; width: 100%; }
#miniContent p { margin: 0 0 0.55em; }
#miniContent p:last-child { margin-bottom: 0; }
.mini-line { position: absolute; left: 0; right: 0; height: 3px; background: rgba(255,80,80,.6); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1;
  padding: 9px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.tab.on { background: #10222c; border-color: var(--accent); color: var(--accent); }

.mobile-only { display: none; }

@media (max-width: 980px) {
  .main { grid-template-columns: 1fr; }
  .col { border-right: none; border-bottom: 1px solid var(--line); }
  .col.hide-mobile { display: none; }
  .mobile-only { display: flex; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13.5px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.err { border-color: #7f2a2a; color: #fca5a5; }

/* --------------------------------------------------------- administración */

.admin { overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 18px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 20px;
}
.panel h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel .note { color: var(--muted); font-size: 13px; line-height: 1.6; margin: -6px 0 14px; max-width: 720px; }
.panel .note code { background: var(--panel-2); padding: 2px 6px; border-radius: 5px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .mono { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.table .num, .table .last { color: var(--muted); white-space: nowrap; }
.table .acts { white-space: nowrap; text-align: right; }
.table .acts .btn { margin-left: 6px; }

.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.chip.on { color: var(--accent); border-color: #1d4a5e; background: #10222c; }
.chip.ok { color: var(--accent-2); border-color: #1d4a2e; background: #10241a; }
.chip.off { color: #fca5a5; border-color: #4b2226; background: #2a1618; }

/* ---------------------------------------------------------------- modales */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3,6,10,.72);
}
.modal.show { display: flex; }
.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.modal-card h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  margin: 0 0 16px;
}
.modal-card .big-code {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 0 14px 10px;
  margin-bottom: 10px;
}
.modal-card .sep { height: 1px; background: var(--line); margin: 20px 0 18px; }
