/* --- カスタムスクロールバー (Cryscroller) --- */
#cryscroller-scroll-zone {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--cryscroller-scroll-width);
    height: 100%;
    background-color: rgba(0, 0, 0, 0.02);
    z-index: 90;
    touch-action: none;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        background-color 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

body.cryscroller-scroll-enabled #cryscroller-scroll-zone {
    opacity: var(--cryscroller-scroll-opacity, 0.3);
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

body.cryscroller-scroll-enabled #cryscroller-scroll-zone.is-dragging,
body.cryscroller-scroll-enabled #cryscroller-scroll-zone.is-scrolling {
    opacity: var(--cryscroller-scroll-active-opacity, 1);
}
@media (hover: hover) {
    body.cryscroller-scroll-enabled #cryscroller-scroll-zone:hover {
        opacity: var(--cryscroller-scroll-active-opacity, 1);
    }
}

body.cryscroller-scroll-enabled #chat-screen .main-content {
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-right: var(--cryscroller-scroll-width) !important;
}
body.cryscroller-scroll-enabled #chat-screen .main-content::-webkit-scrollbar {
    display: none;
}

#cryscroller-scroll-handle {
    position: absolute;
    right: 2px;
    width: calc(var(--cryscroller-scroll-width) - 4px);
    min-height: 40px;
    background-color: rgba(100, 100, 100, 0.5);
    border-radius: 4px;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        height 0.1s ease;
}

#cryscroller-scroll-zone:active #cryscroller-scroll-handle,
#cryscroller-scroll-zone:hover #cryscroller-scroll-handle {
    background-color: rgba(100, 100, 100, 0.7);
}

body.dark-mode #cryscroller-scroll-zone {
    background-color: rgba(255, 255, 255, 0.02);
}
body.dark-mode #cryscroller-scroll-handle {
    background-color: rgba(200, 200, 200, 0.4);
}
body.dark-mode #cryscroller-scroll-zone:active #cryscroller-scroll-handle {
    background-color: rgba(200, 200, 200, 0.6);
}

.scroll-marker {
    position: absolute;
    right: 0;
    width: 75%;
    height: 4px;
    z-index: 89;
    cursor: pointer;
    pointer-events: auto;
    border-radius: 10px 0 0 10px;
}
.scroll-marker:hover {
    height: 6px;
    transform: scaleX(1.2);
    z-index: 91;
}
.scroll-marker.user {
    background-color: rgba(200, 200, 200, 0.6);
}
.scroll-marker.model {
    background-color: rgba(50, 50, 50, 0.6);
}
body.dark-mode .scroll-marker.user {
    background-color: rgba(255, 255, 255, 0.6);
}
body.dark-mode .scroll-marker.model {
    background-color: rgba(0, 0, 0, 0.8);
}

#cryscroller-scroll-zone.is-dragging .scroll-marker {
    pointer-events: none;
}

body.immersive-mode #cryscroller-scroll-zone {
    top: var(--header-height, 50px) !important;
    height: calc(100% - var(--header-height, 50px) - var(--footer-height, 60px)) !important;
}

/* ── 設定画面スクロールバー ── */
#settings-cryscroller-scroll-zone {
    position: absolute;
    top: 50px;
    right: 0;
    width: var(--cryscroller-scroll-width);
    height: calc(100% - 50px);
    background-color: rgba(0, 0, 0, 0.02);
    z-index: 90;
    touch-action: none;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        background-color 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}
