/* Stretch the page panels, while books keep their existing dimensions. */
:root #shelf-content {
  align-items: stretch;
}
:root #shelf-content > * {
  min-width: 0;
}
:root
  #shelf-content
  > :is(.home-shelf, .album-detail, #today-panel, .reading-note) {
  align-self: stretch;
}
[data-theme='walnut'] #shelf-content {
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr);
  grid-template-areas:
    'intro intro'
    'tools tools'
    'notice notice'
    'shelf preview'
    'today today'
    'note note';
}
:is([data-theme='walnut'], [data-theme='night'], [data-theme='airmail'])
  #shelf-content
  > .home-shelf {
  display: flex;
  flex-direction: column;
}
:is([data-theme='walnut'], [data-theme='night'], [data-theme='airmail'])
  #shelf-content
  > .home-shelf
  > .shelf-panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
:root #shelf-content .home-shelf .shelf-scene {
  flex: 1;
}
:root[data-theme='walnut'] #shelf-content > .home-shelf {
  display: contents;
}
[data-theme='walnut'] #shelf-content .shelf-toolbar {
  grid-area: tools;
  margin: 0;
}
[data-theme='walnut'] #shelf-content .storage-notice {
  grid-area: notice;
  margin: 0;
}
[data-theme='walnut'] #shelf-content .home-shelf > .shelf-panel {
  grid-area: shelf;
}
[data-theme='walnut'] #shelf-edit-status {
  grid-area: editnote;
  margin: 0;
}
[data-theme='walnut'] #shelf-order-reset {
  grid-area: reset;
  justify-self: end;
  align-self: center;
}
:root #shelf-content > #today-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-block: 0;
}
:root #today-panel > .today-grid {
  flex: 1;
  grid-auto-rows: minmax(min-content, 1fr);
  align-items: stretch;
}
:root #shelf-content > .reading-note {
  margin-block: 0;
}
[data-theme='night'] #shelf-content:has(#today-panel[hidden]) {
  grid-template-areas: 'intro intro' 'shelf shelf' 'preview preview' 'note note';
}
[data-theme='airmail'] #shelf-content:has(#today-panel[hidden]) {
  grid-template-areas: 'intro intro' 'shelf shelf' 'preview note';
}
[data-theme='walnut'] #shelf-content:has(#today-panel[hidden]) {
  grid-template-areas:
    'intro intro'
    'tools tools'
    'notice notice'
    'shelf preview'
    'note note';
}
:root[data-theme='walnut'] #shelf-content:has(.is-shelf-editing) {
  grid-template-areas:
    'intro intro'
    'tools tools'
    'notice notice'
    'editnote reset'
    'shelf shelf'
    'today today'
    'note note';
}
[data-theme='night'] #shelf-content:has(.is-shelf-editing) {
  grid-template-areas: 'intro intro' 'shelf shelf' 'today today' 'note note';
}
:is([data-theme='walnut'], [data-theme='night'], [data-theme='airmail'])
  #shelf-content:has(.is-shelf-editing):has(#today-panel[hidden]) {
  grid-template-areas: 'intro intro' 'shelf shelf' 'note note';
}
[data-theme='walnut']
  #shelf-content:has(.is-shelf-editing):has(#today-panel[hidden]) {
  grid-template-areas:
    'intro intro'
    'tools tools'
    'notice notice'
    'editnote reset'
    'shelf shelf'
    'note note';
}
:root[data-theme='press'] .press-directory {
  align-self: stretch;
}
:root .shelf-overview-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr);
  align-items: stretch;
  gap: clamp(20px, 2.5vw, 36px);
  flex: 1;
}
:root .shelf-overview-layout:has(> .overview-details[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
:root .overview-shelves {
  display: grid;
  min-width: 0;
  min-height: 0;
}
:root #shelf-overview .overview-layer:not([hidden]) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}
:root #shelf-overview .overview-layer > .shelf-scene {
  flex: 1;
}
:root #shelf-overview .overview-details:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-self: stretch;
}
:root .overview-cover-image {
  flex: 0 0 auto;
  max-width: none;
}
:root .overview-detail-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
:root .overview-detail-actions {
  margin-top: auto;
  padding-top: 20px;
}
/* Empty shelves have no selected-album panel to reserve a column or row for. */
[data-theme='walnut'] #shelf-content:has(> .album-detail[hidden]) {
  grid-template-areas:
    'intro intro'
    'tools tools'
    'notice notice'
    'shelf shelf'
    'today today'
    'note note';
}
[data-theme='night'] #shelf-content:has(> .album-detail[hidden]) {
  grid-template-areas: 'intro intro' 'shelf shelf' 'today today' 'note note';
}
[data-theme='airmail'] #shelf-content:has(> .album-detail[hidden]) {
  grid-template-areas: 'intro intro' 'shelf shelf' 'today today' 'note note';
}
[data-theme='airmail']
  #shelf-content:has(> .album-detail[hidden]):has(.is-shelf-editing) {
  grid-template-areas: 'intro intro' 'shelf shelf' 'today today' 'note note';
}
:is([data-theme='walnut'], [data-theme='night'], [data-theme='airmail'])
  #shelf-content:has(> .album-detail[hidden]):has(#today-panel[hidden]) {
  grid-template-areas: 'intro intro' 'shelf shelf' 'note note';
}
[data-theme='walnut']
  #shelf-content:has(> .album-detail[hidden]):has(#today-panel[hidden]) {
  grid-template-areas:
    'intro intro'
    'tools tools'
    'notice notice'
    'shelf shelf'
    'note note';
}
[data-theme='walnut']
  #shelf-content:has(> .album-detail[hidden]):has(.is-shelf-editing) {
  grid-template-areas:
    'intro intro'
    'tools tools'
    'notice notice'
    'editnote reset'
    'shelf shelf'
    'today today'
    'note note';
}
[data-theme='walnut']
  #shelf-content:has(> .album-detail[hidden]):has(.is-shelf-editing):has(
    #today-panel[hidden]
  ) {
  grid-template-areas:
    'intro intro'
    'tools tools'
    'notice notice'
    'editnote reset'
    'shelf shelf'
    'note note';
}
[data-theme='press'] #shelf-content:has(> .album-detail[hidden]) > .home-shelf {
  grid-template-areas: 'tools tools' 'notice notice' 'shelf shelf';
}
@media (max-width: 900px) {
  :root #shelf-content {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }
  :root:not([data-theme='press']) #shelf-content {
    grid-template-areas: 'intro' 'shelf' 'preview' 'today' 'note';
  }
  :root:not([data-theme='press']) #shelf-content:has(.is-shelf-editing) {
    grid-template-areas: 'intro' 'shelf' 'today' 'note';
  }
  :root:not([data-theme='press']) #shelf-content:has(#today-panel[hidden]) {
    grid-template-areas: 'intro' 'shelf' 'preview' 'note';
  }
  :root:not([data-theme='press'])
    #shelf-content:has(.is-shelf-editing):has(#today-panel[hidden]) {
    grid-template-areas: 'intro' 'shelf' 'note';
  }
  :root[data-theme='walnut'] #shelf-content {
    grid-template-areas:
      'intro'
      'tools'
      'notice'
      'shelf'
      'preview'
      'today'
      'note';
  }
  :root[data-theme='walnut'] #shelf-content:has(.is-shelf-editing) {
    grid-template-areas:
      'intro'
      'tools'
      'notice'
      'editnote'
      'reset'
      'shelf'
      'today'
      'note';
  }
  :root[data-theme='walnut'] #shelf-content:has(#today-panel[hidden]) {
    grid-template-areas: 'intro' 'tools' 'notice' 'shelf' 'preview' 'note';
  }
  :root[data-theme='walnut']
    #shelf-content:has(.is-shelf-editing):has(#today-panel[hidden]) {
    grid-template-areas:
      'intro'
      'tools'
      'notice'
      'editnote'
      'reset'
      'shelf'
      'note';
  }
  :root[data-theme='press'] .home-shelf {
    grid-template: 'tools' auto 'notice' auto 'shelf' auto 'index' auto / minmax(
        0,
        1fr
      );
  }
  :root[data-theme='press'] .home-shelf:has(.is-shelf-editing) {
    grid-template-areas: 'tools' 'notice' 'shelf';
  }
  :root #today-panel > .today-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
  }
  :root .shelf-overview-layout {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }
  :root #shelf-overview .overview-details {
    align-self: start;
  }
  :root .overview-detail-actions {
    margin-top: 20px;
    padding-top: 0;
  }
  :root:not([data-theme='press']) #shelf-content:has(> .album-detail[hidden]) {
    grid-template-areas: 'intro' 'shelf' 'today' 'note';
  }
  :root:not([data-theme='press'])
    #shelf-content:has(> .album-detail[hidden]):has(#today-panel[hidden]) {
    grid-template-areas: 'intro' 'shelf' 'note';
  }
  :root[data-theme='walnut'] #shelf-content:has(> .album-detail[hidden]) {
    grid-template-areas: 'intro' 'tools' 'notice' 'shelf' 'today' 'note';
  }
  :root[data-theme='walnut']
    #shelf-content:has(> .album-detail[hidden]):has(#today-panel[hidden]) {
    grid-template-areas: 'intro' 'tools' 'notice' 'shelf' 'note';
  }
  :root[data-theme='walnut']
    #shelf-content:has(> .album-detail[hidden]):has(.is-shelf-editing) {
    grid-template-areas:
      'intro'
      'tools'
      'notice'
      'editnote'
      'reset'
      'shelf'
      'today'
      'note';
  }
  :root[data-theme='walnut']
    #shelf-content:has(> .album-detail[hidden]):has(.is-shelf-editing):has(
      #today-panel[hidden]
    ) {
    grid-template-areas:
      'intro'
      'tools'
      'notice'
      'editnote'
      'reset'
      'shelf'
      'note';
  }
  :root[data-theme='press']
    #shelf-content:has(> .album-detail[hidden])
    > .home-shelf {
    grid-template-areas: 'tools' 'notice' 'shelf';
  }
}
