/* App de chat — hoja de estilos base. La piel del cliente se inyecta aparte con
   WEBAPP_BRAND_CSS, así que acá no va ninguna identidad de marca. */

@font-face {
  font-family: "DM Sans";
  font-weight: 100 1000;
  font-display: swap;
  src: url("/static/fonts/dmsans-vf.woff2") format("woff2");
}
@font-face {
  font-family: "DM Mono";
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/dmmono.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --ink: #191919;
  --ink-deep: #16181f;
  --graphite: #55565A;
  --silver: #8E9094;
  --line: #E6E7E9;
  --panel: #F4F4F5;
  --paper: #FFFFFF;
  --active-bg: #E7E7E9;
  --hover-bg: rgba(25, 25, 25, .05);
  --accent-bg: #191919;     /* botones y monogramas (se invierte en oscuro) */
  --accent-fg: #FFFFFF;
  --accent-bg-hover: #000000;
  --bolt: #ffe115;          /* amarillo rayo (eléctrico, no dorado) */
  --ok: #2E7D46;
  --ok-bg: #EAF4ED;
  --warn: #8A6A00;
  --warn-bg: #FAF3DC;
  --warn-line: #EADFB8;
  --danger: #A33;
  --danger-bg: #FBEEEE;
}

/* Modo oscuro: sigue al sistema, salvo elección manual (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #ECECEE;
    --ink-deep: #E8E9EF;
    --graphite: #A6A8B0;
    --silver: #7D8089;
    --line: #2A2C34;
    --panel: #1D1F26;
    --paper: #16181F;
    --active-bg: #2B2E38;
    --hover-bg: rgba(236, 236, 238, .06);
    --accent-bg: #ECECEE;
    --accent-fg: #16181F;
    --accent-bg-hover: #FFFFFF;
    --ok: #7CC98F;
    --ok-bg: #1C2B21;
    --warn: #E4C654;
    --warn-bg: #2A2513;
    --warn-line: #4A3F1C;
    --danger: #E08585;
    --danger-bg: #33201F;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #ECECEE;
  --ink-deep: #E8E9EF;
  --graphite: #A6A8B0;
  --silver: #7D8089;
  --line: #2A2C34;
  --panel: #1D1F26;
  --paper: #16181F;
  --active-bg: #2B2E38;
  --hover-bg: rgba(236, 236, 238, .06);
  --accent-bg: #ECECEE;
  --accent-fg: #16181F;
  --accent-bg-hover: #FFFFFF;
  --ok: #7CC98F;
  --ok-bg: #1C2B21;
  --warn: #E4C654;
  --warn-bg: #2A2513;
  --warn-line: #4A3F1C;
  --danger: #E08585;
  --danger-bg: #33201F;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--bolt); outline-offset: 2px; }

.wordmark { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.wordmark .dot { color: var(--bolt); }
.wordmark small {
  display: block; margin-top: 4px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 9.5px; font-weight: 500; letter-spacing: .24em;
  text-transform: uppercase; color: var(--silver);
}

/* Malla neuronal ambiente (canvas detrás del contenido) */
.mesh-canvas {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
}

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px 14px;
  background: var(--accent-bg); color: var(--accent-fg);
  border: none; border-radius: 9px; font-weight: 600; font-size: 14px;
}
.btn-primary:hover { background: var(--accent-bg-hover); }
.btn-ghost {
  background: none; border: none; color: var(--silver);
  font-size: 12px; padding: 6px 8px; border-radius: 6px;
}
.btn-ghost:hover { background: var(--panel); color: var(--ink); }

/* ---------------- ingreso ---------------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  position: relative; overflow: hidden;
  background: radial-gradient(720px 340px at 50% -80px, var(--panel), transparent 70%), var(--paper);
}
.login-card {
  width: min(360px, 100%); text-align: center;
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper);
  padding: 40px 34px 28px;
  position: relative; z-index: 1;
  box-shadow: 0 24px 70px -30px rgba(22, 24, 31, .35);
}
.login-card p { margin: 20px 0 22px; font-size: 13.5px; line-height: 1.5; color: var(--graphite); }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 14px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  font-weight: 600; font-size: 14px; text-decoration: none;
}
.btn-google:hover { background: var(--hover-bg); border-color: var(--silver); }
.btn-google svg { flex: none; }
.login-or {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 14px;
}
.login-or::before, .login-or::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.login-or span { font-size: 11.5px; color: var(--silver); white-space: nowrap; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input {
  font: inherit; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--paper);
}
.login-card input:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.login-error {
  margin-top: 14px; font-size: 13px; color: var(--danger);
  background: var(--danger-bg); border-radius: 8px; padding: 10px 12px;
}
.login-foot {
  margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--silver);
}

/* ---------------- app ---------------- */
.app { display: grid; grid-template-columns: 264px 1fr; height: 100vh; }

