/* ===========================
   ORGANÍZATE · styles.css
   Header + Footer estilo GUI‑on (compacto, premium, móvil como ensaYOnesa)
   =========================== */

/* ===========================
   VARIABLES
   =========================== */
:root{
  /* Paleta base (tuya) */
  --bg:#b4a9a99a;
  --surface:#18191dee;
  --text:#e5e7eb;
  --muted:#94a3b8;

  --brand:#22d3ee;
  --accent:#a3eb449a;
  --ok:#34d399;
  --danger:#ebf87188;
  --warn:#11125abd;

  --chip:#464e5a;
  --border:#2c6e48;

  /* Sombra “app” */
  --shadow:0 10px 25px rgba(0, 0, 0, 0.76);

  /* Inputs */
  --field-bg: #98a3b4;
  --field-bg-filled: #748092;
  --dropdown-bg: #18191dee;

  /* Dimensiones */
  --detail-w:min(1180px,96vw);

  /* ✅ Header/footer height para layouts sticky/fixed */
  --header-h: 56px;  /* JS puede sobrescribir si ya lo haces */
  --ftrH: 56px;

  /* Reserva para footer fijo (evita que tape contenido) */
  --footer-space: 86px;

  /* Columnas */
  --actions-col:200px;
  --list-max:100%;

  /* Anim/glifos */
  --glyph-gap: 10px;

  /* === Gradientes (ORIGINAL/CLÁSICO) === */
  --bg-g1:#b4a9a99a;
  --bg-g2:#1e1935e3;
  --bg-g3:#1d1235;

  --card-g1:#3d4250;
  --card-g2:#414044c2;
  --card-g3:#797c81;

  --bg-grad: 120deg, var(--bg-g1), var(--bg-g2) 60%, var(--bg-g3);
  --card-grad: 180deg, var(--card-g1), var(--card-g2) 50%, var(--card-g3);

  /* ===========================
     GUI‑on Glass / Glow
     =========================== */
  --glass: blur(16px) saturate(1.22);
  --glow:
    0 14px 35px rgba(0,0,0,.60),
    0 0 0 1px rgba(255,255,255,.03),
    inset 0 1px 0 rgba(255,255,255,.14);

  --ghost: color-mix(in oklab, var(--surface) 70%, transparent);

  /* Compact sizes */
  --hdr-btn-h: 32px;
  --ftr-btn-h: 26px;

  --logo-size: clamp(32px, 5vw, 48px);
  --logo-size-mobile: clamp(32px, 18vw, 56px);

  --brand-size: clamp(1.4rem, 3.2vw, 2.1rem);

  --tag-gap: clamp(10px, 3vw, 40px);
  --glyph-gap-compact: 4px;

  --glyph-sm: 1.45rem;
  --glyph-orb: 1.4rem;
  --glyph-sun: 1.6rem;
  --glyph-dash: 1.5rem;
}

/* Responsive footer space */
@media (max-width: 720px){
  :root{ --footer-space: 98px; }
}

/* ===========================
   RESET / BASE
   =========================== */
*{box-sizing:border-box}
html,body{min-height:100%}
body{
  margin:0;
  font:14px system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Helvetica Neue",Arial;
  background:linear-gradient(var(--bg-grad));
  color:var(--text);
  overflow-x:hidden;
}

/* Utilidad accesible (como ensaYOnesa) */
.sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* ===========================
   HEADER (GUI‑on style)
   =========================== */
header{
  position: sticky;
  top: 0;
  z-index: 90;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;

  padding: 6px 14px;
  padding-top: calc(6px + env(safe-area-inset-top));

  background:
    radial-gradient(circle at 0 0, color-mix(in oklab, var(--brand) 18%, transparent), transparent 60%),
    linear-gradient(180deg, color-mix(in oklab, var(--brand) 26%, rgba(0,0,0,.85)), rgba(0,0,0,0)),
    var(--surface);

  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);

  border-bottom: 1px solid color-mix(in oklab, var(--brand) 40%, var(--border));
  box-shadow: var(--glow);

  /* ✅ para que el z-index interno (tagline vs botones) sea estable */
  isolation:isolate;
}

/* Columna izquierda (marca) */
header .title{
  display:flex;
  align-items:center;
  gap:8px;
  min-height:40px;
  font-weight:800;
  letter-spacing:.2px;
  flex: 1 1 auto;
  min-width: 0;

  /* ✅ deja logo/textos por encima de la tagline centrada */
  position:relative;
  z-index:2;
}

