.profile .cert-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  margin: 0 0 24px;
}
.cert-grid tbody, .cert-grid tr { display: contents; }
.profile .cert-grid td {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 18px 12px;
  border: 1px solid #44435a;
  border-radius: 12px;
  background: linear-gradient(155deg, #24263b, #181c2a 64%);
}
.cert-grid td > br { display: none; }
.cert-grid td > a:first-child {
  display: grid;
  place-items: center;
  margin: 0 -18px 12px;
  border-radius: 11px 11px 0 0;
  background:
    radial-gradient(ellipse at 40% 80%, #5b527e55, transparent 62%),
    repeating-linear-gradient(125deg, transparent 0 24px, #bdb0f007 25px, transparent 26px),
    linear-gradient(125deg, #27273d, #171b2d);
  border-bottom: 1px solid #66607966;
}
.cert-grid td > a:first-child img {
  display: block;
  width: min(100%, 310px);
  aspect-ratio: 680 / 515;
  object-fit: contain;
}
.cert-grid td > strong { font-size: 1.08rem; line-height: 1.3; color: #f1edfc; }
.cert-grid td > em { margin: 5px 0 8px; color: #c7c4d5; font: inherit; font-size: .9rem; }
.cert-grid td > span { margin-top: auto; color: #847d99; }
.cert-grid td > span a { display: inline-block; padding: 6px 2px; font-size: .91rem; font-weight: 600; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .cert-grid td > a:first-child img { transition: transform .25s ease-out; }
  .cert-grid td > a:first-child:is(:hover,:focus-visible) img {
    transform: perspective(700px) rotateY(-5deg) rotateX(3deg) translateY(-3px);
  }
}
@media (max-width: 580px) {
  .profile .cert-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}

.cert-viewer {
  width: min(1020px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 1px solid #66617b;
  border-radius: 15px;
  color: #f1eefb;
  background: #181b29;
  box-shadow: 0 18px 100px #000b;
}
.cert-viewer[open] { display: flex; flex-direction: column; }
.cert-viewer::backdrop { background: #080b16d9; }
html:has(.cert-viewer[open]) { overflow: hidden; }
.cert-viewer header, .cert-viewer footer { display: flex; gap: 8px 14px; padding: 12px 16px; align-items: center; }
.cert-viewer header { justify-content: space-between; }
.cert-viewer h2 { margin: 0; font-size: clamp(1rem, 3vw, 1.35rem); line-height: 1.3; }
.cert-viewer footer { flex-wrap: wrap; border-top: 1px solid #47445b; }
.cert-viewer button, .cert-viewer footer a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 6px 12px; border: 1px solid #6f6983; border-radius: 8px;
  background: #2c2d43; color: #f1edff; font: inherit; font-size: .92rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.cert-viewer :is(button, footer a):hover { background: #403c55; }
.cert-viewer button[aria-pressed="true"] { background: #49435e; }
.cert-viewer .cert-sheet {
  overflow: auto; overscroll-behavior: contain; background: #10131e; min-height: 0; border-top: 1px solid #47445b;
}
.cert-sheet img {
  display: block; width: 100%; height: min(65dvh, 720px); object-fit: contain;
}
.cert-sheet[data-zoom] img { width: max(100%, 1600px); height: auto; max-width: none; }
@media (max-width: 580px) {
  .cert-viewer header, .cert-viewer footer { padding: 10px; gap: 8px; }
  .cert-viewer footer > * { flex: auto; }
  .cert-sheet img { height: auto; max-height: 60dvh; }
}
