[hidden] {
  display: none !important;
}
main.wrap {
  margin: 0 auto;
  padding: 36px 20px;
  width: min(100%, 820px);
}
.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
}
.mast {
  background: #fff;
  border-bottom: 1px solid var(--edge);
}
.mast .wrap,
#account,
.identity,
.listbar,
.actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.mast .wrap {
  min-height: 64px;
  justify-content: space-between;
}
.identity {
  font-size: 19px;
  font-weight: 650;
  color: var(--green);
}
.identity b {
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  padding: 2px 7px;
}
#who {
  word-break: break-all;
}
#account button {
  flex-shrink: 0;
}
#auth {
  max-width: 465px;
  margin: 6vh auto;
  padding: 28px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: #fff;
}
h1 {
  font-size: 26px;
  margin: 0 0 16px;
}
h2 {
  font-size: 16px;
  margin: 0;
}
.hint,
#status,
.empty {
  color: var(--sub);
}
label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
}
input,
textarea {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #fff;
}
textarea {
  resize: vertical;
}
.editor {
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 10px 18px 16px;
  background: #fff;
}
.actions {
  margin-top: 14px;
}
.listbar {
  justify-content: space-between;
  margin: 26px 0 12px;
}
.note header {
  justify-content: space-between;
}
.note time {
  margin: 0;
}
.note p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#status {
  text-align: center;
}
#status.error,
form .hint.error {
  color: #923d35;
}
button:disabled {
  opacity: 0.6;
}

.versions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.versions > div {
  padding: 12px;
  border: 1px solid var(--edge);
  border-radius: 8px;
}
.versions h3 {
  margin: 0 0 8px;
  font-size: 14px;
}
.versions p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.editor .actions,
.card-editor .actions {
  flex-wrap: wrap;
}
@media (max-width: 560px) {
  .versions {
    grid-template-columns: minmax(0, 1fr);
  }
}

main.wrap:has(#library:not([hidden])) {
  width: min(100%, 1060px);
  max-width: 1060px;
}
.library-layout {
  display: grid;
  grid-template-columns: minmax(165px, 230px) minmax(0, 1fr);
  gap: 24px;
  margin-top: 16px;
}
.tag-nav {
  align-self: start;
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 14px 10px;
}
.tag-nav h2 {
  margin: 0 8px 8px;
}
.tag-nav button {
  display: block;
  text-align: left;
  width: 100%;
  border: 0;
  background: transparent;
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 7px 8px;
}
.tag-nav button[aria-current="page"] {
  background: #e4efe8;
  color: var(--green);
  font-weight: 650;
}
.tag-context {
  color: var(--green);
  font-size: 14px;
  overflow-wrap: anywhere;
  margin: 6px 0;
}
.card-tag {
  max-width: 100%;
  color: var(--green);
  background: #edf4ed;
  border: 0;
  padding: 4px 8px;
  overflow-wrap: anywhere;
  text-align: start;
}
#list-title {
  overflow-wrap: anywhere;
}
@media (max-width: 650px) {
  .library-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  #tag-list {
    max-height: 180px;
    overflow: auto;
  }
}
.tag-nav-head,
.tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tag-nav-head h2 {
  margin-inline-end: 0;
  margin-bottom: 0;
}
.tag-nav-head {
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.tag-nav-head #new-root-tag { padding-inline: 4px; }
.tag-nav-actions { display: flex; align-items: center; margin-inline-start: auto; }
.tag-sort-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 0;
  padding: 7px 5px;
  color: var(--green);
  font-size: 13px;
  cursor: pointer;
}
.tag-sort-control:hover { background: #edf1ef; border-radius: 5px; }
.tag-sort-control:has(select:focus-visible) { outline: 2px solid var(--green); border-radius: 5px; }
.tag-sort-control select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.tag-nav-head button,
.tag-row .add-child,
.tag-row .manage-tag {
  width: auto;
  flex-shrink: 0;
  color: var(--green);
}
.tag-nav-head button {
  font-size: 13px;
}
.tag-row .add-child,
.tag-row .manage-tag {
  min-width: 36px;
  text-align: center;
  font-size: 18px;
}
#tag-dialog {
  width: min(24rem, 90vw);
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 20px;
}
#tag-dialog select {
  width: 100%;
}
#tag-error {
  color: #923d35;
}

#managed-path {
  overflow-wrap: anywhere;
}
#delete-tag {
  color: #923d35;
}
#new-tag-form .actions {
  flex-wrap: wrap;
}

