/* Tipografías compartidas con /presentacion; colores de la referencia del chat. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/presentacion/assets/fonts/inter-var.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-style: normal; font-weight: 800; font-display: swap; src: url("/presentacion/assets/fonts/barlow-sc-800.woff2") format("woff2"); }
@font-face { font-family: "Martian Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("/presentacion/assets/fonts/martian-mono-var.woff2") format("woff2"); }

:root {
  --brand: #db817a;
  --brand-hover: #e79a93;
  --on-brand: #14201d;
  --accent: #14201d;
  --bg: #f7f7f2;
  --panel: #ffffff;
  --ink: #14201d;
  --muted: #635f5c;
  --line: #b9b9ad;
  --field-border: #635f5c;
  --surface-subtle: #e4e5db;
  --user: #db817a;
  --highlight: #f7e5ad;
  --ok: #14201d;
  --warn: #72510b;
  --err: #a52f26;
  --radius: 0;
  --shadow: 4px 4px 0 var(--ink);
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  --font-mono: "Martian Mono", ui-monospace, "SFMono-Regular", monospace;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  display: flex; flex-direction: column;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  height: 100vh; height: var(--app-height, 100dvh);
  overflow: hidden;
}
.chat-window { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; background: var(--bg); }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button, a, summary, input, select, textarea { -webkit-tap-highlight-color: rgba(219,129,122,.25); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.label-short { display: none; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  background: var(--surface-subtle); border-bottom: 3px solid var(--ink);
  flex: none; position: relative; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 38px; height: 38px; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); border-radius: 0; background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center; font: 800 25px var(--font-display); flex: none;
}
.brand h1 { font: 700 18px/1.3 var(--font-mono); text-transform: uppercase; margin: 0; letter-spacing: .025em; }
.brand p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.status { display: inline-flex; align-items: center; gap: 6px; font: 500 10px/1.4 var(--font-mono); text-transform: uppercase; letter-spacing: .03em; padding: 6px 10px; border-radius: 0; background: transparent; color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 10px; height: 10px; border: 2px solid var(--ink); background: var(--surface-subtle); flex: none; }
.status.ok { background: transparent; color: var(--ink); }
.status.ok::before { background: var(--highlight); }
.status.bad::before { background: var(--brand); }
.status.bad { background: #fdecea; color: var(--err); }
.ghost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; background: transparent; border: 2px solid var(--ink); border-radius: 0; padding: 8px 12px; color: var(--ink); }
.ghost { font: 600 11px/1.4 var(--font-mono); text-transform: uppercase; letter-spacing: .02em; }
.ghost svg { flex: none; }
.ghost:hover:not(:disabled) { background: var(--highlight); border-color: var(--ink); color: var(--ink); }

.chat {
  flex: 1; min-height: 0; min-width: 0; overflow-y: auto; overscroll-behavior-y: contain;
  padding: 32px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left));
  scroll-padding-block: 16px;
}
.welcome, .messages { max-width: 880px; margin: 0 auto; }
.welcome-hero { display: grid; grid-template-columns: minmax(0, 1fr) 240px; column-gap: 28px; align-items: center; margin-bottom: 20px; }
.welcome-copy { min-width: 0; }
.eyebrow { margin: 0 0 10px; color: var(--muted); font: 500 11px/1.4 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.welcome h2 { font: 800 60px/.98 var(--font-display); letter-spacing: -.025em; margin: 0 0 12px; color: var(--ink); }
.welcome .lead { grid-column: 1; color: var(--muted); margin: 0; line-height: 1.55; max-width: 470px; }
.welcome-art { grid-column: 2; grid-row: 1 / 3; width: 100%; height: auto; }
.suggestions-heading { margin: 0 0 12px; }
.suggestions-heading h3 { margin: 0 0 4px; font: 800 26px/1.1 var(--font-display); }
.suggestions-heading p { margin: 0; font-size: 13px; color: var(--muted); }
.suggestions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.suggestions button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-width: 0;
  text-align: left; background: var(--panel); border: 2px solid var(--ink); border-radius: 0;
  padding: 16px; min-height: 142px; color: var(--ink); line-height: 1.4; box-shadow: var(--shadow);
}
.suggestions button:hover:not(:disabled) { background: var(--highlight); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.suggestion-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 0; background: var(--brand); border: 2px solid var(--ink); color: var(--ink); flex: none; }
.suggestions button:nth-child(even) .suggestion-icon { background: var(--highlight); }
.suggestion-icon svg { width: 22px; height: 22px; }
.suggestion-copy { display: grid; gap: 4px; overflow-wrap: anywhere; }
.suggestion-copy strong { font-size: 15px; font-weight: 700; }
.suggestion-copy small { font-size: 13px; color: var(--muted); }
.demo-notice { margin: 0 0 20px; border: 2px solid var(--ink); border-radius: 0; background: var(--surface-subtle); color: var(--muted); font-size: 13px; }
.demo-notice summary { display: flex; align-items: center; gap: 9px; padding: 10px 12px; min-height: 44px; cursor: pointer; list-style: none; }
.demo-notice strong { color: var(--ink); font-weight: 600; }
.notice-icon { width: 20px; height: 20px; flex: none; color: var(--accent); }
.disclosure-icon { width: 16px; height: 16px; flex: none; margin-left: auto; }
details[open] > summary .disclosure-icon { transform: rotate(180deg); }
.demo-notice p { margin: 0; padding: 0 12px 12px 41px; line-height: 1.55; }
.capabilities { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.capabilities > details { min-width: 0; overflow-wrap: anywhere; background: var(--panel); border: 2px solid var(--ink); border-radius: 0; }
.capabilities summary { display: flex; align-items: center; gap: 8px; padding: 14px; min-height: 52px; cursor: pointer; list-style: none; font-size: 14px; font-weight: 600; }
.demo-notice summary::-webkit-details-marker, .capabilities summary::-webkit-details-marker { display: none; }
.resource-count { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 0; background: var(--highlight); border: 1px solid var(--ink); color: var(--ink); font: 500 11px/1 var(--font-mono); font-weight: 600; }
.resource-count:empty { display: none; }
.capabilities ul { margin: 0 14px 14px; padding-left: 18px; font-size: 14px; line-height: 1.65; }
.capabilities .muted, .muted { color: var(--muted); }
@media (max-width: 640px) { .capabilities { grid-template-columns: 1fr; } }

.msg { margin: 0 0 18px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble { min-width: 0; max-width: 100%; overflow-wrap: anywhere; line-height: 1.6; font-size: 16px; }
.msg.user .bubble { background: var(--user); border: 2px solid var(--ink); padding: 14px 18px; border-radius: 0; max-width: 85%; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--panel); border: 2px solid var(--ink); border-radius: 0; padding: 18px 20px; box-shadow: var(--shadow); width: 100%; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 10px; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble h3, .bubble h4 { margin: 14px 0 6px; font-size: 15.5px; color: var(--ink); }
.bubble code { background: var(--surface-subtle); padding: 1px 5px; border-radius: 0; font: 400 12px/1.6 var(--font-mono); }
.bubble pre { background: var(--surface-subtle); padding: 10px; border-radius: 0; overflow-x: auto; max-width: 100%; }
.table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; margin: 8px 0 12px; border-radius: 0; }
.bubble table { border-collapse: collapse; font-size: 14px; width: 100%; min-width: 480px; }
.bubble th, .bubble td { border: 2px solid var(--ink); padding: 6px 8px; text-align: left; vertical-align: top; }
.bubble th { background: var(--surface-subtle); }
.bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
sup.cite a { display: inline-block; background: var(--highlight); border: 1px solid var(--ink); text-decoration: none; font: 600 11px/1.5 var(--font-mono); padding: 0 4px; }

.thinking { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.thinking summary { cursor: pointer; user-select: none; padding-block: 10px; }
.thinking .reasoning { white-space: pre-wrap; margin-top: 6px; padding: 8px 10px; background: var(--surface-subtle); border-radius: 0; max-height: 220px; overflow-y: auto; font-size: 12.5px; }
.typing::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.sources { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; font-size: 13px; }
.sources summary { cursor: pointer; color: var(--ink); font: 500 11px/1.5 var(--font-mono); background: var(--highlight); border: 2px solid var(--ink); min-height: 44px; padding: 10px; width: fit-content; max-width: 100%; }
.sources ol { margin: 8px 0 0; padding-left: 22px; }
.sources li { margin: 6px 0; }
.sources li.cited { background: var(--highlight); border-left: 3px solid var(--ink); padding: 4px 10px; }
.sources li:not(.cited) { color: var(--muted); }
.sources .meta { color: var(--muted); font-size: 12px; }
.sources a { display: inline-block; padding-block: 6px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.sources a:hover { text-decoration: underline; }

.doc-card, .tool-status {
  display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px;
  border: 2px solid var(--ink); border-radius: 0; background: var(--surface-subtle);
}
.doc-card .icon { width: 40px; height: 48px; border-radius: 0; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font: 600 10px/1 var(--font-mono); border: 2px solid var(--ink); flex: none; }
.doc-card .info { flex: 1; min-width: 0; }
.doc-card .info strong { display: block; }
.doc-card .info span { color: var(--muted); font-size: 12.5px; }
.doc-card a.primary { text-decoration: none; }
.tool-status { color: var(--muted); font-size: 14px; }
.bubble .content:empty + .tool-status { margin-top: 0; }
.tool-status.err { color: var(--err); border-color: #f3c7c2; background: #fdf3f2; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { margin-top: 10px; padding: 8px 12px; border-radius: 0; font-size: 13.5px; background: #fdecea; color: var(--err); }
.alert.warn { background: #fff6e0; color: var(--warn); }

.composer-wrap {
  flex: none; background: var(--bg);
  padding: 8px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.composer {
  max-width: 880px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end;
  background: var(--panel); border: 3px solid var(--ink); border-radius: 0; padding: 8px; box-shadow: var(--shadow);
}
.composer:focus-within { outline: 2px solid var(--ink); outline-offset: 3px; }
.composer textarea { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; resize: none; font: inherit; font-size: 16px; line-height: 1.5; padding: 10px 8px; min-height: 44px; max-height: 160px; max-height: min(160px, 30dvh); background: transparent; }
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 1; }
.primary { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; background: var(--brand); color: var(--on-brand); border: 2px solid var(--ink); border-radius: 0; padding: 10px 14px; font: 700 12px/1.4 var(--font-mono); letter-spacing: .03em; text-transform: uppercase; text-align: center; }
#send { flex: none; }
.voice-button { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 10px; border: 2px solid var(--ink); border-radius: 0; background: var(--panel); color: var(--accent); }
.voice-button svg { width: 22px; height: 22px; }
.voice-button:hover { background: var(--surface-subtle); border-color: var(--accent); }
.voice-button.listening { background: var(--brand); color: var(--on-brand); border-color: var(--accent); }
.voice-button .voice-stop-icon, .voice-button.listening .microphone-icon { display: none; }
.voice-button.listening .voice-stop-icon { display: block; }
.voice-button:disabled { opacity: .5; cursor: default; }
.voice-feedback { display: flex; align-items: center; gap: 10px; max-width: 880px; margin: 0 auto 8px; padding: 8px 12px; border: 2px solid var(--ink); border-radius: 0; background: var(--surface-subtle); color: var(--ink); }
.voice-feedback[hidden], #voice-cancel[hidden] { display: none; }
.voice-feedback p { flex: 1; margin: 0; font-size: 13px; line-height: 1.4; }
.voice-feedback .ghost { font-size: 13px; padding: 8px; flex: none; }
.voice-feedback.error { color: var(--err); background: #fdf3f2; border-color: #f3c7c2; }
.composer textarea:read-only { color: var(--ink); }
.primary:hover:not(:disabled) { background: var(--brand-hover); }
.primary:disabled { opacity: .6; cursor: default; }
.primary.stop { background: var(--ink); color: #fff; }

/* Tarjeta de confirmación de documento */
.confirm-card { margin-top: 12px; border: 2px solid var(--ink); border-radius: 0; background: var(--surface-subtle); padding: 14px; }
.confirm-card.done, .confirm-card.cancelled { opacity: .7; border-color: var(--line); background: var(--bg); }
.confirm-card.done .confirm-actions, .confirm-card.cancelled .confirm-actions { display: none; }
.confirm-head strong { display: block; color: var(--ink); }
.confirm-head span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.confirm-card .fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; margin-top: 14px; }
.confirm-card .field { display: flex; min-width: 0; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.confirm-card .field:has(textarea) { grid-column: 1 / -1; }
.confirm-card .field.req > span::after { content: " *"; color: var(--accent); }
.confirm-card input, .confirm-card select, .confirm-card textarea {
  min-width: 0; width: 100%; max-width: 100%; min-height: 44px;
  font: inherit; font-size: 16px; color: var(--ink); padding: 10px; border: 2px solid var(--field-border); border-radius: 0; background: var(--panel);
}
.confirm-card input:focus, .confirm-card select:focus, .confirm-card textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.confirm-card textarea { resize: vertical; }
.confirm-msg { margin-top: 10px; font-size: 13px; color: var(--ok); }
.confirm-msg:empty { display: none; }
.confirm-msg.err { color: var(--err); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
@media (max-width: 640px) { .confirm-card .fields { grid-template-columns: 1fr; } }

/* Los enlaces-botón dentro de la burbuja conservan el estilo de botón */
.bubble a.primary { color: var(--on-brand); text-decoration: none; }
.capabilities a { color: var(--accent); }

@media (max-width: 640px) {
  .topbar {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px;
    padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
    padding-bottom: 10px;
  }
  .brand h1 { font-size: 14px; }
  .brand { grid-column: 1; grid-row: 1; gap: 10px; }
  .brand p { display: none; }
  .top-actions { display: contents; }
  #new-chat { grid-column: 2; grid-row: 1 / 3; font-size: 11px; }
  #new-chat .label-wide { display: none; }
  #new-chat .label-short { display: inline; }
  .status { grid-column: 1; grid-row: 2; justify-self: start; margin-left: 48px; margin-top: 4px; padding: 0; background: transparent; font-size: 9px; }
  .chat { padding-top: 18px; }
  .welcome-hero { grid-template-columns: minmax(0, 1fr) clamp(96px, 30vw, 160px); column-gap: 10px; margin-bottom: 16px; }
  .eyebrow { font-size: 9px; letter-spacing: .05em; margin-bottom: 8px; }
  .welcome h2 { font-size: clamp(34px, 9vw, 42px); line-height: .98; letter-spacing: -.02em; margin: 0 0 8px; }
  .welcome-art { grid-row: 1; }
  .welcome .lead { grid-column: 1 / -1; font-size: 14px; max-width: none; }
  .suggestions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .suggestions button { padding: 12px; min-height: 126px; gap: 8px; }
  .suggestion-icon { width: 34px; height: 34px; border-radius: 0; }
  .suggestion-copy strong { font-size: 14px; }
  .suggestion-copy small { font-size: 12px; }
  .demo-notice { margin-bottom: 16px; }
  #demo-notice { font-size: 13px; line-height: 1.5; }
  .capabilities { gap: 12px; }
  .msg { margin-bottom: 14px; }
  .msg.assistant .bubble { padding: 12px; }
  .msg.user .bubble { max-width: 92%; padding: 10px 12px; }
  .confirm-card { padding: 12px; }
  .confirm-head span { font-size: 13px; }
  .doc-card { display: grid; grid-template-columns: 40px minmax(0, 1fr); padding: 12px; gap: 10px; }
  .doc-card a.primary { grid-column: 1 / -1; width: 100%; }
  .composer { padding: 6px; gap: 4px; border-radius: 0; }
  .composer-wrap { padding-top: 6px; }
}

@media (max-width: 400px) {
  .chat { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .confirm-actions { flex-direction: column; }
  .confirm-actions button { width: 100%; }
  .composer-wrap { padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right)); }
}

/* Deja espacio para conversar cuando el teclado reduce la pantalla. */
@media (max-height: 500px) {
  .topbar { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .composer-wrap { padding-top: 4px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .composer textarea { max-height: 72px; }
}

/* Adjuntar oficio (dictamen técnico) */
.attach[hidden] { display: none; }
body.dropping .composer { border: 2px dashed var(--accent); background: var(--surface-subtle); }

/* Tarjeta de dictamen técnico (misma base que .confirm-card) */
.dictamen-card fieldset { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
.dictamen-card legend {
  padding: 0; margin-bottom: 8px; font-size: 12px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--accent);
}
.dictamen-card legend .count { color: var(--muted); font-weight: 600; }
.dictamen-card .fields { margin-top: 0; }
.dictamen-card .field.wide { grid-column: 1 / -1; }
.dictamen-card .hint { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.dictamen-card .hint:empty { display: none; }
.dictamen-card input.missing { border-color: var(--err); background: #fdf3f2; }
.dictamen-card input:disabled { background: var(--bg); color: var(--ink); }
.dictamen-card .equipos-wrap { position: relative; overflow-x: auto; border: 2px solid var(--ink); border-radius: 0; background: var(--panel); }
.bubble .dictamen-card table.equipos { margin: 0; font-size: 13px; }
.bubble .dictamen-card .equipos th, .bubble .dictamen-card .equipos td { border: 0; border-top: 1px solid var(--line); padding: 4px; vertical-align: middle; }
.bubble .dictamen-card .equipos thead th { border-top: 0; font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; padding: 6px 4px; }
.dictamen-card .equipos th.req::after { content: " *"; color: var(--accent); }
.dictamen-card .equipos .n { width: 28px; text-align: center; color: var(--muted); }
.dictamen-card .equipos input { width: 100%; min-width: 100px; padding: 5px 6px; font-size: 16px; }
.dictamen-card .equipos input[data-name="tipo_equipo"] { min-width: 280px; }
.dictamen-card .equipos input[data-name="numero_serie"] { min-width: 240px; }
.dictamen-card .equipos input[data-name="modelo"] { min-width: 150px; }
.dictamen-card .equipos input[data-name="numero_inventario"] { min-width: 180px; }
.dictamen-card .equipos input[data-name="motivo"] { min-width: 170px; }
.dictamen-card .equipos .remove { min-width: 44px; padding: 3px 8px; font-size: 12px; border-radius: 0; }
.dictamen-card .equipos-empty { padding: 12px; font-size: 13px; color: var(--muted); }
.dictamen-card .equipos-empty.missing { color: var(--err); background: #fdf3f2; }
.dictamen-card .add { margin-top: 8px; font-size: 13px; padding: 6px 10px; }
.dictamen-card .confirm-actions { flex-wrap: wrap; }
.dictamen-card .confirm-actions [hidden] { display: none; }
.dictamen-card .confirm-msg.pending { color: var(--muted); }
.dictamen-card .confirm-msg.warn { color: var(--warn); }
.dictamen-card.is-done, .dictamen-card.is-cancelled { border-color: var(--line); background: var(--bg); }
.dictamen-card.is-cancelled { opacity: .7; }
.ghost:disabled { opacity: .5; cursor: default; }
.ghost:disabled:hover { border-color: var(--line); color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }


@media (prefers-reduced-motion: reduce) {
  .typing::after, .spinner { animation: none; }
}
