:root {
    --bg: #f6f7f9;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --surface-soft: #fbfcfd;
    --border: #e6e8ec;
    --border-strong: rgba(31, 41, 55, 0.14);
    --text: #1f2937;
    --text-soft: #6b7280;
    --text-faint: #94a3b8;
    --accent: #1e7d4f;
    --accent-strong: #17603d;
    --accent-soft: rgba(30, 125, 79, 0.12);
    --shadow-lg: 0 22px 50px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 14px 26px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 8px 18px rgba(15, 23, 42, 0.05);
    --sidebar-width: 220px;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 12px;
    --transition: 0.25s ease;
    --book-frame-width: 90vw;
    --book-frame-height: 82vh;
    --book-gutter: 10px;
    --ambient-rgb: 30 125 79;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
    font-family: "Inter", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(30, 125, 79, 0.07), transparent 28%),
        radial-gradient(circle at right bottom, rgba(148, 163, 184, 0.12), transparent 20%),
        linear-gradient(180deg, #fbfcfd 0%, var(--bg) 100%);
}

button,
a,
input,
canvas {
    font: inherit;
}

button {
    cursor: pointer;
}

svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-shell {
    position: relative;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.app-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.42), transparent 36%),
        radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.56), transparent 18%);
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 14px;
    height: 100vh;
    padding: 18px 14px 16px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px);
    border-right: 1px solid rgba(255, 255, 255, 0.74);
    box-shadow: inset -1px 0 0 rgba(15, 23, 42, 0.03);
}

.sidebar__header {
    display: grid;
    gap: 8px;
    padding: 4px 8px 14px;
    border-bottom: 1px solid var(--border);
}

.sidebar__eyebrow,
.topbar__eyebrow,
.toc-sheet__eyebrow,
.hotspot-card__eyebrow,
.sidebar-thumbnails__hint,
.status-pill__label {
    margin: 0;
    color: var(--text-faint);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.sidebar__title,
.topbar__title,
.toc-sheet__title,
.hotspot-card__title {
    margin: 0;
    font-size: clamp(1.75rem, 2vw, 2.2rem);
    line-height: 1.02;
    letter-spacing: -0.03em;
    color: var(--text);
}

.sidebar__title {
    font-size: 1.5rem;
}

.sidebar__caption {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.86rem;
    line-height: 1.5;
}

.search-field {
    min-height: 42px;
    padding: 0 14px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-sm);
}

.search-field svg {
    width: 18px;
    height: 18px;
    color: var(--text-soft);
}

.search-field input {
    width: 100%;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
}

.search-field input::placeholder {
    color: var(--text-soft);
}

.page-nav,
.toc-sheet__nav {
    min-height: 0;
}

.page-nav__list,
.toc-sheet__list {
    list-style: none;
    margin: 0;
    padding: 0 3px 0 0;
    display: grid;
    gap: 8px;
    max-height: 100%;
    overflow: auto;
}

.page-nav__list::-webkit-scrollbar,
.toc-sheet__list::-webkit-scrollbar,
.sidebar-thumbnails__list::-webkit-scrollbar,
.toolbar::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

.page-nav__list::-webkit-scrollbar-thumb,
.toc-sheet__list::-webkit-scrollbar-thumb,
.sidebar-thumbnails__list::-webkit-scrollbar-thumb,
.toolbar::-webkit-scrollbar-thumb {
    background: rgba(31, 41, 55, 0.12);
    border-radius: 999px;
}

.page-nav__button,
.toc-sheet__button {
    position: relative;
    width: 100%;
    padding: 12px 12px 12px 14px;
    border: 1px solid transparent;
    border-radius: 15px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    text-align: left;
    color: var(--text);
    background: rgba(255, 255, 255, 0.52);
    transition:
        transform var(--transition),
        border-color var(--transition),
        background var(--transition),
        box-shadow var(--transition);
}

.page-nav__button::before,
.toc-sheet__button::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 999px;
    background: transparent;
    transition: background var(--transition);
}

.page-nav__button:hover,
.toc-sheet__button:hover {
    transform: translateX(3px);
    border-color: rgba(31, 41, 55, 0.08);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-sm);
}

.page-nav__button.is-active,
.toc-sheet__button.is-active {
    border-color: rgba(30, 125, 79, 0.14);
    background: linear-gradient(135deg, rgba(30, 125, 79, 0.09), rgba(255, 255, 255, 0.96));
    box-shadow: var(--shadow-sm);
}

.page-nav__button.is-active::before,
.toc-sheet__button.is-active::before {
    background: var(--accent);
}

.page-nav__index,
.toc-sheet__index {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 41, 55, 0.05);
    color: var(--text-soft);
    font-size: 0.8rem;
    font-weight: 700;
}

.page-nav__button.is-active .page-nav__index,
.toc-sheet__button.is-active .toc-sheet__index {
    background: var(--accent);
    color: #ffffff;
}

.page-nav__button-label,
.toc-sheet__button-label {
    min-width: 0;
}

.page-nav__title,
.toc-sheet__title-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.93rem;
    font-weight: 600;
    line-height: 1.35;
}

.page-nav__button.is-hidden,
.toc-sheet__item.is-hidden {
    display: none;
}

.sidebar-thumbnails {
    display: grid;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.sidebar-thumbnails__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-thumbnails__title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.sidebar-thumbnails__list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 102px;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.app-main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    height: 100dvh;
    gap: 8px;
    padding: 12px;
    overflow: hidden;
}

.workspace {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    gap: 8px;
    overflow: hidden;
}