/* Header acciones por encima */
header .actions{
  position:relative;
  z-index:2;
}

/* Brand */
.brand{
  display:flex;
  align-items:center;
  gap:8px;
}
.brand-home-link{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  color:inherit;
  text-decoration:none;
}

.brand-home-link:hover,
.brand-home-link:focus-visible{
  text-decoration:none;
  filter:brightness(1.05);
  outline:none;
}
/* Logo */
#appLogo{
  height: var(--logo-size);
  width:  var(--logo-size);
  max-width:none;
  object-fit:contain;
  border-radius:12px;
  box-shadow:none;
}

/* heat */
#appLogo.heat{
  filter:
    url(#heat-waves)
    drop-shadow(0 0 6px rgba(255,255,255,.35))
    drop-shadow(0 0 16px rgba(34,211,238,.35));
}

/* “OptimeFlow(s)” */
#brandWord,
.brand-neon{
  font-weight:800;
  font-size: var(--brand-size);
  letter-spacing:.2px;

  color:#000;
  animation:hue 12s linear infinite, glow 3.2s ease-in-out infinite;
}

.mobile-brand-word{
  display:none;
  white-space:nowrap;
}

@keyframes hue{from{filter:hue-rotate(0)}to{filter:hue-rotate(360deg)}}
@keyframes glow{
  0%,100%{text-shadow:0 0 6px rgba(255,255,255,.25),0 0 14px rgba(34,211,238,.55)}
  50%{text-shadow:0 0 10px rgba(255,255,255,.5),0 0 24px rgba(167,139,250,.7)}
}

/* ✅ Tagline centrada respecto a TODO el header */
#tagline{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);

  display:flex;
  align-items:center;
  justify-content:center;
  gap: var(--glyph-gap-compact);

  white-space:nowrap;
  pointer-events:none;
  text-align:center;
  line-height:1;
  max-width: min(70vw, 820px);

  /* queda por debajo de .title y .actions (z-index 2) */
  z-index:1;
}

/* Huecos */
.brand-gap{ width: var(--tag-gap); }
.tag-gap{ display:inline-block; width: var(--tag-gap); }

/* Glifos base */
.glyph{ display:inline-block; letter-spacing:0; line-height:1; transform-origin:center bottom; }
.rotate-z{ display:inline-block; transform-origin:center; animation:tiltZ 5s ease-in-out infinite alternate; }
@keyframes tiltZ{ from{transform:rotate(-6deg)} to{transform:rotate(6deg)} }

@keyframes floatY{0%,100%{transform:translateY(0)}50%{transform:translateY(-2px)}}
@keyframes wave{0%,100%{transform:translateY(0);opacity:.6}50%{transform:translateY(-3px);opacity:.85}}
@media (prefers-reduced-motion:reduce){ .brand-neon,.big-letter,.paren{animation:none} }
.no-motion *{ animation:none !important; transition:none !important; }

