/* Foto a CodeClone. Oscuro, como el editor: lo único en color es una línea de 1px que marca lo seleccionado,
   como la pestaña activa de VS Code. */
@font-face {
  font-family: "Public Sans";
  src: url("/fonts/public-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ground: #171719;
  --surface: #131217;
  --raised: #212023;
  --border: #222224;
  --rule: #1b1a1f;
  --control: #3a3a3e;
  --text: #ffffff;
  --muted: #8a8c92;
  --soft: #bdbdc0;
  --accent: #0078d4;
  --positive: #44a282;
  --pos-bg: #1b2828;
  --pos-ink: #5fc39c;
  --neg-bg: #2c1a20;
  --neg-ink: #e5566f;
  --warn-bg: #2a2416;
  --warn-ink: #d9a441;
  --editor: #1f1f1f;
  --tabstrip: #181818;
  --editor-line: #2b2b2b;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --nav-h: 84px;
  --gutter: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--ground); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--text);
  font: 400 13px/20px var(--font);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 16px; height: 16px; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ---------- cabecera ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: env(safe-area-inset-top) var(--gutter) 0;
  background: var(--ground);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; text-decoration: none; }
.brand svg { width: 24px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; text-decoration: none; font-size: 14px; background: none; border: 0; padding: 0; }
.presence { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58%; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--control); flex: none; }
.dot.on { background: var(--positive); }
.dot.bad { background: var(--neg-ink); }
.top .icon-btn { margin-left: auto; }
.top .presence + .icon-btn { margin-left: 4px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; color: var(--muted); border-radius: 6px; }
.icon-btn:active { background: var(--raised); }