.topbar,
.toolbar,
.viewer-panel,
.toc-sheet__panel,
.hotspot-card {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 70;
    width: min(360px, calc(100vw - 24px));
    padding: 16px;
    display: grid;
    gap: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.96)),
        rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.14);
    transform-origin: bottom right;
}

.hotspot-card[hidden] {
    display: none !important;
}

.hotspot-card:not([hidden]):not(.is-closing) {
    animation: hotspotCardIn 0.25s ease;
}

.hotspot-card.is-closing {
    animation: hotspotCardOut 0.2s ease forwards;
    pointer-events: none;
}

.hotspot-card__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.hotspot-card__header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.hotspot-card__title {
    font-size: 1.36rem;
}

.hotspot-card__body {
    display: grid;
    gap: 10px;
}

.hotspot-card__code {
    width: max-content;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    background: rgba(30, 125, 79, 0.08);
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hotspot-card__description {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
}

.hotspot-card__actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.hotspot-card__link,
.hotspot-card__dismiss,
.cta-button,
.contact-modal__action {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 700;
    border: 1px solid transparent;
    appearance: none;
    cursor: pointer;
}

.hotspot-card__link {
    width: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(30, 125, 79, 0.2);
}

.hotspot-card__link span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.hotspot-card__link span::after {
    content: ">";
    font-size: 0.9rem;
    font-weight: 800;
}

.hotspot-card__dismiss {
    min-width: 86px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    border-color: rgba(31, 41, 55, 0.08);
    box-shadow: var(--shadow-sm);
}

.hotspot-card.is-minimized {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
}

.hotspot-fab {
    position: fixed;
    right: 18px;
    bottom: 84px;
    z-index: 74;
    width: 52px;
    height: 52px;
    border: 1px solid rgba(30, 125, 79, 0.18);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    box-shadow: 0 18px 34px rgba(30, 125, 79, 0.24);
    transition: transform var(--transition), opacity var(--transition), box-shadow var(--transition);
}

.hotspot-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 38px rgba(30, 125, 79, 0.28);
}

.hotspot-fab[hidden] {
    display: none;
}

.cta-button {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 45;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    border: 1px solid rgba(31, 41, 55, 0.08);
    box-shadow: var(--shadow-lg);
}

.hotspot-card:not([hidden]) ~ .cta-button,
body.is-modal-open .cta-button {
    opacity: 0;
    pointer-events: none;
}

body.is-modal-open {
    overflow: hidden;
}

.contact-modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 20px;
}

.contact-modal[hidden] {
    display: none;
}

.contact-modal__backdrop,
.contact-modal__dialog {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.contact-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    opacity: 0;
}

.contact-modal__dialog {
    position: relative;
    width: min(560px, calc(100vw - 24px));
    max-height: min(88vh, 760px);
    padding: 24px;
    display: grid;
    gap: 18px;
    overflow: auto;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 251, 0.96));
    box-shadow: 0 32px 80px rgba(15, 23, 42, 0.22);
    opacity: 0;
    transform: translateY(20px) scale(0.98);
}

.contact-modal.is-visible .contact-modal__backdrop {
    opacity: 1;
}

.contact-modal.is-visible .contact-modal__dialog {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.contact-modal__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.contact-modal__eyebrow {
    margin: 0 0 8px;
    color: var(--text-faint);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.contact-modal__title {
    margin: 0;
    color: var(--text);
    font-size: clamp(1.6rem, 2vw, 2.2rem);
    line-height: 1.04;
}

.contact-modal__body {
    padding: 2px 0;
}

.contact-modal__details {
    margin: 0;
    display: grid;
    gap: 14px;
}

.contact-modal__detail-item {
    padding: 14px 16px;
    border-radius: 20px;
    background: rgba(248, 250, 252, 0.94);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.contact-modal__detail-item dt {
    margin: 0 0 6px;
    color: var(--text-faint);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.contact-modal__detail-item dd {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.6;
}

.contact-modal__detail-item a {
    color: inherit;
    text-decoration: none;
}

.contact-modal__detail-item a:hover {
    color: var(--accent);
}

.contact-modal__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.contact-modal__action {
    min-height: 48px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
    border-color: rgba(31, 41, 55, 0.08);
    box-shadow: var(--shadow-sm);
}

.contact-modal__action--primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    border-color: rgba(30, 125, 79, 0.22);
    box-shadow: 0 16px 32px rgba(30, 125, 79, 0.18);
}

.contact-modal__action:hover {
    color: var(--accent);
    background: #ffffff;
}

.contact-modal__action--primary:hover {
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translate(-50%, 16px);
    min-width: 220px;
    max-width: min(90vw, 420px);
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.9);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
    z-index: 80;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 640px) {
    .contact-modal {
        padding: 12px;
    }

    .contact-modal__dialog {
        width: min(100vw - 20px, 560px);
        max-height: calc(100vh - 24px);
        padding: 18px;
        border-radius: 22px;
    }

    .contact-modal__actions {
        grid-template-columns: 1fr;
    }
}

.app-shell.is-sidebar-open .icon-button--nav span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.app-shell.is-sidebar-open .icon-button--nav span:nth-child(2) {
    opacity: 0;
}

.app-shell.is-sidebar-open .icon-button--nav span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    to {
        background-position: -220% 0;
    }
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.18);
    }
}

@keyframes hotspotCardIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes hotspotCardOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
}

@media (min-width: 1920px) {
    .app-main {
        padding: 18px;
    }
}

