/* ===== Kommentarii k fragmentu teksta (TZ 5.1) ===== */
/* Punktirnoe podchyorkivanie fragmenta s tredom + bejdz «💬N»; panel treda; tyomnaya tema. */

/* Podchyorknutyj fragment (yakor treda) */
.aya-frag-underline {
    text-decoration: underline dotted currentColor;
    text-underline-offset: 3px;
    text-decoration-thickness: 1.5px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s ease;
}
.aya-frag-underline:hover,
.aya-frag-underline:focus-visible {
    background: rgba(10, 124, 136, 0.14);
    outline: none;
}

/* Bejdz-schetchik «💬N» srazu posle fragmenta */
.aya-frag-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 3px;
    padding: 0 6px;
    height: 18px;
    font-size: 11px;
    line-height: 18px;
    font-weight: 600;
    color: #0a7c88;
    background: rgba(10, 124, 136, 0.12);
    border-radius: 9px;
    cursor: pointer;
    vertical-align: baseline;
    white-space: nowrap;
    user-select: none;
}
.aya-frag-badge:hover { background: rgba(10, 124, 136, 0.22); }

/* ===== Overlay + shtorka treda ===== */
.aya-frag-overlay {
    position: fixed;
    inset: 0;
    z-index: 100050;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.42);
    -webkit-tap-highlight-color: transparent;
    animation: ayaFragFade 0.15s ease;
}
@keyframes ayaFragFade { from { opacity: 0; } to { opacity: 1; } }

.aya-frag-sheet {
    width: 100%;
    max-width: 520px;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #1a1a1a;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.28);
    animation: ayaFragUp 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}
@keyframes ayaFragUp { from { transform: translateY(24px); } to { transform: translateY(0); } }
@media (min-width: 560px) {
    .aya-frag-overlay { align-items: center; }
    .aya-frag-sheet { border-radius: 16px; }
}

.aya-frag-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex: 0 0 auto;
}
.aya-frag-title { font-size: 16px; font-weight: 700; }
.aya-frag-close {
    border: none;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
}
.aya-frag-close:hover { background: rgba(0, 0, 0, 0.06); }

.aya-frag-body {
    padding: 14px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tsitata fragmenta */
.aya-frag-quote {
    margin: 0 0 12px;
    padding: 8px 12px;
    border-left: 3px solid #0a7c88;
    background: rgba(10, 124, 136, 0.08);
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    color: #333;
    font-style: italic;
    word-break: break-word;
}

.aya-frag-orphan {
    margin: 0 0 10px;
    padding: 7px 10px;
    font-size: 12.5px;
    color: #9a6b00;
    background: rgba(240, 180, 0, 0.14);
    border-radius: 8px;
}

/* Spisok kommentov */
.aya-frag-comments { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.aya-frag-empty { font-size: 13px; color: #999; padding: 6px 0; }

.aya-frag-comment {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.035);
    border-radius: 10px;
}
.aya-frag-c-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}
.aya-frag-c-name { font-size: 12.5px; font-weight: 700; color: #0a7c88; }
.aya-frag-c-time { font-size: 11px; color: #999; margin-right: auto; }
.aya-frag-c-del {
    border: none;
    background: transparent;
    color: #c0392b;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 6px;
    opacity: 0.7;
}
.aya-frag-c-del:hover { opacity: 1; background: rgba(192, 57, 43, 0.1); }
.aya-frag-c-text { font-size: 14px; line-height: 1.4; word-break: break-word; white-space: pre-wrap; }

/* Pole vvoda */
.aya-frag-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    color: inherit;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    resize: vertical;
    outline: none;
}
.aya-frag-input:focus { border-color: #0a7c88; background: #fff; }

.aya-frag-reply { border-top: 1px solid rgba(0, 0, 0, 0.07); padding-top: 12px; }
.aya-frag-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.aya-frag-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.aya-frag-cancel { background: rgba(0, 0, 0, 0.07); color: #444; }
.aya-frag-cancel:hover { background: rgba(0, 0, 0, 0.12); }
.aya-frag-send { background: #0a7c88; color: #fff; }
.aya-frag-send:hover { background: #096570; }
.aya-frag-send:disabled { opacity: 0.55; cursor: default; }

/* Knopka «💬» v paneli vydeleniya (.msg-phrase-bar) — sm. INTEGRATION-SPEC */
.msg-phrase-bar-comment {
    font-size: 16px;
    line-height: 1;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
}
.msg-phrase-bar-comment:hover { background: rgba(0, 0, 0, 0.08); }

/* ===== Tyomnaya tema ===== */
body.dark-theme .aya-frag-badge,
html[data-theme="dark"] .aya-frag-badge {
    color: #5fd3df;
    background: rgba(95, 211, 223, 0.16);
}
body.dark-theme .aya-frag-badge:hover,
html[data-theme="dark"] .aya-frag-badge:hover { background: rgba(95, 211, 223, 0.26); }
body.dark-theme .aya-frag-underline:hover,
body.dark-theme .aya-frag-underline:focus-visible,
html[data-theme="dark"] .aya-frag-underline:hover,
html[data-theme="dark"] .aya-frag-underline:focus-visible { background: rgba(95, 211, 223, 0.16); }

body.dark-theme .aya-frag-sheet,
html[data-theme="dark"] .aya-frag-sheet {
    background: #1e2529;
    color: #e8ecee;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
}
body.dark-theme .aya-frag-head,
html[data-theme="dark"] .aya-frag-head { border-bottom-color: rgba(255, 255, 255, 0.1); }
body.dark-theme .aya-frag-close:hover,
html[data-theme="dark"] .aya-frag-close:hover { background: rgba(255, 255, 255, 0.08); }
body.dark-theme .aya-frag-quote,
html[data-theme="dark"] .aya-frag-quote {
    background: rgba(95, 211, 223, 0.1);
    border-left-color: #5fd3df;
    color: #c8d2d5;
}
body.dark-theme .aya-frag-comment,
html[data-theme="dark"] .aya-frag-comment { background: rgba(255, 255, 255, 0.05); }
body.dark-theme .aya-frag-c-name,
html[data-theme="dark"] .aya-frag-c-name { color: #5fd3df; }
body.dark-theme .aya-frag-c-time,
html[data-theme="dark"] .aya-frag-c-time { color: #7a8890; }
body.dark-theme .aya-frag-input,
html[data-theme="dark"] .aya-frag-input {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    color: #e8ecee;
}
body.dark-theme .aya-frag-input:focus,
html[data-theme="dark"] .aya-frag-input:focus { border-color: #5fd3df; background: rgba(255, 255, 255, 0.08); }
body.dark-theme .aya-frag-reply,
html[data-theme="dark"] .aya-frag-reply { border-top-color: rgba(255, 255, 255, 0.1); }
body.dark-theme .aya-frag-cancel,
html[data-theme="dark"] .aya-frag-cancel { background: rgba(255, 255, 255, 0.1); color: #ccc; }
body.dark-theme .aya-frag-send,
html[data-theme="dark"] .aya-frag-send { background: #0a7c88; }
body.dark-theme .msg-phrase-bar-comment:hover,
html[data-theme="dark"] .msg-phrase-bar-comment:hover { background: rgba(255, 255, 255, 0.1); }
