.practice-reference-editor { min-width: 0; margin: 8px 0; padding: 20px; border: 1px solid var(--line); border-radius: 10px; }
.practice-reference-editor legend { padding: 0 8px; color: var(--primary); font-weight: 700; }
.practice-reference-editor > p:first-of-type { margin-top: 0; }
.reference-editor-list { display: grid; gap: 20px; }
.reference-editor-item { display: grid; grid-template-columns: 160px minmax(0,1fr); gap: 24px; padding-block: 12px 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.reference-thumbnail { display: flex; flex-direction: column-reverse; align-items: center; justify-content: end; gap: 12px; }
.reference-thumbnail img { max-width: 100%; max-height: 150px; object-fit: contain; background: #fff; border-radius: 4px; }
.reference-editor-fields { display: grid; gap: 16px; min-width: 0; }
.reference-editor-fields input { min-width: 0; }
.reference-editor-fields .checkbox { align-self: end; }
.question-references { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.question-references .reading-image-link { min-height: 44px; }
.image-viewer { width: min(1120px,calc(100vw - 32px)); max-width: none; max-height: 92vh; max-height: 92dvh; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 80px #0006; }
.image-viewer::backdrop { background: rgb(5 16 32 / 78%); }
.image-viewer-open { overflow: hidden; }
.image-viewer-panel { display: flex; flex-direction: column; max-height: 90vh; max-height: 90dvh; }
.image-viewer-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; }
.image-viewer-header h2 { margin: 0; font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
.image-viewer button { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--primary); font: inherit; font-weight: 650; cursor: pointer; }
.image-viewer button:hover, .image-viewer button[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary-border); }
.image-viewer button:focus-visible, .image-viewer-stage:focus-visible { outline: 3px solid var(--focus-ring, #e4ae2c); outline-offset: -3px; }
.image-viewer button:disabled { color: var(--disabled-ink); background: var(--disabled-surface); border-color: var(--disabled-border); cursor: wait; }
.image-viewer .image-viewer-close { width: 44px; padding: 8px; }
.image-viewer-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0 20px 12px; }
.image-viewer-controls [role="status"] { font-size: 14px; color: var(--muted); }
.image-viewer-stage { min-height: 120px; min-width: 0; overflow: auto; overscroll-behavior: contain; background: #fff; padding: 12px; border-top: 1px solid var(--line); }
.image-viewer-stage img { display: block; margin: auto; width: auto; height: auto; max-width: 100%; max-height: calc(90vh - 160px); max-height: calc(90dvh - 160px); }
.image-viewer.is-zoomed .image-viewer-stage img { max-width: none; max-height: none; }
@media (any-pointer: fine) {
  .image-viewer.is-zoomed .image-viewer-stage img { cursor: grab; user-select: none; }
  .image-viewer.is-zoomed .image-viewer-stage.is-dragging,
  .image-viewer.is-zoomed .image-viewer-stage.is-dragging img { cursor: grabbing; }
}
@media (max-width: 600px) {
  .practice-reference-editor { padding: 16px; }
  .reference-editor-item { grid-template-columns: minmax(0,1fr); gap: 16px; }
  .reference-thumbnail { align-items: start; }
  .image-viewer { width: calc(100vw - 12px); max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px); border-radius: 10px; }
  .image-viewer-panel { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .image-viewer-header { padding: 10px 12px; gap: 8px; }
  .image-viewer-header h2 { font-size: 18px; }
  .image-viewer-controls { padding: 0 12px 10px; }
  .image-viewer-controls button { font-size: 14px; padding-inline: 10px; }
  .image-viewer-stage { padding: 8px; }
  .image-viewer-stage img { max-height: calc(100vh - 176px); max-height: calc(100dvh - 176px); }
}