@media (max-width: 1320px) {
    .topbar {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
        grid-template-areas:
            "left search"
            "right right";
    }

    .topbar__left {
        grid-area: left;
    }

    .search-field--header {
        grid-area: search;
        justify-self: end;
        width: 100%;
    }

    .topbar__right {
        grid-area: right;
        justify-content: space-between;
    }
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(88vw, 320px);
        max-width: 100%;
        transform: translateX(-104%);
        transition: transform var(--transition);
        box-shadow: var(--shadow-lg);
    }

    .app-shell.is-sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-shell.is-sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgba(15, 23, 42, 0.28);
        backdrop-filter: blur(4px);
    }

    .icon-button--nav {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .app-main {
        padding: 10px;
    }

    .topbar {
        position: sticky;
        top: 10px;
        z-index: 12;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px 12px;
    }

    .topbar__left,
    .topbar__right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .search-field--header {
        max-width: none;
        width: 100%;
    }

    .toolbar {
        padding: 8px;
    }

    .viewer-panel {
        padding: 6px;
    }

    .book-frame {
        width: min(100%, var(--book-frame-width));
        min-height: 320px;
    }

    .sidebar-thumbnails__list {
        grid-auto-columns: 92px;
    }

    .hotspot-card {
        left: 10px;
        right: 10px;
        bottom: 64px;
        width: auto;
    }

    .hotspot-card__actions {
        grid-template-columns: 1fr;
    }

    .hotspot-card__dismiss {
        width: 100%;
    }

    .cta-button {
        right: 10px;
        bottom: 10px;
    }

    .toast {
        bottom: 62px;
    }
}

@media (max-width: 560px) {
    .app-main {
        padding: 8px;
        gap: 8px;
    }

    .sidebar {
        padding: 16px 12px 14px;
    }

    .sidebar__title {
        font-size: 1.35rem;
    }

    .topbar__title {
        font-size: 1.35rem;
    }

    .topbar__eyebrow {
        display: none;
    }

    .status-pill {
        width: 100%;
    }

    .tool-button,
    .icon-button {
        width: 40px;
        height: 40px;
    }

    .toolbar__badge {
        min-height: 40px;
        padding: 0 12px;
    }

    .page__state,
    .page__overlay {
        left: 10px;
        right: 10px;
    }

    .page__state {
        top: 10px;
        padding: 7px 10px;
        font-size: 0.76rem;
    }

    .page__overlay {
        bottom: 10px;
        gap: 8px;
    }

    .page__badge,
    .page__number {
        min-height: 28px;
        padding: 0 10px;
        font-size: 0.7rem;
    }

    .flip-hint {
        left: 10px;
        right: 10px;
        bottom: 10px;
        justify-content: center;
        text-align: center;
    }

    .toc-sheet__panel {
        width: calc(100vw - 16px);
        max-height: min(88dvh, 760px);
        padding: 14px;
    }

    .cta-button {
        left: 10px;
        right: 10px;
        width: auto;
    }
}



.editor-sheet {
    position: fixed;
    inset: 0;
    z-index: 88;
    display: grid;
    place-items: center;
    padding: 18px;
}

.editor-sheet[hidden] {
    display: none;
}

.editor-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity var(--transition);
}

.editor-sheet__panel {
    position: relative;
    width: min(860px, calc(100vw - 24px));
    max-height: min(90vh, 920px);
    padding: 22px;
    display: grid;
    gap: 18px;
    overflow: auto;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.96));
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.2);
    opacity: 0;
    transform: translateY(18px) scale(0.98);
    transition: opacity var(--transition), transform var(--transition);
}

.editor-sheet.is-open .editor-sheet__backdrop {
    opacity: 1;
}

.editor-sheet.is-open .editor-sheet__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.editor-sheet__header,
.editor-card__header,
.editor-sheet__footer,
.editor-card__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.editor-sheet__header {
    align-items: start;
}

.editor-sheet__eyebrow,
.editor-card__eyebrow,
.editor-field__label {
    margin: 0;
    color: var(--text-faint);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.editor-sheet__title,
.editor-card__title {
    margin: 6px 0 0;
    color: var(--text);
}

.editor-sheet__title {
    font-size: clamp(1.55rem, 2vw, 2rem);
}

.editor-sheet__caption {
    margin: 8px 0 0;
    color: var(--text-soft);
    font-size: 0.94rem;
    line-height: 1.6;
}

.editor-sheet__body {
    display: grid;
    gap: 16px;
}

.editor-card {
    padding: 18px;
    display: grid;
    gap: 14px;
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(248, 250, 252, 0.92);
}

.editor-card__title {
    font-size: 1.02rem;
}

.editor-card__badge,
.editor-card__meta {
    width: max-content;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    background: rgba(30, 125, 79, 0.1);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
}

.editor-card__file {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    line-height: 1.55;
    word-break: break-word;
}

.editor-field {
    display: grid;
    gap: 8px;
}

.editor-field__input {
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    outline: none;
}

.editor-field__input:focus {
    border-color: rgba(30, 125, 79, 0.28);
    box-shadow: 0 0 0 4px rgba(30, 125, 79, 0.08);
}

.editor-page-titles {
    display: grid;
    gap: 10px;
    max-height: min(42vh, 440px);
    padding-right: 6px;
    overflow: auto;
}

.editor-page-title {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.editor-page-title__index {
    width: 52px;
    min-height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 41, 55, 0.06);
    color: var(--text-soft);
    font-size: 0.86rem;
    font-weight: 700;
}

.editor-sheet__footer {
    justify-content: flex-end;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

@media (max-width: 760px) {
    .editor-sheet {
        padding: 10px;
    }

    .editor-sheet__panel {
        width: calc(100vw - 12px);
        max-height: calc(100vh - 20px);
        padding: 16px;
        border-radius: 22px;
    }

    .editor-sheet__footer,
    .editor-card__actions,
    .editor-sheet__header,
    .editor-card__header {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-page-title {
        grid-template-columns: 1fr;
    }

    .editor-page-title__index {
        width: 100%;
    }
}

/* Layout Restore Patch */
.topbar,
.toolbar,
.viewer-panel {
    position: relative;
    right: auto;
    bottom: auto;
    width: auto;
    z-index: auto;
    transform-origin: center;
}

.topbar {
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(240px, 340px) auto;
    align-items: center;
    gap: 12px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.96)),
        rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.08);
}

