.mg-focus {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}
.mg-focus[hidden] { display: none; }

.mg-focus-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 62% 80% at 50% 50%, rgba(3,6,20,.88) 0%, rgba(3,6,20,.75) 48%, rgba(3,6,20,.2) 80%, rgba(3,6,20,0) 100%);
  animation: mg-fade-in 900ms var(--ease-standard) both;
}

.mg-focus-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1120px, calc(92 * var(--vw, 1vw)));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: min(22px, calc(2.6 * var(--vh, 1vh)));
  animation: mg-panel-rise 820ms var(--mg-ease-rise) 340ms both;
}
@keyframes mg-panel-rise {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.mg-focus-panel > * {
  animation: mg-rise-soft 820ms var(--mg-ease-rise) 340ms both;
}

.mg-frame {
  position: relative;
  width: min(380px, calc(44 * var(--vw, 1vw)), calc(42 * var(--vh, 1vh)));
  aspect-ratio: 4/3;
  pointer-events: auto;
  border-radius: 14px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  color: inherit;
  font: inherit;
  transition: transform 260ms var(--ease-standard);
}
.mg-frame:hover { transform: translateY(-2px); }
.mg-frame:focus-visible {
  outline: 2px solid rgba(246,232,190,.9);
  outline-offset: 6px;
}

.mg-frame > * { pointer-events: none; }

.mg-frame-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(8,14,32,.55);
  color: rgba(240,232,208,.9);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-standard);
}
.mg-frame:hover .mg-frame-expand,
.mg-frame:focus-visible .mg-frame-expand { opacity: 1; }
.mg-frame-fill {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(30,52,102,.6), rgba(6,10,26,.92));
  border: 1px solid rgba(214,232,255,.2);
  border-radius: 14px;
}
.mg-frame-photo { border-radius: 14px; }
.mg-frame-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 400ms var(--ease-standard);
}
.mg-frame-photo[src]:not([src=""]) { opacity: 1; }
.mg-frame-border {
  position: absolute;
  inset: -20px;
  z-index: 4;
  border: 32px solid transparent;
  border-image: url('../assets/images/panel.png') 46 / 32px stretch;
  filter: sepia(.4) saturate(2) brightness(1.75) drop-shadow(0 0 7px rgba(238,214,158,.55));
  pointer-events: none;
}
.mg-frame-badge {
  position: absolute;
  left: 50%; top: -46px;
  width: 66px;
  transform: translateX(-50%);
  opacity: .85;
  pointer-events: none;
}
.mg-frame-icon {
  position: absolute;
  left: 50%; top: -30px;
  width: 32px;
  transform: translateX(-50%);
  opacity: .95;
  pointer-events: none;
}

.mg-core-label {
  font-family: 'Cinzel', serif;
  font-size: 10.5px;
  letter-spacing: .38em;
  color: rgba(246,232,190,.75);
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(246,232,190,.25);
  margin-bottom: -6px;
}

.mg-title-row { display: flex; align-items: center; gap: 22px; }
.mg-title-row .mg-rule-line { width: clamp(60px, calc(13 * var(--vw, 1vw)), 190px); }
.mg-rule-line-l { background: linear-gradient(90deg, rgba(226,236,255,0), rgba(226,236,255,.6)); }
.mg-rule-line-r { background: linear-gradient(90deg, rgba(226,236,255,.6), rgba(226,236,255,0)); }
.mg-memory-title {
  margin: 0;
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: clamp(21px, calc(2.6 * var(--vw, 1vw)), 36px);
  letter-spacing: .06em;
  color: var(--mg-ivory);
  white-space: nowrap;
  text-shadow: 0 0 30px rgba(150,190,255,.35);
}

.mg-meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 10px;
  letter-spacing: .28em;
  color: rgba(226,214,180,.8);
}
.mg-meta-sep { opacity: .45; }

.mg-memory-note {
  margin: 0;
  max-width: min(880px, calc(74 * var(--vw, 1vw)));
  text-align: center;
  font-size: 13.5px;
  line-height: 1.9;
  letter-spacing: .02em;
  color: var(--mg-body);
  text-wrap: pretty;
}