.side {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px 12px;
  min-height: 0;
  position: relative; overflow: hidden;
}
.side > * { position: relative; z-index: 1; }
/* Planeta neuronal (esfera geodésica del deck) de fondo, cortado por el borde */
.side-planet {
  position: absolute; z-index: 0; left: -70px; bottom: -50px;
  width: 340px; height: 360px; pointer-events: none;
}
.side-planet canvas { display: block; }
.side-brand { padding: 2px 6px 14px; }
.side-brand .wordmark { font-size: 17px; }
.side-brand small { letter-spacing: .16em; font-size: 9.5px; }
#btn-new { margin-bottom: 6px; padding: 11px 12px; font-size: 13px; }
.side-guide {
  display: block; margin: 0 2px 12px; padding: 6px 8px;
  font-size: 12.5px; color: var(--graphite); text-decoration: none; border-radius: 7px;
  position: relative; z-index: 1;
}
.side-guide:hover { background: var(--panel); color: var(--ink); }

.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.conv-item { display: flex; align-items: center; border-radius: 7px; }
.conv-item > button.conv-open {
  all: unset; flex: 1; min-width: 0; cursor: pointer;
  font: 500 13px/1.35 "DM Sans", system-ui, sans-serif; color: var(--graphite);
  padding: 8px 10px; border-radius: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover { background: var(--hover-bg); }
.conv-item.on { background: var(--active-bg); position: relative; }
.conv-item.on::before {
  content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--bolt);
}
.conv-item.on > button.conv-open { color: var(--ink); font-weight: 600; padding-left: 14px; }
.conv-act {
  background: none; border: none; color: var(--silver); font-size: 13px;
  padding: 4px 6px; border-radius: 6px; visibility: hidden;
}
.conv-item:hover .conv-act { visibility: visible; }
.conv-act:hover { color: var(--ink); }
.conv-del:hover { color: var(--danger); }

/* Estado por conversación: Hermes trabajando (punto que late), esperando
   permiso (rayo), respuesta lista sin leer (punto fijo). */
.conv-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; margin: 0 3px; }
.conv-dot.busy { background: var(--bolt); animation: convpulse 1.4s ease-in-out infinite; }
.conv-dot.new { background: var(--bolt); }
.conv-dot.attn {
  width: auto; height: auto; border-radius: 0; background: none;
  font-size: 12px; line-height: 1; animation: convpulse 1s ease-in-out infinite;
}
@keyframes convpulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .conv-dot.busy, .conv-dot.attn { animation: none; } }