.topbar__left,
.topbar__right,
.toolbar__group,
.topbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar__left,
.topbar__right {
    min-width: 0;
}

.topbar__right {
    justify-content: flex-end;
}

.topbar__title-block {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.topbar__title {
    font-size: clamp(1.45rem, 1.8vw, 2rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-field--header {
    width: 100%;
    max-width: 340px;
}

.status-pill {
    min-width: 0;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 16px;
    display: grid;
    align-content: center;
    gap: 3px;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.status-pill__value {
    min-width: 0;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font-size: 0.96rem;
    line-height: 1.3;
}

.icon-button,
.tool-button {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(31, 41, 55, 0.08);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition:
        transform var(--transition),
        border-color var(--transition),
        background var(--transition),
        box-shadow var(--transition),
        color var(--transition);
}

.icon-button:hover,
.tool-button:hover,
.icon-button.is-active,
.tool-button.is-active {
    transform: translateY(-1px);
    border-color: rgba(30, 125, 79, 0.18);
    background: #ffffff;
    color: var(--accent);
}

.icon-button--nav {
    display: none;
    flex-direction: column;
    gap: 4px;
}

.icon-button--nav span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform var(--transition), opacity var(--transition);
}

.toolbar {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    overflow-x: auto;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.96)),
        rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.06);
}

.toolbar__badge {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: var(--text);
    font-weight: 700;
}

.viewer-panel {
    min-height: 0;
    height: 100%;
    padding: 4px;
    display: grid;
    align-items: stretch;
    justify-items: stretch;
    border-radius: 28px;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at center, rgba(var(--ambient-rgb), 0.14), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 247, 250, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), var(--shadow-lg);
}

.book-viewport {
    position: relative;
    width: 100%;
    min-height: 0;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
}

.book-zoom-stage {
    width: 100%;
    height: 100%;
    flex: 1 1 auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.book-frame {
    position: relative;
    flex: 0 0 auto;
    width: min(var(--book-frame-width), 100%);
    height: min(var(--book-frame-height), 100%);
    min-width: 0;
    min-height: 0;
    margin: 0 auto;
}

.stf__parent,
.stf__wrapper,
.stf__block {
    width: 100%;
    height: 100%;
}

.stf__wrapper {
    position: relative;
    display: block;
}

.stf__block {
    position: absolute;
    inset: 0;
}

.viewer-panel:fullscreen,
.viewer-panel[data-fullscreen="true"] {
    padding: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    place-items: center;
    place-content: center;
    align-content: center;
    justify-content: center;
    background: #000000;
}

.viewer-panel:fullscreen .book-viewport,
.viewer-panel[data-fullscreen="true"] .book-viewport,
.viewer-panel:fullscreen .book-zoom-stage,
.viewer-panel[data-fullscreen="true"] .book-zoom-stage {
    width: 100%;
    height: 100%;
    min-height: 100%;
    align-items: center;
    justify-content: center;
}

.viewer-panel:fullscreen .book-frame,
.viewer-panel[data-fullscreen="true"] .book-frame {
    margin: auto;
}

.book-shadow {
    position: absolute;
    inset: 8% 4% 4%;
    border-radius: 28px;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.12), transparent 70%);
    filter: blur(24px);
    pointer-events: none;
}

.book-gutter {
    position: absolute;
    top: 5%;
    bottom: 5%;
    left: calc(50% - (var(--book-gutter) / 2));
    width: var(--book-gutter);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.1), rgba(255, 255, 255, 0.18), rgba(15, 23, 42, 0.08));
    opacity: 0.7;
    pointer-events: none;
}

.book {
    position: relative;
    width: 100%;
    height: 100%;
}

.page,
.page__surface {
    position: relative;
    width: 100%;
    height: 100%;
}

.page__surface {
    overflow: hidden;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.page__canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #ffffff;
}

.page__annotation-layer,
.page__product-layer {
    position: absolute;
    inset: 0;
}

.page__state,
.page__overlay {
    position: absolute;
    left: 14px;
    right: 14px;
    z-index: 2;
}

