@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=DM+Sans:wght@400;500;600&display=swap');

* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
}

:root {
  --bg-page: #f5f3ee;
  --bg-surface: #f0eee8;
  --bg-card: #fff;
  --text-primary: #1a1a24;
  --text-muted: #8a8a9a;
  --border-subtle: rgba(0,0,0,0.07);
  --green: #2eb87e;
  --green-soft: rgba(46,184,126,0.15);
  --green-border: rgba(46,184,126,0.3);
  --green-text: #1e8a5e;
  --red: #dc5050;
  --red-soft: rgba(220,80,80,0.15);
  --red-border: rgba(220,80,80,0.3);
  --red-text: #b83a3a;
  --font-heading: 'Playfair Display', serif;
  --font-body: 'DM Sans', sans-serif;
}

body {
  margin: 0;
  background: var(--bg-page);
}

.med-split {
  display: flex;
  flex-direction: row;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text-primary);
}

/* ---------- LEFT PANEL — no scroll, flex fill ---------- */
.med-left {
  width: 55%;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  background-image: url('../images/mediatique/film strips.png');
  background-size: cover;
  background-position: center;
}

.med-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.88);
  pointer-events: none;
  z-index: 0;
}

.med-left-inner {
  width: 100%;
  padding: 24px 24px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.med-brand,
.med-tabs,
.med-filters,
.med-count,
.med-recent-label {
  width: 100%;
}

/* ---------- RIGHT PANEL — layered architecture ---------- */
.med-right {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-surface);
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Decorative background — ALWAYS rendered, no interaction */
.med-right-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url('../images/mediatique/cam.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.1;
}

/* Scroll content wrapper — sits above bg */
.med-right-scroll {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

#scrollTrack {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 0 12px;
  width: max-content;
  position: relative;
  will-change: transform;
}

.media-card-template {
  display: none;
}

/* ---------- Brand ---------- */
.med-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.med-title {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  font-weight: 900;
  margin: 0;
  line-height: 1.15;
  background: linear-gradient(135deg, #3a9b6a, #2eb87e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.med-stripe {
  height: 4px;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #3a9b6a, #2eb87e);
}

/* ---------- Tabs ---------- */
.med-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.med-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 18px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-bright);
  background: transparent;
  border: 1.5px solid var(--border-subtle);
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.med-tab:hover {
  border-color: var(--green);
  color: var(--text-primary);
}

.med-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #3a9b6a, #2eb87e);
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(46,184,126,0.3);
}

/* ---------- Filters ---------- */
.med-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.med-search-wrap {
  position: relative;
}

.med-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.med-search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1.5px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  box-sizing: border-box;
}

.med-search-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,184,126,0.15);
}

.med-search-input::placeholder {
  color: var(--text-muted);
}

.med-filter-row {
  display: flex;
  gap: 10px;
}

.med-filter-col {
  flex: 1;
}

.med-filter-col label {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.med-select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-body);
  border: 1.5px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238a8a9a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text-primary);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.25s ease;
  box-sizing: border-box;
}

.med-select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,184,126,0.15);
}

.med-count {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------- Dernier consulté — flex-grow fill ---------- */
.med-recent-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.med-recent-card {
  position: relative;
  width: 100%;
  max-width: 920px;
  align-self: center;
  flex: 1;
  min-height: 0;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.med-recent-card:hover {
  transform: translateY(-2px);
}

.med-recent-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.med-recent-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mask-image: linear-gradient(to bottom, black 0%, black 40%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 40%, transparent 100%);
}

.med-recent-fallback-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  opacity: 0.25;
}

.med-recent-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 12px 14px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 35%,
    rgba(255,255,255,0.75) 60%,
    rgba(255,255,255,0.97) 100%
  );
}

.med-recent-top {
  display: flex;
  align-items: flex-start;
}