/* Tamaños de la tagline */
.tagline{ --glyph-gap: var(--glyph-gap-compact); }
.tagline .frag-silver,
.tagline .frag-white{
  font-size: var(--glyph-sm);
  opacity:.92;
  animation:wave 3.8s ease-in-out infinite;
}
.tagline .frag-silver{
  color:#cfd3d6;
  text-shadow:0 0 6px rgba(255,255,255,.18);
}
.tagline .frag-white{
  color:#fff;
  text-shadow:0 0 8px rgba(255,255,255,.25);
}
.tagline .orb-blue{
  font-weight:900;
  font-size: var(--glyph-orb);
  color:#bfe5ff;
  text-shadow:
    0 0 8px rgba(180,215,255,.9),
    0 0 22px rgba(80,160,255,.85),
    0 0 40px rgba(40,120,255,.7);
}
.tagline .orb-black{
  font-weight:900;
  font-size: var(--glyph-sm);
  color:#000;
  text-shadow:
    0 0 8px rgba(255,255,255,.45),
    0 0 22px rgba(190,190,190,.35),
    0 0 40px rgba(130,130,130,.3);
}
.tagline .orb-dawn{
  font-weight:900;
  font-size: var(--glyph-orb);
  color:#ffd1b1;
  animation:dawnGlow 6s ease-in-out infinite;
}
@keyframes dawnGlow{
  0%{color:#ffd1b1;text-shadow:0 0 8px rgba(255,180,80,.95),0 0 24px rgba(255,140,0,.8),0 0 40px rgba(255,100,0,.65)}
  25%{color:#ffc2ef;text-shadow:0 0 8px rgba(255,0,128,.95),0 0 24px rgba(255,80,160,.8),0 0 40px rgba(255,0,120,.6)}
  50%{color:#ffd9e6;text-shadow:0 0 8px rgba(255,70,160,.95),0 0 24px rgba(255,20,100,.8),0 0 40px rgba(255,50,140,.6)}
  75%{color:#d6f1ff;text-shadow:0 0 8px rgba(120,180,255,.95),0 0 24px rgba(70,140,255,.8),0 0 40px rgba(40,120,255,.6)}
  100%{color:#ffd1b1;text-shadow:0 0 8px rgba(255,180,80,.95),0 0 24px rgba(255,140,0,.8),0 0 40px rgba(255,100,0,.65)}
}
.tagline .sun-i{
  font-weight:900;
  font-size: var(--glyph-sun);
  color:#fff;
  text-shadow:
    0 0 8px rgba(204, 192, 192, 0.9),
    0 0 22px rgba(255, 255, 255, 0.8),
    0 0 40px rgba(207, 229, 248, 0.65);
  animation:none;
}
.tagline .dash-plasma{
  font-weight:900;
  font-size: var(--glyph-dash);
  color:#ffc36b;
  text-shadow: 0 0 8px rgba(255,190,120,.95), 0 0 24px rgba(255,100,0,.8), 0 0 40px rgba(255,80,0,.6);
}

/* ===========================
   HEADER · acciones
   =========================== */
header .actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
  gap:8px;
  flex: 0 0 auto;
}

/* Botones y selects SOLO dentro del header */
header .actions .btn,
header .actions .sel,
header .actions select,
header .actions select.sel,
header .actions #langSelect{
  height: var(--hdr-btn-h);
  padding: 0 10px;

  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--brand) 40%, var(--border));

  background: var(--ghost);
  color: var(--text);

  box-shadow: var(--glow);
  font-weight: 800;
  line-height: 1;

  cursor:pointer;
  transition: border-color .18s ease, transform .15s ease, filter .15s ease;
}

header .actions .btn:hover,
header .actions .sel:hover,
header .actions select:hover{
  border-color: var(--brand);
  transform: translateY(-1px);
  filter: brightness(1.05);
}

header .actions .btn:focus-visible,
header .actions select:focus-visible{
  outline:none;
  box-shadow:
    0 0 0 2px color-mix(in oklab, var(--brand) 30%, transparent),
    var(--glow);
}

/* Botones “pressed” si tu JS los marca */
:root{ --hdr-btn-press-bg: rgba(34,211,238,.14); }
header .actions .btn.is-pressed,
header .actions .btn[aria-expanded="true"]{
  background: var(--hdr-btn-press-bg);
  border-color: var(--brand);
  box-shadow:
    0 0 0 1px var(--brand) inset,
    var(--glow);
  transform:none;
}

/* Dropdown options */
#langSelect option,
#sortBy option,
select.sel option{
  background: var(--surface);
  color: var(--text);
}

/* ===========================
   HEADER MÓVIL (logo + título arriba, botones debajo)
   =========================== */
@media (max-width: 1024px) and (orientation: portrait){
  :root{
    --glyph-sm: 1.15rem;
    --glyph-orb: 1.15rem;
    --glyph-sun: 1.25rem;
    --glyph-dash: 1.25rem;
  }

  header.brand-header{
    display:grid;
    grid-template-columns:1fr;
    grid-template-areas:
      "brand"
      "actions";
    align-items:stretch;
    justify-content:stretch;
    gap:10px;
    padding:8px 12px 10px;
    padding-top:calc(8px + env(safe-area-inset-top));
  }

  header .title{
    grid-area:brand;
    display:flex;
    align-items:center;
    justify-content:flex-start;
    gap:10px;
    min-height:44px;
    width:100%;
    flex:0 0 auto;
    min-width:0;
  }

  header .brand{
    gap:10px;
  }

  header #brandWord,
  header .brand-gap,
  #tagline{
    display:none !important;
  }

   .mobile-brand-word{
    display:inline-flex;
    align-items:center;
    gap:0;
    white-space:nowrap;
    line-height:1;
  }

  #appLogo{
    height:clamp(38px, 10vw, 48px);
    width:clamp(38px, 10vw, 48px);
    flex:0 0 auto;
  }

  header .actions{
    grid-area:actions;
    width:100%;
    margin:0;
    display:grid;
    grid-template-columns:repeat(2, minmax(0,1fr));
    gap:8px;
    flex:none;
    max-width:none;
    overflow:visible;
    justify-content:stretch;
    align-items:stretch;
  }

  header .actions > *{
    min-width:0;
  }

  header .actions .btn{
    width:100%;
    min-height:38px;
    padding:0 8px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  #btnSettings{
    grid-column:1 / -1;
  }

  #headerPanels{
    justify-content:center;
  }

  .sh-panel{
    width:100%;
    max-width:100%;
    border-radius:0;
    margin:0;
    justify-content:center;
  }

  #settingsPanel > div{
    width:100%;
    justify-content:center !important;
  }
}