body.settings-cryscroller-scroll-enabled #settings-cryscroller-scroll-zone {
    opacity: var(--cryscroller-scroll-opacity, 0.3);
    pointer-events: auto;
    transition: opacity 0.3s ease;
}
body.settings-cryscroller-scroll-enabled #settings-cryscroller-scroll-zone.is-dragging,
body.settings-cryscroller-scroll-enabled #settings-cryscroller-scroll-zone.is-scrolling {
    opacity: var(--cryscroller-scroll-active-opacity, 1);
}
@media (hover: hover) {
    body.settings-cryscroller-scroll-enabled #settings-cryscroller-scroll-zone:hover {
        opacity: var(--cryscroller-scroll-active-opacity, 1);
    }
}
#settings-cryscroller-scroll-handle {
    position: absolute;
    right: 2px;
    width: calc(var(--cryscroller-scroll-width) - 4px);
    min-height: 40px;
    background-color: rgba(100, 100, 100, 0.5);
    border-radius: 4px;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        height 0.1s ease;
}
#settings-cryscroller-scroll-zone:active #settings-cryscroller-scroll-handle,
#settings-cryscroller-scroll-zone:hover #settings-cryscroller-scroll-handle {
    background-color: rgba(100, 100, 100, 0.7);
}
body.dark-mode #settings-cryscroller-scroll-zone {
    background-color: rgba(255, 255, 255, 0.02);
}
body.dark-mode #settings-cryscroller-scroll-handle {
    background-color: rgba(200, 200, 200, 0.4);
}
body.dark-mode #settings-cryscroller-scroll-zone:active #settings-cryscroller-scroll-handle {
    background-color: rgba(200, 200, 200, 0.6);
}
body.settings-cryscroller-scroll-enabled #settings-screen .main-content {
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-right: var(--cryscroller-scroll-width) !important;
}
body.settings-cryscroller-scroll-enabled #settings-screen .main-content::-webkit-scrollbar {
    display: none;
}
body.immersive-mode #settings-cryscroller-scroll-zone {
    top: var(--header-height, 50px) !important;
    height: calc(100% - var(--header-height, 50px)) !important;
}

/* ── 履歴画面スクロールバー ── */
#history-cryscroller-scroll-zone {
    position: absolute;
    top: 50px;
    right: 0;
    width: var(--cryscroller-scroll-width);
    height: calc(100% - 50px);
    background-color: rgba(0, 0, 0, 0.02);
    z-index: 90;
    touch-action: none;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        background-color 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}
body.history-cryscroller-scroll-enabled #history-cryscroller-scroll-zone {
    opacity: var(--cryscroller-scroll-opacity, 0.3);
    pointer-events: auto;
    transition: opacity 0.3s ease;
}
body.history-cryscroller-scroll-enabled #history-cryscroller-scroll-zone.is-dragging,
body.history-cryscroller-scroll-enabled #history-cryscroller-scroll-zone.is-scrolling {
    opacity: var(--cryscroller-scroll-active-opacity, 1);
}
@media (hover: hover) {
    body.history-cryscroller-scroll-enabled #history-cryscroller-scroll-zone:hover {
        opacity: var(--cryscroller-scroll-active-opacity, 1);
    }
}
#history-cryscroller-scroll-handle {
    position: absolute;
    right: 2px;
    width: calc(var(--cryscroller-scroll-width) - 4px);
    min-height: 40px;
    background-color: rgba(100, 100, 100, 0.5);
    border-radius: 4px;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        height 0.1s ease;
}
#history-cryscroller-scroll-zone:active #history-cryscroller-scroll-handle,
#history-cryscroller-scroll-zone:hover #history-cryscroller-scroll-handle {
    background-color: rgba(100, 100, 100, 0.7);
}
body.dark-mode #history-cryscroller-scroll-zone {
    background-color: rgba(255, 255, 255, 0.02);
}
body.dark-mode #history-cryscroller-scroll-handle {
    background-color: rgba(200, 200, 200, 0.4);
}
body.dark-mode #history-cryscroller-scroll-zone:active #history-cryscroller-scroll-handle {
    background-color: rgba(200, 200, 200, 0.6);
}
body.history-cryscroller-scroll-enabled #history-screen .main-content {
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-right: var(--cryscroller-scroll-width) !important;
}
body.history-cryscroller-scroll-enabled #history-screen .main-content::-webkit-scrollbar {
    display: none;
}
body.immersive-mode #history-cryscroller-scroll-zone {
    top: var(--header-height, 50px) !important;
    height: calc(100% - var(--header-height, 50px)) !important;
}
