:root {
  --bg: #0d0f12;
  --panel: #13161b;
  --panel-2: #181c22;
  --line: #232831;
  --text: #c9d1d9;
  --muted: #7d8590;
  --accent: #7ee787;
  --accent-dim: rgba(126, 231, 135, 0.12);
  --warn: #e3b341;
  --danger: #ff7b72;
  --mono: "Cascadia Mono", "Cascadia Code", "JetBrains Mono", Consolas, "DejaVu Sans Mono", "Roboto Mono", Menlo, monospace;
  --side-w: 300px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: var(--app-h, 100dvh); margin: 0; }
/* Hueco de la barra de inicio del iPhone; con el teclado abierto no hace falta. */
:root { --safe-b: env(safe-area-inset-bottom); }
:root.kb { --safe-b: 0px; }
body {
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { border-color: var(--muted); }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button.icon { padding: 2px 8px; min-width: 28px; }
.muted { color: var(--muted); }
.touch-only { display: none; }
[hidden] { display: none !important; }

/* Panel lateral */
#side {
  width: var(--side-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  transition: transform 0.18s ease;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
}
body.collapsed #side { margin-left: calc(-1 * var(--side-w)); }
#backdrop { display: none; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 10px 14px;
}
.logo { font-family: var(--mono); font-size: 15px; font-weight: 600; letter-spacing: 0.02em; flex: 1; }
.logo b { color: var(--accent); }
.status { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status.ok { background: var(--accent); }
.status.down { background: var(--danger); }
#filter {
  margin: 0 12px 8px;
  padding: 6px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  outline: none;
}
#filter:focus { border-color: var(--muted); }
#list { flex: 1; overflow-y: auto; padding: 4px 6px calc(12px + var(--safe-b)); overscroll-behavior: contain; }

.sess { margin-bottom: 2px; }
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  min-height: 30px;
}
.row:hover { background: var(--panel-2); }
.sess-row .chev { width: 10px; color: var(--muted); transition: transform 0.12s; font-size: 10px; }
.sess.open .sess-row .chev { transform: rotate(90deg); }
.sess-row .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.att { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.8; }
.sess ul { list-style: none; margin: 0; padding: 0 0 4px 14px; display: none; }
.sess.open ul { display: block; }

.win .idx {
  font-family: var(--mono);
  color: var(--muted);
  min-width: 18px;
  text-align: right;
  font-size: 12px;
}
.win .body { flex: 1; min-width: 0; }
.win .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win .cmd {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.win .panes { color: var(--muted); font-size: 11px; font-family: var(--mono); }
.win .flag { font-family: var(--mono); font-size: 11px; color: var(--warn); }
.win.yours .idx::after { content: "•"; color: var(--accent); margin-left: 2px; }
.win.current { background: var(--accent-dim); box-shadow: inset 2px 0 0 var(--accent); }
.win.current .name { color: #fff; }

.tools { display: none; gap: 2px; }
.row:hover .tools { display: flex; }
.row:hover .count, .row:hover .panes { display: none; }
.tools button {
  border: none;
  background: none;
  color: var(--muted);
  padding: 0 5px;
  font-size: 13px;
  line-height: 20px;
}
.tools button:hover { color: var(--text); }
.tools button.danger:hover { color: var(--danger); }
.none { padding: 24px 14px; color: var(--muted); text-align: center; }

/* Zona principal */
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 46px;
}
#crumb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
#crumb .sep { color: var(--muted); margin: 0 6px; }
#crumb .sname { color: var(--accent); }
#actions { display: flex; gap: 6px; }
#actions .lbl { display: none; }

#terms { flex: 1; position: relative; min-height: 0; }
/* touch-action: el gesto es nuestro (historial de tmux), no un scroll o zoom de la página. */
.term { position: absolute; inset: 0; padding: 6px 0 0 8px; display: none; background: var(--bg); touch-action: none; }
.term.shown { display: block; }
.term .xterm { height: 100%; }
.term .xterm-viewport { scrollbar-width: thin; }
#empty, #stopped { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; }
#stopped { z-index: 3; background: var(--bg); }
#empty .big, #stopped .big { font-size: 18px; margin: 0 0 6px; }
#empty .empty-box, #stopped .empty-box { max-width: 380px; }
#empty button, #stopped button { margin-top: 12px; padding: 10px 18px; }
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(13, 15, 18, 0.82);
  z-index: 5;
  padding: 16px;
}
.overlay div { text-align: center; }
.overlay p { margin: 0 0 12px; }
.overlay button { padding: 10px 18px; }

