/* Trama Posters Viewer */
.tp-app, .tp-modal {
  --tp-primary: #970b1f;
  --tp-primary-dark: #580817;
  --tp-blue: #0f4ea7;
  --tp-ink: #191c21;
  --tp-muted: #5b6270;
  --tp-line: #e3e6ec;
  --tp-bg: #f5f6f8;
  --tp-card: #ffffff;
  --tp-radius: 4px;
  --tp-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --tp-shadow-hover: 0 10px 28px rgba(16, 24, 40, .12);
  color: var(--tp-ink);
  font-size: 15px;
  line-height: 1.5;
}
.tp-app *, .tp-modal * { box-sizing: border-box; }
.tp-app { max-width: 1240px; margin: 0 auto; padding: 8px 0 40px; }
.tp-ico { display: inline-flex; width: 1.1em; height: 1.1em; flex: none; }
.tp-ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Estados */
.tp-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 64px 16px; color: var(--tp-muted); }
.tp-spinner { width: 22px; height: 22px; border: 3px solid var(--tp-line); border-top-color: var(--tp-primary); border-radius: 50%; animation: tp-spin .8s linear infinite; }
@keyframes tp-spin { to { transform: rotate(360deg); } }
.tp-state { grid-column: 1 / -1; text-align: center; padding: 56px 16px; background: var(--tp-bg); border-radius: var(--tp-radius); color: var(--tp-muted); }
.tp-state strong { display: block; color: var(--tp-ink); font-size: 17px; margin-bottom: 4px; }
.tp-state p { margin: 0 0 12px; padding: 0; }