.tag-row { border-radius: 6px; }
.tag-row:hover, .tag-row:has(:focus-visible) { background: #edf1ef; }
.tag-row:has([aria-current="page"]) { background: #e4efe8; }
.tag-row button[aria-current="page"] { background: transparent; }
.tag-row-end {
  display: inline-flex;
  flex: none;
  align-items: center;
}
.tag-count {
  color: #5c6b62;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.tag-count .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (hover: hover) and (pointer: fine) {
  .tag-row-end { display: grid; }
  .tag-row-end > * { grid-area: 1 / 1; }
  .tag-count { text-align: center; padding-inline: 6px; }
  .tag-row:hover .tag-count, .tag-row:has(:focus-visible) .tag-count { opacity: 0; }
  .tag-row .manage-tag { opacity: 0; }
  .tag-row:hover .manage-tag, .tag-row:has(:focus-visible) .manage-tag { opacity: 1; }
}
.tag-row .manage-tag:hover { background: #dde5df; }
.note-choices, #tag-menu, #trash-dialog {
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 5px 24px #162b231f;
}
#tag-menu { position: fixed; margin: 0; padding: 5px; width: 166px; max-height: 90vh; }
#tag-menu::backdrop { background: transparent; }
.note-choices button, #tag-menu button {
  display: block; width: 100%; text-align: left; color: inherit;
  border: 0; border-radius: 5px; background: transparent; padding: 8px 12px;
}
.note-choices button:hover, .note-choices button:focus-visible, #tag-menu button:hover, #tag-menu button:focus-visible { background: #edf1ef; }
#tag-menu #delete-tag, #delete-choices button, #menu-error, #trash-error { color: #923d35; }
#delete-tag span { float: right; }
#delete-choices, #open-trash, .pinned-tags { border-top: 1px solid var(--edge); }
#tag-menu #delete-choices button { padding-left: 20px; }
.pinned-tags { padding: 6px 0; border-bottom: 1px solid var(--edge); }
.pinned-tags h3 { font-size: 13px; margin: 4px 8px; }
#trash-dialog { width: min(420px, 90vw); max-height: 80vh; }
#trash-list article { border-top: 1px solid var(--edge); padding: 8px 0; overflow-wrap: anywhere; }
#trash-list { margin-bottom: 12px; }

.tag-tree { list-style: none; padding: 0; margin: 0; }
.tag-tree .tag-row { --toggle-width: 24px; padding-inline-start: var(--tag-indent); }
.tag-tree .tag-row > button:not(.manage-tag):not(.tag-toggle) {
  min-width: 0;
  padding-inline-start: 2px;
}
.tag-tree .tag-tree .tag-row > button:not(.tag-toggle) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-tree .tag-leaf::before { content: ""; flex: 0 0 var(--toggle-width); }
.tag-tree .tag-toggle {
  flex: 0 0 var(--toggle-width);
  width: var(--toggle-width);
  align-self: stretch;
  display: grid;
  place-items: center;
  padding: 0;
  color: #50655a;
}
.tag-toggle::before {
  content: "";
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 1.5px 1.5px 0 0;
  transform: rotate(45deg);
}
.tag-toggle[aria-expanded="true"]::before { transform: rotate(135deg); }
@media (pointer: coarse) {
  .tag-tree .tag-row { --toggle-width: 34px; min-height: 40px; }
}


.note-actions { position: relative; margin-left: auto; }
.note-actions summary {
  cursor: pointer; list-style: none; text-align: center;
  min-width: 36px; line-height: 36px; border-radius: 6px; color: var(--sub);
  font-size: 20px;
}
.note-actions summary::-webkit-details-marker { display: none; }
.note-actions[open] summary, .note-actions summary:hover { background: #edf1ef; }
.note-choices {
  position: absolute; z-index: 2; top: 100%; right: 0;
  width: 100px; padding: 4px;
}
.note-choices .trash-note, .note-error { color: #923d35; }
@media (pointer: coarse) {
  .note-actions summary, .note-choices button { min-width: 44px; min-height: 44px; }
}

#trash-controls { border: 0; padding: 0; margin: 10px 0; min-width: 0; }
#trash-controls .danger, #empty-trash { color: #923d35; }
#trash-list article button + button { margin-left: 8px; }

.rich-input.ql-container { border: 1px solid var(--edge); border-radius: 8px; font: inherit; }
.rich-input:focus-within { outline: 2px solid var(--green); outline-offset: 1px; }
.rich-input .ql-editor { min-height: 6em; padding: 10px 12px; font: inherit; }
.rich-input .ql-editor p { margin: 0; font: inherit; line-height: 1.55; }
.writing-tools { padding: 0; border: 0; margin: 8px 0; min-width: 0; }
.format-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.format-controls select, .image-picker { font: inherit; font-size: 13px; border: 1px solid var(--edge); border-radius: 6px; padding: 5px 7px; margin: 0; background: white; color: inherit; }
.image-picker { cursor: pointer; }
.ink-red { color: #ab3836; } .ink-blue { color: #245eb2; } .ink-green { color: #237347; } .ink-gray { color: #606a66; }
.weight-light { font-weight: 300; }
.ql-size-small { font-size: .85em; } .ql-size-large { font-size: 1.4em; } .ql-size-huge { font-size: 1.8em; }
.note-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.note-images > div { position: relative; }
.note-images img { display: block; max-width: 100%; width: 120px; height: 100px; object-fit: contain; background: #f2f4f2; border-radius: 6px; }
.note-images .view-image { padding: 0; border: none; background: transparent; cursor: zoom-in; }
.note-content:has(.note-text[hidden]) > .note-images { display: none; }
.note-images .remove-image { position: absolute; right: 2px; top: 2px; border-radius: 50%; background: white; }

.library-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.library-heading h1 { margin: 0; }
#load-shell-update { align-self: flex-start; }
#tag-search {
  display: flex; align-items: center; gap: 5px; width: min(100%, 245px); height: 32px;
  padding-inline: 10px 6px; border-radius: 16px; background: #ebeeeb; color: var(--sub);
}
#tag-search:focus-within { outline: 2px solid #689780; outline-offset: 1px; }
#tag-search svg { flex: none; width: 15px; height: 15px; }
#note-query {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0;
  background: transparent; color: var(--ink); font-size: 13px;
}
#note-query::-webkit-search-cancel-button { display: none; }
#source-filter {
  flex: none; max-width: 7em; padding-inline-start: 6px; border: 0; border-inline-start: 1px solid var(--edge);
  color: inherit; background: transparent; font-size: 12px;
}
#clear-query { flex: none; padding: 0; width: 22px; height: 26px; color: inherit; font-size: 16px; }

@media (min-width: 651px) {
  .mac-desktop .library-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 2.07fr); }
  body:not(.installed-notebook):has(#library:not([hidden])) {
    height: 100dvh; display: flex; flex-direction: column;
  }
  body:not(.installed-notebook) main.wrap:has(#library:not([hidden])),
  body:not(.installed-notebook) #library {
    flex: 1; min-height: 0; display: flex; flex-direction: column;
  }
  body:not(.installed-notebook) main.wrap:has(#library:not([hidden])) { padding-block: 18px 10px; }
  body:not(.installed-notebook) .library-layout { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  body:not(.installed-notebook) .tag-nav,
  body:not(.installed-notebook) .tag-page { max-height: 100%; overflow-y: auto; overscroll-behavior-y: contain; }
  body:not(.installed-notebook) .tag-page { padding: 2px 4px 12px; }
  #status:empty { margin: 0; }
}

#history-books { padding: 0; border: 0; max-height: 42dvh; overflow-y: auto; }
#history-books label { display: flex; align-items: center; gap: .7rem; margin: 0; padding: .65rem .25rem; border-bottom: 1px solid var(--edge); }
#history-books input { flex: none; width: 1.1rem; height: 1.1rem; }
#history-books span { flex: 1; overflow-wrap: anywhere; }
#history-books small { white-space: nowrap; color: var(--sub); }
#history-status { min-height: 1.4em; }

#history-catalog-status:empty { display: none; }
#history-query { margin-bottom: .5rem; }

@media (any-pointer: coarse) {
  .tag-link, #path-preview { -webkit-user-select: none; user-select: none; }
}
#full-tag-path { white-space: normal; overflow-wrap: anywhere; line-height: 1.6; }
.installed-notebook .library-heading { flex-wrap: nowrap; justify-content: flex-start; gap: 12px; }
.installed-notebook main.wrap:has(#library:not([hidden])) { padding-top: 16px; }
#tag-drawer .tag-sort-control { color: #646a66; }
#open-tags { width: 44px; height: 44px; border: 1px solid var(--edge); border-radius: 50%; background: white; color: var(--ink); font-size: 20px; }
.installed-notebook .library-layout { grid-template-columns: minmax(0, 1fr); }
.installed-notebook {
  --drawer-width: min(80vw, 380px);
  --drawer-motion: 240ms cubic-bezier(.22, .72, .24, 1);
}
.installed-notebook main.wrap { overflow-x: clip; }
.installed-notebook #library, .installed-notebook #new-note-bar {
  transition: transform var(--drawer-motion);
}
.installed-notebook:has(#tag-drawer[open]) :is(#library, #new-note-bar) {
  transform: translateX(var(--drawer-drag, var(--drawer-width)));
}
#library[hidden] + #new-note-bar { display: none; }
#tag-drawer {
  box-sizing: border-box; margin: 0; inset: 0 auto 0 0; width: var(--drawer-width);
  height: 100%; max-height: 100%; max-width: none; overflow-y: auto; overscroll-behavior: contain;
  border: 0; border-right: 1px solid #e0e4e1; border-radius: 0; padding: 20px 14px;
  background: #f8f8f8; color: #343735; box-shadow: none; color-scheme: light;
  clip-path: inset(0 100% 0 0);
  transition: clip-path var(--drawer-motion), display var(--drawer-motion) allow-discrete,
    overlay var(--drawer-motion) allow-discrete;
}
#tag-drawer[open] { clip-path: inset(0 calc(100% - var(--drawer-drag, 100%)) 0 0); }
.installed-notebook:has(#library:not([hidden])):not(:has(dialog[open])), #tag-drawer, #tag-drawer::backdrop {
  touch-action: pan-y pinch-zoom;
}
.installed-notebook.dragging-drawer { --drawer-motion: 0s linear; }
@starting-style {
  #tag-drawer[open] { clip-path: inset(0 100% 0 0); }
}
#tag-drawer::backdrop { background: transparent; }
@media (prefers-reduced-motion: reduce) {
  .installed-notebook { --drawer-motion: 0s linear; }
}
#drawer-profile {
  display: grid; align-items: center; grid-template-columns: auto minmax(0,1fr) auto auto;
  grid-template-areas: "avatar who action close" "avatar brand action close";
  column-gap: 7px; padding: 4px 0 16px; margin-bottom: 12px; border-bottom: 1px solid #e4e6e5;
}
#drawer-profile .identity, #drawer-profile #account { display: contents; }
#drawer-profile .identity b {
  grid-area: avatar; display: grid; place-items: center; width: 40px; height: 40px;
  padding: 0; border-radius: 50%; background: #e7eee9; color: #476551; font-size: 18px;
}
#drawer-profile .identity span { grid-area: brand; font-size: 12px; font-weight: 400; color: #676c69; }
#drawer-profile #who {
  grid-area: who; min-width: 0; font-size: 16px; font-weight: 650;
  line-height: 1.25; overflow-wrap: anywhere;
}
#drawer-profile #logout, #drawer-profile #close-drawer {
  min-height: 44px; border: 0; border-radius: 22px; background: #fff; color: #505652;
}
#drawer-profile #logout { grid-area: action; padding: 0 10px; font-size: 13px; white-space: nowrap; }
#drawer-profile #close-drawer { grid-area: close; }
#drawer-activity { margin: 0 6px 22px; }
.activity-totals { display: flex; align-items: start; justify-content: space-between; margin: 0 0 14px; }
.activity-totals button { display: flex; flex-direction: column; align-items: flex-start; min-width: 44px; min-height: 48px; padding: 0; text-align: start; }
.activity-totals button:active { opacity: .68; }
.activity-totals span, #activity-months { color: #656d67; font-size: 12px; }
.activity-totals strong { margin: 0; color: #555d57; font-size: 24px; font-weight: 650; line-height: 1.25; font-variant-numeric: tabular-nums; }
#activity-grid, #activity-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
#activity-grid { grid-auto-flow: column; grid-template-rows: repeat(7, auto); }
.activity-cell { display: block; font-size: 0; line-height: 0; overflow: hidden; padding: 0; min-width: 0; border: 0; aspect-ratio: 1; background: #ebeeec; border-radius: 3px; }
.activity-cell[data-level="1"], #month-picker [data-level="1"], #overview-dates [data-level="1"] { background: #d6e9dc; }
.activity-cell[data-level="2"], #month-picker [data-level="2"], #overview-dates [data-level="2"] { background: #aad4b8; }
.activity-cell[data-level="3"], #month-picker [data-level="3"], #overview-dates [data-level="3"] { background: #75b48d; }
.activity-cell[data-level="4"] { background: #448860; }
.activity-cell[aria-current="date"] { box-shadow: inset 0 0 0 1.5px #539673; }
.activity-cell[data-selected="true"] { outline: 2px solid #315c46; outline-offset: 1px; }
.activity-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
#activity-selection { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 6px; margin-top: 8px; font-size: 13px; }
#open-activity-day { color: var(--green); min-height: 44px; padding: 0 6px; font-weight: 600; }
#activity-page header { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
#activity-page h2 { margin: 0; font-size: 19px; }
#close-activity-day { width: 44px; height: 44px; border-radius: 50%; font: 28px/1 system-ui; background: white; }
#activity-title { min-height: 44px; padding: 0 4px; font: inherit; color: inherit; }
#activity-title::after { content: ""; width: 6px; height: 6px; margin: 0 2px 3px 3px; border: solid var(--sub); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
#month-picker { width: min(360px, calc(100% - 28px)); max-height: 90dvh; padding: 16px; border: 0; border-radius: 18px; background: #fff; color: var(--ink); }
#month-picker::backdrop { background: #16291d48; }
#month-picker header, .month-navigation { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#month-picker h2 { margin: 0; font-size: 18px; }
#month-picker header button, .month-navigation button { width: 44px; height: 44px; font-size: 23px; }
#calendar-month { width: auto; max-width: 60%; text-align: center; border: 0; font: inherit; font-weight: 600; }
.calendar-week, .month-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; gap: 3px; }
.calendar-week { margin: 10px 0 6px; color: var(--sub); font-size: 12px; }
.month-days button {
  display: grid; grid-template-rows: 1.25em 14px; place-content: center; justify-items: center; gap: 1px;
  min-width: 0; min-height: 44px; padding: 0; border-radius: 9px; font-variant-numeric: tabular-nums; line-height: 1.25;
}
.calendar-note-count { font-size: 11px; line-height: 14px; font-weight: 500; }
.month-days .has-notes { color: #133621; font-weight: 650; }
#month-picker [data-level="4"], #overview-dates [data-level="4"] { background: #39764f; color: white; }
#calendar-dates .selected { box-shadow: inset 0 0 0 2px #45765a; }
#calendar-dates .selected[data-level="4"] { box-shadow: inset 0 0 0 2px #294c36, inset 0 0 0 3px white; }
#month-picker button:disabled { opacity: .32; }
#calendar-dates .outside-range:enabled { opacity: .48; }
.calendar-key {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 4px;
  margin: 12px 0 0; padding: 0; list-style: none; color: #42634d; font-size: 12px;
}
.calendar-key button {
  min-height: 44px; min-width: 44px; padding: 0 5px; gap: 4px; border-radius: 8px; white-space: nowrap;
}
.calendar-key button[aria-pressed="true"] { background: #e9f2ed; box-shadow: inset 0 0 0 1.5px #45765a; }
.calendar-key [data-level] { width: 10px; height: 10px; border-radius: 2px; }
#activity-count { margin-inline-start: auto; color: var(--sub); }
#activity-page, #activity-results { touch-action: pan-y pinch-zoom; }
#activity-results { min-height: 0; overflow-y: auto; padding: 0 14px 16px; }
#activity-results .note { margin-bottom: 10px; }
#activity-empty { margin: 12px 18px; }
#activity-months { margin-top: 6px; text-align: center; white-space: nowrap; }
#drawer-home { margin-bottom: 16px; }
#drawer-home button, #close-drawer { background: transparent; border: 0; color: inherit; min-height: 44px; }
#drawer-home button { width: 100%; justify-content: flex-start; border-radius: 8px; text-align: start; padding: 0 10px; }
#close-drawer { min-width: 44px; font-size: 24px; }
#tag-drawer .tag-nav { border: 0; border-radius: 0; padding: 0; background: transparent; color: inherit; }
#tag-drawer .tag-nav-head { margin: 0; }
#tag-drawer .tag-nav h2, #tag-drawer .pinned-tags h3 { font-size: 14px; color: #666c68; }
#tag-drawer .tag-nav button { color: inherit; }
#tag-drawer #tag-list { max-height: none; overflow: visible; }
#tag-drawer .tag-row { position: relative; min-height: 44px; }
#tag-drawer .tag-row:hover, #tag-drawer .tag-row:has(:focus-visible) { background: #edf0ee; }
#drawer-home [aria-current="page"], #tag-drawer .tag-row:has([aria-current="page"]) { background: #e5ede8; color: #294e39; }
#tag-drawer .tag-row .tag-link { flex: 1; min-width: 0; width: auto; padding: 10px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tag-drawer .tag-row .tag-toggle { order: 1; flex-basis: 36px; color: #626b65; }
#tag-drawer .tag-row-end { order: 2; display: inline-flex; }
#tag-drawer .tag-row .tag-count, #tag-drawer .tag-row .manage-tag { opacity: 1; color: #626b65; }
#tag-drawer .manage-tag { min-height: 44px; }
#tag-drawer .manage-tag:hover { background: #e1e6e2; }
#tag-drawer .tag-leaf::before { content: none; }
#tag-drawer .tag-tree .tag-tree .tag-row::after {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: calc(var(--tag-indent) - 6px);
  width: 1px; background: #dce0dd; pointer-events: none;
}
#tag-drawer #open-history, #tag-drawer #open-trash { min-height: 44px; border-color: #e0e4e1; }

/* The installed app keeps the list scrollable behind its compact writing entry. */
.installed-notebook #library { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
#new-note-bar {
  position: fixed; z-index: 2; inset-inline: 16px; bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 36rem); margin-inline: auto; height: 44px;
  display: flex; justify-content: flex-start; align-items: center; gap: 10px; padding: 0 16px; border-radius: 24px;
  border: 1px solid var(--edge); background: #fff; box-shadow: 0 3px 18px #172b2024;
  text-align: start; color: var(--sub); font: inherit;
}
#new-note-bar span:first-child { color: var(--green); font-size: 22px; }
.writing-sheet {
  position: fixed; inset: auto 0 0; margin: 0 auto; box-sizing: border-box;
  width: min(100%, 40rem); max-width: 100%; max-height: 94dvh; padding: 12px 16px;
  overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--edge);
  border-radius: 20px 20px 0 0; background: white; color: var(--ink);
}
.writing-sheet::backdrop { background: #19221c75; backdrop-filter: blur(5px); }
#compose-sheet { bottom: 8px; width: min(calc(100% - 16px), 40rem); border-radius: 18px; }
.writing-sheet .sheet-back {
  border: 0; border-radius: 50%; background: #f0f3f1; color: var(--sub);
  font: 20px/1 sans-serif; width: 34px; height: 34px; padding: 0;
}
#compose-sheet > .sheet-back {
  display: block; margin: -10px auto 0; width: 60px; height: 24px; position: relative;
  background: transparent; font-size: 0;
}
#compose-sheet > .sheet-back::after {
  content: ""; position: absolute; inset: 9px 14px auto; height: 4px; border-radius: 2px; background: #bfcac3;
}
.writing-sheet form { border: 0; padding: 0; margin: 0; }
.writing-sheet .rich-input { border: 0; outline: 0; }
.writing-sheet .rich-input .ql-editor { padding: 6px 0; min-height: clamp(72px, 15dvh, 140px); }
.writing-sheet .tag-context { margin: 0 0 4px; }
.writing-sheet label, .writing-sheet .field-label { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
.writing-sheet .writing-tools { margin: 4px 0; }
.writing-sheet .actions { justify-content: flex-end; margin: 4px 0 0; }
.writing-sheet small:empty { display: none; }
#edit-sheet { height: 94dvh; }
#edit-sheet[open], #edit-sheet-content, #edit-sheet .card-editor { display: flex; flex-direction: column; }
#edit-sheet-content, #edit-sheet .card-editor, #edit-sheet .rich-input { flex: 1; }
#edit-sheet > header { justify-content: flex-start; align-items: center; gap: 10px; margin: 0 0 12px; }
#edit-sheet time { color: var(--sub); font-size: 13px; }
#edit-sheet .ql-editor { height: auto; }

.writing-sheet .format-controls select { width: auto; }
#compose-sheet form { display: flex; flex-direction: column; }
#compose-sheet .writing-tools { margin: 0; }
#compose-sheet .rich-input .ql-editor { max-height: 40dvh; overflow-y: auto; }
#edit-sheet-content, #edit-sheet .card-editor, #edit-sheet .rich-input { min-height: 0; }
#edit-sheet .rich-input { min-height: 5em; }
#edit-sheet .ql-editor { height: 100%; overflow-y: auto; }
#edit-sheet .writing-tools, #edit-sheet .actions { flex: none; }
#edit-sheet .editing-images:not(:empty) { max-height: 18dvh; overflow-y: auto; }
#edit-sheet section:not([hidden]) { max-height: 26dvh; overflow-y: auto; }
#edit-sheet-tag { margin: 0; }

.image-picker svg { display: none; }
.writing-sheet form > .hint { order: 1; }
.writing-sheet form > .actions {
  order: 2; display: flex; flex-flow: row nowrap; align-items: center; justify-content: flex-start;
  gap: 4px; margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--edge);
}
.writing-sheet .actions .insert-tag, .writing-sheet .actions .image-picker, .writing-sheet .more-tools, .writing-sheet .actions .primary {
  display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0;
  flex: 0 0 44px; height: 44px; border: 0; border-radius: 14px; background: transparent; color: var(--sub);
}
.writing-sheet .actions .image-picker, .writing-sheet .actions .primary { font-size: 0; }
.writing-sheet .image-picker svg { display: block; width: 22px; height: 22px; }
.writing-sheet .more-tools { font-size: 24px; line-height: 1; }
.writing-sheet .more-tools[aria-expanded="true"] { color: var(--green); background: #edf4ef; }
.writing-sheet .actions .primary { margin-inline-start: auto; color: white; background: var(--green); border-radius: 50%; }
.writing-sheet .actions .primary::before {
  content: ""; width: 15px; height: 8px; border: solid currentColor; border-width: 0 0 2px 2px;
  transform: translateY(-2px) rotate(-45deg);
}
.writing-sheet .format-controls { padding-block: 6px; gap: 6px; }
.writing-sheet .format-controls .cancel { margin-inline-start: auto; }
.writing-sheet .writing-tools:has(.format-controls[hidden]):has(.editing-images:empty) { margin: 0; }

.writing-sheet .insert-tag { font: 500 23px/1 system-ui, sans-serif; }
#body-tag-picker { width: min(30rem, calc(100vw - 24px)); padding: 16px; }
#body-tag-results { margin-top: 8px; max-height: 43dvh; overflow-y: auto; overscroll-behavior: contain; color: var(--sub); }
.writing-sheet .inline-tag-results {
  max-height: min(24dvh, 11rem); overflow-y: auto; overscroll-behavior: contain;
  border-top: 1px solid var(--edge); color: var(--sub);
}
#body-tag-results button, .writing-sheet .inline-tag-results button {
  display: block; width: 100%; min-height: 44px; padding: 8px 6px; border: 0; border-bottom: 1px solid var(--edge);
  background: transparent; color: var(--ink); text-align: start; overflow-wrap: anywhere;
}

#open-search, #close-search {
  display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px;
  border: 1px solid var(--edge); border-radius: 50%; color: var(--ink); background: #fff;
}
#open-search { margin-inline-start: auto; }
#open-search svg, .search-field svg { width: 21px; height: 21px; }
#search-page, #activity-page, #activity-overview {
  position: fixed; inset: 0; box-sizing: border-box; width: 100%; max-width: none;
  height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0;
  background: #fafbf9; overscroll-behavior: contain;
}
#search-page[open], #activity-page[open] { display: flex; flex-direction: column; }
#activity-overview { padding: 14px 18px 24px; color: var(--ink); overflow-y: auto; }
#activity-overview header { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; margin-bottom: 22px; }
#close-overview { width: 44px; height: 44px; border-radius: 50%; background: #eef1ed; font-size: 24px; }
.overview-tabs { display: flex; justify-self: center; background: #e9ede9; padding: 3px; border-radius: 24px; }
.overview-tabs button { min-width: 66px; min-height: 44px; border-radius: 22px; color: var(--sub); }
.overview-tabs [aria-pressed="true"] { background: white; color: var(--ink); font-weight: 650; }
#overview-period { margin: 0; font-size: 20px; }
#overview-summary { margin: 6px 0 18px; text-align: center; color: var(--sub); font-size: 14px; }
#overview-dates button { min-height: 48px; background: #ecf0ec; }
#overview-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#overview-months button { display: grid; gap: 4px; min-height: 68px; justify-items: center; align-content: center; border-radius: 10px; background: #edf2ed; }
#overview-months small { color: var(--sub); }
#activity-overview button:disabled { opacity: .38; }
#search-top { flex: none; display: flex; gap: 8px; align-items: center; margin: 0; padding: 12px 16px 4px; }
.search-field {
  display: flex; align-items: center; flex: 1; min-width: 0; border-radius: 24px; padding-inline: 14px;
  border: 1px solid var(--edge); color: var(--sub); background: white;
}
.search-field:focus-within { border-color: var(--green); }
#mobile-query { flex: 1; min-width: 0; height: 44px; padding-inline: 8px; border: 0; outline: 0; background: transparent; font: inherit; }
#close-search { font: 26px/1 system-ui; }
.search-content { min-height: 0; overflow-y: auto; padding: 0 16px 24px; }
#search-scope, #result-count { color: var(--sub); font-size: 13px; overflow-wrap: anywhere; }
.search-content h2 { font-size: 14px; color: var(--sub); margin: 18px 0 8px; }
.search-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.search-chips button { max-width: 100%; min-height: 44px; padding: 6px 12px; border: 0; border-radius: 12px; background: #eef1ee; color: var(--ink); font: inherit; overflow-wrap: anywhere; }
.search-chips button[aria-pressed=true] { color: white; background: var(--green); }
#recent-searches header { margin: 14px 0 8px; align-items: center; }
#recent-searches h2 { margin: 0; }
#search-results .note { margin-bottom: 10px; }
:is(#notes, #search-results) .note-text mark {
  background: #f7e2a6;
  color: inherit;
  border-radius: 0.18em;
}
#search-results .excerpt-toggle {
  display: block; min-height: 44px; padding: 0 6px 0 0; border: 0;
  background: transparent; color: var(--green); font: inherit; cursor: pointer;
}
:is(#notes, #search-results) mark.current-hit {
  background: #ffd067; color: #302008; outline: 2px solid #8a5609;
}
.hit-navigation {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--edge); background: white; color: var(--sub); font-size: 13px;
}
.hit-navigation button {
  min-width: 44px; min-height: 44px; padding: 0 8px; border: 0;
  background: transparent; color: #87958e; font: inherit; font-size: 14px;
}
.hit-navigation button:enabled:active, .hit-navigation button:focus-visible { color: var(--green); }
.hit-navigation button:disabled { opacity: 0.4; }

