/* ══════════════════════════════════════════════════════════════
   Prototipo: portada terminal del Modo IA (/terminal)
   Una sola familia: Martian Mono (variable: ancho 75–112.5, peso 100–800).
   Negro cálido + hueso + UN acento lima (actividad del agente). Sin azul.
   ══════════════════════════════════════════════════════════════ */

:root {
    --bg: #0c0c0a;
    --bg-2: #13130f;
    --fg: #e8e4d8;
    --dim: #8a8577;
    --faint: #3a3830;
    --line: #22211c;
    --lime: #d4ff3a;
    --err: #ff7a59;
    --mono: "Martian Mono", ui-monospace, monospace;
    --gut: clamp(16px, 3vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body.tm {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.65;
    font-variation-settings: "wdth" 88;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

a { color: inherit; }
::selection { background: var(--lime); color: var(--bg); }

/* ── Barra ─────────────────────────────────────────────────── */
.tm-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px var(--gut);
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    color: var(--dim);
}
.tm-bar__id { color: var(--fg); }
.tm-bar__id i { font-style: normal; color: var(--dim); }
.tm-bar__nav { display: flex; gap: 20px; white-space: nowrap; }
.tm-bar__nav a { text-decoration: none; }
.tm-bar__nav a:hover { color: var(--lime); }

/* ── Layout ────────────────────────────────────────────────── */
.tm-shell {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
}

/* ── Terminal ──────────────────────────────────────────────── */
.tm-term {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 24px var(--gut) 20px;
    cursor: text;
}

.tm-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--faint) transparent;
    padding-bottom: 8px;
    container-type: inline-size;
}

.tm-row { white-space: pre-wrap; word-break: break-word; }
.tm-dim { color: var(--dim); }
.tm-ok { color: var(--lime); }
.tm-err { color: var(--err); }
.tm-gap { height: 1.1em; }

