:root {
    --bg: #f0e2c8;
    --ink: #1d160d;
    --folio: #7c705c;
    --font: Canela, 'Iowan Old Style', 'New York', Charter, Georgia, serif;
    --fs: 17.5px;
    --lh: 1.55;
    --ls: 0em;
    --ws: 0em;
    --fw: 500;
    --h: 400px;
    --ui: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--ui);
    -webkit-font-smoothing: antialiased;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: default;
}

#stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    touch-action: none;
}

#flow {
    position: absolute;
    left: 0;
    top: 0;
    will-change: transform;
    column-fill: auto;
    font-family: var(--font);
    font-size: var(--fs);
    line-height: var(--lh);
    letter-spacing: var(--ls);
    word-spacing: var(--ws);
    font-weight: var(--fw);
    text-align: left;
    hyphens: none;
    overflow-wrap: break-word;
    text-rendering: optimizeLegibility;
    font-kerning: normal;
    -webkit-text-stroke: 0.35px currentColor;
}

#flow p {
    margin: 0;
    text-indent: 1.1em;
}

#flow h1,
#flow h2,
#flow h3,
#flow h4,
#flow h5,
#flow h6 + p,
#flow h1 + p,
#flow h2 + p,
#flow h3 + p,
#flow h4 + p,
#flow h5 + p {
    text-indent: 0;
}

#flow h1,
#flow h2,
#flow h3,
#flow h4,
#flow h5,
#flow h6 {
    margin: 0;
    padding: 0.9em 0 0.55em;
    font-weight: calc(var(--fw) + 100);
    line-height: 1.2;
    text-align: center;
    break-after: avoid;
}

#flow h1 {
    font-size: 1.75em;
}

#flow h2 {
    font-size: 1.45em;
}

#flow h3 {
    font-size: 1.2em;
}

#flow .chapter {
    break-before: column;
}

#flow .chapter:first-child {
    break-before: auto;
}

#flow blockquote {
    margin: 0.6em 0 0.6em 1.4em;
}

#flow ul,
#flow ol {
    margin: 0.5em 0;
    padding-left: 1.6em;
}

#flow hr {
    border: 0;
    text-align: center;
    margin: 0.9em 0;
}

#flow hr::after {
    content: '* * *';
    letter-spacing: 0.4em;
    color: var(--folio);
}

#flow a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(42, 32, 20, 0.35);
    text-underline-offset: 2px;
}

#flow img,
#flow svg {
    display: block;
    max-width: 100%;
    max-height: var(--h);
    height: auto;
    margin: 0.6em auto;
    break-inside: avoid;
    object-fit: contain;
}

#flow table {
    border-collapse: collapse;
    max-width: 100%;
}

#flow td,
#flow th {
    padding: 0.15em 0.5em;
}

#flow ::selection {
    background: rgba(170, 120, 40, 0.28);
}

.folio {
    position: absolute;
    bottom: 26px;
    transform: translateX(-50%);
    font-size: 11px;
    letter-spacing: 0;
    color: var(--folio);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    user-select: none;
}

#back {
    position: absolute;
    left: 56px;
    bottom: 22px;
    display: flex;
    align-items: center;
    gap: 7px;
    height: 22px;
    color: #3b3329;
    font-size: 13px;
    font-weight: 500;
}

#back[hidden] {
    display: none;
}

#back span {
    color: var(--folio);
}

#bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 14px;
    background: rgba(240, 226, 200, 0.82);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    backdrop-filter: saturate(1.6) blur(18px);
    box-shadow: 0 0.5px 0 rgba(42, 32, 20, 0.14);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 20;
}

#bar.on {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.bar-side {
    display: flex;
    gap: 4px;
}

.bar-side.right {
    justify-content: flex-end;
}

#bar-title {
    max-width: 50vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.size-ctl {
    display: flex;
    align-items: center;
    height: 30px;
    margin-right: 6px;
    border-radius: 15px;
    background: rgba(42, 32, 20, 0.08);
}

.size-ctl button {
    width: 44px;
    height: 30px;
    display: grid;
    place-items: center;
    font-family: var(--font);
    color: #2a2014;
}