/* Toolbar */
.tp-toolbar { background: var(--tp-card); border: 1px solid var(--tp-line); border-top: 3px solid #c46a78; border-radius: var(--tp-radius); padding: 16px; display: grid; gap: 14px; }
.tp-toolbar__top { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.tp-search { flex: 1 1 320px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--tp-line); border-radius: 4px; padding: 0 14px; background: var(--tp-bg); height: 46px; color: var(--tp-muted); transition: border-color .15s, box-shadow .15s, background .15s; margin: 0; }
.tp-search:focus-within { border-color: var(--tp-blue); background: #fff; box-shadow: 0 0 0 3px rgba(15, 78, 167, .15); }
.tp-search__input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; outline: 0; font: inherit; font-size: 15px; color: var(--tp-ink); height: 44px; padding: 0 !important; box-shadow: none !important; }
.tp-field { display: grid; gap: 4px; margin: 0; min-width: 0; }
.tp-field__label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--tp-muted); }
.tp-select { appearance: none; -webkit-appearance: none; font: inherit; font-size: 14px; color: var(--tp-ink); height: 46px; padding: 0 38px 0 12px; border: 1px solid var(--tp-line); border-radius: 4px; width: 100%; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6270' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px; }
.tp-select:focus { outline: 0; border-color: var(--tp-blue); box-shadow: 0 0 0 3px rgba(15, 78, 167, .15); }
.tp-field.is-active .tp-select { border-color: var(--tp-primary); background-color: #fdf3f4; font-weight: 600; }
.tp-field--sort { flex: 0 0 210px; }
.tp-views { display: flex; border: 1px solid var(--tp-line); border-radius: 4px; overflow: hidden; height: 46px; }
.tp-view { border: 0; background: #fff; color: var(--tp-muted); width: 46px; display: grid; place-items: center; cursor: pointer; padding: 0; font-size: 18px; }
.tp-view + .tp-view { border-left: 1px solid var(--tp-line); }
.tp-view[aria-pressed="true"] { background: #4a4f59; color: #fff; }
.tp-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

.tp-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--tp-line); background: #fff; color: var(--tp-ink); border-radius: 3px; padding: 7px 8px 7px 14px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.tp-pill:hover:not(:disabled) { border-color: var(--tp-primary); }
.tp-pill__count { background: var(--tp-bg); color: var(--tp-muted); border-radius: 3px; padding: 1px 8px; font-size: 12px; font-weight: 600; min-width: 26px; text-align: center; }
.tp-pill[aria-pressed="true"] { background: #b5475a; border-color: #b5475a; color: #fff; }
.tp-pill[aria-pressed="true"] .tp-pill__count { background: rgba(255, 255, 255, .22); color: #fff; }
.tp-pill:disabled { opacity: .45; cursor: default; }

/* Resumen + chips */
.tp-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 18px 2px 14px; min-height: 32px; }
.tp-count { margin: 0; padding: 0; font-weight: 700; font-size: 16px; }
.tp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-chip { display: inline-flex; align-items: center; gap: 6px; border: 0; background: #eef3fb; color: var(--tp-blue); border-radius: 3px; padding: 5px 10px 5px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.tp-chip:hover { background: #dbe6f7; }
.tp-chip .tp-ico { width: 14px; height: 14px; }
.tp-reset { border: 0; background: none; color: var(--tp-primary); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 4px; margin-left: auto; }

/* Grid: tarjetas con proporción de póster + overlay inferior */
.tp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 26px 20px; }
.tp-card { --tp-area: #6e7c90; position: relative; aspect-ratio: 5 / 7; background: #fbfaf7; border: 1px solid #e0e2e6; border-radius: 3px; overflow: hidden; cursor: pointer; transition: transform .25s ease, outline-color .2s; outline: 2px solid transparent; outline-offset: 4px; }
.tp-card:hover, .tp-card:focus-within { transform: translateY(-4px); outline-color: var(--tp-area); }
.tp-card__cover { position: absolute; inset: 0; transition: transform .5s ease; }
.tp-card:hover .tp-card__cover { transform: scale(1.035); }
.tp-card__cover img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }

/* Miniatura tipo póster científico (sin imagen) */
.tp-mini { height: 100%; display: flex; flex-direction: column; background: #fbfaf7; }
.tp-mini__head { background: color-mix(in srgb, var(--tp-area) 20%, #fff); color: #2a2d33; border-bottom: 2px solid color-mix(in srgb, var(--tp-area) 55%, #fff); padding: 14px 14px 12px; display: grid; gap: 6px; flex: none; }
.tp-mini__kicker { font-size: 7.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: color-mix(in srgb, var(--tp-area) 80%, #000); }
.tp-mini__title { font-size: 11.5px; font-weight: 800; line-height: 1.22; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tp-mini__authors { font-size: 8px; line-height: 1.3; opacity: .7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tp-mini__cols { flex: 1; overflow: hidden; column-count: 2; column-gap: 12px; column-rule: 1px solid #e4e1d8; padding: 12px 14px; font-size: 7.5px; line-height: 1.5; color: #73767d; text-align: left; }

/* Overlay inferior */
.tp-card__ov { position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: 6px; padding: 56px 16px 14px; color: #fff; background: linear-gradient(to top, rgba(38, 42, 50, .94) 0%, rgba(38, 42, 50, .88) 64%, rgba(38, 42, 50, 0) 100%); }
.tp-card__top, .tp-d__top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tp-num { font-size: 12px; font-weight: 800; letter-spacing: .04em; color: #fff; background: var(--tp-area, var(--tp-ink)); border-radius: 2px; padding: 2px 7px; font-variant-numeric: tabular-nums; }
.tp-card__cat { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; opacity: .75; }
.tp-card__pdf { font-size: 10px; font-weight: 700; border: 1px solid rgba(255, 255, 255, .5); border-radius: 2px; padding: 0 5px; }
.tp-tag { font-size: 12px; font-weight: 600; color: var(--tp-muted); background: var(--tp-bg); border-radius: 2px; padding: 3px 8px; }
.tp-card__title { margin: 0; padding: 0; font-size: 15px; line-height: 1.3; font-weight: 700; color: inherit; }
.tp-card__link { all: unset; cursor: pointer; color: inherit; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tp-card__link:focus-visible { text-decoration: underline; }
.tp-card__authors { margin: 0; padding: 0; font-size: 12.5px; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-card__centre { margin: -3px 0 0; padding: 0; font-size: 11.5px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-card__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; padding-top: 9px; border-top: 1px solid rgba(255, 255, 255, .16); font-size: 11.5px; }
.tp-area { flex: 1 1 100%; display: flex; align-items: center; gap: 7px; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-area::before { content: ""; width: 8px; height: 8px; border-radius: 1px; background: var(--tp-area); flex: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, .35); }
.tp-meta { display: inline-flex; align-items: center; gap: 5px; opacity: .7; }
.tp-meta--room { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Vista lista: filas editoriales con la miniatura reducida */
.tp-grid--list { grid-template-columns: 1fr; gap: 0; border-top: 2px solid #c9ccd2; }
.tp-grid--list .tp-card { aspect-ratio: auto; display: grid; grid-template-columns: 78px 1fr; gap: 20px; padding: 16px 6px; border: 0; border-bottom: 1px solid var(--tp-line); border-radius: 0; background: transparent; overflow: visible; outline: 0; }
.tp-grid--list .tp-card:hover { transform: none; background: #f7f7f5; }
.tp-grid--list .tp-card__cover { position: relative; inset: auto; aspect-ratio: 5 / 7; border: 1px solid #d6d9df; overflow: hidden; align-self: start; transform: none !important; }
.tp-grid--list .tp-mini { width: 333.333%; height: 333.333%; transform: scale(.3); transform-origin: 0 0; }
.tp-grid--list .tp-card__ov { position: static; padding: 0; background: none; color: var(--tp-ink); align-content: center; }
.tp-grid--list .tp-card__cat { color: var(--tp-muted); opacity: 1; }
.tp-grid--list .tp-card__pdf { border-color: var(--tp-primary); color: var(--tp-primary); }
.tp-grid--list .tp-card__title { font-size: 16px; }
.tp-grid--list .tp-card__link { -webkit-line-clamp: 2; }
.tp-grid--list .tp-card__foot { border-top: 0; padding-top: 2px; color: var(--tp-muted); }
.tp-grid--list .tp-area { flex: 0 1 auto; color: var(--tp-area); }
.tp-grid--list .tp-area::before { box-shadow: none; }
.tp-grid--list .tp-meta { opacity: 1; }

/* Botones */
.tp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--tp-line); background: #fff; color: var(--tp-ink); border-radius: 4px; padding: 11px 20px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none !important; transition: background .15s, border-color .15s; }
.tp-btn:hover { border-color: var(--tp-ink); }
.tp-btn--primary { background: var(--tp-primary); border-color: var(--tp-primary); color: #fff !important; }
.tp-btn--primary:hover { background: var(--tp-primary-dark); border-color: var(--tp-primary-dark); }
.tp-more { display: flex; margin: 28px auto 0; min-width: 260px; }
.tp-more[hidden], .tp-reset[hidden] { display: none; }
.tp-updated { text-align: center; font-size: 12.5px; color: var(--tp-muted); margin: 24px 0 0; padding: 0; }

/* Modal */
.tp-noscroll { overflow: hidden; }
.tp-modal { --tp-area: #5b6270; width: min(880px, calc(100vw - 24px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 6px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); background: #fff; overflow: hidden; flex-direction: column; }
.tp-modal[open] { display: flex; }
.tp-modal::backdrop { background: rgba(17, 20, 26, .62); backdrop-filter: blur(3px); }
.tp-modal__bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--tp-line); border-top: 5px solid var(--tp-area); background: #fff; flex: none; }
.tp-modal__nav, .tp-modal__actions { display: flex; align-items: center; gap: 6px; }
.tp-modal__pos { font-size: 13px; color: var(--tp-muted); font-variant-numeric: tabular-nums; min-width: 64px; text-align: center; }
.tp-icon-btn { width: 40px; height: 40px; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--tp-ink); display: grid; place-items: center; cursor: pointer; font-size: 20px; padding: 0; }
.tp-icon-btn:hover:not(:disabled) { background: var(--tp-bg); border-color: var(--tp-line); }
.tp-icon-btn:disabled { opacity: .3; cursor: default; }
.tp-icon-btn.is-done { color: #0e7c66; background: #e7f6f1; }
.tp-modal__body { overflow-y: auto; padding: 26px 32px 32px; overscroll-behavior: contain; }
.tp-d__title { font-size: 24px; line-height: 1.25; margin: 12px 0 12px; padding: 0; color: var(--tp-ink); font-weight: 800; }
.tp-d__authors { margin: 0 0 6px; padding: 0; font-size: 15.5px; font-weight: 600; }
.tp-d__authors sup { font-size: 11px; color: var(--tp-muted); margin-left: 1px; }
.tp-d__presenter { text-decoration: underline; text-decoration-color: var(--tp-area); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.tp-d__centres { margin: 0 0 18px; padding: 0 0 0 18px; font-size: 13.5px; color: var(--tp-muted); }
.tp-d__centres--plain { list-style: none; padding-left: 0; }
.tp-d__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--tp-line); border: 1px solid var(--tp-line); border-radius: 12px; overflow: hidden; margin: 0 0 22px; }
.tp-d__fact { background: var(--tp-bg); padding: 10px 14px; }
.tp-d__fact dt { margin: 0; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--tp-muted); }
.tp-d__fact dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; }
.tp-d__poster { display: block; margin: 0 0 22px; border: 1px solid var(--tp-line); border-radius: 12px; overflow: hidden; }
.tp-d__poster img { display: block; width: 100%; height: auto; }
.tp-d__files { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 22px; }
.tp-d__section { margin: 0 0 20px; }
.tp-d__section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--tp-area); margin: 0 0 8px; padding: 0; font-weight: 800; }
.tp-d__text { font-size: 15.5px; line-height: 1.65; color: #2b3038; }
.tp-d__text p { margin: 0 0 .8em; padding: 0; }
.tp-d__keywords { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

@media (max-width: 900px) {
  .tp-grid--list .tp-card__body { grid-template-columns: 1fr; grid-template-areas: "top" "title" "authors" "centre" "foot"; }
  .tp-grid--list .tp-card__foot { border-left: 0; padding: 10px 0 0; border-top: 1px dashed var(--tp-line); }
}
@media (max-width: 600px) {
  .tp-toolbar { padding: 12px; }
  .tp-field--sort { flex: 1 1 auto; }
  .tp-filters { grid-template-columns: 1fr; }
  .tp-grid { grid-template-columns: 1fr; }
  .tp-grid:not(.tp-grid--list) .tp-card { aspect-ratio: 4 / 5; }
  .tp-grid--list .tp-card { grid-template-columns: 64px 1fr; gap: 14px; }
  .tp-modal { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .tp-modal__body { padding: 20px 18px 28px; }
  .tp-d__title { font-size: 20px; }
  .tp-pills { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px; padding: 0 12px 4px; scrollbar-width: none; }
  .tp-pill { flex: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tp-card, .tp-spinner { transition: none; animation: none; }
}
.tp-grid:not(.tp-grid--list) .tp-card__centre { display: none; }