/* Ultra-narrow: una sola columna de botones si hiciera falta */
@media (max-width: 380px) and (orientation: portrait){
  header .actions{
    grid-template-columns:1fr;
  }

  #btnSettings{
    grid-column:auto;
  }
}

/* ===========================
   BOTONES BASE (resto app)
   =========================== */
.btn{
  border:1px solid var(--border);
  background:#22414bd5;
  color:var(--text);
  padding:8px 10px;
  border-radius:8px;
  cursor:pointer;
  transition:transform .08s ease,background .2s ease,border .2s ease;
  box-shadow:0 2px 8px rgba(3,7,18,.25)
}
.btn:hover{transform:translateY(-1px);border-color:var(--brand)}
.btn.brand{border-color:var(--brand);background:rgb(22, 185, 95)}
.btn.accent{border-color:var(--accent);background:rgba(135, 104, 226, 0.637)}
.btn.ok{border-color:var(--ok);background:rgba(68, 67, 78, 0.596)}
.btn.warn{border-color:var(--warn);background:rgba(251, 190, 36, 0.459)}
.btn.danger{border-color:var(--danger);background:rgba(90, 38, 38, 0.856)}
.btn.ghost{background:transparent}

select.sel{
  border:1px solid var(--border);
  background:var(--field-bg);
  color:var(--text);
  padding:8px 10px;
  border-radius:8px
}

/* ===========================
   LAYOUT PRINCIPAL
   =========================== */
.app{
  display:grid;
  grid-template-columns:320px 1fr;
  gap:16px;
  padding:16px;

  /* ✅ reserva para footer fijo */
  padding-bottom: calc(16px + var(--footer-space) + env(safe-area-inset-bottom));
}

.sidebar{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  box-shadow:var(--shadow);
  position:sticky;
  top:calc(var(--header-h) + 16px);

  /* ✅ resta footer fijo también */
  height:calc(100vh - (var(--header-h) + var(--footer-space) + 32px));
  overflow:auto
}

.sidebar h3{
  margin:8px 0 6px;
  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.08em
}

.control{display:flex;flex-direction:column;gap:6px;margin-bottom:12px}
.control input[type="text"],
.control input[type="date"],
.control input[type="number"],
.control select{
  width:100%;
  padding:10px 12px;
  border-radius:8px;
  border:1px solid var(--border);
  background: var(--field-bg);
  color: var(--text);
  outline:none;
}

.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{
  background:var(--chip);
  color:var(--text);
  border:1px solid var(--border);
  padding:4px 8px;
  border-radius:999px;
  font-size:12px;
  display:inline-flex;
  align-items:center;
  gap:6px
}

.tags-input{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  padding:6px;
  border:1px dashed var(--border);
  border-radius:8px
}
.tags-input input{
  border:none;
  background:transparent;
  outline:none;
  flex:1;
  color:var(--text)
}

.content{
  display:flex;
  flex-direction:column;
  gap:12px;
  transition:padding-right .2s ease
}
body.detail-open .content{padding-right:var(--detail-w)}
body.detail-max .content{padding-right:0}

.toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.stats{display:flex;gap:12px;flex-wrap:wrap}
.stat{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  min-width:140px;
  box-shadow:var(--shadow)
}
.stat .n{font-size:22px;font-weight:700}

.list{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px;
  box-shadow:var(--shadow);
  max-width:var(--list-max)
}

/* Cápsula de la lista */
.row{
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px;
  display:grid;
  grid-template-columns:24px 1fr var(--actions-col);
  gap:10px;
  align-items:center;
  background:linear-gradient(var(--card-grad));
  margin:8px 0
}
.row .meta{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:12px;
  flex-wrap:wrap
}
.row .title{font-weight:600;cursor:pointer}
.row .preview{color:var(--muted);margin-top:4px;max-height:40px;overflow:hidden}
.row .right{display:flex;gap:6px;justify-content:flex-end}
.row button.small{padding:6px 8px;border-radius:6px;font-size:12px}
.row.droptarget{outline:2px dashed var(--brand)}
.row.active{outline:2px solid rgba(57, 40, 131, 0.4)}
.row.origin-assembled{border-color:var(--accent);box-shadow:inset 0 0 0 1px rgba(174, 241, 97, 0.842)}
.row.origin-chatgpt{border-color:var(--border)}