/* ---------- vistas ---------- */
.view { padding: 20px var(--gutter) calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; max-width: 640px; margin: 0 auto; }
.view.with-bar { padding-bottom: calc(96px + env(safe-area-inset-bottom)); gap: 24px; }
h1 { margin: 0; font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
h1.mono { font-size: 24px; font-weight: 500; letter-spacing: 0; }
.lead { margin: 4px 0 0; color: var(--muted); }
h2 { margin: 0; font-size: 14px; line-height: 20px; font-weight: 500; }
h2.label { color: var(--muted); margin-bottom: 4px; }
h2.section { font-size: 20px; line-height: 26px; font-weight: 400; color: var(--muted); }
.notice { margin: 0; padding: 12px 14px; border-radius: 6px; background: var(--neg-bg); color: var(--neg-ink); }
.notice.ok { background: var(--pos-bg); color: var(--pos-ink); }
.hint { margin: 4px 0 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.warn-text { margin: 0; font-size: 12px; line-height: 17px; color: var(--warn-ink); }

/* ---------- tarjetas ---------- */
.card { background: var(--surface); border-radius: 6px; box-shadow: var(--shadow); padding: 16px; }
.card.stack, .view-form { display: flex; flex-direction: column; gap: 14px; }
.card.stack > .hint { margin-top: -10px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; gap: 12px; align-items: center; }
.card.flush .card-head { padding: 16px 16px 12px; }
.card-head .grow { flex: 1; min-width: 0; }
.card-title { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; text-decoration: none; display: block; }
.card-title.mono { font-weight: 500; }
.card-sub { margin: 2px 0 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.card-foot { margin: 12px 0 0; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.card-foot .mono { font-size: 12px; color: var(--text); }
a.card { display: flex; gap: 12px; align-items: center; padding: 12px 16px; text-decoration: none; }
a.card .grow { flex: 1; min-width: 0; }

.thumb { flex: none; width: 44px; height: 52px; border-radius: 2px; object-fit: cover; background: #2a2926; display: grid; place-items: center; color: var(--muted); }
.thumb.result { background: #ffffff; object-fit: cover; object-position: top; }

.pill { flex: none; white-space: nowrap; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 500; background: var(--raised); color: var(--soft); }
.pill.pos { background: var(--pos-bg); color: var(--pos-ink); }
.pill.neg { background: var(--neg-bg); color: var(--neg-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }

/* ---------- recorrido: hora de cada paso ---------- */
.strip { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(var(--stops, 3), minmax(0, 1fr)); border-top: 1px solid var(--control); }
.strip.top0 { margin-top: 0; }
.stop { padding-top: 8px; min-width: 0; }
.stop .t { display: block; font: 12px/16px var(--mono); }
.stop .l { display: block; font-size: 12px; line-height: 16px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop.pending .t { color: var(--muted); }
.stop.current { padding-top: 0; }
.stop.current > span { display: inline-block; max-width: 100%; }
.stop.current .line { display: block; height: 1px; margin-top: -1px; background: var(--accent); }
.stop.current .t { padding-top: 8px; }
.stop.current .l { color: var(--text); }
.stop.failed .l, .stop.failed .t { color: var(--neg-ink); }

/* ---------- editor (código) ---------- */
.editor { background: var(--editor); border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); }
.card .editor { border-radius: 0; box-shadow: none; }
.tabstrip { display: flex; align-items: center; background: var(--tabstrip); border-top: 1px solid var(--editor-line); border-bottom: 1px solid var(--editor-line); }
.editor > .tabstrip:first-child { border-top: 0; }
.tab { padding: 6px 12px; margin: -1px 0; background: var(--editor); border-top: 1px solid var(--accent); font: 12px/18px var(--mono); }
.tabstrip .meta { margin-left: auto; padding-right: 12px; font-size: 12px; color: var(--muted); }
.code { padding: 8px 0 10px; font: 11.5px/18px var(--mono); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.code.preview { overflow: hidden; font-size: 12px; line-height: 20px; }
.code-line { display: flex; white-space: pre; }
.code-line .n { flex: none; width: 30px; padding-right: 12px; text-align: right; color: var(--muted); user-select: none; }
.code-line .c { padding-right: 12px; }
.k1 { color: #569cd6; } .k2 { color: #c586c0; } .fn { color: #dcdcaa; } .str { color: #ce9178; } .num { color: #b5cea8; } .var { color: #9cdcfe; } .com { color: #6a9955; } .pun { color: #cccccc; }

/* ---------- botones ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card .actions { padding: 12px 16px 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--control); background: transparent; color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none; }
.btn:active { background: var(--raised); }
.btn.primary { border: 0; background: #ffffff; color: var(--surface); font-size: 14px; font-weight: 600; padding: 0 22px; }
.btn.primary:disabled { background: var(--control); color: var(--muted); }
.btn.text { border: 0; padding: 0 4px; color: var(--soft); }
.btn.text.right { margin-left: auto; }
.btn.danger { color: var(--neg-ink); }
.btn:disabled { opacity: 0.55; cursor: default; }
.link-btn { border: 0; background: none; padding: 0; min-height: 44px; color: var(--text); font-size: 13px; text-decoration: underline; }

/* ---------- pestañas y opciones: la selección es una línea de 1px ---------- */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { position: relative; flex: none; height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; }
.tabs button.on { color: var(--text); }
/* Dentro del botón: la fila se desplaza de lado y recortaría una línea que asome por debajo. */
.tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--accent); }
.seg { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.seg button { display: inline-flex; flex-direction: column; justify-content: center; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 14px; }
.seg button.on { color: var(--text); }
.seg button.on::after { content: ""; display: block; height: 1px; margin-top: 2px; background: var(--accent); }

.choice { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0; border: 0; border-bottom: 1px solid var(--rule); background: transparent; text-align: left; color: var(--soft); }
.choice .name { display: inline-flex; flex-direction: column; font-size: 14px; }
.choice.on { color: var(--text); }
.choice.on .name::after { content: ""; display: block; height: 1px; margin-top: 2px; background: var(--accent); }
.choice .meta { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- interruptores y casillas ---------- */
.switch-row { display: flex; align-items: center; gap: 12px; }
.switch-row .grow { flex: 1; min-width: 0; }
.switch { flex: none; position: relative; width: 44px; height: 26px; padding: 0; border: 0; border-radius: 999px; background: var(--control); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 0.15s ease; }
.switch[aria-checked="true"] { background: #ffffff; }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: var(--surface); }
.switch:disabled { opacity: 0.5; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--rule); }
.check input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: #ffffff; }
.check .grow { flex: 1; min-width: 0; }
.check .t { display: block; font-size: 14px; }
.check .d { display: block; font-size: 12px; line-height: 16px; color: var(--muted); }

/* ---------- campos ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span:first-child { font-size: 14px; font-weight: 500; }
.field.small > span:first-child { font-size: 12px; font-weight: 400; color: var(--muted); }
.input, textarea.input, select.input { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--control); background: var(--surface); color: var(--text); font-size: 16px; }
textarea.input { padding: 10px 12px; line-height: 21px; resize: vertical; font-size: 14px; }
.input.mono { font-family: var(--mono); }
.input.bad { border-color: var(--neg-ink); }
.inline-save { display: flex; gap: 8px; }
.inline-save .input { flex: 1; min-width: 0; }

/* ---------- inicio ---------- */
.empty p { margin: 0 0 8px; color: var(--muted); max-width: 34em; }
.empty .big { font-size: 20px; line-height: 26px; color: var(--text); font-weight: 600; }

/* ---------- enviar ---------- */
.photos { display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px 2px; }
.photo { position: relative; flex: none; }
.photo img { display: block; width: 84px; height: 108px; object-fit: cover; border-radius: 4px; background: #2a2926; }
.photo button { position: absolute; top: -6px; right: -6px; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 2px solid var(--ground); border-radius: 50%; background: #ffffff; color: var(--surface); }
.photo button svg { width: 14px; height: 14px; stroke-width: 2.4; }
.add-photo { flex: none; width: 84px; height: 108px; border-radius: 4px; border: 1px dashed var(--control); background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 12px; }
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px var(--gutter) calc(16px + env(safe-area-inset-bottom)); background: var(--ground); border-top: 1px solid var(--border); }
.bottom-bar .btn.primary { width: 100%; max-width: 608px; margin: 0 auto; display: flex; height: 52px; font-size: 15px; }

/* ---------- barra de secciones ---------- */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: start;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav a { display: flex; justify-content: center; text-decoration: none; color: var(--muted); }
.nav a > span { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 10px; font-size: 12px; line-height: 16px; }
.nav a.on { color: var(--text); }
.nav a.on > span { padding-top: 0; }
.nav a.on > span::before { content: ""; display: block; align-self: stretch; height: 1px; margin-top: -1px; margin-bottom: 9px; background: var(--accent); }
.nav .shutter { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: -20px; color: var(--muted); font-size: 12px; line-height: 16px; cursor: pointer; }
.nav .shutter span.disc { width: 56px; height: 56px; border-radius: 50%; background: #ffffff; color: var(--surface); display: grid; place-items: center; box-shadow: 0 0 0 4px var(--ground); }
.nav .shutter svg { width: 24px; height: 24px; stroke-width: 1.8; }
.nav .shutter:active span.disc { transform: scale(0.94); }

/* ---------- solución en imagen ---------- */
.result-img { display: block; width: 100%; height: auto; border-radius: 4px; background: #ffffff; box-shadow: var(--shadow); }
.figure { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.figure figcaption { font-size: 12px; line-height: 17px; color: var(--muted); }
.sources { display: flex; gap: 8px; }
.sources img { width: 56px; height: 72px; object-fit: cover; border-radius: 3px; background: #2a2926; }
/* ---------- lo que el puente le agrega a la IA (Tipos) ---------- */
.added-prompts { border: 1px solid var(--border); border-radius: 6px; padding: 0 14px; }
.added-prompts > summary { cursor: pointer; padding: 12px 0; font-size: 14px; font-weight: 500; color: var(--soft); }
.added-prompts[open] > summary { border-bottom: 1px solid var(--rule); margin-bottom: 10px; }
.added-prompts > .hint { margin: 0 0 12px; }
.added-prompt { margin: 0 0 14px; }
.added-prompt h3 { margin: 0; font-size: 13px; font-weight: 600; }
.added-prompt .hint { margin: 2px 0 6px; }
.added-prompt pre { margin: 0; padding: 10px 12px; border-radius: 4px; background: var(--editor); color: var(--soft); font: 12px/18px var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.attempts { list-style: none; margin: 0; padding: 0; }
.attempts li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 12px; line-height: 16px; }
.attempts .t { flex: none; font-family: var(--mono); color: var(--muted); }
.attempts .m { flex: 1; min-width: 0; font-family: var(--mono); color: var(--soft); overflow-wrap: anywhere; }
.attempts .o { flex: none; text-align: right; color: var(--warn-ink); }
.attempts .o.ok, .attempts .o.fixed { color: var(--pos-ink); }
.attempts .o.auth, .attempts .o.unusable, .attempts .o.credit { color: var(--neg-ink); }

/* ---------- WhatsApp ---------- */
.conn h2 { display: inline; }
.conn-head { display: flex; align-items: center; gap: 8px; }
.conn-head .link-btn { margin-left: auto; }
.conn .rule { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.qr { margin: 12px 0 0; }
.qr img { display: block; width: min(240px, 70vw); aspect-ratio: 1; border-radius: 6px; background: #ffffff; padding: 8px; }
.chat { background: #0f0f11; border-radius: 6px; padding: 12px; }
.bubble { margin-left: auto; width: 236px; background: #262a2e; border-radius: 6px; padding: 6px; }
.bubble img { display: block; width: 100%; border-radius: 3px; background: #ffffff; }
.bubble p { margin: 6px 4px 0; font-size: 12px; line-height: 16px; }
.bubble .time { margin: 0 4px; text-align: right; font: 11px/16px var(--mono); color: var(--muted); }
.bubble pre { margin: 0; padding: 8px; border-radius: 3px; background: #1d2023; font: 11px/16px var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 160px; overflow: hidden; }

/* ---------- PCs ---------- */
.pcs { list-style: none; margin: 0; padding: 0; }
.pc { display: flex; align-items: center; gap: 12px; min-height: 64px; border-bottom: 1px solid var(--rule); }
.pc .grow { flex: 1; min-width: 0; }
.pc .name { display: block; font-size: 14px; font-weight: 600; }
.pc .token { display: block; font-size: 12px; line-height: 16px; color: var(--muted); overflow-wrap: anywhere; }
.pc .token span { font-family: var(--mono); color: var(--soft); }
.pc .state { flex: none; font-size: 12px; color: var(--muted); }
.pc .state.on { color: var(--pos-ink); }

/* ---------- entrar ---------- */
.login { display: flex; flex-direction: column; min-height: 100dvh; padding: calc(72px + env(safe-area-inset-top)) 24px calc(32px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; }
.login .brand { font-size: 16px; }
.login .brand svg { width: 28px; height: 28px; }
.login h1 { margin-top: 40px; }
.login .lead { font-size: 14px; line-height: 21px; color: var(--soft); margin-top: 8px; }
.login form { display: flex; flex-direction: column; gap: 16px; margin-top: 32px; }
.login .input { min-height: 48px; font-size: 17px; }
.login .btn.primary { height: 52px; font-size: 15px; }
.login .error { margin: -6px 0 0; font-size: 13px; color: var(--neg-ink); }
.login .foot { margin-top: auto; padding-top: 24px; font-size: 12px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