.side-user {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid var(--line); padding: 12px 6px 2px; margin-top: 10px;
}
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent-fg); display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
}
.side-user-text { flex: 1; min-width: 0; }
.side-user-text b { display: block; font-size: 12.5px; font-weight: 600; }
.side-user-text span {
  display: block; font: 500 10.5px/1.3 "DM Mono", ui-monospace, monospace;
  color: var(--silver); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.main > .main-head, .main > .thread, .main > .composer { position: relative; z-index: 1; }
.main-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.main-head h2 {
  margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.burger { display: none; background: none; border: none; width: 28px; padding: 4px; }
.burger i { display: block; height: 2px; background: var(--ink); border-radius: 2px; margin: 4px 0; }

.thread {
  flex: 1; overflow-y: auto; padding: 24px 22px 10px;
  display: flex; flex-direction: column; gap: 14px;
}
/* Cada conversación conserva su hilo vivo (Hermes puede seguir trabajando en
   uno mientras se mira otro); solo el activo se muestra. display:contents hace
   que sus mensajes participen del flex del hilo como siempre. */
.thread-page { display: none; }
.thread-page.on { display: contents; }
.empty { margin: auto; text-align: center; max-width: 420px; color: var(--graphite); }
.empty-mark {
  width: 52px; height: 52px; border-radius: 13px; margin: 0 auto 16px;
  background: var(--accent-bg); color: var(--accent-fg); display: grid; place-items: center;
  font-size: 24px; font-weight: 700;
  animation: alive 3.2s ease-in-out infinite;
}
@keyframes alive {
  0%, 100% { box-shadow: 0 0 0 0 rgba(238, 182, 14, .0); }
  50% { box-shadow: 0 0 0 9px rgba(238, 182, 14, .16); }
}
@media (prefers-reduced-motion: reduce) { .empty-mark { animation: none; } }
.empty p { font-size: 13.5px; line-height: 1.55; }

.msg { display: flex; gap: 12px; max-width: 680px; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; max-width: 500px; }
.h-mark {
  flex: none; width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent-bg); color: var(--accent-fg); display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700;
}
.bubble { font-size: 14px; line-height: 1.48; min-width: 0; overflow-wrap: break-word; }
.msg.user .bubble { background: var(--panel); border-radius: 14px 14px 4px 14px; padding: 11px 15px; white-space: pre-wrap; }
.bubble p { margin: 0 0 7px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3 { font-size: 14.5px; margin: 10px 0 5px; }
.bubble ul, .bubble ol { margin: 5px 0 7px; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.bubble code {
  font: 500 12.5px/1.4 "DM Mono", ui-monospace, monospace;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px;
}
.bubble pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 14px; overflow-x: auto; margin: 10px 0;
}
.bubble pre code { background: none; border: none; padding: 0; }
.table-scroll { overflow-x: auto; margin: 10px 0; }
.bubble table { border-collapse: collapse; font-size: 13px; }
.bubble th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--silver);
  padding: 0 18px 7px 0; border-bottom: 1px solid var(--line);
}
.bubble td {
  padding: 8px 18px 8px 0; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.bubble tr:last-child td { border-bottom: none; }

.tool-note {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12px; color: var(--silver); padding: 2px 0;
}
/* sinapsis "pensando": los nodos disparan en secuencia y la señal viaja */
.synapse .syn-n { fill: var(--silver); animation: synfire 1.8s ease-in-out infinite; }
.synapse .syn-n2 { animation-delay: .45s; }
.synapse .syn-n3 { animation-delay: .9s; }
.synapse .syn-e { stroke: var(--silver); stroke-width: 1.2; opacity: .4; animation: synedge 1.8s ease-in-out infinite; }
.synapse .syn-e2 { animation-delay: .45s; }
@keyframes synfire {
  0%, 100% { fill: var(--silver); r: 2.2px; }
  22% { fill: var(--bolt); r: 3.2px; }
}
@keyframes synedge {
  0%, 100% { stroke: var(--silver); opacity: .35; }
  30% { stroke: var(--bolt); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .synapse .syn-n, .synapse .syn-e { animation: none; }
}

.approval-card {
  margin-top: 12px; padding: 14px 16px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 12px;
  border-left: 3px solid var(--bolt);
}
.approval-desc { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.approval-card pre {
  margin: 10px 0; padding: 10px 12px; overflow-x: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  font: 500 12px/1.5 "DM Mono", ui-monospace, monospace;
}
.approval-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.approval-note { font-size: 11.5px; color: var(--graphite); margin-left: 4px; }
.approve-btn.ghost { background: none; color: var(--ink); border: 1px solid var(--ink); }
.approve-btn.ghost:hover { background: rgba(25,25,25,.06); }
.approve-btn.danger { background: none; color: var(--danger); border: 1px solid var(--danger); }
.approve-btn.danger:hover { background: var(--danger-bg); }

.approve-row { margin-top: 10px; }
.approve-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-bg); color: var(--accent-fg); border: none; border-radius: 999px;
  padding: 9px 16px; font-weight: 600; font-size: 13px;
}
.approve-btn:hover { background: var(--accent-bg-hover); }
.approve-btn:disabled { opacity: .5; cursor: default; }

.file-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-bg); color: var(--accent-fg); text-decoration: none;
  border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 13px;
}
.file-chip:hover { background: var(--accent-bg-hover); }
.file-img {
  display: block; max-width: 220px; max-height: 220px; border-radius: 10px;
  border: 1px solid var(--line); box-shadow: 0 8px 22px -14px rgba(20,20,25,.5);
}
.file-pdf {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 8px;
  text-decoration: none;
}
.file-pdf .file-img { max-width: 190px; max-height: 250px; }

.error-note {
  font-size: 13px; color: var(--danger);
  background: var(--danger-bg); border-radius: 8px; padding: 10px 12px;
}