/* Detail panel */
.detail{
  position:fixed;
  right:16px;
  top: calc(var(--header-h) + 16px);

  /* ✅ evita footer fijo */
  bottom: calc(16px + var(--footer-space) + env(safe-area-inset-bottom));

  width:var(--detail-w);
  background:
    linear-gradient(var(--card-grad)),
    var(--surface-solid, #0f1220);

  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  box-shadow:var(--shadow);

  transform:translateX(0);
  transition:transform .2s ease;

  display:grid;
  grid-template-rows:auto auto 1fr;
  gap:8px;
  overflow:hidden;
  z-index:20
}
.detail.hidden{transform:translateX(120%)}
body.detail-max .detail{
  left:16px;
  right:16px;
  top:calc(var(--header-h) + 16px);

  /* ✅ evita footer fijo */
  bottom: calc(16px + var(--footer-space) + env(safe-area-inset-bottom));

  width:auto
}

.detail .head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding-bottom:8px;
  background:transparent;
  border-bottom:1px solid var(--border)
}
.detail .title{font-weight:700;font-size:16px}
.chip-origin{
  border:1px solid var(--brand);
  color:var(--brand);
  border-radius:999px;
  padding:2px 8px
}
.chip-origin.assembled{border-color:var(--accent);color:var(--accent)}

.detail .local-search{
  background:transparent;
  padding:6px 0 8px;
  border-bottom:1px solid var(--border);
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  align-items:center
}

.detail-scroll{overflow:auto;padding-right:2px; overflow-x:hidden;}
.msg-list{display:flex;flex-direction:column;gap:8px;margin-top:8px}
.msg{
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
  position:relative;
  background:#2d2f33
}
.msg.user{border-left:3px solid #245e49;background:rgba(55, 124, 97, 0.815)}
.msg.assistant{border-left:3px solid #303c5c;background:rgba(68, 80, 112, 0.966)}
.msg .meta{
  color:var(--muted);
  font-size:12px;
  margin-bottom:6px;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap
}
.msg .text{
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  word-break:break-word;
  max-width:100%;
}
.msg.dragging{outline:2px dashed var(--warn)}

.summary{margin-top:8px;border-top:1px solid var(--border);padding-top:8px;color:var(--muted)}
.cols{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.panel{
  background:rgba(56, 57, 78, 0.788);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
  box-shadow:var(--shadow);
  min-width:0;
}
.muted{color:var(--muted)}
.small{font-size:12px}
.checkbox{width:18px;height:18px;accent-color:var(--brand)}
mark.hl{background:rgba(110, 8, 93, 0.486);color:inherit;padding:0 2px;border-radius:3px}

.overlay{
  position:fixed;
  inset:0;
  background:rgba(0, 0, 0, 0.918);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:99
}
.overlay .box{
  background:#6f80a7;
  border:1px solid var(--border);
  border-radius:12px;
  padding:16px;
  width:min(1100px,94vw);
  max-height:92vh;
  overflow:auto;
  box-shadow:var(--shadow)
}

/* Licencia MIT: panel a la mitad del ancho actual */
#licenseOverlay .box{ width: min(550px, 94vw); }

/* Coherencia por checkbox (si quieres que funcione sin JS) */
#coherenciaToggle:checked + #coherenciaOverlay{
  display:flex;
}

.kbd{
  display:inline-block;
  padding:2px 6px;
  border:1px solid var(--border);
  border-radius:6px;
  background:#0a1323;
  font-size:12px
}

/* Canvases */
canvas{
  width:100%;
  height:220px;
  background:#0b1e21;
  border:1px solid var(--border);
  border-radius:12px
}
.legend{font-size:12px;color:var(--muted);margin-top:4px}

.pager{
  display:flex;
  align-items:center;
  gap:8px;
  justify-content:flex-end;
  flex-wrap:wrap
}
.pager .info{color:#6e7a8a;font-size:12px}
.pager .btn.small{padding:6px 8px;font-size:12px}

.explain{margin-top:6px;color:var(--muted);font-size:12.5px;line-height:1.5}
.explain b{color:var(--text)}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}

.kpis{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:10px;
  margin-bottom:8px
}
.kpi{
  background:rgba(230, 77, 77, 0.02);
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px
}
.kpi .big{font-size:20px;font-weight:700}
.kpi .desc{font-size:12px;color:var(--muted)}

/* ===== Menú temas/idiomas (dropdown) ===== */
.menu{
  position:absolute;
  right:0;
  top:calc(100% + 6px);
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:10px;
  padding:6px;
  box-shadow:var(--shadow);
  min-width:220px;
  z-index:120
}
.menu.hidden{display:none}
.menu .item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  width:100%;
  padding:8px 10px;
  border-radius:8px;
  border:1px solid transparent;
  background:transparent;
  color:var(--text);
  cursor:pointer
}
.menu .item:hover{background:#1c2231;border-color:var(--brand)}
.menu .item.active{outline:2px solid var(--brand)}
.menu .item .swatch{
  width:56px;height:16px;border-radius:4px;border:1px solid var(--border);flex:0 0 56px
}
.dropdown #btnThemes::after{content:" ▾";}

/* Texto negro en inputs (excepto búsquedas) */
.control input[type="text"],
.control input[type="date"],
.control input[type="number"],
.tags-input input{
  color:#000 !important;
}

/* Fondo cuando hay contenido */
.control input[type="text"]:not(:placeholder-shown),
.tags-input input:not(:placeholder-shown),
#detailSearch:not(:placeholder-shown){
  background: var(--field-bg-filled);
}

/* Buscador local del detalle */
#detailSearch{
  color:#331919 !important;
  caret-color:#fff;
}
#detailSearch::placeholder{
  color:#d7e1ef;
  opacity:.85;
}