.size-ctl button:first-child {
    border-radius: 15px 0 0 15px;
}

.size-ctl button:last-child {
    border-radius: 0 15px 15px 0;
}

.size-ctl button + button {
    box-shadow: -0.5px 0 0 rgba(42, 32, 20, 0.3);
}

.size-ctl button:hover {
    background: rgba(42, 32, 20, 0.07);
}

.size-ctl button:active {
    background: rgba(42, 32, 20, 0.14);
}

.size-ctl button:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.icon {
    width: 36px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    color: #3b3329;
}

.icon:hover {
    background: rgba(42, 32, 20, 0.08);
}

.icon:active {
    background: rgba(42, 32, 20, 0.14);
}

#toc {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 310px;
    max-width: 86vw;
    display: flex;
    flex-direction: column;
    background: rgba(238, 238, 240, 0.9);
    -webkit-backdrop-filter: saturate(1.8) blur(30px);
    backdrop-filter: saturate(1.8) blur(30px);
    color: #1d1d1f;
    transform: translateX(-102%);
    transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 40;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
}

#toc.on {
    transform: none;
}

#toc-head {
    padding: 22px 20px 10px;
    font-size: 20px;
    font-weight: 700;
}

#toc-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px 20px;
}

#toc-list button {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border-radius: 7px;
    text-align: left;
    font-size: 13px;
    line-height: 1.35;
}

#toc-list button:hover {
    background: rgba(0, 0, 0, 0.06);
}

#toc-list button.cur {
    background: rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

#toc-scrim {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
}

#toc-scrim.on {
    display: block;
}

#empty {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--bg);
    z-index: 10;
}

#empty[hidden] {
    display: none;
}

#empty.drag .empty-card {
    transform: scale(1.03);
}

.empty-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    color: #5a4d3a;
    transition: transform 0.2s ease;
}

.empty-card h1 {
    margin: 14px 0 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--ink);
}

.empty-card p {
    margin: 2px 0 14px;
    font-size: 14px;
}

#empty-open {
    height: 30px;
    padding: 0 16px;
    border-radius: 15px;
    background: #2b2b2e;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
}

#empty-open:active {
    background: #000;
}

#sheet {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 11px 12px;
    background: rgba(0, 0, 0, 0.26);
    animation: fade 0.25s ease;
}

#sheet[hidden] {
    display: none;
}

@keyframes fade {
    from {
        opacity: 0;
    }
}

@keyframes rise {
    from {
        transform: translateY(26px);
        opacity: 0;
    }
}

.sheet-panel {
    position: relative;
    width: 704px;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    background: #ececec;
    color: #1d1d1f;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35), 0 0 0 0.5px rgba(0, 0, 0, 0.2);
    animation: rise 0.42s cubic-bezier(0.32, 0.72, 0, 1);
}

.sheet-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 22px);
}

.sheet-view[hidden] {
    display: none;
}

.preview-wrap {
    position: relative;
    flex: none;
    height: 288px;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
}

.sheet-head,
.fonts-head {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 37px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2;
}

.sheet-head h2,
.fonts-head h2 {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0;
    text-align: center;
    font-family: var(--ui);
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
}

