body.reader-mode {
    background-color: var(--paper);
    background: #fdfdfd; 
    color: var(--ink);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.reader-header {
    flex-shrink: 0;
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(8px);
    z-index: 50;
}

.reader-body {
    flex: 1;
    overflow-y: scroll;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    background: #fafafa;
}

.reader-container {
    position: relative;
    margin-top: 40px;
    margin-bottom: 200px;
}

.reader-content {
    width: 800px;
    max-width: 90vw;
    font-family: 'Merriweather', 'Georgia', serif;
    font-size: 19px;
    line-height: 1.8;
    white-space: pre-wrap; 
    color: #2c2c2c;
    background: #fff;
    padding: 60px 80px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.02), 
        0 10px 15px -3px rgba(0, 0, 0, 0.04), 
        0 0 0 1px rgba(0,0,0,0.02);
    border-radius: 2px;
}

.reader-gutter {
    position: absolute;
    top: 0;
    right: 100%;
    margin-right: 24px;
    width: 60px;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.gutter-avatar {
    position: absolute;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-200);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    cursor: pointer;
    pointer-events: auto;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #555;
    font-weight: 600;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
} 

.gutter-avatar:hover {
    transform: scale(1.15);
    z-index: 20;
    border-color: var(--primary);
}

.gutter-group {
    position: absolute;
    width: 36px;
    height: 36px;
    z-index: 10;
    cursor: pointer;
}

.gutter-group .gutter-avatar {
    position: absolute;
    top: 0;
    right: 0;
    transition: transform 0.2s;
    border: 2px solid #fff;
}

.gutter-group .gutter-avatar:nth-child(1) {
    z-index: 3;
}
.gutter-group .gutter-avatar:nth-child(2) {
    z-index: 2;
    top: 10px;
    right: 0;  
    opacity: 1;
}
.gutter-group .gutter-avatar:nth-child(3) {
    z-index: 1;
    top: 20px;
    right: 0;
    opacity: 1;
}

.gutter-group:hover .gutter-avatar:nth-child(2) {
   transform: translateY(2px); 
}
.gutter-group:hover .gutter-avatar:nth-child(3) {
   transform: translateY(4px); 
}

body.theme-dark .gutter-group .gutter-avatar {
    border-color: #1e1e1e;
}

.reader-popup {
    transition: opacity 0.2s, transform 0.2s;
}

body.theme-dark .sidebar-comment-item {
   background: #252525;
   color: #e0e0e0;
   border: 1px solid #333;
}
body.theme-dark .sidebar-comment-item div {
    color: #d4d4d4 !important;
}
body.theme-dark .sidebar-comment-item span {
    color: #999 !important;
}

.highlight {
    background-color: rgba(255, 235, 59, 0.4); 
    border-bottom: 2px solid #fbc02d; 
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: inherit;
}

.highlight.group-hover {
    background-color: rgba(54, 92, 255, 0.15);
    border-bottom-color: rgba(54, 92, 255, 0.5);
}

.highlight:hover {
    background-color: rgba(54, 92, 255, 0.35) !important;
    border-bottom-color: var(--primary) !important;
}

body.theme-dark .highlight {
    background-color: rgba(255, 235, 59, 0.25); 
    border-bottom: 2px solid #fdd835;
    color: inherit;
}
body.theme-dark .highlight.group-hover {
    background-color: rgba(90, 120, 255, 0.2);
    border-bottom-color: #79aeff;
}
body.theme-dark .highlight:hover {
    background-color: rgba(90, 120, 255, 0.45) !important;
    border-bottom-color: #79aeff !important;
}

.reader-popup {
    position: absolute;
    width: 420px;
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.1), 
        0 4px 6px -2px rgba(0, 0, 0, 0.05), 
        0 0 0 1px rgba(0,0,0,0.05);
    z-index: 100;
    display: none; 
}

.reader-popup.creation-mode {
    border-radius: 50px;
    padding: 8px;
}

.highlight-draft {
    background-color: rgba(54, 92, 255, 0.2) !important;
    background-image: none !important;
}

.reader-popup.visible {
    display: block !important;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.reader-popup.side-positioned::before {
    top: 16px;
    left: -6px;
    right: auto;
    border-top: none;
    border-left: none;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    border-left: 1px solid rgba(0,0,0,0.05);
    background: #fff;
}

.reader-popup::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 16px; 
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    border-top: 1px solid rgba(0,0,0,0.05);
    border-left: 1px solid rgba(0,0,0,0.05);
    transition: left 0.2s;
}

.reader-popup.arrow-down::before {
    top: auto;
    bottom: -6px;
    border-top: none;
    border-left: none;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    border-right: 1px solid rgba(0,0,0,0.05);
}

.reader-popup.centered-arrow::before {
    left: 50%;
    margin-left: -6px;
}

