:root {
    --tmb-accent: #f0bf55;
    --tmb-foreground: #171717;
    --tmb-muted: #777;
    --tmb-surface: rgba(248, 248, 250, 0.68);
    --tmb-border: rgba(255, 255, 255, 0.78);
    --tmb-bar-height: 68px;
    --tmb-bar-gap: 10px;
    --tmb-bar-edge: 12px;
}

.tmb-bar {
    display: none;
}

.tmb-dialog:not([open]) {
    display: none;
}

@media (max-width: 639px) {
    html.tmb-bar-visible body {
        padding-bottom: calc(
            var(--tmb-body-padding-before, 0px) + var(--tmb-bar-height) +
                var(--tmb-bar-gap) + 10px + env(safe-area-inset-bottom, 0px)
        ) !important;
    }

    html.tmb-dialog-open,
    html.tmb-dialog-open body {
        overflow: hidden;
    }

    .tmb-bar {
        align-items: stretch;
        -webkit-backdrop-filter: blur(30px) saturate(185%);
        background: var(--tmb-surface);
        backdrop-filter: blur(30px) saturate(185%);
        border: 1px solid var(--tmb-border);
        border-radius: 35px;
        bottom: calc(var(--tmb-bar-gap) + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 14px 42px rgba(15, 18, 24, 0.16),
            0 2px 10px rgba(15, 18, 24, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.78);
        box-sizing: border-box;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        left: max(var(--tmb-bar-edge), env(safe-area-inset-left, 0px));
        min-height: var(--tmb-bar-height);
        opacity: 0;
        overflow: hidden;
        padding: 5px;
        pointer-events: none;
        position: fixed;
        right: max(var(--tmb-bar-edge), env(safe-area-inset-right, 0px));
        transform: translateY(calc(100% + var(--tmb-bar-gap) + 20px));
        transition: opacity 160ms ease, transform 220ms ease;
        z-index: 1000;
    }

    .tmb-bar.is-visible {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    .tmb-action,
    .tmb-action--save > button,
    .tmb-action--save > .trl-button,
    .tmb-action--save > .trl-button.uk-button {
        align-items: center;
        appearance: none;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        box-sizing: border-box;
        color: var(--tmb-foreground);
        cursor: pointer;
        display: flex;
        flex-direction: column;
        font-family: inherit;
        font-size: 11px;
        font-weight: 560;
        gap: 2px;
        height: calc(var(--tmb-bar-height) - 10px);
        justify-content: center;
        letter-spacing: 0;
        line-height: 1.15;
        margin: 0;
        min-height: 0;
        min-width: 0;
        padding: 5px 4px 3px;
        position: relative;
        text-align: center;
        text-decoration: none;
        text-transform: none;
        width: 100%;
    }

    .tmb-action--save {
        align-items: stretch;
        display: flex;
        min-width: 0;
        position: relative;
    }

    .tmb-action--save .trl-button::before,
    .tmb-action--save .trl-button::after,
    .tmb-action--save [data-trl-button-label]::before,
    .tmb-action--save [data-trl-button-label]::after {
        background: none !important;
        background-image: none !important;
        content: none !important;
        display: none !important;
    }

    .tmb-action--save .trl-icon,
    .tmb-action__icon {
        fill: none;
        flex: 0 0 auto;
        height: 22px;
        margin: 0;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 1.65;
        width: 22px;
    }

    .tmb-action__icon-wrap {
        align-items: center;
        display: inline-flex;
        height: 30px;
        justify-content: center;
        position: relative;
        width: 30px;
    }

    .tmb-action__icon-wrap .tmb-action__icon {
        height: 18px;
        width: 18px;
    }

    .tmb-action__progress-ring {
        fill: none;
        height: 30px;
        inset: 0;
        pointer-events: none;
        position: absolute;
        transform: rotate(-90deg);
        width: 30px;
    }

    .tmb-action__progress-track,
    .tmb-action__progress-value {
        fill: none;
        stroke-linecap: round;
        stroke-width: 2;
    }

    .tmb-action__progress-track {
        stroke: rgba(60, 60, 67, 0.13);
    }

    .tmb-action__progress-value {
        stroke: #bd8505;
        stroke-dasharray: 100;
        stroke-dashoffset: calc(100 - var(--tmb-progress-value, 0));
        transition: stroke-dashoffset 220ms ease;
    }

    .tmb-action--save .trl-button[data-trl-saved='true'] {
        background: rgba(240, 191, 85, 0.2);
        border-radius: 28px;
        color: #a77200;
    }

    .tmb-action--save .trl-button[data-trl-saved='true'] .trl-icon {
        fill: var(--tmb-accent);
        stroke: #a77200;
    }

    .tmb-action:focus-visible,
    .tmb-action--save .trl-button:focus-visible {
        background: rgba(118, 118, 128, 0.1);
        border-radius: 28px;
        color: var(--tmb-foreground);
        outline: none;
    }

    .tmb-action:focus-visible,
    .tmb-action--save .trl-button:focus-visible {
        box-shadow: inset 0 0 0 2px var(--tmb-accent);
    }

    .tmb-action--save .trl-button[data-trl-saved='true']:hover,
    .tmb-action--save .trl-button[data-trl-saved='true']:focus-visible,
    .tmb-action--save .trl-button[data-trl-saved='true']:active {
        background: rgba(240, 191, 85, 0.24);
        border-radius: 28px;
        color: #8f6200;
    }

    .tmb-action.is-disabled,
    .tmb-action:disabled,
    .tmb-action--save.is-disabled {
        cursor: default;
        opacity: 0.42;
    }

    .tmb-action__label,
    .tmb-action--save [data-trl-button-label] {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tmb-action__badge {
        align-items: center;
        background: var(--tmb-accent);
        border: 2px solid #fff;
        border-radius: 999px;
        color: #4c3500;
        display: inline-flex;
        font-size: 9px;
        font-variant-numeric: tabular-nums;
        font-weight: 700;
        height: 17px;
        justify-content: center;
        line-height: 1;
        min-width: 17px;
        padding: 0 3px;
        position: absolute;
        right: max(8px, 16%);
        top: 4px;
    }

    html.tmb-bar-visible .trl-toast.uk-position-bottom-center {
        --trl-toast-consent-offset: calc(var(--tmb-bar-height) + var(--tmb-bar-gap) + 20px);
        max-width: calc(100vw - 32px);
        width: auto;
    }

    html.tmb-bar-visible .trl-toast .trl-toast__message {
        -webkit-backdrop-filter: blur(18px) saturate(150%);
        background: rgba(31, 31, 33, 0.9) !important;
        backdrop-filter: blur(18px) saturate(150%);
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: 14px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        color: #fff !important;
        font-size: 13px;
        line-height: 1.35;
        min-width: min(360px, calc(100vw - 32px));
        padding: 11px 14px !important;
        text-align: center;
    }

    .tmb-dialog {
        align-items: flex-end;
        background: transparent;
        border: 0;
        box-sizing: border-box;
        color: var(--tmb-foreground);
        height: 100%;
        inset: 0;
        margin: 0;
        max-height: none;
        max-width: none;
        padding: 0;
        position: fixed;
        width: 100%;
    }

    .tmb-dialog[open] {
        display: flex;
    }

    .tmb-dialog::backdrop {
        background: rgba(0, 0, 0, 0.43);
        backdrop-filter: blur(2px);
    }

    .tmb-sheet {
        animation: tmb-sheet-in 220ms ease-out both;
        -webkit-backdrop-filter: blur(28px) saturate(170%);
        background: rgba(250, 250, 252, 0.96);
        backdrop-filter: blur(28px) saturate(170%);
        border-radius: 28px 28px 0 0;
        box-shadow: 0 -16px 50px rgba(0, 0, 0, 0.18);
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        max-height: min(78dvh, 720px);
        min-height: 210px;
        overflow: hidden;
        padding: 10px 20px max(22px, env(safe-area-inset-bottom, 0px));
        width: 100%;
    }

    .tmb-sheet--reading-list {
        max-height: min(84dvh, 760px);
    }

    .tmb-sheet__handle {
        align-self: center;
        background: #d6d6d6;
        border-radius: 999px;
        display: block;
        flex: 0 0 auto;
        height: 4px;
        margin-bottom: 5px;
        width: 42px;
    }

    .tmb-sheet__header {
        align-items: center;
        border-bottom: 1px solid var(--tmb-border);
        display: flex;
        flex: 0 0 auto;
        justify-content: space-between;
        min-height: 54px;
    }

    .tmb-sheet__title {
        color: inherit;
        font-family: inherit;
        font-size: 20px;
        font-weight: 650;
        letter-spacing: -0.01em;
        line-height: 1.25;
        margin: 0;
        text-transform: none;
    }

    .tmb-sheet__close {
        align-items: center;
        appearance: none;
        background: #f2f2f2;
        border: 0;
        border-radius: 999px;
        color: inherit;
        cursor: pointer;
        display: inline-flex;
        height: 36px;
        justify-content: center;
        margin: 0 -4px 0 12px;
        padding: 0;
        width: 36px;
    }

    .tmb-sheet__close:hover,
    .tmb-sheet__close:focus-visible {
        background: #e8e8e8;
        outline: 2px solid var(--tmb-accent);
        outline-offset: 1px;
    }

    .tmb-sheet__close svg {
        fill: none;
        height: 20px;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-width: 1.6;
        width: 20px;
    }

    .tmb-toc,
    .tmb-reading-list {
        -webkit-overflow-scrolling: touch;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .tmb-toc {
        padding: 8px 0;
    }

    .tmb-toc__list {
        counter-reset: tmb-section;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .tmb-toc__item {
        counter-increment: tmb-section;
        margin: 0;
        padding: 0;
    }

    .tmb-toc__link {
        align-items: baseline;
        border-radius: 8px;
        color: #3e3e3e;
        display: grid;
        font-size: 15px;
        gap: 10px;
        grid-template-columns: 28px minmax(0, 1fr);
        line-height: 1.35;
        padding: 10px 9px;
        text-decoration: none;
    }

    .tmb-toc__link::before {
        color: #999;
        content: counter(tmb-section, decimal-leading-zero);
        font-size: 10px;
        font-variant-numeric: tabular-nums;
        font-weight: 600;
        letter-spacing: 0.04em;
        padding-top: 3px;
    }

    .tmb-toc__item--h3 .tmb-toc__link {
        font-size: 14px;
        padding-left: 24px;
    }

    .tmb-toc__link:hover,
    .tmb-toc__link:focus-visible {
        background: #f6f6f6;
        color: #111;
        outline: none;
    }

    .tmb-toc__link.is-active {
        background: rgba(240, 191, 85, 0.16);
        color: #5d4100;
        font-weight: 600;
    }

    .tmb-toc__link.is-active::before {
        color: #a77200;
    }

    .tmb-reading-list {
        padding: 16px 1px 2px;
    }

    .tmb-reading-list .trl-list__status {
        padding: 16px 0;
    }

    .tmb-reading-list .trl-list--compact .trl-card__title-row--custom {
        font-size: 14px;
        line-height: 1.32;
    }

    .tmb-reading-list .trl-list--compact .trl-card__actions {
        padding-top: 8px;
    }

    .tmb-reading-list .trl-card__read.uk-button {
        line-height: 1.35;
        min-height: 0;
        padding: 0;
    }

    .tmb-reading-list .trl-card__read::before,
    .tmb-reading-list .trl-card__read::after,
    .tmb-reading-list .trl-card__read-label::before,
    .tmb-reading-list .trl-card__read-label::after {
        background: none !important;
        background-image: none !important;
        content: none !important;
        display: none !important;
    }

    .tmb-reading-list .trl-list__footer {
        padding-bottom: 6px;
    }
}

@media (max-width: 639px) and (hover: hover) and (pointer: fine) {
    .tmb-action:hover,
    .tmb-action--save .trl-button:hover {
        background: rgba(118, 118, 128, 0.1);
        border-radius: 28px;
        color: var(--tmb-foreground);
        outline: none;
    }

    .tmb-action--save .trl-button[data-trl-saved='true']:hover {
        background: rgba(240, 191, 85, 0.24);
        color: #8f6200;
    }
}

@keyframes tmb-sheet-in {
    from {
        opacity: 0;
        transform: translateY(28px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tmb-bar,
    .tmb-sheet {
        animation: none;
        transition: none;
    }
}