/* Nombre: cada letra respira en el eje de ancho de la fuente */
.tm-name {
    margin: 22px 0 10px;
    font-size: min(8.6cqi, 124px);
    line-height: .95;
    font-weight: 800;
    letter-spacing: -.02em;
    user-select: none;
}
.tm-name span {
    display: inline-block;
    font-variation-settings: "wdth" 75, "wght" 100;
    opacity: 0;
    transition: font-variation-settings .5s cubic-bezier(.2, .9, .2, 1);
    animation: tm-letter .9s cubic-bezier(.2, .9, .2, 1) forwards;
}
.tm-name span.is-sp { width: .45em; }
.tm-word { display: inline-block; white-space: nowrap; }
@container (max-width: 560px) {
    .tm-name { font-size: 15.5cqi; }
    .tm-name .is-sp { display: block; height: 0; }
}
.tm-boot { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes tm-letter {
    0% { opacity: 0; font-variation-settings: "wdth" 75, "wght" 100; }
    40% { opacity: 1; }
    100% { opacity: 1; font-variation-settings: "wdth" 100, "wght" 800; }
}

.tm-lede { max-width: 64ch; font-size: 15px; }
.tm-lede b { color: var(--lime); font-weight: 500; }

.tm-cmds { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.tm-sug { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.tm-sug .tm-cmd { color: var(--dim); text-align: left; }
.tm-sug .tm-cmd::before { content: "› "; color: var(--lime); }
.tm-sug .tm-cmd:hover { color: var(--lime); }
.tm-cmd {
    font: inherit;
    color: var(--fg);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--faint);
    text-underline-offset: 4px;
}
.tm-cmd:hover, .tm-cmd:focus-visible { color: var(--lime); text-decoration-color: var(--lime); outline: none; }

/* Intercambio pregunta/respuesta */
.tm-q { margin-top: 18px; }
.tm-q .tm-ps { color: var(--dim); }
.tm-a { margin-top: 6px; padding-left: 2ch; border-left: 1px solid var(--line); }
.tm-a b { color: #fff; font-weight: 600; }
.tm-a a { color: var(--lime); text-decoration: none; }
.tm-a a:hover { text-decoration: underline; text-underline-offset: 3px; }
.tm-a .tm-tool { color: var(--dim); }
.tm-a .tm-tool em { font-style: normal; color: var(--lime); }
.tm-a .tm-bar-fit { color: var(--lime); }
.tm-spin { color: var(--lime); }

/* Tablas que emite el agente */
.tm-table-wrap { overflow-x: auto; margin: 4px 0; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
.tm-table { border-collapse: collapse; white-space: normal; word-break: normal; overflow-wrap: normal; min-width: min(100%, 420px); font-size: .95em; }
.tm-table td { min-width: 6ch; }
.tm-table th {
    text-align: left;
    font-weight: 400;
    color: var(--dim);
    padding: 0 3ch 6px 0;
    border-bottom: 1px solid var(--faint);
    white-space: nowrap;
}
.tm-table td { padding: 7px 3ch 7px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.tm-table tr:last-child td { border-bottom: 0; }
.tm-table tbody tr:hover td { color: #fff; }
.tm-table td:first-child { color: var(--dim); white-space: nowrap; }

.tm-caret::after {
    content: "";
    display: inline-block;
    width: .6em; height: 1.1em;
    margin-left: 2px;
    vertical-align: -.2em;
    background: var(--lime);
    animation: tm-blink 1s steps(1) infinite;
}
@keyframes tm-blink { 50% { opacity: 0; } }

/* Prompt */
.tm-prompt {
    display: flex;
    align-items: baseline;
    gap: 1ch;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.tm-ps1 { color: var(--dim); white-space: nowrap; }
.tm-ps1 span:first-child { color: var(--lime); }
.tm-input {
    flex: 1;
    min-width: 0;
    background: none;
    border: 0;
    outline: none;
    color: var(--fg);
    font: inherit;
    caret-color: var(--lime);
    padding: 0;
}
.tm-input:disabled { opacity: .5; }

/* ── Inspector ─────────────────────────────────────────────── */
.tm-inspect {
    border-left: 1px solid var(--line);
    background: var(--bg-2);
    padding: 20px 22px;
    overflow-y: auto;
    font-size: 12px;
}
.tm-inspect__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--dim);
    margin-bottom: 12px;
}
.tm-inspect__head + .tm-tele { margin-top: 0; }
.tm-state { color: var(--fg); }
.tm-state.is-live { color: var(--lime); }

.tm-diagram {
    margin: 0 0 28px;
    font: inherit;
    font-size: 11.5px;
    line-height: 1.35;
    color: var(--faint);
    font-variation-settings: "wdth" 75;
    white-space: pre;
    overflow-x: auto;
}
.tm-diagram .n { color: var(--dim); transition: color .4s; }
.tm-diagram .n.on { color: var(--fg); }
.tm-diagram .n.hot { color: var(--lime); }
.tm-diagram .e.lit { color: var(--dim); }
.tm-diagram .pk { color: var(--lime); font-weight: 800; }
.tm-diagram .pk2 { color: rgba(212, 255, 58, .55); }

.tm-tele { margin: 0; }
.tm-tele div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--line);
}
.tm-tele dt { color: var(--dim); }
.tm-tele dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.tm-tele dd.is-new { color: var(--lime); }

.tm-inspect__foot { margin: 16px 0 0; color: var(--dim); font-size: 11px; line-height: 1.6; }
.tm-inspect__foot code { font: inherit; color: var(--fg); }

/* ── Micrófono (Web Speech API, es-MX) ─────────────────────── */
.tm-mic {
    font: inherit;
    font-size: 12px;
    color: var(--dim);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    white-space: nowrap;
}
.tm-mic:hover, .tm-mic:focus-visible { color: var(--lime); outline: none; }
.tm-mic.is-on { color: var(--bg); background: var(--lime); padding: 0 6px; }

/* ── Navegador controlado por el agente ────────────────────── */
.tm-shell.has-site { grid-template-columns: minmax(0, .9fr) minmax(0, 1.35fr); }
.tm-shell.has-site .tm-inspect { display: none; }
.tm-site {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-left: 1px solid var(--line);
    background: var(--bg-2);
}
.tm-site[hidden] { display: none; }
.tm-site__bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    color: var(--dim);
}
.tm-site__who { display: flex; align-items: center; gap: 8px; color: var(--lime); white-space: nowrap; }
.tm-site__dot { width: 7px; height: 7px; background: var(--lime); animation: tm-blink 1.2s steps(1) infinite; }
.tm-site__url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); }
.tm-site__close { font: inherit; color: var(--dim); background: none; border: 0; cursor: pointer; padding: 0; }
.tm-site__close:hover { color: var(--lime); }
.tm-site__frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ── Visión: captura del proyecto con detecciones ──────────── */
.tm-vis { margin: 14px 0 4px; max-width: 760px; white-space: normal; }
.tm-vis__head, .tm-vis__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 11.5px; color: var(--dim); }
.tm-vis__head { margin-bottom: 8px; }
.tm-vis__head b { color: var(--lime); font-weight: 500; }
.tm-vis__stage { position: relative; border: 1px solid var(--faint); overflow: hidden; line-height: 0; }
.tm-vis__stage img { width: 100%; height: auto; display: block; filter: grayscale(.85) brightness(.72) contrast(1.05); transition: filter 1.2s; }
.tm-vis.is-done .tm-vis__stage img { filter: grayscale(.35) brightness(.82); }
.tm-vis__scan {
    position: absolute; left: 0; right: 0; top: 0; height: 2px;
    background: var(--lime);
    box-shadow: 0 0 18px 4px rgba(212, 255, 58, .35);
    animation: tm-scan 1.1s cubic-bezier(.5, 0, .5, 1) forwards;
}
@keyframes tm-scan { from { top: 0; opacity: 1; } 92% { opacity: 1; } to { top: 100%; opacity: 0; } }
.tm-box {
    position: absolute;
    border: 1.5px solid var(--lime);
    opacity: 0;
    transform: scale(1.06);
    transition: opacity .35s, transform .45s cubic-bezier(.2, .9, .2, 1), background .25s;
}
.tm-box.is-on { opacity: 1; transform: none; }
.tm-box.is-hot { background: rgba(212, 255, 58, .16); }
.tm-box span {
    position: absolute; left: -1.5px; bottom: 100%;
    padding: 1px 5px;
    font-size: 9.5px; line-height: 1.35;
    white-space: nowrap;
    color: var(--bg);
    background: var(--lime);
}
.tm-box.is-low span { bottom: auto; top: 100%; }
.tm-box.is-right span { left: auto; right: -1.5px; }
.tm-box.is-in span { bottom: auto; top: -1.5px; }
.tm-box.is-inb span { bottom: -1.5px; }
.tm-box em { font-style: normal; }
.tm-vis { container-type: inline-size; }
@container (max-width: 460px) {
    .tm-box em { display: none; }                  /* en angosto: solo el número; la lista trae el nombre */
    .tm-box span, .tm-box.is-side span, .tm-box.is-right span, .tm-box.is-low span, .tm-box.is-inb span {
        top: -1.5px; bottom: auto; left: -1.5px; right: auto; margin: 0; transform: none;   /* número dentro de su caja */
        font-size: 8px; line-height: 1.25; padding: 0 3px;
    }
    .tm-box.is-right span { left: auto; right: -1.5px; }
}
.tm-box.is-side span { bottom: auto; top: 50%; left: 100%; margin-left: 6px; transform: translateY(-50%); }
.tm-vis__list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12px; line-height: 1.7; }
.tm-vis__list li { display: flex; gap: 1.5ch; opacity: 0; transition: opacity .3s; cursor: default; }
.tm-vis__list li.is-on { opacity: 1; }
.tm-vis__list li:hover { color: var(--lime); }
.tm-vis__list .c { color: var(--dim); margin-left: auto; font-variant-numeric: tabular-nums; }
.tm-vis__foot { margin-top: 6px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
    .tm-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
    .tm-inspect { display: none; }
    .tm-term { padding-top: 16px; }
    body.tm { font-size: 13px; }
    .tm-bar__id i { display: none; }
    .tm-shell.has-site { grid-template-columns: minmax(0, 1fr); }
    .tm-site { position: fixed; inset: 0; z-index: 20; border: 0; }
    .tm-vis__list .c { display: none; }

    /* objetivos táctiles cómodos */
    .tm-bar { padding-top: 6px; padding-bottom: 6px; }
    .tm-bar__nav { gap: 18px; }
    .tm-bar__nav a { display: inline-block; padding: 10px 0; }
    .tm-cmds { gap: 2px 18px; }
    .tm-cmd { padding: 9px 0; }
    .tm-sug { gap: 2px 16px; }
    .tm-prompt { align-items: center; }
    .tm-input { min-height: 40px; font-size: 16px; }   /* 16px evita el zoom automático de iOS al enfocar */
    .tm-mic { padding: 10px 0 10px 6px; }
    .tm-site__bar { padding: 4px 16px; }
    .tm-site__close { padding: 10px 0 10px 8px; }
}

/* Teléfonos angostos: la barra no cabe completa; el nombre ya está en grande en la portada */
@media (max-width: 480px) {
    .tm-bar__id { display: none; }
    .tm-bar { justify-content: flex-end; }
    .tm-bar__nav { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .tm-name span { animation: none; opacity: 1; font-variation-settings: "wdth" 100, "wght" 800; }
    .tm-caret::after { animation: none; }
    .tm-vis__scan { display: none; }
}