.med-recent-bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.med-recent-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.med-recent-info-tags {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.med-recent-info-tag {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(0,0,0,0.06);
  padding: 1px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.med-recent-info-desc {
  font-family: var(--font-body);
  font-size: 11px;
  color: rgba(26,26,36,0.6);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.med-recent-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.med-recent-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.med-recent-badge {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 8px;
  line-height: 1.5;
  border: 1px solid;
}

.med-recent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 14px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  border: none;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
  line-height: 1.4;
}

.med-recent-btn:hover {
  opacity: 0.85;
  color: #fff;
}

.med-recent-count {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ---------- Empty state on LEFT panel ---------- */
.med-recent-empty {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
  min-height: 160px;
  border: 1.5px dashed var(--border-subtle);
  border-radius: 12px;
  color: var(--text-muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  cursor: default;
}

.med-recent-empty svg {
  width: 32px;
  height: 32px;
  opacity: 0.35;
  position: relative;
  z-index: 1;
}

.med-recent-empty span {
  position: relative;
  z-index: 1;
}

/* ---------- Empty state on RIGHT panel ---------- */
.med-right-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

/* ---------- DL button ---------- */
.med-dl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3a9b6a, #2eb87e);
  border: none;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.med-dl-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  color: #fff;
}

.med-dl-count {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Cards ---------- */
.med-card {
  display: flex;
  flex: 0 0 320px;
  height: 173px;
  background: var(--bg-card);
  border-radius: 6px 0 0 6px;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: visible;
  flex-shrink: 0;
  position: relative;
  box-shadow: 6px 0 28px var(--card-glow, rgba(0,0,0,0.06)), -6px 0 28px var(--card-low-glow, rgba(0,0,0,0.03));
}

.med-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--card-accent, #ccc);
  z-index: 3;
  border-radius: 4px 0 0 4px;
  pointer-events: none;
}

.med-card::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--bg-surface);
  border-radius: 50%;
  transform: translateY(-50%);
  z-index: 3;
  pointer-events: none;
}

.med-card:hover {
  transform: translateX(-3px) scale(1.02);
  box-shadow: 6px 0 35px var(--card-glow, rgba(0,0,0,0.06)), -6px 0 35px var(--card-low-glow, rgba(0,0,0,0.03));
  z-index: 3;
}

/* Type-based accent — green/red */
.med-card[data-type="ressource-pedagogique"],
.med-card[data-type="photo"],
.med-card[data-type="video"] {
  --card-accent: var(--green);
  --card-glow: rgba(46,184,126,0.18);
  --card-low-glow: rgba(46,184,126,0.08);
}

.med-card[data-type="evenement"],
.med-card[data-type="social"] {
  --card-accent: var(--red);
  --card-glow: rgba(220,80,80,0.18);
  --card-low-glow: rgba(220,80,80,0.08);
}

/* Full-bleed thumbnail */
.med-card-thumb-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.med-card-thumb-wrap::after {
  content: '';
  position: absolute;
  left: -7px;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--bg-surface);
  border-radius: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
}

.med-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  mask-image: linear-gradient(to right, black 0%, rgba(0,0,0,0.7) 40%, transparent 75%);
  -webkit-mask-image: linear-gradient(to right, black 0%, rgba(0,0,0,0.7) 40%, transparent 75%);
}

.med-card-fallback {
  width: 50%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: 0.2;
}

.med-card[data-type="ressource-pedagogique"] .med-card-fallback,
.med-card[data-type="photo"] .med-card-fallback,
.med-card[data-type="video"] .med-card-fallback {
  color: var(--green);
}

.med-card[data-type="evenement"] .med-card-fallback,
.med-card[data-type="social"] .med-card-fallback {
  color: var(--red);
}

.med-card-body {
  position: relative;
  z-index: 1;
  margin-left: auto;
  width: 55%;
  padding: 16px 14px 16px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-width: 0;
}

.med-card-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.med-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.med-card-badge {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 10px;
  line-height: 1.5;
  display: inline-block;
  flex-shrink: 0;
  border: 1px solid;
}

.med-card-badge-ressource-pedagogique,
.med-card-badge-photo,
.med-card-badge-video {
  background: var(--green-soft);
  border-color: var(--green-border);
  color: var(--green-text);
}

.med-card-badge-evenement,
.med-card-badge-social {
  background: var(--red-soft);
  border-color: var(--red-border);
  color: var(--red-text);
}

.med-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.med-card-tag {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.med-card-featured {
  display: none;
}

/* ---------- Modal ---------- */
.med-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.med-modal.open {
  display: flex;
}

.med-modal.closing {
  display: flex;
}

.med-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  animation: med-fade-in 0.2s ease;
}

.med-modal.closing .med-modal-overlay {
  animation: med-fade-out 0.15s ease forwards;
}

@keyframes med-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes med-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.med-modal-positioner {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 90vw;
  max-width: 1100px;
  max-height: 90vh;
  animation: med-scale-in 0.25s ease-out;
}

.med-modal.closing .med-modal-positioner {
  animation: med-scale-out 0.15s ease forwards;
}

@keyframes med-scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes med-scale-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.95); }
}

.med-modal-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.12), 0 0 40px rgba(46,184,126,0.13);
  overflow: hidden;
}

.med-modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 20;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border-subtle);
  font-size: 1.3rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.med-modal-close:hover {
  background: rgba(0,0,0,0.08);
  color: var(--text-primary);
}