.round {
    position: relative;
    width: 37px;
    height: 37px;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.round.light {
    background: rgba(255, 255, 255, 0.62);
    color: #1d1d1f;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

.round.dark {
    background: #2a2a2d;
    color: #fff;
}

.round:active {
    filter: brightness(0.92);
}

.aa {
    position: absolute;
    left: 36px;
    top: 76px;
    font-size: 38px;
    line-height: 1;
    letter-spacing: var(--ls);
}

.preview {
    position: absolute;
    left: 41px;
    right: 41px;
    top: 132px;
    bottom: 0;
    margin: 0;
    column-count: 2;
    column-gap: 22px;
    font-size: 22px;
    line-height: var(--lh);
    letter-spacing: var(--ls);
    word-spacing: var(--ws);
    font-weight: var(--fw);
    -webkit-mask-image: linear-gradient(to bottom, #000 38%, transparent 96%);
    mask-image: linear-gradient(to bottom, #000 38%, transparent 96%);
}

.sheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 20px 0;
}

.sheet-body::-webkit-scrollbar {
    width: 10px;
}

.sheet-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.28);
    border-radius: 5px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.label {
    padding: 3px 20px 7px;
    font-size: 11px;
    color: #86868b;
}

.label:not(:first-child) {
    margin-top: 18px;
}

.card {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
}

.row {
    position: relative;
    width: 100%;
    min-height: 33px;
    display: flex;
    align-items: center;
    padding: 0 20px 0 14px;
    font-size: 13px;
    text-align: left;
}

.row + .row::before {
    content: '';
    position: absolute;
    left: 49px;
    right: 20px;
    top: 0;
    height: 0.5px;
    background: rgba(0, 0, 0, 0.14);
}

.row.flat {
    padding-left: 20px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.14);
    margin: 0 20px;
    width: auto;
    padding: 0;
    min-height: 33px;
}

.ico {
    width: 35px;
    flex: none;
    font-weight: 600;
}

.aa-ico {
    font-family: Georgia, serif;
    font-size: 15px;
}

.bold-ico {
    font-size: 17px;
    margin-left: 2px;
}

.row-t {
    flex: 1;
}

.row-t.first {
    flex: 1;
}

.row-v {
    color: #86868b;
    font-family: var(--font);
    font-size: 14px;
    margin-right: 10px;
}

.chev {
    color: #b0b0b5;
}

#row-font:active {
    background: rgba(0, 0, 0, 0.05);
}

.tg {
    position: relative;
    width: 53px;
    height: 24px;
    flex: none;
    border-radius: 12px;
    background: #e2e2e4;
    transition: background 0.25s ease;
}

.tg i {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 32px;
    height: 20px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.tg[aria-checked='true'] {
    background: #28282b;
}

.tg[aria-checked='true'] i {
    transform: translateX(17px);
}

.group {
    padding: 0 20px;
    transition: opacity 0.25s ease;
}

.group.off {
    opacity: 0.38;
    pointer-events: none;
}

.grp {
    padding: 9px 0 6px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.14);
}

.grp.last {
    border-bottom: 0;
    padding-bottom: 8px;
}

.cap {
    font-size: 11.5px;
    text-transform: uppercase;
    color: #6e6e73;
    letter-spacing: 0.02em;
    margin-bottom: 3px;
}

.srow {
    display: flex;
    align-items: center;
    gap: 22px;
    height: 30px;
}

.sico {
    flex: none;
    width: 24px;
    color: #3a3a3c;
}

.val {
    flex: none;
    width: 44px;
    text-align: right;
    font-size: 13px;
    color: #6e6e73;
    font-variant-numeric: tabular-nums;
}

input[type='range'] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 24px;
    margin: 0;
    background: none;
    outline: none;
}

input[type='range']::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #1f1f22 var(--p, 50%), #e1e1e3 var(--p, 50%));
}

input[type='range']::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 21px;
    height: 15px;
    margin-top: -4.5px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}

input[type='range']::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: #e1e1e3;
}

input[type='range']::-moz-range-progress {
    height: 6px;
    border-radius: 3px;
    background: #1f1f22;
}

input[type='range']::-moz-range-thumb {
    width: 21px;
    height: 15px;
    border: 0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.foot-space {
    height: 20px;
}

.fonts-head {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    margin: 10px 10px 8px;
    flex: none;
    justify-content: flex-start;
}

.fonts-body {
    padding-top: 6px;
}

.font-item {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 38px;
    padding: 0 20px 0 44px;
    font-size: 17px;
    text-align: left;
}

.font-item + .font-item::before {
    content: '';
    position: absolute;
    left: 44px;
    right: 0;
    top: 0;
    height: 0.5px;
    background: rgba(0, 0, 0, 0.14);
}

.font-item:active {
    background: rgba(0, 0, 0, 0.05);
}

.font-item svg {
    position: absolute;
    left: 16px;
    opacity: 0;
}

.font-item.on svg {
    opacity: 1;
}

@media (max-width: 760px) {
    .folio {
        bottom: 20px;
    }

    #back {
        left: 20px;
    }
}