.composer { padding: 12px 22px 16px; }
.attach-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 4px 10px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 8px 6px 12px; font-size: 12.5px; color: var(--graphite);
  max-width: 260px;
}
.attach-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip button {
  background: none; border: none; color: var(--silver); font-size: 13px;
  padding: 0 4px; border-radius: 50%;
}
.attach-chip button:hover { color: var(--danger); }
.attach-chip.uploading { opacity: .55; }
.attach-chip.with-thumb { padding: 6px 8px; border-radius: 12px; }
.attach-thumb {
  width: 44px; height: 44px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line);
}
.user-files { justify-content: flex-end; }
.user-files .file-img { max-width: 180px; max-height: 180px; }
.main.dropping::after {
  content: "Soltá los archivos acá";
  position: absolute; inset: 10px; z-index: 5;
  display: grid; place-items: center;
  border: 2px dashed var(--bolt); border-radius: 14px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  font-size: 15px; font-weight: 600; color: var(--graphite);
  pointer-events: none;
}
/* ---- elegir una habilidad: botón "+" del compositor ---------------------- */
.skill-picker { position: relative; flex: none; }
.skill-menu {
  position: absolute; bottom: calc(100% + 12px); left: 0; z-index: 30;
  width: 272px; padding: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 32px -14px rgba(25,25,25,.4);
}
.skill-menu-title {
  margin: 0; padding: 8px 10px 6px; font-size: 9.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--silver);
}
.skill-opt {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 8px 10px; border-radius: 10px; color: var(--ink); font: inherit;
}
.skill-opt:hover, .skill-opt:focus-visible { background: var(--panel); outline: none; }
.skill-opt[aria-current="true"] { background: var(--active-bg); }
.skill-opt-name { display: block; font-size: 13.5px; }
.skill-opt-desc { display: block; font-size: 11.5px; color: var(--silver); margin-top: 1px; }
.skill-row { display: flex; padding: 0 4px 10px; }
.skill-chip .chip-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none;
}
.tool-btn[aria-expanded="true"] { background: var(--panel); color: var(--ink); }

.tool-btn {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: none;
  background: none; color: var(--graphite); display: grid; place-items: center;
}
.tool-btn:hover { background: var(--panel); color: var(--ink); }
.tool-btn.recording { background: var(--danger-bg); color: var(--danger); animation: recpulse 1.4s ease-in-out infinite; }
@keyframes recpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(170,51,51,.35); } 50% { box-shadow: 0 0 0 7px rgba(170,51,51,0); } }
@media (prefers-reduced-motion: reduce) { .tool-btn.recording { animation: none; } }
.composer-box {
  display: flex; align-items: flex-end; gap: 10px;
  border: 1px solid var(--line); border-radius: 22px; background: var(--paper);
  box-shadow: 0 2px 10px -6px rgba(25,25,25,.25);
  padding: 8px 8px 8px 20px;
}
#composer-input {
  flex: 1; border: none; resize: none; font: inherit; line-height: 1.45;
  max-height: 160px; padding: 6px 0; background: none;
}
#composer-input:focus { outline: none; }

/* Grabando nota de voz: el cuadro de texto se convierte en espectro en vivo */
.rec-bar { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; align-self: center; }
.rec-dot {
  flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--danger);
  animation: convpulse 1.1s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
#rec-wave { flex: 1; min-width: 0; height: 34px; display: block; }
#rec-time {
  flex: none; font: 500 12px/1 "DM Mono", ui-monospace, monospace;
  color: var(--graphite); min-width: 34px; text-align: right;
}
.send {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--accent-bg); color: var(--accent-fg); display: grid; place-items: center;
}
.send:disabled { opacity: .4; cursor: default; }
.stop-run {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
  background: transparent; color: var(--danger); display: grid; place-items: center;
}
.stop-run span { width: 10px; height: 10px; border-radius: 2px; background: currentColor; }
.stop-run:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.stop-run:disabled { opacity: .45; cursor: default; }
.stop-run[hidden] { display: none; }
.composer small { display: block; text-align: center; margin-top: 8px; font-size: 11px; color: var(--silver); }

/* ---------------- móvil ---------------- */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 25% 0 0; z-index: 20;
    transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: 8px 0 30px -18px rgba(0,0,0,.4);
  }
  @media (prefers-reduced-motion: reduce) { .side { transition: none; } }
  .side.open { transform: none; }
  .burger { display: block; }
  .msg { max-width: 100%; }
}


