:is(.action-link, .reading-account-link, [id="shelf-back"]):not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: .45rem .65rem;
  border: 1px solid #e9cea1;
  border-radius: .65rem;
  background: #ffedc4;
  color: #432c17;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

:is(.action-link, .reading-account-link, [id="shelf-back"]):hover {
  border-color: #b89546;
}

:is(.action-link, .reading-account-link, [id="shelf-back"]):focus-visible {
  outline: 2px solid #765016;
  outline-offset: 2px;
}

.header-inner:has(#library-admin) {
  max-width: none;
  padding-inline: clamp(.85rem, 3vw, 2rem);
}

.header-inner:has(#library-admin) .reading-account-link {
  white-space: nowrap;
}

.header-inner:has(#library-admin) .reading-account-link[href='/account.html'] {
  margin-inline-start: auto;
}

@media (max-width: 440px) {
  .header-inner:has(#library-admin) {
    gap: .4rem;
    padding-inline: .7rem;
  }

  .header-inner:has(#library-admin) .brand-logo {
    width: 2.6rem;
    height: 2.6rem;
  }

  .header-inner:has(#library-admin) .reading-account-link {
    padding-inline: .45rem;
    font-size: .875rem;
  }
}
.account-page { margin: 0; min-height: 100vh; background: #fff5d9; color: #432c17; font: 1rem/1.5 system-ui, "Microsoft YaHei", sans-serif; }
.account { width: min(43rem, calc(100% - 2rem)); margin: 2rem auto; }
.account.login { max-width: 22rem; }
.account section, .account.login { box-sizing: border-box; background: #fffaf0; border: 1px solid #e9cea1; border-radius: 1rem; padding: 1.25rem; margin-bottom: 1.25rem; }
.account h1, .account h2 { margin: 0 0 .65rem; }
.account-header, .account li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.account-header { margin-bottom: 1.25rem; }
.account-header a[href="/"] { margin-bottom: .45rem; }
.account-header p, .notice { margin: .25rem 0; }
.account form { display: grid; gap: .75rem; }
.account label { display: grid; gap: .25rem; }
.account input, .account button { box-sizing: border-box; font: inherit; padding: .55rem .7rem; border-radius: .6rem; border: 1px solid #9a713f; color: inherit; }
.account input { width: 100%; max-width: 24rem; background: white; }
.account button { justify-self: start; font-weight: 700; background: #ffedc4; cursor: pointer; }
.account button:disabled { cursor: wait; opacity: .65; }
.account ul { list-style: none; padding: 0; }
.account li { padding: .65rem 0; border-bottom: 1px solid #eadbc1; }
.account li form { display: flex; gap: .35rem; flex-wrap: wrap; }
.account li form input { width: 10rem; }
.account .notice { color: #8b331f; }

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
}
.history-heading h2 { margin: 0; }
.history-dates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: .5rem;
}
#history-panel details { margin: .55rem 0; }
#history-panel summary {
  padding: .55rem .65rem;
  background: #fff6df;
  border-radius: .5rem;
  cursor: pointer;
}
#history-panel .history-book > ul {
  margin-block: .35rem .55rem;
}
#history-panel li {
  justify-content: flex-start;
  gap: .2rem .65rem;
  padding-block: .22rem;
  font-size: .875rem;
}
#history-panel li a {
  color: #784415;
  text-underline-offset: .15em;
}
#history-panel li a:focus-visible {
  outline: 2px solid #765016;
  outline-offset: 2px;
}
#history-panel li time {
  color: #675639;
}
#history-panel li .history-delete {
  margin-inline-start: auto;
  padding: .12rem .42rem;
}
#history-panel .history-delete { color: #9e2a26; }
#history-panel:not(.history-editing) .history-delete { display: none; }
#delete-history { margin-block: .75rem; }
#delete-history select, #delete-history input { min-width: 0; max-width: 100%; }

