.screenshot-link {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  border-radius: 8px;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  cursor: zoom-in;
}

.screenshot-link img { justify-self: center; }

.screenshot-link-label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 10px;
  color: var(--accent-dark, var(--accent));
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.screenshot-link:focus-visible,
.screenshot-dialog :is(a,button,.screenshot-frame):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

html:has(.screenshot-dialog[open]) { overflow: hidden; }

.screenshot-dialog {
  position: fixed;
  inset: 0;
  width: min(980px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  overscroll-behavior: contain;
}

.screenshot-dialog::backdrop { background: rgb(0 0 0 / 72%); }

.screenshot-dialog-content { display: grid; gap: 10px; padding: 12px; }

.screenshot-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.screenshot-toolbar form { margin: 0 0 0 auto; }

.screenshot-toolbar :is(a,button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.screenshot-toolbar :is(a,button):hover,
.screenshot-toolbar button[aria-pressed="true"] { background: var(--accent-soft); }

.screenshot-caption { margin: 0; color: var(--muted); font-size: 13px; }

.screenshot-frame {
  overflow: auto;
  max-height: 64vh;
  max-height: 64dvh;
  border-radius: 8px;
  background: var(--bg);
  overscroll-behavior: contain;
}

.screenshot-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 64vh;
  max-height: 64dvh;
  margin-inline: auto;
}

.screenshot-frame.is-original-size img { max-width: none; max-height: none; margin: 0; }

@media (max-width: 400px) {
  .screenshot-dialog-content { padding: 8px; }
  .screenshot-toolbar :is(a,button) { padding-inline: 6px; }
}

@media print {
  .screenshot-link-label, .screenshot-dialog { display: none !important; }
}
