                   updated (assoc-in entry [:briefing :time-allocation book] s)]
               (put-fn [:entry/update-local updated]))))]
     (fn briefing-render [entry put-fn edit-mode?]
-      (let [{:keys [pomodoro-stats activity-stats task-stats wordcount-stats
+      (let [books @books
+            {:keys [pomodoro-stats activity-stats task-stats wordcount-stats
                     daily-summary-stats media-stats]} @chart-data
             day (-> entry :briefing :day)
             day-stats (get pomodoro-stats day)

               [:strong (:word-count word-stats)] " words written."])
            (when day-stats [time-by-stories-list day-stats])
            [:hr]
            [:div [horizontal-bar @books :book-name time-allocation 0.0045]]
            [:div [horizontal-bar @books :book-name remaining-times 0.0045]]
            [:div
             "Total planned: "
             [:strong
              (u/duration-string
                (apply + (map second (-> entry :briefing :time-allocation))))]]
            [:div.story-time
             (for [[k v] @books]
               (let [allocation (get-in entry [:briefing :time-allocation k] 0)
                     actual (get-in (:time-by-book day-stats) [k] 0)
                     remaining (- allocation actual)]

                       (when allocation
                         [:span.allocated (u/duration-string allocation)]))
                     (when (pos? remaining)
                       [:span (u/duration-string remaining)])])]))]
            [:hr]
            [:div [horizontal-bar books :book-name last-7-days 0.001]]
            [:div
             "Past seven days: "
             [:strong (u/duration-string (apply + (map second last-7-days)))]]
            [:div.story-time
             (for [[book v] last-7-days]
               (let [book-name (or (:book-name (get books book)) "none")]
                 ^{:key book}
                 [:div
                  [:span.legend
                   {:style {:background-color (cc/item-color book-name)}}]
                  [:strong.name book-name] (u/duration-string v)]))]]])))))