/* ══════════════════════════════════════════════════════════════════════════
   CAPA ATLAS — estética del manual (25/08/2026)
   ──────────────────────────────────────────────────────────────────────────
   Pisa a propósito lo de arriba; el archivo original queda intacto, así que
   volver atrás es borrar este bloque.

   Mismas tres reglas que en la bandeja:
   1. El fondo NO es blanco: es gris azulado. Lo blanco flota encima.
   2. Nada tiene borde: tiene RELIEVE.
   3. El amarillo es el único color, de a gotas.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  --ground: #E4E7EF;
  --panel: #EBEDF3;
  --paper: #F7F8FB;
  --hoja: #FCFCFD;            /* la hoja del chat, lo más claro de todo */
  --line: #D3D8E3;
  --active-bg: #DEE3ED;
  --burbuja-user: #E7EAF1;
  --hover-bg: rgba(74, 84, 112, .07);
  --ink: #1E212A;
  --ink-deep: #14161C;
  --graphite: #5B6070;
  --silver: #868D9E;
  --accent-bg: #1E212A; --accent-fg: #FFFFFF; --accent-bg-hover: #000000;
  --bolt: #FFE115;
  /* El halo es el acento con transparencia. Se deriva de --bolt a proposito: escrito
     a mano, sobrevive al cambio de marca y el amarillo de Hermes se filtra a la piel
     del cliente (paso en agosto con las animaciones). El rgba de abajo es el respaldo
     para navegadores sin color-mix; el @supports del final lo reemplaza. */
  --halo: rgba(255, 225, 21, .22);
  --ok: #2E7D46; --ok-bg: #E3EFE7;
  --warn: #7E6300; --warn-bg: #EAE6C8; --warn-line: #DCD5A8;
  --danger: #B03A3A; --danger-bg: #F2E3E3;

  --radio: 18px; --radio-chico: 11px;
  --relieve: -5px -5px 12px rgba(255,255,255,.92), 6px 8px 20px rgba(74,84,112,.14);
  --relieve-sm: -2px -2px 6px rgba(255,255,255,.9), 3px 5px 12px rgba(74,84,112,.12);
  --hundido: inset 2px 3px 7px rgba(74,84,112,.14), inset -2px -2px 6px rgba(255,255,255,.9);
  --mono: "DM Mono", ui-monospace, monospace;
}

/* Oscuro: no está en el manual (el PDF es todo claro). Deducido con las
   mismas reglas — pizarra profunda, la luz del relieve invertida y el
   amarillo intacto, porque es la marca. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #14171E;
    --panel: #1C2029;
    --paper: #232831;
    --hoja: #191D25;
    --line: #2C323E;
    --active-bg: #2A303B;
    --burbuja-user: #2A303B;
    --hover-bg: rgba(232, 234, 240, .06);
    --ink: #E8EAF0; --ink-deep: #F3F5F9;
    --graphite: #A0A7B8; --silver: #6C7385;
    --accent-bg: #E8EAF0; --accent-fg: #14171E; --accent-bg-hover: #FFFFFF;
    --halo: rgba(255, 225, 21, .15);
    --ok: #6FBF87; --ok-bg: #1B2A20;
    --warn: #E0BE55; --warn-bg: #2A2614; --warn-line: #4A421C;
    --danger: #E08585; --danger-bg: #31201F;
    --relieve: -4px -4px 12px rgba(255,255,255,.035), 6px 8px 22px rgba(0,0,0,.55);
    --relieve-sm: -2px -2px 6px rgba(255,255,255,.03), 3px 5px 12px rgba(0,0,0,.5);
    --hundido: inset 2px 3px 8px rgba(0,0,0,.5), inset -2px -2px 6px rgba(255,255,255,.03);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #14171E;
  --panel: #1C2029;
  --paper: #232831;
  --hoja: #191D25;
  --line: #2C323E;
  --active-bg: #2A303B;
  --burbuja-user: #2A303B;
  --hover-bg: rgba(232, 234, 240, .06);
  --ink: #E8EAF0; --ink-deep: #F3F5F9;
  --graphite: #A0A7B8; --silver: #6C7385;
  --accent-bg: #E8EAF0; --accent-fg: #14171E; --accent-bg-hover: #FFFFFF;
  --halo: rgba(255, 225, 21, .15);
  --ok: #6FBF87; --ok-bg: #1B2A20;
  --warn: #E0BE55; --warn-bg: #2A2614; --warn-line: #4A421C;
  --danger: #E08585; --danger-bg: #31201F;
  --relieve: -4px -4px 12px rgba(255,255,255,.035), 6px 8px 22px rgba(0,0,0,.55);
  --relieve-sm: -2px -2px 6px rgba(255,255,255,.03), 3px 5px 12px rgba(0,0,0,.5);
  --hundido: inset 2px 3px 8px rgba(0,0,0,.5), inset -2px -2px 6px rgba(255,255,255,.03);
}

body { background: var(--ground); }

/* ---------------- ingreso ---------------- */
.login { background: var(--ground); }
.login-card {
  border: 0; border-radius: 24px; background: var(--panel);
  box-shadow: var(--relieve); padding: 44px 36px 30px;
}
.wordmark { letter-spacing: -.035em; }
.wordmark small { font-family: var(--mono); letter-spacing: .28em; color: var(--silver); }
.btn-google, .login-card input {
  border: 0; border-radius: 999px; background: var(--paper);
  box-shadow: var(--relieve-sm);
}
.login-card input { border-radius: 12px; box-shadow: var(--hundido); background: var(--ground); }
.btn-google:hover { background: var(--paper); border: 0; box-shadow: var(--relieve); }
.login-card input:focus { outline: 2px solid var(--bolt); outline-offset: 1px; border: 0; }
.btn-primary { border-radius: 999px; box-shadow: var(--relieve-sm); }
.btn-primary:hover { box-shadow: var(--relieve); }
.login-or span, .login-foot {
  font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; font-size: 9.5px;
}
.login-error { border-radius: 12px; }