/* Paginador superior ocupa toda la línea */
.toolbar #pagerTop{ width:100%; justify-content:flex-start; }

/* 3) Centrar texto dentro de chip de origen en detalle */
.detail .head .chip-origin{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:3px 10px;
  text-align:center;
}

/* ===========================
   PANELES BAJO HEADER
   =========================== */
#headerPanels{
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  z-index: 85;
  pointer-events: none;
  display: flex;
  justify-content: flex-end;
}
.sh-panel{
  display: inline-flex;
  gap: 8px;
  justify-content: flex-end;
  width: max-content;
  max-width: min(96vw, 880px);
  margin: 0 12px 8px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  padding: 8px 12px;
  pointer-events: auto;
}
.hidden{ display:none !important; }

@media (max-width: 720px){
  #headerPanels{ justify-content: center; }
  .sh-panel{
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    margin: 0;
    justify-content: center;
  }
}

/* Fix de menús flotantes */
header { overflow: visible !important; }
#themesMenu.menu { will-change: top, left; }
#themesMenu.menu.floating { position: fixed !important; z-index: 10000 !important; }
#langsMenu.menu { will-change: top, left; }
#langsMenu.menu.floating { position: fixed !important; z-index: 10000 !important; }

/* ===========================
   FOOTER (fijo y compacto, como ensaYOnesa)
   =========================== */
.footer{
  background:
    radial-gradient(circle at 0% 100%, rgba(148,163,184,0.18), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(34,211,238,0.16), transparent 55%),
    linear-gradient(0deg, rgba(0,0,0,.28), rgba(0,0,0,0)),
    var(--surface);

  border-top:1px solid var(--border);
  color:var(--muted);
  box-shadow:0 -12px 28px rgba(0,0,0,.22);

  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;

  padding: 4px 12px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom));

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;

  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
}

.footer strong{ color:var(--text); }
.footer .sep{ opacity:.6; }

/* ✅ Igual que ensaYOnesa: bloque izquierdo en 2 filas */
.footer-left{
  display:flex;
  flex-direction:column;
  gap:2px;
  font-size:0.78rem;
  min-width: 0;
}
.f-left-row1,
.f-left-row2{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}
.footer-author-link{
  display:inline-flex;
  align-items:center;
  color:inherit;
  text-decoration:none;
}

.footer-author-link:hover,
.footer-author-link:focus-visible{
  color:var(--text);
  text-decoration:underline;
  outline:none;
}
.footer-center{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  z-index:1;
}

.footer-right{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:8px;
}

/* Botones footer compactos */
.footer .btn,
.footer a.btn{
  height: var(--ftr-btn-h);
  border-radius: 8px;
  padding: 0 10px;
  font-weight:800;

  background: var(--ghost);
  border: 1px solid var(--border);
  color: var(--text);

  box-shadow: none;
  transform:none;
}