.page__state {
    top: 14px;
    padding: 9px 12px;
    border-radius: 999px;
    width: max-content;
    max-width: calc(100% - 28px);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-soft);
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.page__overlay {
    bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.page__badge,
.page__number {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.page__badge {
    max-width: calc(100% - 64px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page__number {
    flex-shrink: 0;
}

.book-loading {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: grid;
    place-items: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    background: rgba(248, 250, 252, 0.88);
    backdrop-filter: blur(6px);
    transition: opacity var(--transition), visibility var(--transition);
}

.book-loading.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.book-loading.is-error {
    color: #991b1b;
}

.book-loading__spinner {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 3px solid rgba(148, 163, 184, 0.22);
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

.book-loading__content {
    display: grid;
    gap: 8px;
}

.book-loading__content strong,
.book-loading__content p {
    margin: 0;
}

.flip-hint {
    position: absolute;
    left: 16px;
    right: auto;
    bottom: 16px;
    z-index: 5;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: opacity var(--transition), transform var(--transition);
}

.flip-hint.is-hidden {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

.flip-hint__dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--accent);
    animation: pulse 1.8s ease-in-out infinite;
}

.thumbnail-card {
    padding: 8px;
    border: 1px solid rgba(31, 41, 55, 0.08);
    border-radius: 16px;
    display: grid;
    gap: 8px;
    text-align: left;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

.thumbnail-card__preview {
    aspect-ratio: 3 / 4.2;
    overflow: hidden;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(226, 232, 240, 0.6));
}

.thumbnail-card__canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.thumbnail-card__meta {
    display: grid;
    gap: 4px;
}

.thumbnail-card__page {
    color: var(--text-faint);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.thumbnail-card__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.35;
}

.toc-sheet {
    position: fixed;
    inset: 0;
    z-index: 84;
    display: grid;
    place-items: center;
    padding: 18px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.toc-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.36);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity var(--transition);
}

.toc-sheet__panel {
    position: relative;
    right: auto;
    bottom: auto;
    width: min(460px, calc(100vw - 24px));
    max-height: min(88vh, 760px);
    padding: 18px;
    display: grid;
    gap: 14px;
    border-radius: 24px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.96)),
        rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 24px 56px rgba(15, 23, 42, 0.18);
    opacity: 0;
    transform: translateY(18px) scale(0.98);
    transition: opacity var(--transition), transform var(--transition);
}

.toc-sheet__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.toc-sheet.is-open {
    opacity: 1;
    pointer-events: auto;
}

.toc-sheet.is-open .toc-sheet__backdrop {
    opacity: 1;
}

.toc-sheet.is-open .toc-sheet__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.hotspot-card {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 70;
    width: min(360px, calc(100vw - 24px));
    padding: 16px;
    display: grid;
    gap: 12px;
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.96)),
        rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.14);
    transform-origin: bottom right;
}

@media (max-width: 1320px) {
    .topbar {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
        grid-template-areas:
            "left search"
            "right right";
    }

    .topbar__left {
        grid-area: left;
    }

    .search-field--header {
        grid-area: search;
        justify-self: end;
        max-width: none;
    }

    .topbar__right {
        grid-area: right;
        justify-content: space-between;
    }
}