.med-modal-arrow {
  position: absolute;
  top: 50%;
  z-index: 20;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: rgba(255,255,255,0.85);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.med-modal-arrow:hover {
  background: #fff;
  color: var(--text-primary);
}

.med-modal-prev {
  left: -18px;
}

.med-modal-next {
  right: -18px;
}

.med-modal-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.med-modal-image {
  position: relative;
  width: 100%;
  height: auto;
  max-height: 70vh;
  background: #1a1a24;
  display: block;
  overflow: hidden;
  flex-shrink: 0;
}

.med-modal-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

.med-modal-image .med-thumb-fallback {
  width: 64px;
  height: 64px;
  opacity: 0.25;
  color: var(--text-muted);
}

.med-modal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  min-height: 0;
  overflow-y: auto;
}

.med-modal-badge {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
  flex-shrink: 0;
  border: 1px solid;
}

.med-modal-info h2 {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  margin: 0 0 4px;
  flex-shrink: 0;
}

.med-modal-date {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-body);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.med-modal-tags-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  margin-bottom: 10px;
}

.med-modal-tags-wrap::-webkit-scrollbar {
  display: none;
}

.med-modal-tags {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
  padding-bottom: 2px;
}

.med-modal-tags .med-tag {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  pointer-events: none;
  background: rgba(0,0,0,0.04);
  color: var(--text-muted);
}

.med-modal-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  color: rgba(26,26,36,0.65);
  margin-bottom: 12px;
}

.med-modal-desc p {
  margin-bottom: 10px;
}

.med-modal-desc p:last-child {
  margin-bottom: 0;
}

.med-modal-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.med-modal-bottom .med-dl-btn {
  width: auto;
  padding: 12px 28px;
  flex: 1;
  max-width: 320px;
}

/* ── Mode A — overlay (no description / short description) ── */
.med-modal--overlay .med-modal-image {
  flex: 1;
  min-height: 0;
  max-height: 70vh;
}

.med-modal--overlay .med-modal-image img {
  max-height: 70vh;
  object-fit: contain;
  width: 100%;
}

.med-modal--overlay .med-modal-info {
  display: none;
}

.med-modal-overlay-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 24px 24px;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}

.med-modal-overlay-content > * {
  pointer-events: auto;
}

.med-modal-overlay-badge {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 20px;
  flex-shrink: 0;
  border: 1px solid;
}

.med-modal-overlay-title {
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
}

.med-modal-overlay-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.med-modal-overlay-tag {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.med-modal-overlay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 4px;
}

.med-modal-overlay-btn:hover {
  opacity: 0.9;
  color: #fff;
}

/* ── Mode B — stacked (long description) ── */
.med-modal--split .med-modal-image {
  width: 100%;
}

.med-modal--split .med-modal-info {
  max-height: 35vh;
  overflow-y: auto;
}

/* ── Placeholder fallback in image area (no thumbnail) ── */
.med-modal-image-placeholder {
  width: 100%;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
  background: #1a1a24;
}

.med-modal-fallback-icon {
  width: 64px;
  height: 64px;
  opacity: 0.35;
  color: #fff;
}

.med-modal-fallback-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.25;
}

/* ── Minimal mode (no image, no description) ── */
.med-modal--minimal .med-modal-image,
.med-modal--minimal .med-modal-info {
  display: none;
}

.med-modal--minimal .med-modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 40px 32px;
  background: #1a1a24;
  gap: 16px;
  text-align: center;
}

.med-modal--minimal .med-modal-fallback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 28px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3a9b6a, #2eb87e);
  border: none;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
  transition: opacity 0.25s ease;
}

.med-modal--minimal .med-modal-fallback-btn:hover {
  opacity: 0.9;
  color: #fff;
}