/* Botón-ícono centrado */
.footer-logo-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:14px;
  padding:2px;
  border:1px solid transparent;
  background:transparent;
  transition: border-color .18s ease, box-shadow .18s ease, transform .15s ease;
  text-decoration:none;
}
.footer-logo-btn:hover,
.footer-logo-btn:focus-visible{
  border-color:var(--brand);
  box-shadow:0 0 16px color-mix(in oklab, var(--brand) 75%, transparent);
  transform:translateY(-1px);
  outline:none;
}

/* ✅ Tamaño base como ensaYOnesa */
.footer-logo{
  width: clamp(22px, 5vw, 28px);
  height: clamp(22px, 5vw, 28px);
  border-radius:12px;
  border:2px solid rgba(255,255,255,.18);
  box-shadow:0 0 8px rgba(255,255,255,.18);
  object-fit:contain;
}

/* Icono con halo / sway */
.tag-logo{
  object-fit:contain;
  transform-origin:center center;
  animation:sway 5.5s ease-in-out infinite;
  filter:
    drop-shadow(0 0 6px rgba(255,255,255,.35))
    drop-shadow(0 0 16px rgba(34,211,238,.35));
}
@keyframes sway{
  0%{transform:rotate(-3deg)}
  50%{transform:rotate(3deg)}
  100%{transform:rotate(-3deg)}
}

/* Footer móvil: grid 1fr auto 1fr + botones en columna (como ensaYOnesa) */
@media (max-width: 600px) and (orientation: portrait){
  .footer{
    display:grid;
    grid-template-columns: 1fr auto 1fr;
    align-items:center;
    gap:8px;

    padding: 6px 12px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }

  .footer-center{
    position:static;
    transform:none;
    justify-self:center;
  }

  .footer-right{
    flex-direction:column;
    align-items:flex-end;
    gap:6px;
  }

  .footer-left, .footer-right{
    font-size: clamp(11px, 3.1vw, 13px);
    line-height: 1.15;
  }

  /* ✅ En móvil, icono más grande como ensaYOnesa */
  .footer-logo{
    width: clamp(32px, 10vw, 40px);
    height: clamp(32px, 10vw, 40px);
  }
}

/* ===========================
   RESPONSIVE GENERAL
   =========================== */
@media (max-width: 680px){
  .app{ grid-template-columns:1fr; }
  .sidebar{ position:static; height:auto; }
  .row{ grid-template-columns:20px 1fr 120px; }
  .row .right{ flex-wrap:wrap; }
  .detail{ right:8px; left:8px; width:auto; }
}