.mg-index {
  position: absolute;
  right: 36px;
  top: 136px;
  bottom: 104px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: auto;
  animation: mg-fade-in 700ms var(--ease-standard) 520ms both;
}
.mg-index-arrow {
  width: 54px;
  cursor: pointer;
  opacity: .55;
  transition: opacity 200ms var(--ease-standard);
}
.mg-index-arrow-up   { transform: rotate(-90deg); margin-bottom: 8px; }
.mg-index-arrow-down { transform: rotate(90deg);  margin-top: 8px; }
.mg-index-arrow:hover { opacity: 1; }

.mg-index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.mg-index-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  height: 34px;
  padding: 0 14px 0 22px;
  cursor: pointer;
  background: transparent;
  border-radius: 8px 0 0 8px;
  transition: background 220ms var(--ease-standard),
              transform 220ms var(--ease-decel);
}
.mg-index-row:hover {
  transform: translateX(-4px);
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(232,240,255,.08));
}
.mg-index-row:hover .mg-index-name { color: #eaf3ff; }
.mg-index-row.is-active {
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(232,240,255,.14));
}
.mg-index-name {
  font-family: 'Cinzel', serif;
  font-size: 11.5px;
  letter-spacing: .12em;
  white-space: nowrap;
  color: rgba(212,228,255,.55);
  transition: color 220ms var(--ease-standard);
}
.mg-index-row.is-active .mg-index-name { color: #f8f3e6; }
.mg-index-dot {
  width: 7px; height: 7px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(214,232,255,.55);
  background: rgba(10,18,40,.6);
  box-shadow: none;
  transition: all 220ms var(--ease-standard);
}
.mg-index-row.is-active .mg-index-dot {
  background: var(--mg-gold);
  box-shadow: 0 0 12px var(--mg-gold-glow);
}
.mg-index-line {
  position: absolute;
  right: 18px;
  top: 60px;
  bottom: 60px;
  width: 1px;
  background: linear-gradient(180deg, rgba(206,226,255,0), rgba(206,226,255,.35), rgba(206,226,255,0));
  pointer-events: none;
}

.mg-sigil-rail {
  position: absolute;
  left: 0; right: 0;
  bottom: 34px;
  display: flex;
  justify-content: center;
  gap: 18px;
  pointer-events: auto;
  animation: mg-fade-in 700ms var(--ease-standard) 640ms both;
}
.mg-sigil-rail img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  cursor: pointer;
  opacity: .42;
  transform-origin: center bottom;
  transition: opacity 260ms var(--ease-decel),
              transform 260ms var(--ease-decel),
              filter 260ms var(--ease-decel);
}
.mg-sigil-rail img.is-active {
  opacity: 1;
  filter: drop-shadow(0 0 10px rgba(246,232,190,.85))
          drop-shadow(0 0 22px rgba(246,232,190,.4));
}
.mg-sigil-rail img:hover {
  opacity: 1;
  transform: translateY(-4px) scale(1.08);
  filter: drop-shadow(0 0 8px rgba(190,220,255,.85));
}
.mg-sigil-rail img:active { transform: translateY(-1px) scale(.98); }

.mg-back {
  position: absolute;
  left: 30px;
  bottom: 34px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  pointer-events: auto;
  background: var(--mg-glass);
  border: 1px solid var(--mg-glass-brd);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 220ms var(--ease-standard),
              transform 220ms var(--ease-standard);
  animation: mg-fade-in 600ms var(--ease-standard) 700ms both;
}
.mg-back:hover {
  border-color: rgba(240,225,190,.7);
  transform: translateY(-2px);
}
.mg-back img { width: 48px; opacity: .7; }
.mg-back span {
  font-family: 'Cinzel', serif;
  font-size: 10.5px;
  letter-spacing: .24em;
  color: #eaf3ff;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .mg-index { top: 90px; bottom: 90px; right: 18px; }
  .mg-memory-title { font-size: clamp(18px, calc(4 * var(--vw, 1vw)), 26px); }
  .mg-title-row .mg-rule-line { display: none; }
}
