.anatomy-dialog {
  box-sizing: border-box;
  width: min(96%, 760px);
  max-width: none;
  max-height: 90dvh;
  padding: clamp(12px, 3vw, 25px);
  background: #fcf8ed;
  border: 1px solid #d9cebc;
  color: #254435;
  border-radius: 20px;
  overflow: auto;
  overscroll-behavior: contain;
}
.anatomy-dialog::backdrop { background: #18231e80; }
.anatomy-dialog [hidden] { display: none !important; }
.anatomy-dialog header, .anatomy-dialog footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; }
.anatomy-dialog h2 { margin: 0; font: 600 clamp(23px, 5vw, 33px) Georgia, serif; }
.anatomy-dialog button, .anatomy-dialog select { min-height: 44px; max-width: 100%; }
.anatomy-dialog label { font-size: 14px; }
.anatomy-hint { padding: 10px; background: #e5eadc; border-radius: 9px; font-size: 14px; }
.anatomy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(125px, 46%), 1fr)); gap: 10px; margin-top: 12px; }
.anatomy-card { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 8px; min-width: 0; border: 1px solid #d7cdbc; background: #fffdf8; border-radius: 10px; text-align: center; }
.anatomy-card:has(:checked) { outline: 2px solid #77916d; outline-offset: -2px; }
.anatomy-card label { display: block; cursor: pointer; }
.anatomy-card input { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; accent-color: #44634a; }
.anatomy-card img { display: block; width: 100%; height: 90px; object-fit: contain; mix-blend-mode: multiply; }
.anatomy-card span { display: block; padding: 5px 0; font: 16px Georgia, serif; }
.anatomy-card button { margin-top: 4px; font-size: 13px; }
.anatomy-gallery footer { position: sticky; bottom: 0; background: #fcf8ed; padding: 10px 0 2px; }
.anatomy-inserting footer, .anatomy-inserting .anatomy-hint, .anatomy-dialog [data-error]:empty { display: none; }
.anatomy-coloring header { justify-content: flex-start; margin-bottom: 10px; }
.anatomy-paper { position: relative; width: min(100%, 54dvh); aspect-ratio: 900/980; margin: auto; background: white; border: 1px solid #d7cdbc; border-radius: 8px; overflow: hidden; }
.anatomy-paper img, .anatomy-paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.anatomy-paper canvas { touch-action: none; }
.anatomy-coloring footer { justify-content: center; margin-top: 10px; }
.anatomy-coloring footer [aria-pressed=true] { background: #dce6d4; color: #254435; }
.anatomy-print-frame { position: fixed; top: 0; left: -12000px; width: 816px; height: 1056px; border: 0; }
@media (max-width: 600px) {
  .anatomy-dialog { width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0; }
}
.anatomy-gallery { display: flex; flex-direction: column; max-height: calc(90dvh - 52px); }
.anatomy-gallery > :not(.anatomy-grid) { flex-shrink: 0; }
.anatomy-grid { overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: 2px; }

/* The notebook sits beside one stack of two paper cards. */
#shelf .shelfstudytools {
  grid-template-columns: minmax(0, 2.23fr) minmax(0, 1.05fr);
  align-items: start;
}
.shelf-study-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: start;
  gap: 1.7%;
  min-width: 0;
}
.shelf-paper-stack {
  display: grid;
  gap: 3%;
  margin-top: 10%;
  min-width: 0;
}
/* Notebook covers cap .bookitem globally; these study tools fill their tracks. */
#shelf .shelf-study-pair .bookitem { max-width: none; }
#shelf .shelf-paper-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 5px;
  box-shadow: 1px 5px 9px #3b352429;
}
.shelf-paper-card img { display: block; width: 100%; height: auto; border-radius: inherit; }
#shelf .shelf-paper-card:focus-visible { outline: 2px solid #46634e; outline-offset: 3px; }
@media (max-width: 760px) {
  #shelf .shelfstudytools { grid-template-columns: minmax(0, 1fr); }
}
#shelf .shelf-study-pair > .notepadtile .notepadtitletile {
  display: block;
  text-align: left;
  min-height: 0;
  margin: 6px 0 0 14%;
  font: 500 clamp(16px, 4.8cqw, 28px)/1.04 Georgia, serif;
}
#shelf .shelfstudytools #opennotepadlink {
  align-self: start;
  margin: 4px 0 0 14%;
  text-align: left;
  font: italic clamp(12px, 3cqw, 19px) Georgia, serif;
}
.anatomy-dialog { background: #fcf8ed; }
.anatomy-handle { align-self: center; width: 40px; height: 5px; border-radius: 10px; background: #bfc6ad; margin: 0 0 10px; }
.anatomy-dialog [data-close], .anatomy-dialog [data-back] {
  background: transparent;
  border: 0;
  padding: 0;
  width: 44px;
  color: inherit;
  font: 27px Georgia, serif;
}
.anatomy-gallery [data-description] { font: italic 17px Georgia, serif; margin: 6px 0 10px; }
.anatomy-hint { font: italic 14px/1.35 Georgia, serif; margin: 0 0 8px; }
.anatomy-hint b { font-weight: 600; }
.anatomy-categories { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: thin; }
.anatomy-categories button { flex: none; border: 0; border-radius: 99px; padding: 4px 10px; font-size: 13px; background: transparent; color: #33463e; }
.anatomy-categories button[aria-pressed=true] { background: #d7dfc6; color: #234637; font-weight: 650; }
.anatomy-grid { margin-top: 8px; }
.anatomy-card { background: #fffdf8; border-radius: 12px; padding: 6px; }
.anatomy-card span { font: italic 16px/1.15 Georgia, serif; }
.anatomy-card img { height: clamp(76px, 14dvh, 134px); }
.anatomy-card input {
  appearance: none;
  width: 19px;
  height: 19px;
  margin: 0;
  border: 1px solid #8b967e;
  border-radius: 50%;
  background: #fffdf8;
}
.anatomy-card input:checked { background: #7d9b71; border-color: #7d9b71; }
.anatomy-card input:checked::after { content: '✓'; display: block; color: white; font: 700 14px/17px system-ui; }
.anatomy-card button { background: #e6ebdb; color: #234535; border: 0; border-radius: 99px; padding: 4px 8px; min-height: 34px; }
.anatomy-gallery footer { display: grid; grid-template-columns: auto minmax(0,1fr); padding-top: 8px; }
.anatomy-gallery [data-count] { font: 14px Georgia, serif; }
.anatomy-gallery [data-print] { width: 100%; background: #244b37; color: #fffdf5; font: 600 17px Georgia, serif; border: 0; border-radius: 9px; }
.anatomy-gallery [data-print]:disabled { opacity: .55; }
.anatomy-coloring header { display: grid; grid-template-columns: 44px 1fr 44px; text-align: center; }
.anatomy-coloring header p { margin: 3px 0 0; font: italic 15px Georgia, serif; }
.anatomy-paper { width: min(100%, 58dvh); }
.anatomy-paper canvas { pointer-events: auto; z-index: 1; user-select: none; }
.anatomy-coloring footer { background: #faf5e9; border: 1px solid #e2d8c8; border-radius: 10px; gap: 2px; padding: 3px; }
.anatomy-coloring footer button { border: 0; border-radius: 20px; padding: 4px 7px; background: transparent; color: #254435; font-size: 13px; }
.anatomy-coloring [data-undo] { font-size: 21px; }
.anatomy-coloring [data-tool=erase] svg { display: block; }
.anatomy-palette { display: flex; gap: 2px; padding: 0 4px; border-inline: 1px solid #e2d8c8; }
.anatomy-coloring .anatomy-palette button { min-width: 22px; padding: 0; }
.anatomy-palette button::before { content: ''; display: block; margin: auto; width: 17px; height: 17px; border-radius: 50%; background: var(--ink-color); }
.anatomy-coloring .anatomy-palette button[aria-pressed=true] { background: transparent; }
.anatomy-palette button[aria-pressed=true]::before { outline: 1px solid #426346; outline-offset: 2px; }
@media (max-width: 760px) {
  #shelf .shelfstudytools > .heartmindart { grid-column: 1 / -1; }
  #shelf .shelfstudytools { column-gap: clamp(14px, 5vw, 22px); }
}
@media (max-width: 600px) {
  .anatomy-dialog { padding: 10px clamp(12px, 4vw, 20px) max(10px, env(safe-area-inset-bottom)); max-height: 85dvh; }
  .anatomy-gallery { max-height: calc(85dvh - 23px - env(safe-area-inset-bottom)); }
  .anatomy-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .anatomy-dialog.anatomy-is-coloring { margin: auto 0 0; height: 100dvh; max-height: 100dvh; border-radius: 0; padding-top: max(12px, env(safe-area-inset-top)); }
  .anatomy-coloring { display: flex; flex-direction: column; min-height: 100%; }
  .anatomy-paper { width: 100%; flex: 1; min-height: 0; }
}
.anatomy-gallery.anatomy-inserting footer { display: none; }
.anatomy-paper canvas { object-fit: fill; }

.anatomy-coloring .anatomy-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 2px;
  margin-top: 6px;
  padding: 4px;
  border: 1px solid #e2d8c8;
  border-radius: 10px;
}
.anatomy-coloring .anatomy-palette button { border: 0; padding: 0; min-height: 36px; }
.anatomy-coloring .anatomy-palette label { display: flex; align-items: center; justify-content: center; gap: 4px; grid-column: span 3; }
.anatomy-coloring [data-palette]::before { content: ''; display: inline-block; width: 13px; height: 13px; border-radius: 50%; margin-right: 5px; vertical-align: -2px; background: var(--ink-color); }
.anatomy-coloring [data-palette][aria-expanded=true] { background: #dce6d4; }
.anatomy-export { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.anatomy-export button { border-radius: 9px; color: #254435; background: #fffdf8; border: 1px solid #d7cdbc; }
.anatomy-export button.primary { color: white; background: #244b37; border-color: #244b37; }
.anatomy-export-status { margin: 4px 0 0; font-size: 13px; }
.anatomy-export-status:empty { display: none; }
@media (max-width: 600px) {
  .anatomy-coloring { min-height: 0; height: 100%; }
  .anatomy-coloring > :not(.anatomy-paper) { flex-shrink: 0; }
}
.anatomy-coloring { position: relative; }
.anatomy-coloring .anatomy-palette {
  position: absolute;
  z-index: 2;
  inset-inline: 0;
  bottom: 108px;
  background: #fcf8ed;
  box-shadow: 0 3px 14px #42372b29;
}
.anatomy-export-status { min-height: 1.2em; }
.anatomy-export-status:empty { display: block; }

.anatomy-export [data-add-notepad] { grid-column: 1 / -1; }
.anatomy-coloring .anatomy-palette { bottom: 160px; }

.anatomy-gallery [data-embryo-note] { margin: 5px 0 0; font-size: 13px; }
