/* Tempmail · cliente de correo de tres paneles dentro de un marco. La "mecha" de caducidad recorre la
   cabecera de la dirección activa y es el único elemento con color fuerte. En móvil cada panel es una
   pantalla. Movimiento según Emil Kowalski: transform/opacity, curvas propias, < 300 ms. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --line: #e3e6eb;
  --line-strong: #cdd2da;
  --ink: #141720;
  --ink-2: #394050;
  --muted: #5d6474;
  --accent: #2d4fcf;
  --accent-ink: #ffffff;
  --accent-soft: #e9eefc;
  --ok: #0f7a59;
  --ok-soft: #e4f3ec;
  --warn: #a05607;
  --warn-soft: #fcf1e2;
  --crit: #c3281e;
  --crit-soft: #fdeceb;
  --on-crit: #ffffff;
  --av-1: #dbe4ff; --av-1-ink: #233a8c;
  --av-2: #ddf1e8; --av-2-ink: #145c43;
  --av-3: #fbe7d6; --av-3-ink: #8a4410;
  --av-4: #efe2f7; --av-4-ink: #5d2a7a;
  --av-5: #e3eef2; --av-5-ink: #24505e;
  --shadow-sm: 0 1px 2px rgb(16 20 30 / .06);
  --shadow-md: 0 1px 2px rgb(16 20 30 / .06), 0 10px 28px -14px rgb(16 20 30 / .22);

  --font-ui: "Geist Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono Variable", ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;

  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e12; --surface: #13161c; --surface-2: #1a1e26; --line: #242932; --line-strong: #323946;
    --ink: #e9ebf0; --ink-2: #c4c9d3; --muted: #969dac;
    --accent: #8aa2ff; --accent-ink: #0b1024; --accent-soft: #1b2342;
    --ok: #46c596; --ok-soft: #10302a; --warn: #f1a74a; --warn-soft: #33250f; --crit: #ff7166; --crit-soft: #3a1919; --on-crit: #1f0807;
    --av-1: #222d52; --av-1-ink: #b9c8ff; --av-2: #173a2e; --av-2-ink: #9fe0c4; --av-3: #3d2814; --av-3-ink: #f6c497;
    --av-4: #34203f; --av-4-ink: #ddb8f2; --av-5: #1b333b; --av-5-ink: #a9d6e4;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .45);
    --shadow-md: 0 1px 2px rgb(0 0 0 / .45), 0 14px 34px -14px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e12; --surface: #13161c; --surface-2: #1a1e26; --line: #242932; --line-strong: #323946;
  --ink: #e9ebf0; --ink-2: #c4c9d3; --muted: #969dac;
  --accent: #8aa2ff; --accent-ink: #0b1024; --accent-soft: #1b2342;
  --ok: #46c596; --ok-soft: #10302a; --warn: #f1a74a; --warn-soft: #33250f; --crit: #ff7166; --crit-soft: #3a1919; --on-crit: #1f0807;
  --av-1: #222d52; --av-1-ink: #b9c8ff; --av-2: #173a2e; --av-2-ink: #9fe0c4; --av-3: #3d2814; --av-3-ink: #f6c497;
  --av-4: #34203f; --av-4-ink: #ddb8f2; --av-5: #1b333b; --av-5-ink: #a9d6e4;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .45);
  --shadow-md: 0 1px 2px rgb(0 0 0 / .45), 0 14px 34px -14px rgb(0 0 0 / .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 16px; }

.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-lg { width: 20px; height: 20px; }

/* ---------- Botones ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; white-space: nowrap; user-select: none; -webkit-user-select: none;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: var(--muted);
  transition: transform 160ms var(--ease-out), background-color 150ms ease, color 150ms ease;
}
.icon-btn:active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { border-color: var(--muted); }
  .btn-primary:hover:not(:disabled) { background: var(--ink-2); border-color: var(--ink-2); }
  .btn-accent:hover:not(:disabled) { filter: brightness(1.06); }
  .btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
  .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
}

/* Intercambio de contenido con desenfoque (copiar -> copiada) */
.swap { display: inline-grid; }
.swap > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  transition: opacity 200ms ease, filter 200ms ease, transform 200ms var(--ease-out); }
.swap > .b { opacity: 0; filter: blur(2px); transform: scale(.96); }
[data-state="done"] .swap > .a { opacity: 0; filter: blur(2px); transform: scale(.96); }
[data-state="done"] .swap > .b { opacity: 1; filter: none; transform: none; }
[data-state="done"]:not(.btn-primary):not(.btn-accent) { color: var(--ok); }