@media (max-width: 768px) {
  .med-split {
    flex-direction: column;
    height: auto;
    max-height: none;
  }

  .med-left {
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .med-left-inner {
    padding: 20px 16px;
    gap: 14px;
  }

  .med-right {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
  }

  .med-recent-card {
    height: 220px;
    flex: none;
    display: block;
  }

  .med-recent-empty {
    min-height: 120px;
    flex: none;
  }

  .med-right-scroll {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  .med-card {
    flex: 0 0 240px;
    border-radius: 8px;
  }

  .med-right-bg {
    display: none;
  }

  /* modal overrides */
  .med-modal-positioner {
    width: 95vw;
    max-height: 92vh;
  }

  .med-modal-image {
    max-height: 45vh;
  }

  .med-modal--overlay .med-modal-image {
    max-height: 45vh;
  }

  .med-modal-image img {
    max-height: 45vh;
  }

  .med-modal-info {
    max-height: 40vh;
    padding: 18px;
  }

  .med-modal--split .med-modal-info {
    max-height: 40vh;
  }

  .med-modal--minimal .med-modal-content {
    min-height: 260px;
    padding: 28px 20px;
  }

  .med-modal-prev {
    left: 8px;
  }

  .med-modal-next {
    right: 8px;
  }
}

@media (max-width: 600px) {
  .med-left-inner {
    padding: 18px 16px;
  }

  .med-recent-card {
    height: 260px;
    flex: none;
  }

  .med-tabs {
    gap: 8px;
  }

  .med-tab {
    font-size: 12px;
    padding: 6px 14px;
  }

  .med-filter-row {
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 768px) {
  .med-left {
    width: 100%;
  }

  .med-card {
    flex: 0 0 280px;
  }

  .med-right-vscroll {
    height: auto;
    overflow: visible;
    display: none !important;
  }

  #med-right-scroll {
    display: block !important;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: contain;
  }

  .med-right-scroll {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

/* ===== DESKTOP (≥769px) — vertical infinite scroll ===== */
@media (min-width: 769px) {
  #med-right-scroll {
    display: none;
  }

  .med-right-vscroll {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    position: relative;
    flex: 1;
    height: 95%;
    min-height: 0;
    z-index: 1;
  }

  #verticalTrack {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .med-vcard {
    flex: none;
    width: 100%;
    height: 180px;
    margin-bottom: 8px;
    border-radius: 0;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: none;
    cursor: pointer;
    position: relative;
    transition: box-shadow 0.25s ease;
  }

  .med-vcard::after { display: none; }
  .med-vcard::before { border-radius: 0; }

  .med-vcard:hover {
    transform: none;
    background: rgba(46,184,126,0.04);
    box-shadow: inset 4px 0 0 var(--green), 0 0 20px rgba(46,184,126,0.12);
  }

  .med-vcard .med-card-thumb-wrap {
    width: 40% !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    right: auto !important;
    overflow: hidden !important;
  }

  .med-vcard .med-card-thumb {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    mask-image: linear-gradient(to right, black 0%, black 70%, transparent 100%) !important;
    -webkit-mask-image: linear-gradient(to right, black 0%, black 70%, transparent 100%) !important;
  }

  .med-vcard .med-card-fallback {
    width: 100% !important;
    height: 100% !important;
    font-size: 2.5rem !important;
  }

  .med-vcard .med-card-body {
    margin-left: 40%;
    width: 60%;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    height: 100%;
    box-sizing: border-box;
  }

  .med-vcard .med-card-title {
    font-size: 21px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .med-vcard .med-card-excerpt {
    font-size: 13px;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
  }

  .med-recent-card {
    flex: 1;
    min-height: 0;
  }

  .med-vlist-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--font-body);
  }
}

/* ===== TABLET (769–899px) — fixed-height panels, footer scrolls below ===== */
@media (min-width: 769px) and (max-width: 899px) {
  .med-split {
    height: calc(100vh - 80px);
    max-height: calc(100vh - 80px);
    overflow: hidden;
  }

  .med-left {
    height: calc(100vh - 80px);
    overflow-y: auto;
    width: calc(55% + 5px);
  }

  .med-right {
    height: 100%;
    overflow: hidden;
  }

  #med-right-scroll {
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    flex: 1;
    height: 100%;
    min-height: 0;
  }

  #scrollTrack,
  .med-scroll-track {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    align-items: stretch;
    height: auto !important;
  }

  #med-right-scroll .med-card {
    width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 210px !important;
    height: 210px !important;
    align-self: auto;
  }

  .med-right-vscroll {
    display: none !important;
  }
}

/* ===== DESKTOP (≥900px) — left panel constrained, background fills ===== */
@media (min-width: 900px) {
  .med-left {
    max-height: 90vh;
    min-height: 100%;
    width: calc(55% + 5px);
  }

  .med-recent-card {
    margin: 0 10px;
    box-sizing: border-box;
  }

  #med-right-scroll {
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    flex: 1;
    height: 100%;
    min-height: 0;
  }

  #med-right-scroll .med-card,
  #med-right-scroll .med-hcard,
  #med-right-scroll > * {
    width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 210px !important;
    height: 210px !important;
    align-self: auto;
  }

  #scrollTrack,
  .med-scroll-track {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    align-items: stretch;
    height: auto !important;
  }

  .med-right-vscroll {
    display: none !important;
  }
}