/* ---------------- la app: dos tarjetas flotando ---------------- */
.app { padding: 12px; gap: 12px; background: var(--ground); }
.side {
  border-right: 0; border-radius: var(--radio); background: var(--panel);
  box-shadow: var(--relieve); overflow: hidden; padding: 18px 14px 16px;
}
.main {
  border-radius: var(--radio); background: var(--hoja);
  box-shadow: var(--relieve); overflow: hidden;
}
.main-head { background: transparent; border-bottom: 1px solid var(--line); }
.main-head h2 { letter-spacing: -.025em; font-size: 15.5px; }

#btn-new { border-radius: 999px; box-shadow: var(--relieve-sm); }
.side-guide {
  border-radius: 999px; background: var(--paper); box-shadow: var(--relieve-sm);
  margin: 0 2px 14px; padding: 8px 14px;
}
.side-guide:hover { background: var(--paper); box-shadow: var(--relieve); color: var(--ink); }

.conv-item { border-radius: var(--radio-chico); }
.conv-item > button.conv-open { border-radius: var(--radio-chico); }
.conv-item.on { background: var(--paper); box-shadow: var(--hundido); }
.conv-item.on::before { box-shadow: 0 0 0 3px var(--halo); }
.side-user { border-top: 1px solid var(--line); padding-bottom: 6px; }
.side-user-text span { font-family: var(--mono); letter-spacing: .04em; }
.avatar { border-radius: 10px; box-shadow: var(--relieve-sm); }

/* ---------------- hilo ---------------- */
.thread { padding: 26px 26px 12px; }
.h-mark, .empty-mark { border-radius: 9px; box-shadow: var(--relieve-sm); }
.empty-mark { border-radius: 15px; }
/* Color propio, no --panel: sobre la hoja casi blanca (claro) y sobre la
   hoja casi negra (oscuro) el panel casi no se distingue. */
.msg.user .bubble {
  background: var(--burbuja-user); border-radius: 16px 16px 4px 16px;
  box-shadow: var(--relieve-sm); padding: 12px 16px;
}
.bubble code, .bubble pre {
  border: 0; background: var(--panel); box-shadow: var(--relieve-sm);
  border-radius: 8px;
}
.bubble pre { border-radius: 12px; padding: 14px 16px; }
.bubble th { font-family: var(--mono); letter-spacing: .16em; }
.tool-note { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; }
/* las viñetas amarillas del manual */
.bubble ul { list-style: none; padding-left: 4px; }
.bubble ul > li { position: relative; padding-left: 18px; }
.bubble ul > li::before {
  content: ""; position: absolute; left: 0; top: .52em;
  width: 8px; height: 8px; border-radius: 3px;
  background: var(--bolt); box-shadow: 0 0 0 3px var(--halo);
}

/* ---------------- la tarjeta de autorización ----------------
   Es la placa 08 del manual: franja amarilla al costado, el motivo
   adelante y dos decisiones de un toque. */
