.phone-fit .panel.storytime-open {
  background: #f8ebd1;
  padding: 0;
}
.panel.storytime-open > :not(#storytimePanel),
.phone-fit .panel.storytime-open > #actions[style] {
  display: none !important;
}
#storytimePanel[hidden] { display: none; }
#storytimePanel {
  box-sizing: border-box;
  width: 100%;
  padding: 12px clamp(12px, 4%, 24px);
  color: #214232;
  background: radial-gradient(ellipse at top, #fff5e1, #f6e6c8);
}
#storytimePanel header,
#storytimePanel footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#storytimePanel h2 {
  flex: 1;
  margin: 0;
  font: 700 clamp(16px, 4vw, 25px)/1.12 Fraunces, Georgia, serif;
  color: #214232;
}
#storytimePanel header button,
#storytimePanel footer button {
  flex: none;
  min-height: 38px;
  min-width: 40px;
  padding: 5px 10px;
  border: 1px solid #a77a4e;
  border-radius: 12px;
  background: #faeed7;
  color: #214232;
  font-size: 12px;
}
#storytimePanel button:disabled { opacity: .45; }
#storytimePanel .storytime-next { background: #234734; color: #fff3d9; }
.storytime-books {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 9px;
  margin-top: 8px;
}
.storytime-books button {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #214232;
}
.storytime-books img {
  display: block;
  width: 100%;
  max-height: 100px;
  object-fit: contain;
}
.storytime-books small { display: block; font-size: 10px; }
.storytime-reader-head img {
  width: clamp(42px, 14%, 64px);
  border-radius: 5px;
}
.storytime-text {
  margin: 13px 0;
  font: 400 clamp(16px, 3.9vw, 21px)/1.5 Georgia, serif;
  text-wrap: pretty;
}
#storytimePanel footer {
  padding-top: 8px;
  border-top: 1px solid #b58a5d85;
  font-size: 12px;
  font-weight: 700;
}

/* Give the prose the full lower panel, with controls outside its scroller. */
#storytimePanel.storytime-reading:not([hidden]) {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: auto minmax(5rem, 1fr) auto;
  padding: 8px clamp(10px, 3%, 20px);
}
.storytime-reading .storytime-reader-head img { width: 36px; }
#storytimePanel.storytime-reading h2 { font-size: clamp(16px, 4vw, 22px); }
.storytime-page {
  overflow-y: auto;
  overscroll-behavior-y: contain;
}
.storytime-page .storytime-text {
  margin: 8px 0;
  padding-inline-end: 3px;
  font-size: clamp(16px, 3.75vw, 20px);
  line-height: 1.45;
}
#storytimePanel.storytime-reading footer { padding-top: 5px; }

#storytimePanel.storytime-reading .storytime-reader-head {
  display:grid;grid-template-columns:auto minmax(0,1fr) auto;
  align-items:start;text-align:left;gap:8px;
}
#storytimePanel.storytime-reading .storytime-reader-head h2 {align-self:center;}
#storytimePanel .storytime-reader-head button {justify-self:end;margin:0;}
#storytimePanel.storytime-reading {grid-template-rows:auto minmax(0,1fr) auto;row-gap:5px;}
#storytimePanel .storytime-page {display:block;min-height:0;text-align:left;}
#storytimePanel .storytime-page .storytime-text {margin:0;padding:0;}
#storytimePanel .storytime-text p {margin:0 0 .55em;font:inherit;white-space:pre-line;}
#storytimePanel .storytime-text h3 {margin:0 0 .3em;font:700 1em/1.25 Georgia,serif;}
.storytime-cover-title {display:block;font:700 14px/1.2 Georgia,serif;margin:3px 0 5px;}
#storytimePanel .storytime-books {overflow:auto;align-content:start;min-height:0;}
#storytimePanel:not(.storytime-reading):not([hidden]){display:flex;flex-direction:column;min-height:0;}
#storytimePanel.storytime-reading .storytime-reader-head {
  position:static;min-height:0;height:auto;padding:0;margin:0;
}
#storytimePanel.storytime-reading .storytime-reader-head img {height:auto;max-height:38px;object-fit:contain;}