/* Vista chat: el historial del panel como texto, con scroll nativo y una caja de escribir */
#reader {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
#reader-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 8px;
}
#reader-text {
  margin: 0;
  font: 13px/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  user-select: text;
  -webkit-user-select: text;
}
#reader-more { display: block; margin: 0 auto 12px; padding: 8px 14px; }
#reader-text .rule {
  display: inline-block;
  width: 100%;
  height: 0;
  border-top: 1px solid currentColor;
  opacity: 0.45;
  vertical-align: middle;
}
#reader-bottom {
  position: absolute;
  right: 14px;
  bottom: 76px;
  z-index: 5;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
#composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
#composer-text {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 160px;
  padding: 10px 14px;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  outline: none;
}
#composer-text:focus { border-color: var(--muted); }
#composer-send { width: 42px; height: 42px; padding: 0; border-radius: 50%; display: grid; place-items: center; flex: none; }
#composer-send .svg { width: 20px; height: 20px; stroke-width: 2.4; vertical-align: 0; }
#view .ic-term { display: none; }
body.chat #view .ic-chat { display: none; }
body.chat #view .ic-term { display: inline; }
body.chat #view { color: var(--accent); border-color: var(--accent); }
#view .svg { vertical-align: -3px; }

@media (max-width: 720px) {
  #view { min-width: 40px; min-height: 36px; }
  #reader-scroll { padding: 10px 10px 8px; }
}

/* Teclas extra (pantallas táctiles) */
#keys {
  display: flex;
  gap: 4px;
  padding: 5px 6px calc(5px + var(--safe-b));
  background: var(--panel);
  border-top: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
}
#keys::-webkit-scrollbar { display: none; }
#keys button {
  flex: none;
  min-width: 44px;
  height: 40px;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 14px;
  user-select: none;
  -webkit-user-select: none;
}
#keys button.on { background: var(--accent); color: #0d0f12; border-color: var(--accent); }
#keys button:active { background: var(--line); }
#keys .pfx { color: var(--accent); }

/* Pegar y adjuntar */
.svg {
  width: 18px;
  height: 18px;
  vertical-align: -4px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sheet-actions .svg { margin-right: 4px; }
.modal {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--app-h, 100dvh);
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px;
}
.sheet-box {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
#paste-text {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  padding: 10px;
  font: 13px/1.4 var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
#paste-text:focus { border-color: var(--muted); }
.sheet-actions { display: flex; gap: 8px; align-items: center; }
.sheet-actions .grow { flex: 1; }
.sheet-actions button { min-height: 40px; padding: 0 14px; }
button.primary { background: var(--accent); color: #0d0f12; border-color: var(--accent); font-weight: 600; }
.sheet-note { margin: 0; color: var(--muted); font-size: 12px; }
#terms.dropping::after {
  content: "Suelta para subir y pegar la ruta";
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 10px;
  background: rgba(13, 15, 18, 0.8);
  color: var(--accent);
  z-index: 6;
  pointer-events: none;
}

@media (max-width: 720px) {
  .modal { align-items: flex-end; padding: 0; }
  .sheet-box { border-radius: 14px 14px 0 0; padding-bottom: calc(14px + var(--safe-b)); }
}

/* Vista previa y avisos */
#preview {
  position: fixed;
  z-index: 20;
  width: min(640px, calc(100vw - 320px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  overflow: hidden;
}
#preview .pv-head { padding: 6px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
#preview pre {
  margin: 0;
  padding: 8px 10px;
  font: 11px/1.3 var(--mono);
  max-height: 340px;
  overflow: hidden;
  white-space: pre;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
#toast {
  position: fixed;
  bottom: calc(16px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--danger);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 30;
  max-width: calc(100vw - 32px);
}
#toast.info { border-color: var(--accent); }

/* Sin ratón: los botones de cada fila siempre visibles y con área de toque cómoda. */
@media (hover: none) {
  /* Con menos de 16px, Safari del iPhone amplía la página al tocar el campo y ya no cabe. */
  input, textarea, #composer-text, #paste-text, #filter { font-size: 16px; }
  .hover-only { display: none; }
  .touch-only { display: inline-block; }
  .tools { display: flex; }
  .count, .panes { display: none; }
  .row { min-height: 44px; }
  .tools button { min-width: 36px; min-height: 36px; font-size: 16px; }
  #preview { display: none !important; }
}

/* Pantalla estrecha: el panel es un cajón y las acciones van en el menú ⋯. */
@media (max-width: 720px) {
  :root { --side-w: min(320px, 86vw); }
  #side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 15;
    margin-left: 0 !important;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  }
  body.collapsed #side { transform: translateX(-100%); box-shadow: none; }
  body:not(.collapsed) #backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 14;
    background: rgba(0, 0, 0, 0.5);
  }
  #bar { gap: 8px; padding-left: 8px; padding-right: 8px; }
  #toggle, #more { min-width: 40px; min-height: 36px; font-size: 16px; }
  #actions {
    display: none;
    position: absolute;
    right: 8px;
    top: calc(100% + 4px);
    z-index: 12;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    min-width: 240px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  }
  body.menu-open #actions { display: flex; }
  #actions button {
    display: flex;
    align-items: center;
    gap: 12px;
    border: none;
    background: none;
    text-align: left;
    padding: 10px 12px;
    min-height: 44px;
    font-size: 15px;
  }
  #actions button:active { background: var(--panel-2); }
  #actions .ic { width: 24px; text-align: center; font-family: var(--mono); color: var(--muted); }
  #actions .lbl { display: inline; }
  #actions button.danger { color: var(--danger); }
  .term { padding: 4px 0 0 4px; }
}