.hit-navigation .hit-counter {
  margin-inline-end: auto; padding-inline: 0 8px; color: var(--sub);
  font-size: inherit; font-variant-numeric: tabular-nums;
}
#hit-jump { width: min(20rem, calc(100vw - 32px)); }
#hit-jump .actions { display: flex; justify-content: flex-end; gap: 8px; }
#hit-jump .actions button { min-height: 44px; }
#hit-jump-error:empty { display: none; }

:is(#weread-settings, #external-settings, #craft-settings) { width: min(410px, 92vw); max-height: 88dvh; overflow-y: auto; padding: 20px; border: 1px solid var(--edge); border-radius: 16px; }
:is(#weread-settings, #external-settings, #craft-settings) header, #weread-commands { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
:is(#weread-settings, #external-settings, #craft-settings) h2 { margin: 0; font-size: 20px; }
#weread-form { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
#weread-form label, #weread-key { grid-column: 1 / -1; }
#weread-key { min-width: 0; padding: 10px; border: 1px solid var(--edge); border-radius: 8px; }
#weread-official { color: var(--green); }
:is(#weread-settings, #external-settings, #craft-settings) button, #tag-drawer #open-external { min-height: 44px; }
#weread-last, #weread-message { color: var(--sub); font-size: 14px; }

.craft-original { margin: 1em 0; }
.craft-original p { white-space: pre-wrap; overflow-wrap: anywhere; }

.craft-document { line-height: 1.6; overflow-wrap: anywhere; }
.craft-document p { margin: .5em 0; white-space: normal; }
.craft-document h1, .craft-document h2, .craft-document h3 { line-height: 1.3; margin: .8em 0 .4em; }
.craft-document .craft-callout { margin: .45em 0; padding: .55em .9em; border-radius: .5em; background: #f2f4f2; }
.craft-document .craft-callout > :first-child { margin-top: 0; }
.craft-document .craft-callout > :last-child { margin-bottom: 0; }
.craft-document blockquote { margin: .4em 0; padding-left: .75em; border-left: 3px solid #b1b9ac; }
.craft-document details { margin: .45em 0; padding: .4em .75em; border: 1px solid #d9dfd9; border-radius: .5em; }
.craft-document summary { cursor: pointer; font-weight: 600; }
.craft-document small { color: #58635d; }
.craft-document pre { white-space: pre-wrap; background: #f4f4f3; padding: .65em; }
.craft-document a { color: #235b78; text-decoration: underline; }
.craft-document mark { color: inherit; background: #fff0a7; }
.craft-document .craft-brown { background: #eddbc0; }
.craft-document .craft-green { background: #d5ead0; }
.craft-document .craft-blue { background: #cfe3f4; }
.craft-document .craft-purple { background: #e4d7f1; }
.craft-document .craft-pink, .craft-document .craft-red { background: #f4d3d6; }
.craft-document .craft-orange { background: #ffdfbc; }
.craft-document .note-images { display: block; margin: .6em 0; }
.craft-document .view-image img { width: auto; max-width: 100%; max-height: 24rem; height: auto; object-fit: contain; }

#external-settings > button { display: block; width: 100%; margin-top: 8px; text-align: left; }
#craft-form { display: grid; gap: 8px; }
#craft-form input { min-width: 0; padding: 10px; border: 1px solid var(--edge); border-radius: 8px; }
#craft-form .primary { justify-self: end; }
#craft-last, #craft-message, #external-account { font-size: 14px; color: var(--sub); }

.filing { flex: none; text-align: center; padding: 4px; font-size: 12px; }
.filing a { color: var(--sub); }
.installed-notebook .filing { display: none; }
