/* v0.4.5: shared controls and an unobstructed image viewer. */
.image-dialog {
  --viewer-bg: #f9faf6;
  --viewer-stage: #edf0eb;
  --viewer-text: #2d3b35;
  --viewer-muted: #65746b;
  --viewer-line: #dce3d9;
  --viewer-button: #eef3eb;
  --viewer-hover: #e1eadb;
  --viewer-accent: #3d745e;
  width: max-content;
  max-width: 95vw;
  max-height: 94vh;
  max-height: 94dvh;
  padding: 0;
  margin: auto;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--viewer-line);
  border-radius: 16px;
  background: var(--viewer-bg);
  color: var(--viewer-text);
  box-shadow: 0 28px 100px #182c2440;
  scrollbar-width: thin;
}
html[data-theme="dark"] .image-dialog {
  --viewer-bg: #252e39;
  --viewer-stage: #1c232d;
  --viewer-text: #ecf1f5;
  --viewer-muted: #adbac7;
  --viewer-line: #3e4b59;
  --viewer-button: #303d49;
  --viewer-hover: #3b4f59;
  --viewer-accent: #83e0cc;
  background: var(--viewer-bg);
  border-color: var(--viewer-line);
  box-shadow: 0 28px 100px #050d19b3;
}
.image-dialog-toolbar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 64px; padding: 10px 16px 10px 20px; border-bottom: 1px solid var(--viewer-line); background: var(--viewer-bg); }
.image-dialog-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; letter-spacing: .02em; }
.image-close { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none; min-height: 44px; padding: 0 12px; border: 1px solid var(--viewer-line); border-radius: 9px; background: var(--viewer-button); color: var(--viewer-text); font: 12px/1.5 var(--sans); cursor: pointer; transition: background-color .15s, border-color .15s; }
.image-close svg { display: block; width: 18px; height: 18px; }
.image-close kbd { margin-left: 8px; border-left: 1px solid var(--viewer-line); padding-left: 10px; font: 10px/1.5 var(--mono); color: var(--viewer-muted); }
.image-close:hover { background: var(--viewer-hover); border-color: var(--viewer-accent); }
.image-close:focus-visible { outline: 2px solid var(--viewer-accent); outline-offset: 3px; }
.image-dialog-stage { display: flex; align-items: center; justify-content: center; padding: 12px; background: var(--viewer-stage); }
/* Preserve the original image budget; toolbar and caption scroll within the shell. */
.image-dialog .image-dialog-stage img { display: block; width: auto; height: auto; max-width: calc(95vw - 26px); max-height: 80vh; max-height: 80dvh; object-fit: contain; border-radius: 6px; }
.image-dialog .image-caption,
html[data-theme="dark"] .image-dialog .image-caption { max-width: none; margin: 0; padding: 14px 20px 16px; border-top: 1px solid var(--viewer-line); color: var(--viewer-muted); font-size: 12px; line-height: 1.8; }

/* Consistent line icons and quieter gallery controls. */
.search-control .search-icon { display: grid; place-items: center; flex: 0 0 20px; width: 20px; height: 20px; }
.search-icon svg { width: 18px; height: 18px; }
.library-empty .empty-search-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; }
.empty-search-icon svg { width: 36px; height: 36px; }
.case-gallery-controls { gap: 10px; }
.case-gallery-controls button { border-radius: 10px; background: #f0f4ec; border-color: #dce4d5; transition: background-color .15s, border-color .15s; }
.case-gallery-controls button svg { display: block; width: 20px; height: 20px; }
html[data-theme="dark"] .case-gallery-controls button { background: #2e3946; border-color: #4b5b6a; }
.case-gallery-count { font-variant-numeric: tabular-nums; }

/* Tablet cards keep screenshots and summaries large enough to read. */
@media (min-width: 641px) and (max-width: 1000px) {
  .home-cases { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px; }
  .home-cases .index-card-copy { padding: 20px; }
  .home-cases .index-card h3 { font-size: 19px; }
  .home-cases .index-card-copy > p { font-size: 14px; }
}
@media (max-width: 640px) {
  .image-dialog { border-radius: 12px; }
  .image-dialog-toolbar { min-height: 60px; gap: 12px; padding: 8px 10px 8px 14px; }
  .image-dialog-title { font-size: 12px; }
  .image-close { padding: 0 10px; gap: 6px; }
  .image-close kbd { display: none; }
  .image-dialog .image-dialog-stage img { border-radius: 4px; }
  .image-dialog .image-caption { padding: 12px 14px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .image-close, .case-gallery-controls button { transition: none; }
}