/* Mantener pulsado para borrar (lento al decidir, rápido al soltar) */
.hold { overflow: hidden; color: var(--crit); border-color: var(--line-strong); touch-action: none; }
.hold-label { display: inline-flex; align-items: center; gap: 7px; }
.hold-fill {
  position: absolute; inset: 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--crit); color: var(--on-crit); pointer-events: none;
  clip-path: inset(0 100% 0 0); transition: clip-path 200ms var(--ease-out);
}
.hold.holding .hold-fill { clip-path: inset(0 0 0 0); transition: clip-path 1100ms linear; }

/* ---------- Estructura ---------- */
.page {
  height: 100%;
  display: flex; flex-direction: column; gap: 12px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: -.01em; min-width: 0; flex-shrink: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark .bm-bg { fill: var(--ink); }
.brand-mark .bm-line { fill: none; stroke: var(--bg); stroke-width: 1.8; stroke-linejoin: round; }
.brand-mark .bm-dot { fill: var(--accent); stroke: var(--ink); stroke-width: 1.4; }
.top-actions { display: flex; align-items: center; gap: 4px; min-width: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px 0 4px; height: 36px; color: var(--ink-2); min-width: 0; }
.user-chip .avatar { width: 26px; height: 26px; font-size: 11px; flex: none; }
.user-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }

.shell {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 296px minmax(300px, 380px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "rail head head" "rail list reader";
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); overflow: hidden;
}
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-rail { grid-area: rail; border-right: 1px solid var(--line); background: var(--surface); }
.addr-head { grid-area: head; border-bottom: 1px solid var(--line); }
.pane-inbox { grid-area: list; border-right: 1px solid var(--line); }
.pane-reader { grid-area: reader; }
.scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1; }
.back { display: none; }

@media (max-width: 1099px) {
  .shell { grid-template-columns: 272px minmax(0, 1fr); grid-template-areas: "rail head" "rail main"; }
  .pane-inbox, .pane-reader { grid-area: main; border-right: 0; }
  .shell[data-view="reader"] .pane-inbox { display: none; }
  .shell:not([data-view="reader"]) .pane-reader { display: none; }
  .pane-reader .back { display: inline-grid; }
}
@media (max-width: 759px) {
  .page { gap: 8px; padding-top: max(8px, env(safe-area-inset-top, 0px)); padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "head" "main"; border-radius: var(--r-md); }
  .pane-rail { grid-area: 1 / 1 / -1 / -1; border-right: 0; }
  .shell[data-view="addresses"] .addr-head,
  .shell[data-view="addresses"] .pane-inbox,
  .shell[data-view="addresses"] .pane-reader { display: none; }
  .shell:not([data-view="addresses"]) .pane-rail { display: none; }
  .shell[data-view="reader"] .addr-head { display: none; }
  .shell[data-view="reader"] .pane-reader { grid-area: 1 / 1 / -1 / -1; }
  .addr-head .back { display: inline-grid; }
  .addr-input input, .input-wrap input { font-size: 16px; } /* evita el zoom al enfocar en iOS */
}