/* Detail mobile grid */
@media (max-width: 1024px){
  .detail .head{
    display: grid;
    grid-template-rows: auto auto;
    row-gap: 8px;
  }
  .detail .head > :first-child{
    justify-content: center !important;
    text-align: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .detail .head > :last-child{
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px !important;
    justify-items: stretch;
  }
  .detail .head > :last-child .btn{ width: 100%; }
  #btnToggleMax{ display: none !important; }
}

/* Smallest polish */
@media (max-width: 480px){
  body{ font-size: 13px; }
  header{
    padding: 8px 12px 10px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  #appLogo{ height: 40px; width: 40px; }
  .mobile-brand-word{ font-size: 1.45rem; }
  .sidebar{ margin-top: 4px; padding: 10px; }
  .list{ padding: 6px; }
  .row{ grid-template-columns: 18px 1fr 110px; padding: 8px; }
  .row .right{ gap: 4px; flex-wrap: wrap; }
  .row .right .btn.small{ padding: 4px 6px; font-size: 11px; }
  .detail{ right: 4px; left: 4px; }

  header .actions .btn{
    font-size:12.5px;
  }
}
/* ===========================
   MÓVIL · botón engranaje + menú desplegable del header
   =========================== */

.icon-button.mobile-header-toggle{
  display:none !important;
}

.icon-button{
  width:40px;
  height:40px;
  padding:0;
  border-radius:999px;
  border:1px solid color-mix(in oklab, var(--brand) 40%, var(--border));
  background:
    radial-gradient(circle at 30% 0%, rgba(255,255,255,.16), transparent 55%),
    linear-gradient(145deg, rgba(15,23,42,.98), rgba(15,23,42,.85));
  color:var(--text);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow:var(--glow);
  transition:border-color .18s ease, transform .15s ease, filter .15s ease;
}

.icon-button:hover{
  border-color:var(--brand);
  transform:translateY(-1px);
  filter:brightness(1.05);
}

.icon-button:focus-visible{
  outline:none;
  box-shadow:
    0 0 0 2px color-mix(in oklab, var(--brand) 30%, transparent),
    var(--glow);
}

.icon-gear{
  width:18px;
  height:18px;
  border-radius:999px;
  border:2px solid var(--brand);
  box-shadow:0 0 0 1px rgba(15,23,42,.8);
  position:relative;
}

.icon-gear::before,
.icon-gear::after{
  content:"";
  position:absolute;
  border-radius:999px;
}

.icon-gear::before{
  inset:4px;
  border:2px solid rgba(148,163,184,.8);
}

.icon-gear::after{
  inset:7px;
  border:3px solid var(--brand);
}

@media (max-width: 1024px) and (orientation: portrait){
  header.brand-header{
    grid-template-columns:1fr auto;
    grid-template-areas:"brand gear";
    align-items:center;
    gap:10px;
  }

  header .title{
    grid-area:brand;
    width:100%;
    min-width:0;
  }

    .icon-button.mobile-header-toggle{
    display:inline-flex !important;
    grid-area:gear;
    justify-self:end;
    align-self:center;
  }

  /* En móvil ocultamos las acciones del header
     y las convertimos en menú flotante */
  header .actions{
    position:fixed;
    top:calc(var(--header-h) + 8px);
    right:12px;
    left:auto;
    z-index:95;

    width:min(280px, calc(100vw - 24px));
    margin:0;
    padding:10px;

    display:none;
    grid-template-columns:1fr;
    gap:8px;

    background:
      radial-gradient(circle at 0% 0%, rgba(148,163,184,0.18), transparent 55%),
      radial-gradient(circle at 120% 0%, rgba(34,211,238,0.16), transparent 55%),
      var(--surface);

    border:1px solid color-mix(in oklab, var(--brand) 40%, var(--border));
    border-radius:16px;
    box-shadow:var(--glow);
    backdrop-filter:var(--glass);
    -webkit-backdrop-filter:var(--glass);
  }

  body.mobile-header-menu-open header .actions{
    display:grid;
  }

  header .actions > *{
    min-width:0;
  }

  header .actions .btn{
    width:100%;
    min-height:38px;
    justify-content:center;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  /* anulamos tu regla anterior que hacía gigante Ajustes */
  #btnSettings{
    grid-column:auto;
  }

  /* que los paneles Exportar/Ajustes salgan a la derecha, no centrados */
  #headerPanels{
    justify-content:flex-end;
    padding-right:12px;
  }

  .sh-panel{
    width:min(320px, calc(100vw - 24px));
    max-width:calc(100vw - 24px);
    margin:0 12px 8px 0;
    border-radius:16px;
    justify-content:flex-start;
  }

  #settingsPanel > div{
    width:100%;
    display:flex;
    flex-direction:column;
    align-items:stretch;
    justify-content:flex-start !important;
  }

  #settingsPanel > div > *{
    width:100%;
  }

  #settingsPanel .dropdown .btn,
  #settingsPanel > div > .btn{
    width:100%;
  }
}

@media (max-width: 380px) and (orientation: portrait){
  header .actions{
    width:calc(100vw - 16px);
    right:8px;
  }

  #headerPanels{
    padding-right:8px;
  }

  .sh-panel{
    width:calc(100vw - 16px);
    max-width:calc(100vw - 16px);
    margin:0 8px 8px 0;
  }
}
/* ===========================
   orgAnIzAte móvil con glifos propios
   =========================== */

#mobileBrandWord .glyph{
  display:inline-block;
  letter-spacing:0;
  line-height:1;
  transform-origin:center bottom;
}

#mobileBrandWord .frag-silver,
#mobileBrandWord .frag-white{
  font-size:clamp(1.35rem, 6vw, 1.9rem);
  opacity:.92;
  animation:wave 3.8s ease-in-out infinite;
}

#mobileBrandWord .frag-silver{
  color:#cfd3d6;
  text-shadow:0 0 6px rgba(255,255,255,.18);
}

#mobileBrandWord .frag-white{
  color:#fff;
  text-shadow:0 0 8px rgba(255,255,255,.25);
}

#mobileBrandWord .orb-blue{
  font-weight:900;
  font-size:clamp(1.4rem, 6.2vw, 2rem);
  color:#bfe5ff;
  text-shadow:
    0 0 8px rgba(180,215,255,.9),
    0 0 22px rgba(80,160,255,.85),
    0 0 40px rgba(40,120,255,.7);
}

#mobileBrandWord .orb-dawn{
  font-weight:900;
  font-size:clamp(1.4rem, 6.2vw, 2rem);
  color:#ffd1b1;
  animation:dawnGlow 6s ease-in-out infinite;
}