.shelf-breadcrumb {
  --capsule-height: 22px;
  --capsule-overlap: .95rem;
  --capsule-seam-gap: 8px;
  --capsule-cut-width: 2px;
  --capsule-cut: #fffdf6;
  min-inline-size: 0;
  margin-block: 0 .7rem;
  color: var(--muted, #675639);
}

.shelf-layout:not(:has(> .sibling-nav:not([hidden]))) {
  grid-template-columns: minmax(0, 1fr);
}

.shelf-breadcrumb ol {
  display: flex;
  align-items: center;
  inline-size: max-content;
  max-inline-size: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-block: .1rem;
  padding-inline: 0;
  margin: 0;
  list-style: none;
}

.shelf-breadcrumb li {
  --capsule-fill: #ffcb42;
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-inline-size: 3rem;
  position: relative;
  border-radius: 999px;
  background: var(--capsule-fill);
}

.shelf-breadcrumb li:first-child {
  --capsule-fill: #ffda70;
  flex: none;
}

.shelf-breadcrumb li:has(.chapter-crumb) {
  flex: none;
}

.shelf-breadcrumb li[hidden] {
  display: none;
}

.shelf-breadcrumb li + li {
  margin-inline-start: calc(-1 * var(--capsule-overlap));
  box-shadow: calc(-1 * var(--capsule-cut-width)) 0 0 var(--capsule-cut);
}

.shelf-breadcrumb .shelf-crumb {
  display: inline-block;
  box-sizing: border-box;
  min-inline-size: 0;
  block-size: var(--capsule-height);
  max-inline-size: min(19rem, 48vw);
  padding: 0 .75rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #432c17;
  font: inherit;
  font-size: .75rem;
  line-height: var(--capsule-height);
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shelf-breadcrumb li + li .shelf-crumb {
  padding-inline-start: var(--capsule-seam-gap);
}

.shelf-breadcrumb li:has(+ li:not([hidden])) > .shelf-crumb {
  padding-inline-end: calc(var(--capsule-overlap) + var(--capsule-cut-width) + var(--capsule-seam-gap));
}

.shelf-breadcrumb .shelf-crumb:focus-visible {
  outline: 2px solid #765016;
  outline-offset: -3px;
}

.shelf-breadcrumb li:has(a:hover, select:not(:disabled):hover) {
  background: #ffdb75;
}

.shelf-breadcrumb li[aria-current='page'],
.shelf-breadcrumb li:has(.chapter-crumb) {
  --capsule-fill: #f8bb20;
}

.shelf-breadcrumb select.shelf-crumb {
  appearance: none;
  padding-inline-end: 1.2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right .64rem center, right .39rem center;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.reader-heading:has(.reader-breadcrumb) {
  flex-wrap: wrap;
}

.reader-heading .reader-breadcrumb {
  flex: 1 1 14rem;
  margin: 0;
}

.shelf #shelf-title,
.reader-heading:has(.reader-breadcrumb) > h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.compact-reader {
  grid-template-columns: minmax(0, 1fr);
  box-shadow: none;
}

.reader-view .workspace {
  --reader-edge-gap: 1rem;
  padding-block: var(--reader-edge-gap) max(var(--reader-edge-gap), env(safe-area-inset-bottom, 0px));
}

@media (max-width: 800px) {
  .reader-view .workspace {
    --reader-edge-gap: .85rem;
  }
}

.reader-view > .topbar .header-inner {
  height: 40px;
  gap: .45rem;
}

.reader-view > .topbar .brand-logo {
  width: 32px;
  height: 32px;
}

.reader-view > .topbar .sample-label {
  font-size: .75rem;
}

@media (max-width: 590px) {
  .reader-view .workspace > .sibling-toggle {
    inset-block-start: 9px;
    inset-inline-start: calc(.85rem + 32px + .45rem);
  }

  .reader-view .workspace > .sibling-nav[popover] {
    inset-block-start: 2.75rem;
    max-height: calc(100dvh - 3.6rem);
  }
}

.compact-reader :is(.reader-heading, .transport) {
  gap: .3rem;
  padding: .32rem .43rem;
}

.compact-reader .transport :is(button, .return-button),
.reader-view :is(.sibling-nav a, .sibling-toggle, .topbar .reading-account-link, .control-card button) {
  box-sizing: border-box;
  min-height: 22px;
  padding: .12rem .37rem;
  border-radius: 999px;
  font-size: .75rem;
  line-height: 1.15;
}

.compact-reader .page-steps {
  flex: none;
  align-items: center;
  gap: .24rem;
}

.compact-reader .speed-control {
  box-sizing: border-box;
  height: 22px;
  padding: 0;
  font-size: .72rem;
}

.compact-reader .speed-control span {
  display: none;
}

.compact-reader .speed-control select {
  min-height: 20px;
  inline-size: 3.15rem;
  padding: .1rem .59rem;
  background-position: right .46rem center, right .25rem center;
  background-size: 4px 4px;
  text-align: center;
  text-align-last: center;
  font-variant-numeric: tabular-nums;
}

.compact-reader .jump-button {
  gap: .25rem;
}

.compact-reader :is(.jump-position, .jump-label, .audio-note, .audio-error) {
  font-size: .75rem;
}

.compact-reader .page-zoom-tools {
  gap: .2rem;
}

.compact-reader .page-zoom-tools button {
  min-height: 18px;
  min-width: 18px;
  padding: .05rem .23rem;
  font-size: .72rem;
  line-height: 1.12;
}

.compact-reader .page-zoom-tools .page-zoom-value {
  min-width: 2rem;
}

.history-group-contents {
  padding-inline-start: clamp(.4rem, 2vw, .85rem);
  border-inline-start: 1px solid #e9cea1;
}

#history-panel .history-group > summary {
  background: #f6e6bd;
}