/* ---------- Barra lateral ---------- */
.composer { display: grid; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.addr-input {
  display: flex; align-items: center; min-width: 0; height: 40px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.addr-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.addr-input[data-invalid="true"] { border-color: var(--crit); }
.addr-input input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  padding: 0 0 0 12px; font-family: var(--font-mono); font-size: 13px;
}
.addr-input input::placeholder { color: var(--muted); }
.addr-input .dom { color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.addr-input .icon-btn { width: 34px; height: 34px; margin-right: 2px; flex: none; }
.field-error { color: var(--crit); font-size: 12.5px; margin: -2px 0 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }

.rail-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px 6px; }
.rail-head .count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.addr-list { list-style: none; margin: 0; padding: 4px 8px 12px; display: grid; gap: 2px; }
.addr-list > li { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 220ms var(--ease-out), opacity 180ms ease, transform 180ms var(--ease-out); }
.addr-list > li > * { min-height: 0; overflow: hidden; }
.addr-list > li.leaving { grid-template-rows: 0fr; opacity: 0; transform: translateX(-6px); }
.addr-list > li.entering { opacity: 0; transform: translateY(-6px); }
.addr {
  width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px; border: 0; border-radius: var(--r-md); background: transparent; text-align: left;
  transition: background-color 150ms ease;
}
.addr[aria-current="true"] { background: var(--surface-2); }
.addr:focus-visible, .msg:focus-visible { outline-offset: -2px; border-radius: var(--r-md); }
@media (hover: hover) and (pointer: fine) { .addr:hover { background: var(--surface-2); } }
.addr-name { min-width: 0; display: grid; }
.addr-name .local { font-family: var(--font-mono); font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr-name .sub { font-size: 12px; color: var(--muted); }
.addr-side { display: grid; justify-items: end; gap: 2px; }
.addr-side .t { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.addr-side .t[data-level="warn"] { color: var(--warn); }
.addr-side .t[data-level="crit"] { color: var(--crit); }
.pill { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }

.ring { width: 28px; height: 28px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--line); }
.ring .prog { stroke: var(--ink-2); stroke-linecap: round; transition: stroke-dashoffset 500ms linear, stroke 300ms ease; }
.ring[data-level="warn"] .prog { stroke: var(--warn); }
.ring[data-level="crit"] .prog { stroke: var(--crit); }

.rail-empty { margin: 8px 16px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--muted); font-size: 13px; }

/* ---------- Cabecera de la dirección: la mecha ---------- */
.addr-head { position: relative; padding: 16px 20px 18px; display: grid; gap: 14px; background: var(--surface); }
.head-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.addr-title { margin: 0; min-width: 0; flex: 1; font-family: var(--font-mono); font-size: 20px; font-weight: 500; letter-spacing: -.01em; overflow-wrap: anywhere; line-height: 1.3; }
.dom { color: var(--muted); }
.addr-title .dom { white-space: nowrap; } /* solo se parte antes de la @, nunca dentro del dominio */
.timer-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.clock { display: grid; gap: 2px; }
.clock .mm { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 40px; line-height: 1; font-weight: 500; letter-spacing: -.03em; transition: color 300ms ease; }
.clock[data-level="warn"] .mm { color: var(--warn); }
.clock[data-level="crit"] .mm { color: var(--crit); }
.clock .sub { font-size: 13px; color: var(--muted); }
.clock .state { font-weight: 500; color: var(--ink-2); }
.clock[data-level="warn"] .state { color: var(--warn); }
.clock[data-level="crit"] .state { color: var(--crit); }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fuse { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--line); }
.fuse-bar { position: absolute; inset: 0; transform-origin: left center; background: var(--accent); transition: transform 500ms linear, background-color 300ms ease; }
.fuse-spark {
  position: absolute; top: 50%; left: 0; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 12px 2px var(--accent);
  transition: transform 500ms linear, background-color 300ms ease, box-shadow 300ms ease;
}
.fuse[data-level="warn"] .fuse-bar, .fuse[data-level="warn"] .fuse-spark { background: var(--warn); }
.fuse[data-level="warn"] .fuse-spark { box-shadow: 0 0 0 3px var(--warn-soft), 0 0 12px 2px var(--warn); }
.fuse[data-level="crit"] .fuse-bar, .fuse[data-level="crit"] .fuse-spark { background: var(--crit); }
.fuse[data-level="crit"] .fuse-spark { box-shadow: 0 0 0 3px var(--crit-soft), 0 0 14px 3px var(--crit); animation: flicker 900ms ease-in-out infinite; }
@keyframes flicker { 50% { opacity: .55; } }

