:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #18241f;
  background: #f5f4ef;
}
* { box-sizing: border-box; }
body { margin: 0; }
header {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 4rem; padding: .75rem clamp(1rem, 5vw, 4.5rem); border-bottom: 1px solid #dcded6;
}
.brand, h1 { font-family: Georgia, serif; font-weight: 500; }
.brand { font-size: 1.65rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); margin: 0 0 1rem; }
.login {
  max-width: 31rem; margin: 8vh auto 0; padding: clamp(1.25rem, 5vw, 2.5rem);
  border: 1px solid #dcded6; background: #fffefa; border-radius: 1rem;
}
.login form { display: grid; gap: .65rem; margin-top: 1.2rem; }
.login details { margin-top: 1.25rem; }
.login summary { cursor: pointer; }
button, input, select { font: inherit; border-radius: .5rem; min-height: 44px; padding: .5rem .85rem; }
input, select { border: 1px solid #aeb6ac; background: #fffefa; color: inherit; min-width: 0; }
button { background: #234737; color: white; border: 1px solid transparent; cursor: pointer; }
button.quiet { background: transparent; color: inherit; border-color: #aeb6ac; }
button:disabled { opacity: .4; cursor: default; }
.viewer-page {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.viewer-page header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: .35rem .7rem;
  min-height: 0;
  padding: .3rem clamp(.45rem, 2vw, 1.25rem);
}
.viewer-brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.viewer-brand .brand { font-size: clamp(1rem, 2vw, 1.4rem); }
.viewer-brand h1 { margin: 0; font-size: clamp(.95rem, 2vw, 1.45rem); }
.brand-logo { display: block; width: auto; height: 32px; max-width: 112px; object-fit: contain; }
.reader { min-width: 0; min-height: 0; padding: .25rem clamp(.25rem, 1vw, .8rem) .4rem; }
.module-picker, .controls { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.module-picker select { flex: 1; max-width: 100%; }
.viewer-page button, .viewer-page select { min-height: 36px; padding: .25rem .55rem; }
.book {
  display: grid;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #19231e;
  color: #fffefa;
  padding: .35rem;
  border-radius: .6rem;
}
.slide { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.slide img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.controls { position: relative; justify-content: center; flex-wrap: nowrap; min-height: 41px; padding: .3rem .1rem 0; }
.controls label { white-space: nowrap; }
.book:fullscreen { width: 100%; height: 100%; border-radius: 0; }
@media (max-width: 740px) {
  .viewer-page header { grid-template-rows: auto auto; }
  .viewer-page .viewer-menus { grid-column: 1 / -1; grid-row: 2; }
  .viewer-brand { flex-wrap: wrap; gap: .15rem .4rem; }
}
.slide-actions { display: contents; }
.slide-navigation { display: flex; gap: .35rem; align-items: center; flex-wrap: nowrap; }
.book select { color: #18241f; background-color: #fffefa; }

#slide-counter { min-width: 7ch; text-align: center; font-variant-numeric: tabular-nums; }
#jump-slide { width: 8.5rem; }
.module-completion { grid-column: 2; justify-self: center; width: clamp(9rem, 20vw, 10rem); text-align: center; }
.module-completion button { white-space: nowrap; }
.direction-icon { display: none; }
.slide-menu .unviewed-link { display: block; margin-top: .4rem; }
@media (max-width: 440px) {
  .direction-label, .completion-label { display: none; }
  .direction-icon { display: inline; }
  .module-completion { width: 7rem; }
  #slide-counter { min-width: 5ch; }
}

.viewer-menus { justify-self: end; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.viewer-menu { position: relative; }
.viewer-menu summary {
  cursor: pointer;
  min-height: 36px;
  padding: .35rem .55rem;
  border: 1px solid #aeb6ac;
  border-radius: .5rem;
  white-space: nowrap;
}
.account-menu summary {
  max-width: clamp(7rem, 23vw, 18rem);
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-panel {
  position: absolute;
  z-index: 2;
  top: calc(100% + .35rem);
  right: 0;
  width: max-content;
  max-width: min(20rem, calc(100vw - 1rem));
  padding: .55rem;
  border: 1px solid #aeb6ac;
  border-radius: .55rem;
  background: #fffefa;
  color: #18241f;
  box-shadow: 0 .3rem 1rem #0003;
}
.module-picker select { max-width: min(15rem, 62vw); }
.account-menu p { margin: 0 0 .55rem; overflow-wrap: anywhere; }
.slide-menu { position: absolute; right: .1rem; }
.slide-menu .menu-panel { inset: auto 0 calc(100% + .35rem) auto; }
.slide-menu .menu-panel select { width: auto; }
.viewer-page:fullscreen { position: relative; grid-template-rows: minmax(0, 1fr); }
.viewer-page:fullscreen header {
  position: absolute;
  z-index: 4;
  inset: 0 0 auto;
  background: #f5f4ef;
  visibility: hidden;
}
.viewer-page:fullscreen:has(.fullscreen-edge:hover) header,
.viewer-page:fullscreen header:hover,
.viewer-page:fullscreen header:focus-within,
.viewer-page:fullscreen[data-menu-open] header { visibility: visible; }
.viewer-page:fullscreen .fullscreen-edge {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: transparent;
  background: transparent;
}
.viewer-page:fullscreen .fullscreen-edge:focus-visible {
  color: #fffefa;
  background: #234737;
}
@media (max-width: 740px) {
  #module-menu .menu-panel, #settings-menu .menu-panel { right: auto; left: 0; }
  .account-menu { margin-inline-start: auto; }
}
@media (hover: none) {
  .viewer-page:fullscreen .fullscreen-edge { min-height: 24px; }
}
