#view-history-drawer {
    --panel-width: min(400px, calc(100vw - 36px));
    --handle-width: 30px;

    position: fixed;
    top: 0;
    right: 0;
    width: calc(var(--panel-width) + var(--handle-width));
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transform: translateX(var(--panel-width));
    transition: transform 0.25s ease;
    z-index: 99999;

    /* 透明な外枠そのものはクリック・ホバー判定を持たせない */
    pointer-events: none;
}

/* つまみ、または開いたパネル上にいる間だけ展開状態を維持 */
#view-history-drawer:hover,
#view-history-drawer.is-open {
    transform: translateX(0);
}

#view-history-handle {
    position: absolute;
    top: 50%;
    left: 0;
    width: var(--handle-width);
    height: 135px;
    padding: 0;
    border: 0;
    border-radius: 14px 0 0 14px;
    background: rgba(160, 160, 160, 0.7);
    color: #444;
    cursor: pointer;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;

    /* 見えているつまみだけ判定を復活 */
    pointer-events: auto;
}

#view-history-handle span {
    display: block;
    font-size: 13px;
    line-height: 1;
    transition: transform 0.25s ease;
}

#view-history-drawer:hover #view-history-handle span,
#view-history-drawer.is-open #view-history-handle span {
    transform: rotate(180deg);
}

#view-history-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--panel-width);
    height: 100%;
    min-height: 0;
    padding: 40px 30px 30px;
    box-sizing: border-box;
    background: rgba(25, 25, 25, 0.94);
    color: #eee;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;

    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;

    /* 開いたパネル部分は操作可能 */
    pointer-events: auto;
}

#view-history-panel h2 {
    margin: 0 0 18px;
    padding: 0 0 12px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 22px;
    font-weight: normal;
}

#view-history-limit {
    margin: -8px 0 14px;
    color: #999;
    font-size: 12px;
    line-height: 1.5;
}

#view-history-list {
    min-width: 0;
    min-height: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

#view-history-list li {
    margin: 0;
    padding: 11px 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

#view-history-list a {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: #e5e5e5;
    text-decoration: none;
    line-height: 1.6;
    overflow-wrap: anywhere;
    transition: color 0.15s ease;
}

#view-history-list a:hover {
    color: #42e3ff;
}

#view-history-list li i{
    padding-right:4px;
}

#view-history-list li.current a {
    color: #42e3ff;
}

#view-history-list .view-history-icon {
    flex: 0 0 auto;
    width: 16px;
    text-align: center;
}

#view-history-clear {
    width: 100%;
    margin: 20px 0 0;
    padding: 9px 12px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #eee;
    cursor: pointer;
    box-sizing: border-box;
}

#view-history-clear:hover {
    background: rgba(255, 255, 255, 0.15);
}

#view-history-list .history-empty {
    padding: 14px 5px;
    border: 0;
    color: #aaa;
}

@media (hover: none) {
    #view-history-drawer:hover {
        transform: translateX(var(--panel-width));
    }

    #view-history-drawer.is-open {
        transform: translateX(0);
    }
}