.approval-card {
  border: 0; border-left: 0; border-radius: 14px;
  background: var(--warn-bg); box-shadow: var(--relieve-sm);
  padding: 16px 18px 16px 22px;
  position: relative; overflow: hidden;
}
/* franja recta a ras del borde, como la placa 08 del manual */
.approval-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--bolt);
}
.approval-desc { font-size: 14px; font-weight: 700; letter-spacing: -.015em; }
.approval-card pre { border: 0; background: var(--hoja); box-shadow: var(--hundido); }
.approval-note { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.approve-btn {
  background: var(--paper); color: var(--ink); box-shadow: var(--relieve-sm);
  border: 0; font-weight: 700;
}
.approve-btn:hover { background: var(--paper); box-shadow: var(--relieve); }
.approve-btn.ghost { background: var(--paper); border: 0; box-shadow: var(--relieve-sm); }
.approve-btn.danger {
  background: var(--paper); color: var(--danger); border: 0;
  box-shadow: var(--relieve-sm);
}
.approve-btn.danger:hover { background: var(--paper); box-shadow: var(--relieve); }
.file-chip { box-shadow: var(--relieve-sm); }
.file-img { border: 0; box-shadow: var(--relieve-sm); border-radius: 12px; }

/* ---------------- barra de escritura ---------------- */
.composer { padding: 12px 26px 18px; }
.composer-box {
  border: 0; border-radius: 26px; background: var(--paper);
  box-shadow: var(--relieve); padding: 8px 8px 8px 20px;
}
.send { box-shadow: var(--relieve-sm); }
.tool-btn:hover { background: var(--panel); box-shadow: var(--relieve-sm); }
.attach-chip { border: 0; background: var(--panel); box-shadow: var(--relieve-sm); }
.attach-thumb { border: 0; box-shadow: var(--relieve-sm); }
.composer small { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; }
#rec-time { font-family: var(--mono); }

/* ---------------- móvil ---------------- */
@media (max-width: 720px) {
  .app { padding: 0; gap: 0; }
  .main { border-radius: 0; box-shadow: none; }
  .side { border-radius: 0; }
}


/* ══════════════════════════════════════════════════════════════════════════
   CAPA CELULAR + AVISOS (26/08/2026)
   ──────────────────────────────────────────────────────────────────────────
   Va al final a propósito, como la capa Atlas: pisa lo de arriba sin borrar
   una línea, así volver atrás es borrar este bloque.

   Cuatro problemas concretos del teléfono, no "que se vea responsive":
   1. `height: 100vh` miente en móvil (la barra del navegador se suma y se
      resta): el compositor quedaba debajo del borde. Se usa 100dvh.
   2. El cajón de conversaciones se abría sin fondo: se veía el chat detrás y
      un toque al costado no lo cerraba.
   3. Los botones eran de 28px: abajo del mínimo que un dedo acierta (44px).
   4. Un textarea con letra menor a 16px hace que iPhone haga zoom solo al
      escribir, y después la pantalla queda corrida.
   ══════════════════════════════════════════════════════════════════════════ */

/* -------------------------------------------------- campanita de la barra -- */
.head-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  position: relative; width: 38px; height: 38px; padding: 0;
  background: var(--paper); color: var(--graphite);
  border: 0; border-radius: 999px; box-shadow: var(--relieve-sm); cursor: pointer;
}
.head-btn:hover { color: var(--ink); }
.head-btn:active { box-shadow: var(--hundido); }
.head-btn.con-avisos { color: var(--ink); }
#btn-theme { display: inline-flex; align-items: center; justify-content: center; }
.hoja-x { display: inline-flex; align-items: center; justify-content: center; }
.globo {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 999px; background: var(--bolt); color: #1E212A;
  font-family: var(--mono); font-size: 10px; font-weight: 500; line-height: 17px;
  text-align: center; box-shadow: 0 0 0 2px var(--hoja);
}
.globo[hidden] { display: none; }

/* --------------------------------------------------- panel (hoja) de avisos -- */
.hoja { position: fixed; inset: 0; z-index: 40; display: flex; }
.hoja[hidden] { display: none; }
.hoja-fondo { position: absolute; inset: 0; background: rgba(20, 23, 30, .38); }
.hoja-caja {
  position: relative; z-index: 1; margin-left: auto;
  width: min(420px, 100%); height: 100%;
  display: flex; flex-direction: column;
  background: var(--hoja); box-shadow: -12px 0 40px -18px rgba(20,23,30,.45);
}
.hoja-cab {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
}
.hoja-cab h3 { margin: 0; flex: 1; font-size: 15px; font-weight: 700; }
.hoja-x {
  width: 38px; height: 38px; flex: none; border: 0; border-radius: 999px;
  background: var(--paper); color: var(--graphite);
  box-shadow: var(--relieve-sm); cursor: pointer; font-size: 14px;
}
.hoja-tabs { display: flex; gap: 8px; padding: 12px 18px 0; }
.hoja-tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 14px; min-height: 40px; border-radius: 999px;
  font: inherit; font-size: 12.5px; color: var(--graphite);
}
.hoja-tab.on { background: var(--paper); box-shadow: var(--relieve-sm); color: var(--ink); font-weight: 600; }
.hoja-cuerpo { flex: 1; overflow-y: auto; padding: 14px 18px 22px; }
.hoja-cuerpo[hidden] { display: none; }
.hoja-nota { margin: 12px 2px; font-size: 12px; line-height: 1.5; color: var(--silver); }
.hoja-nota em { color: var(--graphite); font-style: normal; }

.caja-aviso {
  background: var(--paper); border-radius: var(--radio-chico);
  box-shadow: var(--relieve-sm); padding: 14px; margin-bottom: 14px;
}
.caja-aviso[hidden] { display: none; }
.caja-aviso b { display: block; font-size: 13px; margin-bottom: 5px; }
.caja-aviso p { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--graphite); }
.caja-push-botones { display: flex; gap: 8px; flex-wrap: wrap; }
.caja-push-botones button { min-height: 44px; padding: 0 16px; }

