/* Utensio · sistema de diseño compartido por todas las apps */

:root {
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --brand: "Manrope", var(--sans);

  --bg: #f7f7f5;
  --panel: #ffffff;
  --sunken: #f1f1ee;
  --hover: #ececE8;
  --border: #e6e5e1;
  --border-2: #d7d6d1;
  --text: #1b1b19;
  --text-2: #5c5b56;
  --text-3: #95938d;
  --accent: #4f46e5;
  --accent-hover: #4239c9;
  --accent-soft: rgba(79, 70, 229, .09);
  --accent-line: rgba(79, 70, 229, .38);
  --on-accent: #ffffff;
  --danger: #c93b30;
  --danger-soft: rgba(201, 59, 48, .08);
  --ok: #2e9e5b;
  --ok-soft: rgba(46, 158, 91, .1);
  --star: #d99a00;
  --overlay: rgba(20, 20, 16, .28);
  --shadow-sm: 0 1px 2px rgba(20, 20, 15, .06);
  --shadow-md: 0 2px 4px rgba(20, 20, 15, .04), 0 12px 32px rgba(20, 20, 15, .08);
  --shadow-lg: 0 24px 64px rgba(20, 20, 15, .18), 0 2px 6px rgba(20, 20, 15, .06);
  --checker: #e4e4e0;

  --r: 6px;
  --r-lg: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --panel: #1a1a19; --sunken: #151514; --hover: #252523; --border: #282826; --border-2: #363632;
    --text: #ebeae6; --text-2: #a5a39d; --text-3: #6d6c67;
    --accent: #8d87ee; --accent-hover: #a29df2; --accent-soft: rgba(141, 135, 238, .12); --accent-line: rgba(141, 135, 238, .42); --on-accent: #12102e;
    --danger: #f0786d; --danger-soft: rgba(240, 120, 109, .1); --ok: #5cc98a; --ok-soft: rgba(92, 201, 138, .12); --star: #f2b82e;
    --overlay: rgba(0, 0, 0, .5);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .2), 0 12px 32px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
    --checker: #2a2a28;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --panel: #1a1a19; --sunken: #151514; --hover: #252523; --border: #282826; --border-2: #363632;
  --text: #ebeae6; --text-2: #a5a39d; --text-3: #6d6c67;
  --accent: #8d87ee; --accent-hover: #a29df2; --accent-soft: rgba(141, 135, 238, .12); --accent-line: rgba(141, 135, 238, .42); --on-accent: #12102e;
  --danger: #f0786d; --danger-soft: rgba(240, 120, 109, .1); --ok: #5cc98a; --ok-soft: rgba(92, 201, 138, .12); --star: #f2b82e;
  --overlay: rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .2), 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
  --checker: #2a2a28;
  color-scheme: dark;
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.45 var(--sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.grow { flex: 1; }
[hidden] { display: none !important; }

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

kbd {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  font: 500 10.5px/1 var(--sans);
  color: var(--text-2);
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 4px;
}
kbd + kbd { margin-left: 3px; }

/* ───────── Botones ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--panel); color: var(--text);
  font-weight: 500; font-size: 12.5px; white-space: nowrap; text-decoration: none;
  transition: background-color .12s, border-color .12s, color .12s, transform .1s;
}
.btn:hover { background: var(--hover); }
.btn:active, .icon-btn:active { transform: scale(.96); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.sm .ic { width: 14px; height: 14px; }
.btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn:disabled, .icon-btn:disabled { opacity: .4; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: var(--r);
  background: transparent; color: var(--text-2);
  transition: background-color .12s, color .12s, transform .1s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.lang-btn { width: auto; min-width: 28px; padding: 0 5px; font: 600 11px/1 var(--sans); letter-spacing: .04em; }
.icon-btn.sm { width: 24px; height: 24px; }
.icon-btn.sm .ic { width: 14px; height: 14px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

/* ───────── Barra superior y marca ───────── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 48px; padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; letter-spacing: -.01em; white-space: nowrap; text-decoration: none;
  border-radius: var(--r); padding: 4px 6px 4px 2px; margin-left: -2px;
}
.brand:hover .brand-suite { color: var(--text); }
.brand strong { font-weight: 600; }
.brand-suite { color: var(--text-2); font: 700 14.5px var(--brand); letter-spacing: -.035em; transition: color .12s; }
.brand .brand-name { font: 700 15.5px var(--brand); letter-spacing: -.035em; }
.brand-mark { flex: none; display: block; }
.brand-sep { color: var(--border-2); margin: 0 -2px; }
.top-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }

/* Iconos de app */
.app-icon {
  --s: 20px;
  position: relative;
  display: inline-grid; place-items: center; flex: none;
  width: var(--s); height: var(--s);
  border-radius: calc(var(--s) * .28);
  background: var(--c, var(--accent));
  color: #fff;
}
.app-icon .ic { width: 58%; height: 58%; stroke-width: 2; position: relative; z-index: 1; }
/* Color: las 7 piezas del logo en rueda */
.app-icon.spectrum { background: conic-gradient(from 200deg, #4f46e5, #7b52d6, #d6409f, #e5484d, #f08a2e, #e0a010, #2ea36b, #4f46e5); }

/* Selector de apps */
.switcher {
  position: fixed; top: 52px; right: 10px; z-index: 70;
  width: 392px; padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border-2); border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop .16s var(--ease);
  transform-origin: top right;
}
.switcher-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.switcher a {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 4px 10px;
  border-radius: 10px; text-decoration: none; font-size: 12px; font-weight: 500;
}
.switcher a:hover, .switcher a:focus-visible { background: var(--hover); }
.switcher a[aria-current="page"] { background: var(--accent-soft); }
.switcher a .app-icon { --s: 40px; }
.switcher-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 8px 6px 2px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.switcher-foot a { flex-direction: row; padding: 4px 8px; color: var(--text-2); }

/* ───────── Formularios ───────── */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-l { font-size: 11.5px; font-weight: 500; color: var(--text-2); }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), .field select, .field textarea {
  width: 100%; height: 30px; padding: 0 9px;
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--panel); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { height: auto; min-height: 64px; padding: 7px 9px; resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.lg { height: 40px; font-size: 16px; }
.input.bad, .field input.bad, .field input.bad:focus { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input.mono, .field input.mono { font-family: var(--mono); font-size: 12.5px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer; user-select: none; }
.check input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.check.mini { font-size: 11.5px; color: var(--text-2); gap: 6px; }
input[type="range"] { accent-color: var(--accent); }
.suffix { position: relative; }
.suffix > span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 12px; pointer-events: none; }
.suffix > input { padding-right: 30px !important; }

.seg { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: var(--r); background: var(--sunken); }
.seg button { height: 22px; padding: 0 9px; border: 0; border-radius: 4px; background: none; font-size: 11.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.seg.block { display: flex; }
.seg.block button { flex: 1; }

.sec-t { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.tag { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 99px; background: var(--sunken); border: 1px solid var(--border); font-size: 11px; color: var(--text-2); white-space: nowrap; }
.tag.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.tag.bad { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

/* ───────── Tarjetas (apps de paneles) ───────── */
.page { height: calc(100dvh - 48px); overflow: auto; padding: 14px; }
.cards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-flow: dense;
  gap: 12px; max-width: 1680px; margin: 0 auto; align-items: start;
}
.card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px;
  scroll-margin: 14px;
}
.card.span-2 { grid-column: span 2; }
.card.span-3 { grid-column: 1 / -1; }
.card.row-2 { grid-row: span 2; }
/* Colocación en columnas (shell.js · flowCards): filas de columnas con las tarjetas apiladas */
.cards.flow { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.flow-row { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.flow-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.flow-col > .card:last-child { flex: 1 1 auto; }   /* las columnas terminan a la vez: el bloque queda como un rectángulo */
.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent-line), 0 0 0 6px var(--accent-soft); } 100% { box-shadow: 0 0 0 3px transparent, 0 0 0 6px transparent; } }
.card-h { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border); }
.card-t { font-weight: 600; font-size: 13.5px; letter-spacing: -.01em; }
.card-sub { color: var(--text-3); font-size: 12px; }
.card-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.card-b { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.row { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.row > .field { flex: 1; }

/* Resultados clave-valor (clic para copiar) */
.kv { display: grid; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.kv-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 7px 10px; border: 0; border-top: 1px solid var(--border);
  background: var(--panel); text-align: left; width: 100%;
  cursor: copy; transition: background-color .1s;
}
.kv-row:first-child { border-top: 0; }
.kv-row:hover { background: var(--hover); }
.kv-k { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.kv-v { font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.kv-row.hl { background: var(--accent-soft); }
.kv-row.hl .kv-v { color: var(--accent); font-size: 15px; font-weight: 600; }
.big { font-size: 26px; font-weight: 600; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1.15; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--border); }
.stat { padding: 8px 10px; background: var(--panel); min-width: 0; }
button.stat { border: 0; text-align: left; cursor: copy; }
button.stat:hover { background: var(--hover); }
.stat-v { font-size: 15px; font-weight: 500; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-l { font-size: 11px; color: var(--text-3); }

.tbl-wrap { overflow: auto; max-height: 340px; border: 1px solid var(--border); border-radius: 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tbl th { position: sticky; top: 0; background: var(--sunken); color: var(--text-2); font-weight: 500; font-size: 11.5px; text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }

.empty { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 18px 8px; }

/* ───────── Overlays y avisos ───────── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
  background: var(--overlay);
  animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.985); } }
.modal {
  width: min(640px, 100%); padding: 18px 20px 20px;
  background: var(--panel);
  border: 1px solid var(--border-2); border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: pop .18s var(--ease);
}
.modal.sm { width: min(420px, 100%); }
.modal h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.modal-h { display: flex; align-items: center; justify-content: space-between; margin: -4px -6px 10px 0; }
.modal-h h2 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toasts {
  position: fixed; left: 50%; bottom: 40px; z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 14px;
  min-height: 36px; padding: 8px 14px;
  border-radius: 8px;
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px; white-space: nowrap;
  pointer-events: auto;
  animation: toastIn .22s var(--ease);
  transition: opacity .18s, transform .18s;
}
.toast:has(button) { padding-right: 6px; }
.toast button {
  height: 24px; padding: 0 9px;
  border: 0; border-radius: 5px;
  background: color-mix(in srgb, var(--bg) 16%, transparent);
  color: var(--bg); font-weight: 600; font-size: 12px;
}
.toast button:hover { background: color-mix(in srgb, var(--bg) 26%, transparent); }
.toast.out { opacity: 0; transform: translateY(4px); }
.toast .toast-x { flex: none; align-self: flex-start; width: 24px; padding: 0; background: none; font-size: 17px; font-weight: 400; line-height: 24px; opacity: .75; }
.toast .toast-x:hover { opacity: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.checker {
  background-color: var(--panel);
  background-image: conic-gradient(var(--checker) 25%, transparent 0 50%, var(--checker) 0 75%, transparent 0);
  background-size: 14px 14px;
}

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card.span-2 { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .card.row-2 { grid-row: auto; }
  .page { height: auto; padding: 10px; }
  .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { white-space: normal; }
  .switcher { right: 8px; left: 8px; width: auto; }
  .card-h { flex-wrap: wrap; row-gap: 6px; }
  .card-sub { flex: 1 1 auto; }
  .card-tools { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Buscador del selector de apps */
.switcher-search { position: relative; margin-bottom: 8px; }
.switcher-search .ic { position: absolute; left: 10px; top: 9px; width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.switcher-search input { width: 100%; height: 32px; padding: 0 10px 0 31px; border: 1px solid var(--border); border-radius: 8px; background: var(--sunken); outline: none; }
.switcher-search input:focus { border-color: var(--accent); background: var(--panel); }
.switcher-search input::-webkit-search-cancel-button { display: none; }
.switcher-grid { max-height: min(430px, 60vh); overflow: auto; }
.switcher-grid a[hidden] { display: none; }
.switcher-none { margin: 10px 0; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* Menú «Abrir en…» */
.send-menu { position: fixed; z-index: 75; min-width: 240px; padding: 6px; background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow-lg); animation: pop .14s var(--ease); }
.send-h { padding: 4px 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.send-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: 8px; background: none; text-align: left; }
.send-menu button:hover, .send-menu button:focus-visible { background: var(--hover); }
.send-menu button > span:not(.app-icon) { display: flex; flex-direction: column; min-width: 0; }
.send-menu b { font-size: 13px; font-weight: 600; }
.send-menu small { font-size: 11.5px; color: var(--text-3); }

/* Paleta global */
.gpal-wrap { position: fixed; inset: 0; z-index: 85; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: var(--overlay); animation: fade .12s ease-out; }
.gpal { width: min(620px, 100%); overflow: hidden; background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .16s var(--ease); }
.gpal-in { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.gpal-in input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 15px; color: var(--text); }
.gpal-list { max-height: min(440px, 60vh); overflow: auto; padding: 6px; }
.gpal-g { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.gpal-item { display: grid; grid-template-columns: 24px minmax(0, auto) minmax(0, 1fr); align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; text-decoration: none; }
.gpal-item.on { background: var(--accent-soft); }
.gpal-t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gpal-s { justify-self: end; color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gpal-act { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--sunken); color: var(--text-2); }
.gpal-act .ic { width: 14px; height: 14px; }
.gpal-none { padding: 22px; text-align: center; color: var(--text-3); }

/* Modo sin distracciones (común) */
body.zen .topbar { display: none; }

/* Atajos solo con teclado y ratón: en pantallas táctiles se ocultan o se cambian por un texto alternativo */
.touch-only { display: none !important; }
:root[data-input="touch"] .mouse-only { display: none !important; }
:root[data-input="touch"] .touch-only { display: revert !important; }
:root[data-input="touch"]:not([data-kbd="on"]) .kbd-only,
:root[data-input="touch"]:not([data-kbd="on"]) kbd:not(.keep),
:root[data-kbd="off"] .kbd-only,
:root[data-kbd="off"] kbd:not(.keep) { display: none !important; }

/* ───────── Ajustes: color de acento ─────────
   Cada acento define su tono para tema claro (--ac-l) y oscuro (--ac-d); el resto se deriva. */
:root[data-accent] {
  --accent: var(--ac-l); --on-accent: var(--ac-on, #fff);
  --accent-hover: color-mix(in srgb, var(--ac-l) 86%, #000);
  --accent-soft: color-mix(in srgb, var(--ac-l) 10%, transparent);
  --accent-line: color-mix(in srgb, var(--ac-l) 40%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root[data-accent]:not([data-theme="light"]) {
    --accent: var(--ac-d); --on-accent: var(--ac-on-dark, #111110);
    --accent-hover: color-mix(in srgb, var(--ac-d) 85%, #fff);
    --accent-soft: color-mix(in srgb, var(--ac-d) 14%, transparent);
    --accent-line: color-mix(in srgb, var(--ac-d) 44%, transparent);
  }
}
:root[data-accent][data-theme="dark"] {
  --accent: var(--ac-d); --on-accent: var(--ac-on-dark, #111110);
  --accent-hover: color-mix(in srgb, var(--ac-d) 85%, #fff);
  --accent-soft: color-mix(in srgb, var(--ac-d) 14%, transparent);
  --accent-line: color-mix(in srgb, var(--ac-d) 44%, transparent);
}
/* Los colores de las piezas del logo. En naranja y ámbar el texto encima va oscuro para que se lea */
:root[data-accent="violeta"] { --ac-l: #7b52d6; --ac-d: #a98fe4; }
:root[data-accent="rosa"] { --ac-l: #d6409f; --ac-d: #e483c1; }
:root[data-accent="rojo"] { --ac-l: #e5484d; --ac-d: #ee888b; }
:root[data-accent="naranja"] { --ac-l: #f08a2e; --ac-d: #f4a762; --ac-on: #1b1b19; }
:root[data-accent="ambar"] { --ac-l: #e0a010; --ac-d: #e8b84c; --ac-on: #1b1b19; }
:root[data-accent="verde"] { --ac-l: #2ea36b; --ac-d: #62ba90; }

/* Ajustes: reducir animaciones aunque el sistema no lo pida */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

.switcher-links { display: flex; gap: 2px; }

/* Ajustes abiertos por encima de una app */
.settings-ov { position: fixed; inset: 0; z-index: 1000; background: var(--bg); animation: settings-in .2s cubic-bezier(.2, .8, .2, 1); }
.settings-ov iframe { display: block; width: 100%; height: 100%; border: 0; }
html.settings-open, html.settings-open body { overflow: hidden; }
@keyframes settings-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .settings-ov { animation: none; } }
:root[data-motion="reduce"] .settings-ov { animation: none; }
.embed-back { display: inline-flex; align-items: center; gap: 7px; height: 32px; margin-right: 12px; padding: 0 12px 0 8px; font-size: 13px; }
.embed-back .ic { width: 16px; height: 16px; }
.embed-back b { font-weight: 600; }

/* Menú del clic derecho (común) */
.cm { position: fixed; z-index: 80; display: grid; gap: 1px; min-width: 210px; max-width: 300px; padding: 5px; border: 1px solid var(--border-2); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow-lg); font-size: 13px; animation: pop .12s var(--ease); }
.cm .cm-t { overflow: hidden; padding: 5px 10px 6px; color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; text-overflow: ellipsis; white-space: nowrap; }
.cm hr { margin: 3px 6px; border: 0; border-top: 1px solid var(--border); }
.cm button { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; cursor: pointer; }
.cm button:hover:not(:disabled), .cm button:focus-visible { background: var(--hover); outline: none; }
.cm button:disabled { opacity: .4; cursor: default; }
.cm button.danger { color: #e5484d; }
.cm kbd { color: var(--text-3); font: 500 11px var(--mono, ui-monospace, monospace); }
.cm { max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain; }
/* Con el dedo: hoja desde abajo, con fondo oscuro detrás */
.cm-backdrop { position: fixed; inset: 0; z-index: 79; background: rgba(0, 0, 0, .35); animation: cmFade .15s ease-out; }
.cm.cm-sheet { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); top: auto; max-width: 560px; margin: 0 auto; max-height: 72dvh; padding: 18px 6px 6px; border-radius: 16px; animation: sheet .22s var(--ease); }
.cm.cm-sheet::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border-2); }
.cm.cm-sheet .cm-t { white-space: normal; }
/* Zonas con menú de mantener pulsado: con el dedo no se selecciona el texto (los campos sí) */
:root[data-input="touch"] .cm-host { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
:root[data-input="touch"] .cm-host :is(input, textarea, [contenteditable="true"]) { -webkit-user-select: text; user-select: text; }

/* ───────── Móvil y pantallas táctiles: base común ─────────
   Zonas de toque de al menos ~40 px, letra de 16 px en los campos (así el móvil no amplía la página al escribir),
   ventanas que suben desde abajo como en las apps nativas y margen para la muesca y la barra de gestos.
   Cada app añade después su propia vista móvil en su styles.css. */
:root[data-input="touch"] { -webkit-tap-highlight-color: transparent; }
:root[data-input="touch"] .btn { min-height: 38px; height: auto; padding: 0 14px; font-size: 14px; }
:root[data-input="touch"] .btn.sm { min-height: 34px; padding: 0 11px; font-size: 13px; }
:root[data-input="touch"] .icon-btn { width: 40px; height: 40px; }
:root[data-input="touch"] .icon-btn.sm { width: 34px; height: 34px; }
:root[data-input="touch"] .icon-btn .ic { width: 18px; height: 18px; }
:root[data-input="touch"] .icon-btn.lang-btn { min-width: 40px; }
:root[data-input="touch"] .seg button { min-height: 34px; height: auto; padding: 0 12px; font-size: 13px; }
:root[data-input="touch"] :is(.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), .field select) { height: 42px; font-size: 16px; }
:root[data-input="touch"] :is(textarea, .field textarea, .input.mono, .field input.mono) { font-size: 16px; }
:root[data-input="touch"] .field-l { font-size: 12.5px; }
:root[data-input="touch"] .check { min-height: 36px; font-size: 14px; gap: 10px; }
:root[data-input="touch"] .check input { width: 20px; height: 20px; }
:root[data-input="touch"] input[type="range"] { min-height: 30px; }
:root[data-input="touch"] .cm { min-width: 230px; font-size: 15px; }
:root[data-input="touch"] .cm button { padding: 11px 12px; }
:root[data-input="touch"] .gpal-item { padding: 11px 10px; }
:root[data-input="touch"] .switcher-grid a { min-height: 44px; }
:root[data-input="touch"] .send-menu button { padding: 11px 8px; }
:root[data-input="touch"] .brand { min-height: 40px; }
:root[data-input="touch"] .chips button { min-height: 38px; padding-inline: 14px; font-size: 13.5px; }
:root[data-input="touch"] .chips { gap: 6px; }
.page { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.toasts { bottom: calc(28px + env(safe-area-inset-bottom)); max-width: calc(100vw - 20px); }
@media (max-width: 640px) {
  .toasts { left: 10px; right: 10px; max-width: none; transform: none; }
  .toast { max-width: 100%; white-space: normal; line-height: 1.4; }
  .toast button { white-space: nowrap; }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 6px 0 10px; }
  .overlay:has(> .modal) { align-items: flex-end; padding: 0; }
  .overlay > .modal { width: 100%; max-height: 92dvh; overflow: auto; border-radius: 16px 16px 0 0; border-bottom: 0;
    padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); animation: sheet .22s var(--ease); }
  .overlay > .modal::before { content: ""; display: block; width: 38px; height: 4px; margin: -8px auto 12px; border-radius: 99px; background: var(--border-2); }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions > .btn { flex: 1 1 auto; }
}
@media (max-width: 420px) {
  .brand-suite, .brand-sep { display: none; }
}
@keyframes sheet { from { opacity: 0; transform: translateY(40px); } }

/* Aviso «mejor en horizontal» (lo pone shell.js en las apps con data-orient="landscape") */
.orient-hint { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 70;
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 14px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 13.5px; line-height: 1.4; animation: sheet .25s var(--ease); }
.orient-hint svg { flex: none; width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; animation: orient 2.4s ease-in-out infinite; }
.orient-hint button { flex: none; min-height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: color-mix(in srgb, var(--bg) 18%, transparent); color: inherit; font: 600 13px var(--sans); }
@keyframes orient { 0%, 30% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
body:has(> .orient-hint) .toasts { bottom: calc(100px + env(safe-area-inset-bottom)); }
/* Elementos solo para el móvil (las apps los colocan en su diseño estrecho) */
@media (min-width: 701px) { .m-only { display: none !important; } }
@keyframes cmFade { from { opacity: 0; } }
/* Campos de fecha y hora: en el móvil tienen un ancho mínimo propio que se sale del diseño */
input:is([type="date"], [type="datetime-local"], [type="time"], [type="month"], [type="week"]) { min-width: 0; max-width: 100%; }
:root[data-input="touch"] input:is([type="date"], [type="datetime-local"], [type="time"], [type="month"], [type="week"]) { -webkit-appearance: none; appearance: none; width: 100%; min-height: 42px; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }
@media (max-width: 600px) {
  .grid2:has(input:is([type="date"], [type="datetime-local"])) { grid-template-columns: minmax(0, 1fr); }
}

/* ───────── Abrir y cerrar apps como en iOS (lo prepara shared/transicion.js) ─────────
   Abrir: el icono pulsado («app-open») crece hasta la pantalla entera con la app dentro y el inicio se aleja detrás.
   Cerrar: la app entera («app-close») se encoge hasta su icono del inicio. --vt-r y --vt-bg: redondeo y color del icono. */
@view-transition { navigation: auto; }
::view-transition-group(app-open), ::view-transition-group(app-close) {
  z-index: 2; animation-duration: .4s; animation-timing-function: cubic-bezier(.2, .9, .3, 1);
}
/* Lo que crece o encoge es una tarjeta del color del icono (--vt-bg); el dibujo del icono no se amplía porque se pixelaría */
::view-transition-image-pair(app-open), ::view-transition-image-pair(app-close) { overflow: clip; background: var(--vt-bg, transparent); }
::view-transition-image-pair(app-open) { animation: vt-round-out .4s cubic-bezier(.2, .9, .3, 1) both; }
::view-transition-image-pair(app-close) { animation: vt-round-in .4s cubic-bezier(.2, .9, .3, 1) both; }
::view-transition-old(app-open), ::view-transition-new(app-open), ::view-transition-old(app-close), ::view-transition-new(app-close) {
  width: 100%; height: 100%; object-fit: cover; mix-blend-mode: normal;
}
::view-transition-new(app-open), ::view-transition-old(app-close) { object-position: top center; }   /* la app: se ve su parte de arriba */
::view-transition-old(app-open) { animation: none; opacity: 0; }   /* abrir: el dibujo se va al instante, crece solo el color */
::view-transition-new(app-open) { animation: vt-fade .18s .14s ease-out both; }     /* y la app aparece encima cuando ya es grande */
::view-transition-old(app-close) { animation: vt-fade .14s ease-in reverse both; }  /* cerrar: la app se funde en el color y encoge */
::view-transition-new(app-close) { animation: vt-pop .16s .3s cubic-bezier(.3, 1.5, .5, 1) both; }   /* y al llegar casi al tamaño del icono, reaparece su dibujo */
.vt-open::view-transition-old(root) { animation: vt-back .4s cubic-bezier(.2, .9, .3, 1) both; }
.vt-close::view-transition-new(root) { animation: vt-back .4s cubic-bezier(.2, .9, .3, 1) reverse both; }
@keyframes vt-round-out { from { border-radius: var(--vt-r, 20px); } to { border-radius: 0; } }
@keyframes vt-round-in { from { border-radius: 0; } to { border-radius: var(--vt-r, 20px); } }
@keyframes vt-fade { from { opacity: 0; } }
@keyframes vt-pop { from { opacity: 0; transform: scale(.55); } }
@keyframes vt-back { to { transform: scale(1.06); opacity: .35; filter: blur(2px); } }