.comment-form-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 0;
}

.comment-input-inline {
    flex: 1;
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    padding: 8px 16px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    background: var(--gray-50);
    transition: all 0.2s ease;
    min-width: 0;
}

.comment-input-inline:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(54, 92, 255, 0.1);
}

.btn-icon-send {
    flex-shrink: 0;
    width: 36px; 
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center; 
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 10px rgba(54, 92, 255, 0.3);
}

.btn-icon-send:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 14px rgba(54, 92, 255, 0.4);
}

.btn-icon-send svg {
    margin: 0;
}

.btn-delete-comment {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
    margin-left: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center; justify-content: center;
    transition: color 0.2s, background 0.2s;
}
.btn-delete-comment:hover {
    color: #ef4444;
    background: #fef2f2;
}

.comment-view {
    font-size: 14px;
    color: var(--gray-700);
}
.comment-view:not(:last-child) {
    border-bottom: 1px solid var(--gray-200) !important;
}
.comment-view-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.comment-avatar-sm {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gray-200);
}
.comment-author-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-900);
}
.comment-date {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--gray-400);
    font-weight: 500;
}
.comment-content-text {
    line-height: 1.5;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.comment-author-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-900);
}
.comment-date {
    margin-left: auto;
    font-size: 11px;
    color: var(--gray-400);
}

#selection-btn {
    position: absolute;
    background: #fff;
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 100;
    box-shadow: 
        0 4px 12px rgba(0,0,0,0.1), 
        0 0 0 1px rgba(54,92,255,0.1);
    transform: translate(-50%, 0);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0;
}
#selection-btn:hover {
    transform: translate(-50%, -46px);
    box-shadow: 0 6px 16px rgba(54,92,255,0.15);
}
#selection-btn.visible {
    opacity: 1;
    transform: translate(-50%, -48px);
    pointer-events: auto;
}
#selection-btn::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    display: block;
}


body.theme-dark {
    background: #121212;
    color: #e0e0e0;
}
body.theme-dark .reader-body {
    background: #121212 !important; 
}
body.theme-dark .reader-content {
    background: #1e1e1e;
    color: #d4d4d4;
    box-shadow: none;
    border: 1px solid #333;
}
body.theme-dark .reader-header {
    background: rgba(30,30,30,0.9);
    border-color: #333;
}
body.theme-dark .reader-header .header__title {
    background: none;
    -webkit-text-fill-color: #eee;
    color: #eee;
}
body.theme-dark .btn-icon {
    background: #2a2a2a;
    color: #eee;
    border-color: #444;
}
body.theme-dark .btn-icon:hover {
    background: #333;
    border-color: #555;
}
body.theme-dark .reader-popup {
    background: #252525;
    border: 1px solid #333;
    color: #eee;
}
body.theme-dark .reader-popup::before {
    background: #252525;
    border-color: #333;
}
body.theme-dark .comment-form textarea {
    background: #333;
    border-color: #444;
    color: #eee;
}
body.theme-dark .gutter-avatar {
    border-color: #1e1e1e;
}
body.theme-dark #selection-btn {
    background: #252525;
    color: #5fa5fa; 
    border-color: #333;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
body.theme-dark #selection-btn::after {
    border-color: #252525 transparent transparent transparent;
}
body.theme-dark .comment-view {
    color: #ccc;
}
body.theme-dark .comment-author-name {
    color: #fff;
}
body.theme-dark .comment-content-text {
    color: #d4d4d4 !important;
}

.reader-sidebar-panel {
    position: fixed;
    top: 64px;
    right: 0;
    bottom: 0;
    width: 320px;
    background: #fff;
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 12px rgba(0,0,0,0.05);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(8px);
    z-index: 40;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}
.reader-sidebar-panel.open {
    transform: translateX(0);
}
body.theme-dark .reader-sidebar-panel {
    background: rgba(30,30,30,0.95);
    border-left-color: #333;
}

.sidebar-header {
    padding: 16px 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
body.theme-dark .sidebar-header {
    border-bottom-color: #333;
    color: #eee;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}
.sidebar-comment-item {
    background: #f9f9f9;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.sidebar-comment-item:hover {
    background: #fff;
    border-color: var(--border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
body.theme-dark .sidebar-comment-item {
   background: #222;
   color: #ccc;
}
body.theme-dark .sidebar-comment-item:hover {
   background: #2a2a2a;
   border-color: #444;
}

.controls { display: flex; gap: 8px; }
.btn-icon { 
    background: #fff; 
    border: 1px solid var(--gray-200); 
    cursor: pointer; 
    font-size: 14px; 
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--gray-700);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
}
.btn-icon:hover { 
    background: var(--gray-50); 
    border-color: var(--gray-300);
    color: var(--gray-900);
}
