/**
 * article-toolbar.css — AI interaction toolbar + dialogs for article pages.
 * All selectors are n24tb- prefixed so nothing leaks into the site styles.
 * Dark mode follows the html.dark class set by the theme toggle.
 */
.n24tb-wrap {
    --n24tb-primary: #cc0000;
    --n24tb-border: #e5e7eb;
    --n24tb-text: #374151;
    --n24tb-muted: #6b7280;
    --n24tb-hover-bg: #fef2f2;

    display: flex;
    align-items: stretch;
    background: #fff;
    border: 1px solid var(--n24tb-border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 4px 14px -8px rgba(0, 0, 0, .08);
    margin: 4px 0 26px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.n24tb-wrap::-webkit-scrollbar { display: none; }
.dark .n24tb-wrap {
    --n24tb-border: #374151;
    --n24tb-text: #d1d5db;
    --n24tb-muted: #9ca3af;
    --n24tb-hover-bg: rgba(239, 68, 68, .08);
    background: #1f2937;
}

.n24tb-btn {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 54px;
    padding: 8px 16px;
    border: 0;
    border-left: 1px solid var(--n24tb-border);
    background: transparent;
    color: var(--n24tb-text);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .18s ease, color .18s ease, transform .1s ease;
}
.n24tb-btn:first-child { border-left: 0; }
.n24tb-btn:hover { color: var(--n24tb-primary); background: var(--n24tb-hover-bg); }
.n24tb-btn:active { transform: scale(.97); }
.n24tb-btn:focus-visible,
.n24tb-chip:focus-visible,
.n24tb-react:focus-visible,
.n24tb-share-row:focus-visible,
.n24tb-close:focus-visible,
.n24tb-ask-input:focus-visible,
.n24tb-ask-send:focus-visible,
.n24tb-speech-stop:focus-visible {
    outline: 2px solid var(--n24tb-primary);
    outline-offset: 2px;
}
.n24tb-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.n24tb-btn.is-open {
    color: var(--n24tb-primary);
    background: var(--n24tb-hover-bg);
    box-shadow: inset 0 -3px 0 var(--n24tb-primary);
}
.dark .n24tb-btn.is-open { box-shadow: inset 0 -3px 0 #ef4444; }

.n24tb-ic { width: 20px; height: 20px; flex: none; }
.n24tb-label { display: inline-block; }

@media (max-width: 480px) {
    .n24tb-btn { padding: 8px 13px; font-size: 12.5px; gap: 6px; }
    .n24tb-ic { width: 18px; height: 18px; }
}

/* Listen state on the toolbar button */
.n24tb-btn[data-listen-state="playing"],
.n24tb-btn[data-listen-state="paused"] { color: var(--n24tb-primary); }

/* ---------- speech fallback strip ---------- */
.n24tb-speech {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -18px 0 22px;
    padding: 9px 14px;
    border: 1px solid var(--n24tb-border);
    border-radius: 10px;
    background: #fff8f8;
    color: #7f1d1d;
    font-size: 13px;
}
.dark .n24tb-speech { background: rgba(127, 29, 29, .15); color: #fecaca; }
.n24tb-speech[hidden] { display: none; }
.n24tb-speech-dots { display: inline-flex; gap: 3px; align-items: center; }
.n24tb-speech-dots i {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--n24tb-primary);
    animation: n24tb-dot 1s ease-in-out infinite;
}
.n24tb-speech-dots i:nth-child(2) { animation-delay: .18s; }
.n24tb-speech-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes n24tb-dot { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.n24tb-speech-stop {
    margin-left: auto;
    border: 1px solid #fca5a5;
    background: #fff;
    color: #b91c1c;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 9999px;
    cursor: pointer;
}
.dark .n24tb-speech-stop { background: transparent; color: #fca5a5; }

/* ---------- overlay + dialogs ---------- */
.n24tb-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    animation: n24tb-fade .18s ease;
}
.n24tb-overlay[hidden] { display: none; }
@keyframes n24tb-fade { from { opacity: 0; } }

.n24tb-dialog {
    width: 100%;
    max-width: 560px;
    max-height: min(82vh, 640px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--n24tb-border);
    border-radius: 16px;
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .35);
    overflow: hidden;
    animation: n24tb-pop .22s cubic-bezier(.22, 1, .36, 1);
}
@keyframes n24tb-pop {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
}
.n24tb-dialog-sm { max-width: 420px; }

.n24tb-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--n24tb-border);
    flex: none;
}
.n24tb-dialog-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}
.n24tb-dialog-title .n24tb-ic { color: var(--n24tb-primary); }
.dark .n24tb-dialog-title { color: #f3f4f6; }
.n24tb-close {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border: 0; border-radius: 10px;
    background: transparent;
    color: var(--n24tb-muted);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.n24tb-close:hover { background: #f3f4f6; color: #111827; }
.dark .n24tb-close:hover { background: #374151; color: #f9fafb; }
.n24tb-close svg { width: 18px; height: 18px; }

.n24tb-dialog > .n24tb-result,
.n24tb-chips, .n24tb-ask, .n24tb-react-grid, .n24tb-react-sub,
.n24tb-share-list, .n24tb-react-status, .n24tb-share-status { flex: none; }
.n24tb-dialog .n24tb-result { flex: 1 1 auto; overflow-y: auto; }

/* ---------- AI Assist: chips, ask box, result ---------- */
.n24tb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 18px 4px;
}
.n24tb-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--n24tb-border);
    border-radius: 9999px;
    background: #f9fafb;
    color: var(--n24tb-text);
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease, transform .1s ease;
}
.dark .n24tb-chip { background: #111827; }
.n24tb-chip:hover { border-color: var(--n24tb-primary); color: var(--n24tb-primary); }
.n24tb-chip:active { transform: scale(.96); }
.n24tb-chip[disabled] { opacity: .55; cursor: progress; }

/* translate = chip wrapper holding the button + language select */
.n24tb-chip-translate { padding: 3px 6px 3px 13px; gap: 6px; }
.n24tb-chip-btn {
    border: 0;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
}
.n24tb-chip[disabled], .n24tb-chip-translate .n24tb-chip-btn[disabled] { opacity: .55; cursor: progress; }
.n24tb-chip select {
    margin-left: 2px;
    border: 1px solid var(--n24tb-border);
    border-radius: 8px;
    background: #fff;
    font-size: 12px;
    font-family: inherit;
    padding: 2px 4px;
    color: #111827;
}
.dark .n24tb-chip select { background: #1f2937; color: #f3f4f6; }

.n24tb-ask {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
}
.n24tb-ask-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--n24tb-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: #111827;
    background: #fff;
}
.dark .n24tb-ask-input { background: #111827; color: #f3f4f6; }
.n24tb-ask-input::placeholder { color: var(--n24tb-muted); }
.n24tb-ask-send {
    padding: 10px 20px;
    border: 0;
    border-radius: 10px;
    background: var(--n24tb-primary);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: filter .15s ease, transform .1s ease;
}
.n24tb-ask-send:hover { filter: brightness(1.12); }
.n24tb-ask-send:active { transform: scale(.96); }
.n24tb-ask-send[disabled] { opacity: .6; cursor: progress; }

.n24tb-result { padding: 6px 18px 18px; font-size: 14.5px; line-height: 1.65; color: #1f2937; }
.dark .n24tb-result { color: #e5e7eb; }

.n24tb-empty { text-align: center; color: var(--n24tb-muted); padding: 22px 8px; font-size: 13.5px; }
.n24tb-empty p { margin: 0 0 4px; }
.n24tb-empty-sub { font-size: 12px; opacity: .8; }

.n24tb-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13.5px;
}
.dark .n24tb-error { background: rgba(185, 28, 28, .15); border-color: #7f1d1d; color: #fca5a5; }

/* answer bullets (key points / summary) */
.n24tb-points { margin: 0; padding: 0 0 0 2px; list-style: none; }
.n24tb-points li {
    position: relative;
    padding: 0 0 10px 22px;
}
.n24tb-points li::before {
    content: '';
    position: absolute;
    left: 4px; top: 8px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--n24tb-primary);
}
.dark .n24tb-points li::before { background: #ef4444; }
.n24tb-answer { white-space: pre-wrap; overflow-wrap: break-word; }
.n24tb-answer-note {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--n24tb-border);
    font-size: 11.5px;
    color: var(--n24tb-muted);
}

/* skeleton shimmer */
.n24tb-skeleton { padding: 6px 0; }
.n24tb-skeleton i {
    display: block;
    height: 13px;
    border-radius: 6px;
    background: linear-gradient(90deg, #eceef1 25%, #f6f7f8 45%, #eceef1 65%);
    background-size: 200% 100%;
    animation: n24tb-shimmer 1.2s linear infinite;
    margin-bottom: 11px;
}
.n24tb-skeleton i:nth-child(1) { width: 92%; }
.n24tb-skeleton i:nth-child(2) { width: 100%; }
.n24tb-skeleton i:nth-child(3) { width: 84%; }
.n24tb-skeleton i:nth-child(4) { width: 60%; margin-bottom: 0; }
@keyframes n24tb-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.dark .n24tb-skeleton i {
    background: linear-gradient(90deg, #1f2937 25%, #374151 45%, #1f2937 65%);
    background-size: 200% 100%;
}

.n24tb-dialog-foot {
    padding: 12px 18px 16px;
    border-top: 1px solid var(--n24tb-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex: none;
}
.n24tb-primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: 0;
    border-radius: 10px;
    background: var(--n24tb-primary);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: filter .15s ease, transform .1s ease;
}
.n24tb-primary-btn:hover { filter: brightness(1.12); }
.n24tb-primary-btn:active { transform: scale(.97); }
.n24tb-primary-btn[disabled] { opacity: .5; cursor: not-allowed; }
.n24tb-primary-btn .n24tb-ic { width: 16px; height: 16px; }

/* ---------- reactions ---------- */
.n24tb-react-sub {
    margin: 0;
    padding: 10px 18px 0;
    font-size: 12.5px;
    color: var(--n24tb-muted);
}
.n24tb-react-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px 18px 6px;
}
@media (max-width: 480px) {
    .n24tb-react-grid { grid-template-columns: repeat(2, 1fr); }
}
.n24tb-react {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 12px 6px 10px;
    border: 1px solid var(--n24tb-border);
    border-radius: 12px;
    background: #fff;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, transform .1s ease;
}
.dark .n24tb-react { background: #111827; }
.n24tb-react:hover { border-color: var(--n24tb-primary); background: var(--n24tb-hover-bg); }
.n24tb-react:active { transform: scale(.95); }
.n24tb-react.is-mine {
    border-color: var(--n24tb-primary);
    background: var(--n24tb-hover-bg);
    box-shadow: inset 0 0 0 1px var(--n24tb-primary);
}
.n24tb-react[disabled] { opacity: .6; cursor: progress; }
.n24tb-react-emoji { font-size: 24px; line-height: 1; }
.n24tb-react-name { font-size: 12px; font-weight: 600; color: var(--n24tb-text); }
.n24tb-react-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--n24tb-muted);
    min-height: 14px;
}
.n24tb-react-status {
    margin: 0;
    padding: 8px 18px 14px;
    font-size: 12.5px;
    color: #047857;
    min-height: 30px;
}
.n24tb-react-status.is-error { color: #b91c1c; }

/* ---------- share ---------- */
.n24tb-share-list { padding: 10px 14px 6px; }
.n24tb-share-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--n24tb-text);
    cursor: pointer;
    text-align: left;
    transition: background-color .15s ease;
}
.n24tb-share-row:hover { background: #f3f4f6; }
.dark .n24tb-share-row:hover { background: #1f2937; }
.n24tb-share-row:active { transform: scale(.99); }
.n24tb-share-ic {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 10px;
    color: #fff;
    flex: none;
}
.n24tb-share-ic svg { width: 20px; height: 20px; }
.n24tb-share-wa { background: #25d366; }
.n24tb-share-fb { background: #1877f2; }
.n24tb-share-x  { background: #111827; }
.n24tb-share-na { background: #6366f1; }
.n24tb-share-cp { background: #0891b2; }
.n24tb-share-status {
    margin: 0;
    padding: 6px 18px 14px;
    font-size: 12.5px;
    color: #047857;
    min-height: 26px;
}
.n24tb-share-status.is-error { color: #b91c1c; }

/* sr-only helper */
.n24tb-sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- mobile: dialogs become bottom sheets ---------- */
@media (max-width: 640px) {
    .n24tb-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .n24tb-dialog,
    .n24tb-dialog-sm {
        max-width: 100%;
        max-height: 84vh;
        border-radius: 18px 18px 0 0;
        border-bottom: 0;
        animation: n24tb-sheet .26s cubic-bezier(.22, 1, .36, 1);
    }
    @keyframes n24tb-sheet {
        from { transform: translateY(40px); opacity: .4; }
    }
    .n24tb-dialog-head::before {
        content: '';
        position: absolute;
    }
}

/* body scroll lock while a dialog is open */
body.n24tb-locked { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
    .n24tb-overlay, .n24tb-dialog, .n24tb-skeleton i,
    .n24tb-speech-dots i, .n24tb-btn, .n24tb-chip, .n24tb-react {
        animation: none !important;
        transition: none !important;
    }
}