/* ---------- Bandeja ---------- */
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.live { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 500; }
.live-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 2.2s var(--ease-out) infinite; }
.live[data-offline="true"] { color: var(--warn); }
.live[data-offline="true"] .live-dot { background: var(--warn); }
.live[data-offline="true"] .live-dot::after { animation: none; }
@keyframes ping { 0% { transform: scale(.5); opacity: .7; } 100% { transform: scale(1.4); opacity: 0; } }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-row { position: relative; border-bottom: 1px solid var(--line); }
.msg-row.fresh { animation: fresh 1600ms ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }
.msg {
  width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 14px 16px; border: 0; background: transparent; text-align: left; transition: background-color 150ms ease;
}
.msg-row.has-code .msg { padding-bottom: 46px; }
.msg[aria-current="true"] { background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) { .msg:hover { background: var(--surface-2); } }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.avatar[data-hue="1"] { background: var(--av-1); color: var(--av-1-ink); }
.avatar[data-hue="2"] { background: var(--av-2); color: var(--av-2-ink); }
.avatar[data-hue="3"] { background: var(--av-3); color: var(--av-3-ink); }
.avatar[data-hue="4"] { background: var(--av-4); color: var(--av-4-ink); }
.avatar[data-hue="5"] { background: var(--av-5); color: var(--av-5-ink); }
.msg-body { min-width: 0; display: grid; gap: 1px; }
.msg-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.msg-from { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.msg-subject { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread .msg-from { color: var(--ink); font-weight: 600; }
.unread .msg-subject { font-weight: 600; }
.unread .msg-from::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.code-chip {
  position: absolute; left: 62px; bottom: 12px;
  display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  font-family: var(--font-mono); font-size: 13px; font-weight: 500; letter-spacing: .08em; font-variant-numeric: tabular-nums;
  transition: transform 160ms var(--ease-out), border-color 150ms ease, color 150ms ease, opacity 160ms ease;
}
.code-chip:active { transform: scale(.97); }
.code-chip .i { width: 14px; height: 14px; }
.code-chip[data-state="done"] { border-color: var(--ok); }

.empty { margin: auto; max-width: 360px; padding: 32px 20px; text-align: center; display: grid; justify-items: center; gap: 8px; color: var(--muted); }
.empty-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); margin-bottom: 4px; }
.empty h3 { margin: 0; font-size: 15px; color: var(--ink); font-weight: 600; text-wrap: balance; }
.empty p { margin: 0; font-size: 13px; text-wrap: pretty; }
.empty .btn { margin-top: 8px; }
.dev-hint { margin-top: 10px; width: 100%; text-align: left; display: grid; gap: 6px; }
.dev-hint code { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font: 12px/1.5 var(--font-mono); overflow-x: auto; white-space: nowrap; }

/* ---------- Lector ---------- */
.reader-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 53px; }
.reader-bar .left, .reader-bar .right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-2); gap: 2px; }
.seg button { height: 26px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 500; transition: background-color 150ms ease, color 150ms ease; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.reader-content { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.reader-subject { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; overflow-wrap: anywhere; }
.reader-meta { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: center; }
.reader-meta .who { min-width: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.reader-meta .who strong { color: var(--ink); font-weight: 600; }
.code-callout {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-2);
}
.code-callout .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.code-callout .code { font-family: var(--font-mono); font-size: 26px; font-weight: 500; letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; }
.att { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--ink-2); max-width: 100%; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--muted); }
.att-note { font-size: 12px; color: var(--muted); width: 100%; }
.paper { flex: 1; min-height: 380px; display: flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: #fff; }
.paper iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.plain { margin: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-md); font: 13.5px/1.65 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); background: var(--surface); }
.skeleton { display: grid; gap: 12px; }
.skeleton span { display: block; height: 14px; border-radius: 6px; background: var(--surface-2); }
.skeleton span:nth-child(1) { width: 60%; height: 22px; }
.skeleton span:nth-child(2) { width: 40%; }
.skeleton span:nth-child(3) { height: 240px; }