@media (min-width: 721px) {
  #more { display: none; }
}

/* nido: filas de sesión, estado, formularios */
.sess-item .body { flex: 1; min-width: 0; }
.sess-item .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sess-item .cmd {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sess-item .flag { font-size: 11px; color: var(--muted); font-weight: 400; }
.sess-item.current { background: var(--accent-dim); box-shadow: inset 2px 0 0 var(--accent); }
.sess-item.current .name { color: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; background: var(--muted); }
.dot.busy { background: var(--warn); box-shadow: 0 0 0 3px rgba(227, 179, 65, 0.18); }
.dot.idle { background: var(--accent); }
.dot.run { background: #79c0ff; }
.dot.off { background: transparent; border: 1.5px solid var(--muted); }
#crumb .state.busy { color: var(--warn); }
#crumb .state.idle { color: var(--accent); }
#crumb .state.run { color: #79c0ff; }
#crumb .state.off { color: var(--muted); }
#reader-text .marker {
  display: block;
  margin: 10px 0;
  text-align: center;
  font: 11.5px system-ui, sans-serif;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field input {
  font: 14px var(--mono);
  padding: 9px 11px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.field input:focus { border-color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
button.primary:disabled { opacity: 0.5; }

/* Vista chat (Claude): la conversación desde su transcripción */
#chat-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }
#chat-list:empty { display: none; }
.msg { max-width: 100%; overflow-wrap: anywhere; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.msg.user {
  align-self: flex-end;
  max-width: 85%;
  background: #1f3a2a;
  border: 1px solid #2c5a3f;
  color: #e6edf3;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap;
}
.msg.user .pasted { margin: 2px 0; white-space: normal; }
.msg.user .pasted > summary { cursor: pointer; color: #9fd8b4; font-size: 13px; list-style: none; }
.msg.user .pasted > summary::before { content: "▸ "; }
.msg.user .pasted[open] > summary::before { content: "▾ "; }
.msg.user .pasted pre {
  margin: 6px 0 0; padding: 8px; max-height: 50vh; overflow: auto; white-space: pre-wrap;
  background: #142a1d; border-radius: 6px; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.msg.notice {
  align-self: center; max-width: 92%; text-align: center;
  font-size: 12.5px; color: var(--muted);
  padding: 3px 10px; border: 1px dashed #30363d; border-radius: 999px;
}
.msg.notice > details > summary { cursor: pointer; list-style: none; display: inline; }
.msg.notice > details > summary::after { content: " ▸"; }
.msg.notice > details[open] > summary::after { content: " ▾"; }
.msg.notice pre {
  text-align: left; margin: 6px 0 4px; padding: 8px; max-height: 40vh; overflow: auto; white-space: pre-wrap;
  background: var(--bg); border-radius: 6px; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.msg.notice:has(details[open]) { border-radius: 10px; }
.msg.notice::before { content: "⚙ "; }
.msg.notice.ok::before { content: "✓ "; color: #3fb950; }
.msg.notice.bad::before { content: "✗ "; color: #ff6b6b; }
.msg.user .img { color: var(--muted); font-size: 12px; margin-left: 4px; }
.msg.assistant { color: var(--text); }
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant > :last-child { margin-bottom: 0; }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { font-size: 15.5px; margin: 12px 0 6px; }
.msg.assistant ul, .msg.assistant ol { margin: 4px 0 8px; padding-left: 22px; }
.msg.assistant li { margin: 2px 0; }
.msg.assistant a { color: #79c0ff; }
.msg.assistant code { font: 13px var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.msg.assistant pre { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; margin: 6px 0 8px; }
.msg.assistant pre code { background: none; padding: 0; font-size: 12.5px; white-space: pre; }
.msg.assistant table { border-collapse: collapse; display: block; overflow-x: auto; margin: 6px 0 8px; font-size: 13.5px; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.msg.assistant th { background: var(--panel-2); }
.msg.assistant blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.msg.tool { font: 12.5px var(--mono); color: var(--muted); }
.msg.tool summary { cursor: pointer; list-style: none; padding: 4px 8px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.tool summary::-webkit-details-marker { display: none; }
.msg.tool summary::before { content: "▸ "; }
.msg.tool[open] summary::before { content: "▾ "; }
.msg.tool summary:hover { background: var(--panel-2); }
.msg.tool .tname { color: #d2a8ff; }
.msg.tool.error .tname { color: var(--danger); }
.msg.tool.pending .tname::after { content: " …"; }
.msg.tool pre { margin: 4px 0 6px 14px; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; white-space: pre-wrap; max-height: 260px; overflow: auto; color: var(--text); }
.msg.tool pre.result { color: var(--muted); }
.chat-note { text-align: center; color: var(--muted); font-size: 12px; }

/* Franja en vivo: lo de abajo de la pantalla de Claude (menús, permisos, modo) */
#live { border-top: 1px solid var(--line); background: var(--panel); flex: none; }
.live-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; border-radius: 0; background: none;
  padding: 5px 12px; font-size: 12px; color: var(--muted); text-align: left;
}
.live-head .dot { width: 7px; height: 7px; }
.live-head #live-state { flex: 1; }
#live.open .chev { transform: rotate(180deg); }
#live-text {
  margin: 0; padding: 2px 12px 8px;
  font: 12px/1.35 var(--mono); color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 34vh; overflow-y: auto;
}

.msg.tools-group { font: 12.5px var(--mono); color: var(--muted); }
.msg.tools-group > summary { cursor: pointer; list-style: none; padding: 4px 8px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.tools-group > summary::-webkit-details-marker { display: none; }
.msg.tools-group > summary::before { content: "▸ "; }
.msg.tools-group[open] > summary::before { content: "▾ "; }
.msg.tools-group > summary:hover { background: var(--panel-2); }
.msg.tools-group .tname { color: #d2a8ff; }
.msg.tools-group.error > summary .tname { color: var(--danger); }
.msg.tools-group.pending > summary .tname::after { content: " …"; }
.msg.tools-group .tools-body { padding-left: 12px; border-left: 1px solid var(--line); margin-left: 10px; }

/* En pantallas anchas, el chat a un ancho cómodo de lectura. */
#chat-list { max-width: 860px; margin: 0 auto; width: 100%; }
#live-text { max-width: 860px; margin: 0 auto; }

/* Adjuntos de la caja de escribir */
#attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 10px 0; background: var(--panel); border-top: 1px solid var(--line); }
#attachments + #composer { border-top: none; }
.att-item { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; }
.att-item img { width: 100%; height: 100%; object-fit: cover; }
.att-name { font: 10.5px var(--mono); color: var(--muted); padding: 4px; text-align: center; overflow-wrap: anywhere; }
.att-rm { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border-radius: 50%; border: none; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 14px; line-height: 20px; }

/* Carpetas lógicas en la lista */
.folder { margin-bottom: 2px; }
.folder-row { min-height: 30px; font-weight: 600; color: var(--text); }
.folder-row .chev { width: 10px; color: var(--muted); transition: transform 0.12s; font-size: 10px; }
.folder.open .folder-row .chev { transform: rotate(90deg); }
.folder-row .dot { width: 7px; height: 7px; }
.folder-row .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-row .count { font-weight: 400; }
.folder-body { display: none; padding-left: 12px; }
.folder.open .folder-body { display: block; }
.folder-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.folder-pick button { padding: 6px 12px; border-radius: 999px; }

/* Ordenar arrastrando */
.grip {
  flex: none; cursor: grab; color: var(--muted); opacity: 0.55;
  padding: 0 2px; font-size: 14px; line-height: 1;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.grip:hover { opacity: 1; }
#list.filtering .grip { visibility: hidden; }
.dragging { opacity: 0.35; }
.drag-ghost {
  position: fixed; z-index: 50; pointer-events: none; margin: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); opacity: 0.95; cursor: grabbing;
}
@media (hover: none) { .grip { opacity: 0.8; font-size: 18px; padding: 6px 4px; } }

/* «Sin leer» y «te necesita» */
.dot.idle { background: #3d7a4a; }
.dot.unread { background: var(--accent); box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.22); }
.dot.wait { background: #ff3b30; box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.35); animation: nido-pulse 1.6s ease-in-out infinite; }
@keyframes nido-pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 59, 48, 0.1); } }
@media (prefers-reduced-motion: reduce) { .dot.wait { animation: none; } }
.sess-item.attn .name { color: #fff; font-weight: 700; }
#crumb .state.unread { color: var(--accent); }
#crumb .state.idle { color: #6fae7c; }
#crumb .state.wait { color: #ff453a; font-weight: 600; }

/* Teclear en Claude desde la franja en vivo */
#live-text { cursor: text; }
.live-hint { color: var(--muted); opacity: 0.7; font-size: 11px; margin-left: auto; padding-right: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#live.typing { box-shadow: inset 0 0 0 1px var(--accent); }
#live.typing .live-hint { color: var(--accent); opacity: 1; }
#live.typing #live-text { background: rgba(126, 231, 135, 0.04); }
@media (max-width: 720px) { .live-hint { display: none; } #live.typing .live-hint { display: inline; } }

/* «Sin leer», bien visible: verde vivo, halo y parpadeo (sin parpadeo si se pide menos movimiento) */
.dot.unread {
  background: #39ff6e;
  box-shadow: 0 0 0 3px rgba(57, 255, 110, 0.35), 0 0 10px rgba(57, 255, 110, 0.8);
  animation: nido-blink 1s ease-in-out infinite;
}
.sess-item .dot.unread { width: 11px; height: 11px; }
@keyframes nido-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.2; transform: scale(0.7); }
}
.sess-item.st-unread .name { color: #39ff6e; }
#crumb .state.unread { color: #39ff6e; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .dot.unread { animation: none; } }

/* Carpetas: que se distingan de las conversaciones (banda propia, icono, nombre en versalitas;
   sus conversaciones cuelgan de una línea, sangradas). */
.folder { margin: 8px 0 4px; }
.folder:first-child { margin-top: 2px; }
.folder-row {
  background: #1a1f27;
  border: 1px solid #262c36;
  border-radius: 7px;
  min-height: 32px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #aab4c0;
}
.folder-row:hover { background: #20262f; }
.folder-row .ficon { width: 15px; height: 15px; color: #8b949e; flex: none; }
.folder.open .folder-row .ficon { color: #c9d1d9; }
.folder-row .count {
  font-weight: 600; letter-spacing: 0; color: var(--muted);
  background: var(--bg); border-radius: 999px; padding: 0 7px; line-height: 18px;
}
.folder-body { margin: 4px 0 0 13px; padding-left: 8px; border-left: 1px solid #2a313c; }
.folder-body .sess-item { min-height: 40px; }
@media (hover: none) { .folder-row .count { display: inline-block; } }

/* Cuentas de Claude (cswap) */
#accounts-btn .svg { width: 18px; height: 18px; }
#accounts-btn.warn { color: #e3b341; border-color: #6b5420; background: #2a2210; }
#accounts-btn.crit { color: #ff3b30; border-color: #7a2420; background: #2d1210; }
.accounts-box { width: min(560px, 100%); max-height: calc(var(--app-h, 100dvh) - 40px); overflow-y: auto; }
#accounts-list { display: flex; flex-direction: column; gap: 10px; }
.acc { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.acc.active { border-color: #2c5a3f; box-shadow: inset 3px 0 0 var(--accent); }
.acc.disabled { opacity: .6; }
.acc.old .acc-bar i { filter: saturate(.3); }
.acc > header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.acc-num { font: 600 12px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.acc-name { font-weight: 600; overflow-wrap: anywhere; flex: 1; min-width: 0; }
.acc-mail { font-weight: 400; color: var(--muted); font-size: 12px; }
.acc-badge { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.acc-badge.on { color: #39ff6e; border-color: #2c5a3f; }
.acc-badge.bad { color: #ff6b6b; border-color: #5a2c2c; }
.acc-win { display: grid; grid-template-columns: 52px 1fr 44px; align-items: center; gap: 2px 8px; margin: 6px 0; }
.acc-label { font-size: 12px; color: var(--muted); }
.acc-pct { font: 600 12.5px var(--mono); text-align: right; }
.acc-reset { grid-column: 2 / 4; font-size: 11.5px; color: var(--muted); }
.acc-ahead { font-weight: 500; color: var(--warn); }
.acc-out { font-weight: 600; color: #ff6b6b; }
.acc-bar { position: relative; height: 10px; border-radius: 5px; background: #21262d; overflow: hidden; }
.acc-bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: #3fb950; }
.acc-bar.warn > i { background: #d29922; }
.acc-bar.crit > i { background: #ff3b30; }
.acc-pace { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px #0d1117; }
.acc-foot-line { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; font-size: 11.5px; color: var(--muted); min-height: 0; }
.acc-foot-line > span { flex: 1; }
.acc-use { margin-left: auto; font: 600 13px system-ui, sans-serif; padding: 6px 14px; border-radius: 8px; border: 1px solid #2c5a3f; background: #1f3a2a; color: #e6edf3; cursor: pointer; }
.acc-use:disabled { opacity: .5; cursor: default; }
.acc-note { color: var(--muted); font-size: 13px; margin: 8px 0; }
.acc-foot { color: var(--muted); font-size: 11.5px; margin: 10px 2px 0; }

/* Emparejar este navegador (antes de cargar la web) */
body.pairing > :not(#pair-screen):not(#web-changed) { display: none !important; }
#pair-screen { max-width: 460px; margin: 12vh auto 0; padding: 0 16px; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
#pair-screen h1 { font: 600 20px var(--mono); margin: 0 0 12px; }
#pair-screen p { color: var(--muted); margin: 0 0 14px; }
#pair-screen code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; color: var(--text); }
#pair-form { display: flex; gap: 8px; }
#pair-form input { flex: 1; min-width: 0; font: 16px var(--mono); padding: 10px 12px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
#pair-form button { font: 600 15px system-ui, sans-serif; padding: 10px 16px; background: var(--accent); color: var(--bg); border: 0; border-radius: 8px; }
#pair-error { color: var(--danger) !important; min-height: 1.5em; margin-top: 10px !important; }
.pair-note { font-size: 13px; }
#web-changed { position: fixed; inset: 0 0 auto; z-index: 100; padding: 10px 14px; background: #3a2a00; color: #ffd866; font: 14px system-ui, sans-serif; text-align: center; }
#web-changed button { margin-left: 8px; }
#e2e-state { display: none; }
body.e2e-down #e2e-state:not(:empty) { display: block; position: fixed; inset: auto 0 0; z-index: 90; padding: 8px 14px; background: #2d1210; color: #ff7b72; font: 13px system-ui, sans-serif; }

