/* Pulso — estilos. Claro/oscuro según el sistema. */
:root {
  --bg: #f6f5fa; --surface: #ffffff; --surface-2: #f0eef7; --text: #1b1830; --muted: #6b6785; --line: #e3e0ee;
  --accent: #6d28d9; --accent-2: #8b5cf6; --accent-ink: #ffffff; --hit: #fff3b0; --hit-ink: #3d3200;
  --danger: #c0262d; --ok: #15803d; --shadow: 0 1px 2px rgba(20,17,31,.06), 0 6px 20px rgba(20,17,31,.06);
  --radius: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0d18; --surface: #1a1727; --surface-2: #231f35; --text: #ece9f7; --muted: #9a95b5; --line: #2e2943;
          --accent: #a78bfa; --accent-2: #8b5cf6; --accent-ink: #14111f; --hit: #4a3d00; --hit-ink: #fff2b8;
          --danger: #f87171; --ok: #4ade80; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

/* Botones y campos */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--accent-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 6px 4px; }
input[type=text], input[type=search], input[type=password], input:not([type]) { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
input:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; white-space: nowrap; }

/* Acceso */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.card { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card form { display: grid; gap: 12px; margin-top: 12px; }
.card label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { border-radius: 9px; }
.brand small { display: block; color: var(--muted); font-size: 13px; }
.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 10px 12px; border-radius: 10px; }

/* Encabezado */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
       padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top nav { display: flex; align-items: center; gap: 4px; }
.top nav form { margin: 0; }
.tab { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
.tab.on { background: var(--surface-2); color: var(--text); }
.pill { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 8px; }
.banner { margin: 12px 16px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }

/* Bandeja */
.view { max-width: 1200px; margin: 0 auto; padding: 12px 16px 40px; }
.toolbar { display: grid; gap: 10px; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.chip .n { color: var(--muted); font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tools input[type=search] { flex: 1 1 200px; }
.split { display: grid; gap: 14px; }
@media (min-width: 900px) { .split { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; } .detail { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; } }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); border-radius: 12px; padding: 10px 12px; cursor: pointer; display: grid; gap: 3px; }
.item:hover { border-color: var(--accent-2); border-left-color: var(--c, var(--accent)); }
.item.sel { outline: 2px solid var(--accent-2); }
.item .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.item .meta .ch { font-weight: 700; color: var(--c, var(--accent)); }
.item .t { font-weight: 600; }
.item.unread .t::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 2px; }
.item .b { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.alta { background: var(--danger); color: #fff; border-radius: 6px; padding: 0 6px; font-weight: 700; font-size: 11px; }
.more { display: block; margin: 14px auto 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* Detalle */
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.detail h2 { margin: 4px 0 6px; font-size: 19px; line-height: 1.3; }
.detail .body { white-space: pre-wrap; }
.detail .acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.detail .close { float: right; }
.detail pre.txt { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: 10px; max-height: 60vh; overflow: auto; }
@media (max-width: 899px) { .detail { position: fixed; inset: 0; z-index: 20; border-radius: 0; overflow: auto; padding-top: max(16px, env(safe-area-inset-top)); } }
table.ctx { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.ctx th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); padding: 6px; }
table.ctx td { border-bottom: 1px solid var(--line); padding: 6px; vertical-align: top; }
table.ctx td.pos { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.ctx td.who { color: var(--muted); font-size: 12px; width: 22%; }
table.ctx tr.hit td { background: var(--hit); color: var(--hit-ink); font-weight: 600; }

/* Ajustes */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; max-width: 760px; margin-left: auto; margin-right: auto; }
.panel h2 { margin: 0 0 6px; font-size: 18px; }
.panel h3 { margin: 16px 0 6px; font-size: 15px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.row input { flex: 1 1 220px; }
.stack { display: grid; gap: 8px; max-width: 360px; }
.rows { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.rows li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--surface-2); border-radius: 10px; }
.rows li .name { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.rows li small { color: var(--muted); }
.secret { background: var(--hit); color: var(--hit-ink); padding: 12px; border-radius: 10px; word-break: break-all; margin: 8px 0; }
.howto pre { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: calc(100% - 32px); }