/* ---------- Avisos (pila tipo Sonner) ---------- */
.toaster { position: fixed; z-index: 40; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 360px; max-width: calc(100vw - 32px); margin: 0; padding: 0; list-style: none; }
.toast {
  position: absolute; right: 0; bottom: 0; width: 100%;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 12px 10px 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow-md); transform-origin: bottom center;
  transition: transform 400ms ease, opacity 400ms ease;
}
.toast[data-removed="true"] { transition-duration: 200ms; }
.toast .t-icon { color: var(--ink-2); display: grid; }
.toast[data-type="mail"] .t-icon { color: var(--accent); }
.toast[data-type="danger"] .t-icon { color: var(--crit); }
.toast[data-type="ok"] .t-icon { color: var(--ok); }
.toast-title { margin: 0; font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.toast-desc { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.toast-close { width: 28px; height: 28px; }

/* ---------- Pantalla de acceso ---------- */
.auth { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: center; max-width: 1080px; width: 100%; margin: 0 auto; overflow-y: auto; padding-block: 8px; }
.auth-intro { display: grid; gap: 22px; align-content: center; padding: 8px 8px 8px 0; }
.auth-intro h1 { margin: 0; font-size: clamp(30px, 4.4vw, 48px); line-height: 1.04; letter-spacing: -.035em; font-weight: 600; text-wrap: balance; }
.auth-intro .lead { margin: 0; max-width: 46ch; font-size: 16px; color: var(--muted); text-wrap: pretty; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.facts li { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); }
.facts .i { margin-top: 2px; color: var(--muted); }
.sample { position: relative; max-width: 420px; padding: 16px 18px 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-md); overflow: hidden; display: grid; gap: 8px; }
.sample .addr-title { font-size: 15px; }
.sample .clock .mm { font-size: 28px; }
.auth-card { width: 100%; max-width: 400px; justify-self: center; padding: 24px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-md); display: grid; gap: 18px; }
.auth-card h2 { margin: 0; font-size: 18px; font-weight: 600; }
.tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.tabs-layer { display: grid; grid-template-columns: 1fr 1fr; grid-area: 1 / 1 / 2 / 3; }
.tabs-layer button { height: 32px; border: 0; background: transparent; font-weight: 500; font-size: 13.5px; color: var(--muted); border-radius: 8px; }
.tabs-active { pointer-events: none; transition: clip-path 220ms var(--ease-out); }
.tabs-active span { display: grid; place-items: center; height: 32px; background: var(--surface); color: var(--ink); font-weight: 500; font-size: 13.5px; box-shadow: var(--shadow-sm); }
.tabs-active span:first-child { border-radius: 8px 0 0 8px; }
.tabs-active span:last-child { border-radius: 0 8px 8px 0; }
.tabs[data-mode="login"] .tabs-active { clip-path: inset(0 50% 0 0 round 8px); }
.tabs[data-mode="register"] .tabs-active { clip-path: inset(0 0 0 50% round 8px); }
.form-stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input-wrap { display: flex; align-items: center; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); transition: border-color 150ms ease, box-shadow 150ms ease; }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-wrap[data-invalid="true"] { border-color: var(--crit); }
.input-wrap input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; padding: 0 12px; font-size: 14px; }
.input-wrap .icon-btn { width: 34px; height: 34px; margin-right: 2px; flex: none; }
.form-error { margin: 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--crit-soft); color: var(--crit); font-size: 13px; }
.auth-foot { margin: 0; font-size: 12.5px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 600ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { margin: auto; color: var(--muted); display: inline-flex; align-items: center; gap: 10px; }
@media (max-width: 859px) {
  .auth { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .auth-intro { padding: 4px 0 0; gap: 14px; }
  .auth-intro .sample, .auth-intro .facts { display: none; }
  .auth-card { justify-self: stretch; max-width: none; }
}
@media (max-width: 420px) {
  .addr-head { padding: 14px 16px 16px; }
  .addr-title { font-size: 17px; }
  .clock .mm { font-size: 34px; }
}

/* ---------- Movimiento ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(-3px); } }
/* Pantalla de acceso: entrada escalonada (se ve pocas veces; 50 ms entre piezas, nunca bloquea) */
.auth-intro > *, .auth-card { animation: rise 420ms var(--ease-out) both; }
.auth-intro > :nth-child(2) { animation-delay: 50ms; }
.auth-intro > :nth-child(3) { animation-delay: 100ms; }
.auth-intro > :nth-child(4) { animation-delay: 150ms; }
.auth-card { animation-delay: 80ms; }
/* La app aparece una vez por sesión, al entrar */
.shell.app-enter { animation: rise 320ms var(--ease-out) both; }
/* Los errores aparecen junto al campo en lugar de saltar */
.field-error:not([hidden]), .form-error:not([hidden]) { animation: msg-in 180ms var(--ease-out); }
/* Fila de correo nuevo mientras abre hueco */
.msg-row.growing { overflow: hidden; }
.msg-row.growing .code-chip { opacity: 0; } /* aparece cuando la fila ya ha abierto hueco */

/* ---------- Botón "Nueva" (solo móvil, fuera de la lista de direcciones) ---------- */
.new-mobile { display: none; }
@media (max-width: 759px) {
  .page[data-view="inbox"] .new-mobile,
  .page[data-view="reader"] .new-mobile { display: inline-flex; }
}
@media (max-width: 420px) {
  .user-chip { display: none; }
  .logout span { display: none; }
  .logout { padding: 0 8px; }
  .addr-input .dom { max-width: 42%; }
}
@media (max-width: 360px) {
  .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .btn, .icon-btn, .code-chip, .addr-list > li, .toast, .fuse-bar, .fuse-spark, .ring .prog, .swap > span, .tabs-active {
    transition-property: opacity, background-color, color, border-color !important;
  }
  .btn:active, .icon-btn:active, .code-chip:active { transform: none; }
}