.avisos-lista { display: flex; flex-direction: column; gap: 8px; }
.aviso-item {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  width: 100%; border: 0; cursor: pointer; font: inherit;
  background: var(--paper); border-radius: var(--radio-chico);
  box-shadow: var(--relieve-sm); padding: 12px 14px; min-height: 44px;
}
.aviso-item:active { box-shadow: var(--hundido); }
.aviso-item b { font-size: 13px; font-weight: 600; color: var(--ink); }
.aviso-item.nuevo { box-shadow: var(--relieve-sm), inset 3px 0 0 var(--bolt); }
.aviso-cuerpo {
  font-size: 12.5px; line-height: 1.45; color: var(--graphite);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.aviso-item time { font-family: var(--mono); font-size: 10px; color: var(--silver); }

.alarma-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--paper); border-radius: var(--radio-chico);
  box-shadow: var(--relieve-sm); padding: 12px 14px;
}
.alarma-item.apagada { opacity: .55; }
.alarma-texto { flex: 1; min-width: 0; }
.alarma-texto b { display: block; font-size: 13px; font-weight: 600; }
.alarma-cuando {
  font-family: var(--mono); font-size: 10.5px; color: var(--silver);
  letter-spacing: .03em;
}
.alarma-acciones { display: flex; gap: 4px; flex: none; }
.alarma-acciones button { min-height: 40px; padding: 0 10px; font-size: 12px; }
.btn-ghost.peligro { color: var(--danger); }

/* ------------------------------------------------------------- CELULAR ----- */
@media (max-width: 720px) {
  /* 100dvh: la unidad que descuenta la barra del navegador de verdad. */
  .app { height: 100dvh; height: 100vh; }
  @supports (height: 100dvh) { .app { height: 100dvh; } }

  /* El cajón, con fondo que se puede tocar para cerrarlo. */
  .side { inset: 0 14% 0 0; z-index: 45; box-shadow: 10px 0 40px -14px rgba(20,23,30,.5); }
  .side-planet { display: none; }        /* canvas animado: fuera del teléfono */
  .mesh-canvas { display: none; }
  .side.open ~ .main::before {
    content: ""; position: fixed; inset: 0; z-index: 40;
    background: rgba(20, 23, 30, .38);
  }

  .main-head { padding: 10px 12px; gap: 8px; }
  .main-head h2 { font-size: 15px; }
  .burger { width: 44px; height: 44px; padding: 12px 8px; }

  .thread { padding: 14px 12px 6px; gap: 12px; }
  .msg { max-width: 100%; }

  /* Compositor: pegado abajo, respetando el borde curvo del iPhone. */
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  /* 16px justos: menos que eso y iPhone hace zoom solo al escribir. */
  #composer-input { font-size: 16px; }
  .composer-box { align-items: flex-end; }
  .tool-btn, .send, .stop-run { min-width: 40px; min-height: 40px; }
  /* La leyenda de abajo se come una línea de chat en una pantalla de 6". */
  .composer small { display: none; }

  /* El panel entra desde abajo y no tapa toda la pantalla. */
  .hoja-caja {
    margin: auto 0 0; width: 100%; height: min(86dvh, 86vh);
    border-radius: var(--radio) var(--radio) 0 0;
    box-shadow: 0 -12px 40px -18px rgba(20,23,30,.5);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .hoja-cab { padding-top: 18px; }
  /* Manija: le dice al dedo que esto se cierra tirando (o tocando el fondo). */
  .hoja-caja::before {
    content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 999px; background: var(--line);
  }
}

/* En pantalla angosta el título de la alarma peleaba con los dos botones y
   quedaba partido en tres líneas: los botones pasan abajo, a la derecha. */
@media (max-width: 480px) {
  .alarma-item { flex-direction: column; align-items: stretch; gap: 8px; }
  .alarma-acciones { justify-content: flex-end; }
  .alarma-cuando { display: block; margin-top: 2px; }
}

/* Pantallas muy angostas (iPhone SE y similares). */
@media (max-width: 380px) {
  .thread { padding: 12px 9px 4px; }
  .alarma-acciones button { padding: 0 8px; }
}

/* --- halo derivado del acento (ver nota arriba) ------------------------------
   Con color-mix el halo sigue a --bolt, asi que la piel del cliente se lleva
   tambien el resplandor. Para Hermes el resultado es identico al rgba de arriba:
   color-mix(in srgb, #FFE115 22%, transparent) == rgba(255,225,21,.22).
   Los selectores son LOS MISMOS que usa el tema oscuro mas arriba en este archivo
   (no `:root` a secas): si no, pisarian la eleccion manual de tema claro. */
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  :root { --halo: color-mix(in srgb, var(--bolt) 22%, transparent); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --halo: color-mix(in srgb, var(--bolt) 15%, transparent); }
  }
  :root[data-theme="dark"] { --halo: color-mix(in srgb, var(--bolt) 15%, transparent); }
}