@media (max-width: 1100px) {
    .icon-button--nav {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .topbar {
        position: sticky;
        top: 10px;
        z-index: 12;
        grid-template-columns: 1fr;
        grid-template-areas: none;
        padding: 10px 12px;
        gap: 10px;
    }

    .topbar__left,
    .topbar__right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .search-field--header {
        width: 100%;
    }

    .toolbar {
        padding: 8px;
    }

    .viewer-panel {
        padding: 6px;
    }

    .book-frame {
        min-height: auto;
    }

    .hotspot-card {
        left: 10px;
        right: 10px;
        bottom: 64px;
        width: auto;
    }

    .flip-hint {
        left: 10px;
        right: 10px;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 560px) {
    .topbar__title {
        font-size: 1.35rem;
    }

    .topbar__eyebrow {
        display: none;
    }

    .status-pill {
        width: 100%;
    }

    .tool-button,
    .icon-button {
        width: 40px;
        height: 40px;
    }

    .toolbar__badge {
        min-height: 40px;
        padding: 0 12px;
    }

    .toc-sheet__panel {
        width: calc(100vw - 16px);
        max-height: min(88dvh, 760px);
        padding: 14px;
    }
}

/* Mobile Readability Final Override */
@media (max-width: 768px) {
    .search-field--header {
        display: none !important;
    }

    .workspace {
        grid-template-rows: auto minmax(0, 1fr) !important;
        min-height: 0 !important;
        height: 100% !important;
        gap: 6px !important;
    }

    .topbar {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        top: 8px !important;
        gap: 8px !important;
        padding: 10px 12px !important;
        border-radius: 18px !important;
        align-items: center !important;
    }

    .topbar__left {
        min-width: 0 !important;
        align-items: center;
        justify-content: flex-start !important;
        gap: 10px !important;
    }

    .topbar__title {
        font-size: 1.16rem !important;
        line-height: 1.08 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .topbar__title-block {
        display: none !important;
    }

    .topbar__right {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        width: auto !important;
        min-width: 0 !important;
    }

    .topbar__actions {
        justify-content: flex-end !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    .topbar__right .status-pill:not(.status-pill--primary) {
        display: none !important;
    }

    .status-pill {
        min-height: 0 !important;
        width: auto !important;
        padding: 8px 12px !important;
        border-radius: 999px !important;
        gap: 2px !important;
        white-space: nowrap !important;
    }

    .status-pill__label {
        display: none !important;
    }

    .status-pill__value {
        font-size: 0.88rem !important;
        line-height: 1 !important;
    }

    .toolbar {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 10px !important;
        padding: 8px 10px !important;
        border-radius: 16px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .toolbar__group {
        gap: 8px !important;
        flex-wrap: nowrap !important;
        flex: 0 0 auto !important;
    }

    .viewer-panel {
        padding: 2px !important;
        border-radius: 20px !important;
        min-height: 0 !important;
        height: 100% !important;
        align-items: stretch !important;
    }

    .book-viewport {
        min-height: 0 !important;
        height: 100% !important;
        align-items: start !important;
    }

    .book-frame {
        min-height: 0 !important;
    }

    .book-zoom-stage {
        height: 100% !important;
        align-items: start !important;
    }

    .book-shadow {
        display: none !important;
    }

    .page__surface {
        box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08) !important;
    }

    .sidebar-thumbnails {
        display: none !important;
    }

    .hotspot-card {
        left: 10px !important;
        right: 10px !important;
        bottom: 12px !important;
        width: auto !important;
        max-height: min(24vh, 188px) !important;
        padding: 12px !important;
        border-radius: 20px !important;
        overflow: auto !important;
        z-index: 72 !important;
    }

    .hotspot-card__title {
        font-size: 0.96rem !important;
        line-height: 1.15 !important;
    }

    .hotspot-card__description {
        font-size: 0.84rem !important;
        line-height: 1.4 !important;
    }

    .hotspot-card__actions {
        grid-template-columns: minmax(0, 1fr) auto !important;
        gap: 8px !important;
    }

    .hotspot-card__link,
    .hotspot-card__dismiss,
    .cta-button {
        min-height: 40px !important;
        font-size: 0.88rem !important;
    }

    .hotspot-card__header-actions {
        gap: 6px !important;
    }

    .hotspot-card__close,
    .hotspot-card__minimize {
        width: 40px !important;
        height: 40px !important;
        border-radius: 14px !important;
    }

    .hotspot-card.is-minimized {
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateY(16px) scale(0.94) !important;
    }

    .cta-button {
        right: 12px !important;
        bottom: 12px !important;
        left: auto !important;
        width: 52px !important;
        min-width: 52px !important;
        height: 52px !important;
        min-height: 52px !important;
        padding: 0 !important;
        border-radius: 999px !important;
        z-index: 40 !important;
    }

    .cta-button span {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }

    .cta-button::before {
        content: "\260E";
        font-size: 1.25rem !important;
        line-height: 1 !important;
    }

    .hotspot-card:not([hidden]):not(.is-minimized) ~ .cta-button,
    .hotspot-fab:not([hidden]) ~ .cta-button {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateY(10px) !important;
    }

    .hotspot-fab {
        right: 12px !important;
        bottom: 12px !important;
        width: 52px !important;
        height: 52px !important;
        border-radius: 999px !important;
        z-index: 75 !important;
    }
}

@media (max-width: 560px) {
    .app-main {
        padding: 6px !important;
        gap: 6px !important;
    }

    .workspace {
        min-height: 0 !important;
        height: 100% !important;
        gap: 4px !important;
    }

    .topbar__eyebrow,
    .status-pill__label {
        display: none !important;
    }

    .topbar__title {
        font-size: 1rem !important;
    }

    .topbar__right {
        gap: 6px !important;
    }

    .topbar__right .status-pill:not(.status-pill--primary) {
        display: none !important;
    }

    .status-pill {
        padding: 7px 10px !important;
    }

    .status-pill__value {
        font-size: 0.8rem !important;
    }

    .tool-button,
    .icon-button {
        width: 38px !important;
        height: 38px !important;
        border-radius: 12px !important;
    }

    .toolbar {
        gap: 8px !important;
        padding: 7px 8px !important;
    }

    .toolbar__group {
        gap: 6px !important;
    }

    .toolbar__badge {
        min-height: 38px !important;
        padding: 0 12px !important;
        border-radius: 12px !important;
        font-size: 0.86rem !important;
    }

    .viewer-panel {
        padding: 0 !important;
    }

    .book-viewport {
        min-height: 0 !important;
        height: 100% !important;
    }

    .hotspot-card {
        bottom: 8px !important;
        max-height: min(21vh, 160px) !important;
        padding: 10px !important;
    }

    .hotspot-card__title {
        font-size: 0.88rem !important;
    }

    .hotspot-card__eyebrow {
        font-size: 0.62rem !important;
    }

    .hotspot-card__description {
        display: none !important;
    }

    .hotspot-card__body {
        gap: 0 !important;
        min-height: 0 !important;
    }

    .hotspot-card__code {
        min-height: 22px !important;
        padding: 0 8px !important;
        font-size: 0.68rem !important;
    }

    .hotspot-card__actions {
        grid-template-columns: 1fr auto !important;
    }

    .hotspot-card__link,
    .hotspot-card__dismiss {
        min-height: 38px !important;
        font-size: 0.82rem !important;
    }

    .hotspot-fab {
        bottom: 10px !important;
        width: 44px !important;
        height: 44px !important;
    }

    .cta-button {
        right: 10px !important;
        bottom: 10px !important;
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
    }

    .cta-button::before {
        font-size: 1.05rem !important;
    }
}

.viewer-panel[data-fullscreen="true"] {
    place-items: center !important;
}

.viewer-panel[data-fullscreen="true"] .book-viewport,
.viewer-panel[data-fullscreen="true"] .book-zoom-stage {
    place-items: center !important;
    place-content: center !important;
    align-items: center !important;
    align-content: center !important;
    justify-content: center !important;
    justify-items: center !important;
}

/* Catalog Viewer Layout Refactor */
:root {
    --shell-padding-y: 20px;
    --shell-padding-x: 20px;
    --sidebar-width: 320px;
    --viewer-header-height: 0px;
    --viewer-pad-x: 24px;
    --viewer-pad-top: 16px;
    --viewer-pad-bottom: 24px;
}

body {
    overflow: hidden;
}

.app-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: 20px;
    min-height: 100dvh;
    height: 100dvh;
    padding: var(--shell-padding-y) var(--shell-padding-x);
    overflow: hidden;
}

.sidebar {
    top: var(--shell-padding-y);
    height: calc(100dvh - (var(--shell-padding-y) * 2));
    padding: 18px 16px 16px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow:
        inset -1px 0 0 rgba(15, 23, 42, 0.03),
        0 18px 42px rgba(15, 23, 42, 0.08);
}

.app-main {
    min-width: 0;
    min-height: 0;
    height: calc(100dvh - (var(--shell-padding-y) * 2));
    padding: 0;
    gap: 16px;
    overflow: hidden;
}

.workspace {
    min-width: 0;
    min-height: 0;
    height: 100%;
    gap: 16px;
    overflow: hidden;
}

.topbar,
.toolbar,
.viewer-panel {
    position: relative;
    right: auto;
    bottom: auto;
    width: auto;
    z-index: auto;
    transform-origin: center;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 14;
    min-height: 86px;
    padding: 12px 16px;
    gap: 12px;
    border-radius: 24px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.toolbar {
    position: sticky;
    top: 0;
    z-index: 13;
    min-height: 62px;
    padding: 10px 16px;
    gap: 12px;
    flex-wrap: wrap;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 20px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.07);
}

.viewer-panel {
    min-height: 0;
    height: calc(100dvh - (var(--shell-padding-y) * 2) - var(--viewer-header-height));
    padding: 0;
    display: grid;
    border-radius: 30px;
    overflow: hidden;
    background:
        radial-gradient(circle at center, rgba(var(--ambient-rgb), 0.14), transparent 40%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(242, 245, 249, 0.96));
}

.book-viewport {
    position: relative;
    width: 100%;
    min-height: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding:
        var(--viewer-pad-top)
        var(--viewer-pad-x)
        var(--viewer-pad-bottom);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable both-edges;
}

.book-zoom-stage {
    width: 100%;
    min-width: 100%;
    min-height: 100%;
    height: 100%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-frame {
    flex: 0 0 auto;
    width: min(var(--book-frame-width), 100%);
    height: min(var(--book-frame-height), 100%);
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    margin: auto;
}

.book-shadow {
    inset: 10% 6% 5%;
    border-radius: 32px;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.14), transparent 72%);
    filter: blur(30px);
}

.page,
.page__surface {
    display: flex;
    align-items: center;
    justify-content: center;
}

.page__surface {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.page__canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 16px;
    background: #ffffff;
}

.stf__parent,
.stf__wrapper,
.stf__block,
.book {
    max-width: 100%;
    max-height: 100%;
}

.viewer-panel:fullscreen,
.viewer-panel[data-fullscreen="true"] {
    padding: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    background: #0b1020;
}

.viewer-panel:fullscreen .book-viewport,
.viewer-panel[data-fullscreen="true"] .book-viewport {
    padding: 20px 28px 24px;
}

@media (min-width: 1024px) {
    .viewer-panel {
        --desktop-book-shift-x: 0px;
    }

    .book-frame {
        transition:
            width 0.28s ease,
            height 0.28s ease,
            transform 0.28s ease;
    }

    .viewer-panel[data-spread-kind="single"] .book-frame {
        transform: translateX(var(--desktop-book-shift-x));
    }

    .viewer-panel[data-spread-kind="spread"] .book-gutter {
        opacity: 0.72;
        box-shadow:
            0 0 18px rgba(15, 23, 42, 0.12),
            0 0 34px rgba(15, 23, 42, 0.08);
        background:
            linear-gradient(
                180deg,
                rgba(15, 23, 42, 0.1),
                rgba(255, 255, 255, 0.5),
                rgba(15, 23, 42, 0.1)
            );
    }

    .viewer-panel[data-spread-kind="single"] .book-gutter {
        opacity: 0;
    }
}

@media (min-width: 1441px) {
    :root {
        --viewer-pad-x: 32px;
        --viewer-pad-top: 18px;
        --viewer-pad-bottom: 28px;
    }

    .topbar,
    .toolbar {
        padding-left: 18px;
        padding-right: 18px;
    }
}

@media (max-width: 1100px) {
    :root {
        --shell-padding-y: 16px;
        --shell-padding-x: 16px;
        --viewer-pad-x: 18px;
        --viewer-pad-bottom: 20px;
    }

    .app-shell {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .sidebar {
        top: 0;
        height: 100dvh;
        border-radius: 0 28px 28px 0;
    }

    .app-main {
        height: calc(100dvh - (var(--shell-padding-y) * 2));
    }

    .topbar {
        min-height: auto;
    }
}

@media (max-width: 768px) {
    :root {
        --shell-padding-y: 10px;
        --shell-padding-x: 10px;
        --viewer-pad-x: 12px;
        --viewer-pad-top: 12px;
        --viewer-pad-bottom: 16px;
    }

    body {
        overflow: hidden !important;
    }

    .app-main {
        gap: 12px !important;
    }

    .workspace {
        gap: 12px !important;
    }

    .topbar {
        top: 0 !important;
        padding: 10px 12px !important;
        border-radius: 20px !important;
    }

    .toolbar {
        top: 0 !important;
        padding: 8px 10px !important;
        border-radius: 18px !important;
        flex-wrap: nowrap !important;
    }

    .viewer-panel {
        height: calc(100dvh - (var(--shell-padding-y) * 2) - var(--viewer-header-height)) !important;
        padding: 0 !important;
        border-radius: 22px !important;
    }

    .book-viewport {
        padding:
            var(--viewer-pad-top)
            var(--viewer-pad-x)
            var(--viewer-pad-bottom) !important;
    }

    .book-shadow {
        display: none !important;
    }
}

@media (max-width: 560px) {
    :root {
        --shell-padding-y: 8px;
        --shell-padding-x: 8px;
        --viewer-pad-x: 8px;
        --viewer-pad-top: 10px;
        --viewer-pad-bottom: 12px;
    }

    .app-main {
        gap: 8px !important;
    }

    .workspace {
        gap: 8px !important;
    }

    .topbar {
        padding: 9px 10px !important;
    }

    .toolbar {
        padding: 7px 8px !important;
    }

    .viewer-panel {
        border-radius: 18px !important;
    }

    .book-viewport {
        padding:
            var(--viewer-pad-top)
            var(--viewer-pad-x)
            var(--viewer-pad-bottom) !important;
    }
}

@media (max-width: 768px) {
    .app-shell {
        padding: 8px !important;
        gap: 8px !important;
        overflow: visible !important;
    }

    .app-main {
        height: calc(100dvh - 16px) !important;
        padding: 0 !important;
        gap: 8px !important;
        overflow: visible !important;
    }

    .workspace {
        grid-template-rows: auto minmax(0, 1fr) !important;
        height: 100% !important;
        gap: 8px !important;
        overflow: visible !important;
    }

    .sidebar,
    .app-shell.is-sidebar-open::after,
    .sidebar-thumbnails,
    .search-field--header,
    .topbar__actions,
    .topbar__right .status-pill:not(.status-pill--primary),
    #sidebarToggle,
    .toolbar > .toolbar__group,
    .flipbook-autoplay-panel,
    .flip-hint,
    .hotspot-card,
    .hotspot-fab,
    .cta-button {
        display: none !important;
    }

    .topbar {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        min-height: 44px !important;
        padding: 0 !important;
        gap: 0 !important;
        border-radius: 0 !important;
        top: 0 !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    .topbar__left,
    .topbar__right {
        width: auto !important;
        min-width: 0 !important;
        gap: 8px !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }

    .topbar__left {
        display: none !important;
    }

    .topbar__right {
        width: 100% !important;
        justify-content: flex-end !important;
    }

    .topbar__title-block {
        display: grid !important;
        min-width: 0 !important;
        gap: 0 !important;
    }

    .topbar__eyebrow {
        display: none !important;
    }

    .topbar__title {
        font-size: 0.98rem !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .status-pill {
        min-height: 36px !important;
        padding: 6px 10px !important;
        border-radius: 999px !important;
        gap: 0 !important;
        width: auto !important;
    }

    .status-pill__label {
        display: none !important;
    }

    .status-pill__value {
        font-size: 0.82rem !important;
        line-height: 1 !important;
    }

    .toolbar {
        position: relative !important;
        display: block !important;
        min-height: auto !important;
        padding: 0 !important;
        gap: 0 !important;
        border-radius: 0 !important;
        overflow: visible !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    .mobile-toolbar {
        display: grid !important;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 8px !important;
        align-items: center !important;
        padding: 8px !important;
        border-radius: 16px !important;
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.96)),
            rgba(255, 255, 255, 0.94);
        border: 1px solid rgba(255, 255, 255, 0.72);
        box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    }

    .mobile-toolbar[hidden],
    .mobile-more-menu[hidden] {
        display: none !important;
    }

    .mobile-toolbar__button,
    .tool-button,
    .icon-button {
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
        border-radius: 14px !important;
        justify-self: center;
    }

    .mobile-more-menu {
        position: absolute;
        top: calc(100% + 8px);
        right: 8px;
        z-index: 45;
        width: min(220px, calc(100vw - 32px));
        padding: 8px;
        display: grid;
        gap: 4px;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid rgba(15, 23, 42, 0.08);
        box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
        backdrop-filter: blur(18px);
    }

    .mobile-more-menu button {
        min-height: 44px;
        padding: 0 12px;
        border: 0;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        background: transparent;
        color: var(--text);
        font: inherit;
        font-size: 0.92rem;
        font-weight: 600;
    }

    .mobile-more-menu button.is-active {
        background: rgba(30, 125, 79, 0.1);
        color: var(--accent);
    }

    .viewer-panel {
        margin-top: var(--mobile-viewer-overlap, 0px) !important;
        height: calc(100dvh - 16px - var(--viewer-header-height) - var(--mobile-viewer-overlap, 0px)) !important;
        min-height: 0 !important;
        padding: 0 !important;
        border-radius: 18px !important;
        overflow: visible !important;
        scroll-margin-top: var(--mobile-header-height, 0px) !important;
    }

    .book-viewport {
        height: 100% !important;
        min-height: 0 !important;
        display: flex !important;
        padding-top: 0 !important;
        padding-bottom: 8px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        align-items: flex-start !important;
        justify-content: center !important;
        overflow: auto !important;
        scrollbar-gutter: auto !important;
        scroll-padding-top: 8px !important;
    }

    .book-zoom-stage {
        width: max-content !important;
        min-width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: center !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .book-frame {
        width: var(--book-frame-width) !important;
        height: var(--book-frame-height) !important;
        max-width: none !important;
        max-height: none !important;
        min-height: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        left: auto !important;
        right: auto !important;
    }

    .stf__parent,
    .stf__wrapper,
    .stf__block,
    .book {
        max-width: none !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .book-shadow {
        display: none !important;
    }

    .page__surface,
    .page__canvas {
        border-radius: 14px !important;
    }

    .page__surface {
        overflow: visible !important;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1) !important;
    }

    .page__state,
    .page__overlay {
        left: 8px !important;
        right: 8px !important;
    }

    .page__state {
        top: 8px !important;
        padding: 6px 10px !important;
        font-size: 0.72rem !important;
    }

    .page__overlay {
        bottom: 8px !important;
    }
}
