/* Image presentation stays separate from the chat and its split preview. */
html body.memory-workspace .miv-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 320px));
  gap: 16px;
  margin: 12px 0;
  max-width: 100%;
}
html body.memory-workspace .miv-card {
  position: relative;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--workspace-side, var(--card-bg));
}
html body.memory-workspace button.miv-card-image,
html body.memory-workspace button.miv-inline {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: zoom-in;
  overflow: hidden;
}
html body.memory-workspace .miv-card-image img {
  display: block;
  width: 100%;
  height: 280px;
  object-fit: contain;
}
html body.memory-workspace button.miv-inline {
  width: fit-content;
  max-width: 100%;
  margin: 8px 0;
  border-radius: 12px;
}
html body.memory-workspace .miv-inline img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}
html body.memory-workspace .miv-card figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
html body.memory-workspace .miv-card-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
html body.memory-workspace .miv-card-actions { display: flex; gap: 4px; }
html body.memory-workspace .miv-card-actions button {
  width: auto;
  padding: 6px 8px;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
}
html body.memory-workspace .miv-card-actions button:hover { background: var(--line); }
html body.memory-workspace button.miv-card-canvas {
  position: absolute;
  top: 12px;
  right: 12px;
  width: auto;
  min-height: 36px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #fff5;
  border-radius: 12px;
  background: #15191dda;
  color: #fff;
  box-shadow: 0 3px 12px #0002;
  font-size: 13px;
  opacity: 0;
  transition: opacity 120ms ease;
}
html body.memory-workspace .miv-card:hover .miv-card-canvas,
html body.memory-workspace .miv-card:focus-within .miv-card-canvas { opacity: 1; }
html body.memory-workspace .miv-card button:focus-visible,
html body.memory-workspace .miv-inline:focus-visible { outline: 3px solid #4382ef; outline-offset: -3px; }

html body.memory-workspace dialog.miv-dialog {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: min(1400px, calc(100vw - 48px));
  height: calc(100dvh - 48px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #ffffff24;
  border-radius: 20px;
  background: #17191d;
  color: #f5f6f8;
  box-shadow: 0 24px 100px #0006;
}
html body.memory-workspace dialog.miv-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
html body.memory-workspace .miv-dialog::backdrop { background: #080b10b8; backdrop-filter: blur(6px); }
html body.memory-workspace .miv-header,
html body.memory-workspace .miv-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  background: #202226;
}
html body.memory-workspace .miv-header { border-bottom: 1px solid #ffffff12; }
html body.memory-workspace .miv-heading { min-width: 0; flex: 1; }
html body.memory-workspace .miv-heading h2 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.4; color: #f5f6f8; overflow-wrap: anywhere; }
html body.memory-workspace .miv-subtitle { margin: 5px 0 0; font-size: 12px; line-height: 1.5; color: #b5bac4; }
html body.memory-workspace .miv-header-actions,
html body.memory-workspace .miv-zoom,
html body.memory-workspace .miv-image-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
html body.memory-workspace .miv-dialog button {
  width: auto;
  min-width: 36px;
  min-height: 36px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #ffffff18;
  border-radius: 9px;
  background: #ffffff08;
  color: #f5f6f8;
  font-size: 13px;
  line-height: 1.3;
  box-shadow: none;
}
html body.memory-workspace .miv-dialog button:hover { background: #ffffff18; }
html body.memory-workspace .miv-dialog button:focus-visible { outline: 2px solid #8db5ff; outline-offset: 3px; }
html body.memory-workspace .miv-dialog button.miv-primary { background: #eef2f8; border-color: #eef2f8; color: #17191d; font-weight: 600; }
html body.memory-workspace .miv-dialog [hidden] { display: none !important; }
html body.memory-workspace .miv-viewport {
  position: relative;
  overflow: hidden;
  min-height: 0;
  touch-action: none;
  user-select: none;
  cursor: grab;
  background: #17191d;
}
html body.memory-workspace .miv-viewport:active { cursor: grabbing; }
html body.memory-workspace .miv-dialog[data-mode="canvas"] .miv-viewport { background-image: radial-gradient(#ffffff24 1px, transparent 1px); background-size: 22px 22px; }
html body.memory-workspace .miv-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
html body.memory-workspace .miv-full-image { display: block; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; pointer-events: none; }
html body.memory-workspace .miv-dialog button.miv-tile {
  position: absolute;
  width: 280px;
  height: 320px;
  display: grid;
  grid-template-rows: 1fr 40px;
  overflow: hidden;
  padding: 0;
  border: 2px solid #ffffff24;
  border-radius: 14px;
  background: #282b31;
  text-align: left;
  cursor: pointer;
}
html body.memory-workspace .miv-dialog .miv-tile[aria-pressed="true"] { border-color: #91b6ff; box-shadow: 0 0 0 3px #91b6ff33; }
html body.memory-workspace .miv-tile img { width: 100%; height: 276px; max-width: none; object-fit: contain; pointer-events: none; }
html body.memory-workspace .miv-tile span { padding: 10px 14px; font-size: 13px; }
html body.memory-workspace .miv-load-error img { padding: 20px; box-sizing: border-box; }
html body.memory-workspace .miv-zoom-label { min-width: 46px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; color: #c5cad3; }
html body.memory-workspace .miv-notice { margin: 0; padding: 0 20px 12px; background: #202226; color: #c5cad3; font-size: 12px; }
html body.memory-workspace .miv-notice:empty { display: none; }
html body.memory-workspace .miv-notice a { margin-left: 6px; color: #a9c6ff; }
@media (hover: none), (pointer: coarse) {
  html body.memory-workspace button.miv-card-canvas { opacity: 1; }
}
@media (max-width: 680px) {
  html body.memory-workspace dialog.miv-dialog { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  html body.memory-workspace .miv-header { padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); gap: 8px; }
  html body.memory-workspace .miv-footer { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); justify-content: center; gap: 8px; }
  html body.memory-workspace .miv-dialog button { min-height: 40px; padding: 8px 11px; }
  html body.memory-workspace .miv-heading h2 { font-size: 15px; }
  html body.memory-workspace .miv-subtitle { font-size: 11px; }
  html body.memory-workspace .miv-card-image img { height: 260px; }
  html body.memory-workspace button.miv-card-canvas { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html body.memory-workspace button.miv-card-canvas { transition: none; }
}
